Ludeon Forums

Ludeon Forums

  • August 11, 2020, 08:06:54 PM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Kilroy232

Pages: [1] 2 3 ... 16
1
Help / Creating a Semicircle Explosion
« on: March 12, 2019, 03:27:19 PM »
I have been looking at the C# code for the CompExplosion and wondering if it is possible for me to create a 'directed' explosion? I have experience in C# but most of what I do is procedural programming so I am not great at Class based programming.

I understand how the Radius for an explosion is calculated based on the number of combustible items in a stack if that is applicable but not where the "shape" of the explosion is derived from and is it possible for me to create new shapes.

I have provided the contents of the CompExplosive file for reference.

Code: [Select]
public class CompExplosive : ThingComp
{
public bool wickStarted;

protected int wickTicksLeft;

private Thing instigator;

public bool destroyedThroughDetonation;

protected Sustainer wickSoundSustainer;

public CompProperties_Explosive Props => (CompProperties_Explosive)props;

protected int StartWickThreshold => Mathf.RoundToInt(Props.startWickHitPointsPercent * (float)parent.MaxHitPoints);

private bool CanEverExplodeFromDamage
{
get
{
if (Props.chanceNeverExplodeFromDamage < 1E-05f)
{
return true;
}
Rand.PushState();
Rand.Seed = parent.thingIDNumber.GetHashCode();
bool result = Rand.Value < Props.chanceNeverExplodeFromDamage;
Rand.PopState();
return result;
}
}

public override void PostExposeData()
{
base.PostExposeData();
Scribe_References.Look(ref instigator, "instigator");
Scribe_Values.Look(ref wickStarted, "wickStarted", defaultValue: false);
Scribe_Values.Look(ref wickTicksLeft, "wickTicksLeft", 0);
Scribe_Values.Look(ref destroyedThroughDetonation, "destroyedThroughDetonation", defaultValue: false);
}

public override void CompTick()
{
if (wickStarted)
{
if (wickSoundSustainer == null)
{
StartWickSustainer();
}
else
{
wickSoundSustainer.Maintain();
}
wickTicksLeft--;
if (wickTicksLeft <= 0)
{
Detonate(parent.MapHeld);
}
}
}

private void StartWickSustainer()
{
SoundDefOf.MetalHitImportant.PlayOneShot(new TargetInfo(parent.Position, parent.Map));
SoundInfo info = SoundInfo.InMap(parent, MaintenanceType.PerTick);
wickSoundSustainer = SoundDefOf.HissSmall.TrySpawnSustainer(info);
}

private void EndWickSustainer()
{
if (wickSoundSustainer != null)
{
wickSoundSustainer.End();
wickSoundSustainer = null;
}
}

public override void PostDraw()
{
if (wickStarted)
{
parent.Map.overlayDrawer.DrawOverlay(parent, OverlayTypes.BurningWick);
}
}

public override void PostPreApplyDamage(DamageInfo dinfo, out bool absorbed)
{
absorbed = false;
if (!CanEverExplodeFromDamage)
{
return;
}
if (dinfo.Def.ExternalViolenceFor(parent) && dinfo.Amount >= (float)parent.HitPoints && CanExplodeFromDamageType(dinfo.Def))
{
if (parent.MapHeld != null)
{
Detonate(parent.MapHeld);
if (parent.Destroyed)
{
absorbed = true;
}
}
}
else if (!wickStarted && Props.startWickOnDamageTaken != null && dinfo.Def == Props.startWickOnDamageTaken)
{
StartWick(dinfo.Instigator);
}
}

public override void PostPostApplyDamage(DamageInfo dinfo, float totalDamageDealt)
{
if (CanEverExplodeFromDamage && CanExplodeFromDamageType(dinfo.Def) && !parent.Destroyed)
{
if (wickStarted && dinfo.Def == DamageDefOf.Stun)
{
StopWick();
}
else if (!wickStarted && parent.HitPoints <= StartWickThreshold && dinfo.Def.ExternalViolenceFor(parent))
{
StartWick(dinfo.Instigator);
}
}
}

public void StartWick(Thing instigator = null)
{
if (!wickStarted && !(ExplosiveRadius() <= 0f))
{
this.instigator = instigator;
wickStarted = true;
wickTicksLeft = Props.wickTicks.RandomInRange;
StartWickSustainer();
GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(parent, Props.explosiveDamageType);
}
}

public void StopWick()
{
wickStarted = false;
instigator = null;
}

public float ExplosiveRadius()
{
CompProperties_Explosive props = Props;
float num = props.explosiveRadius;
if (parent.stackCount > 1 && props.explosiveExpandPerStackcount > 0f)
{
num += Mathf.Sqrt((float)(parent.stackCount - 1) * props.explosiveExpandPerStackcount);
}
if (props.explosiveExpandPerFuel > 0f && parent.GetComp<CompRefuelable>() != null)
{
num += Mathf.Sqrt(parent.GetComp<CompRefuelable>().Fuel * props.explosiveExpandPerFuel);
}
return num;
}

protected void Detonate(Map map)
{
if (!parent.SpawnedOrAnyParentSpawned)
{
return;
}
CompProperties_Explosive props = Props;
float num = ExplosiveRadius();
if (props.explosiveExpandPerFuel > 0f && parent.GetComp<CompRefuelable>() != null)
{
parent.GetComp<CompRefuelable>().ConsumeFuel(parent.GetComp<CompRefuelable>().Fuel);
}
if (props.destroyThingOnExplosionSize <= num && !parent.Destroyed)
{
destroyedThroughDetonation = true;
parent.Kill();
}
EndWickSustainer();
wickStarted = false;
if (map == null)
{
Log.Warning("Tried to detonate CompExplosive in a null map.");
return;
}
if (props.explosionEffect != null)
{
Effecter effecter = props.explosionEffect.Spawn();
effecter.Trigger(new TargetInfo(parent.PositionHeld, map), new TargetInfo(parent.PositionHeld, map));
effecter.Cleanup();
}
IntVec3 positionHeld = parent.PositionHeld;
float radius = num;
DamageDef explosiveDamageType = props.explosiveDamageType;
Thing thing = instigator ?? parent;
int damageAmountBase = props.damageAmountBase;
float armorPenetrationBase = props.armorPenetrationBase;
SoundDef explosionSound = props.explosionSound;
ThingDef postExplosionSpawnThingDef = props.postExplosionSpawnThingDef;
float postExplosionSpawnChance = props.postExplosionSpawnChance;
int postExplosionSpawnThingCount = props.postExplosionSpawnThingCount;
GenExplosion.DoExplosion(positionHeld, map, radius, explosiveDamageType, thing, damageAmountBase, armorPenetrationBase, explosionSound, null, null, null, postExplosionSpawnThingDef, postExplosionSpawnChance, postExplosionSpawnThingCount, props.applyDamageToExplosionCellsNeighbors, props.preExplosionSpawnThingDef, props.preExplosionSpawnChance, props.preExplosionSpawnThingCount, props.chanceToStartFire, props.damageFalloff);
}

private bool CanExplodeFromDamageType(DamageDef damage)
{
return Props.requiredDamageTypeToExplode == null || Props.requiredDamageTypeToExplode == damage;
}
}



2
Releases / Re: [A18] Extended Turrets Mod --Alpha 18 Update--
« on: October 31, 2018, 08:41:45 PM »
For everyone that doesn't use the steam version of the game I have uploaded the 1.0 release compatible version of the mod to Nexus Mods for you.

3
Releases / Re: [A18] Extended Turrets Mod --Alpha 18 Update--
« on: October 19, 2018, 09:59:06 AM »
Oh ya, I will be doing that as soon as possible! I have updated the mod to A19 on steam already and hopefully I can have it updated for 1.0 before next week

4
Releases / Re: [A18] Extended Turrets Mod --Alpha 18 Update--
« on: May 08, 2018, 01:50:55 PM »
CE version pls

What is CE version?

5
Outdated / Re: [B18] Extended Surgery Mod
« on: February 25, 2018, 04:29:41 PM »
There is a non-Steam version on NexusMods :)
I just had to wait for the new mod to be verified before anyone could download it.

You can have a look as what is required for the operation but right now the colonist who preforms the operation must have a medical skill of at least 5 as well as an artistic of 5 or higher.

I have compared this mod to other mods and what I wanted to make was definitely similar to DESurgeries which is very vanilla friendly. I wanted to keep the mod as close to vanilla as I thought it should be. In my opinion EPOE and RBSE alter too much of the same, I know not everyone may agree and that's fine but I made this for myself and just thought I would share it.

As for compatibility I would need to do some testing, mods that change the way operations work in the C# code then it may not be compatible. I will have to do some testing.

6
Outdated / [B18] Extended Surgery Mod
« on: February 25, 2018, 12:42:11 PM »
Extended Surgery Mod



Description
This mod adds new basic surgeries intended for mid to late game play that will help keep colonists happier and also stay as close to the vanilla game as possible.

With the ability to add replace whole limbs with bionics I think it is only reasonable that a player can expect to have the ability to preform less complex but still important surgeries. This is the premise for this mod.

The mod includes prosthetics for missing ears, eyes and noses to prevent colonists from picking on disfigured people. The ability to replace any shattered bone and to heal scratches to help reduce the amount of pain a colonist is in and to improve their productivity.

The mod doesn't require any research but you need to have a colonist with a high enough level of caring for all of the surgeries as well as artistics for the prostetics.

Notes
- You DO NOT need to start a new game for this mod
- Note that bones are replaced with Plasteel so you must have some to preform the operation

Changes For Version 1.1.0:
- I have added the ability to harvest and replace natural eyes

Download





Install
- Subscribe to the mod from the steam workshop page provided above or download from NexusMods.
- Activate the mod in the mod menu in the game.

License
Download and share this mod as you want but don't change it or sell it without my consent

7
Releases / Re: [A18] Extended Turrets Mod --Alpha 18 Update--
« on: February 07, 2018, 05:38:25 PM »
This mod has been updated by me and with minor play testing I have found no bugs. If you find any errors please let me know.

If you have any suggestions or requests I am always happy to hear them!

8
Why do you want made a new mod, when basicly a similar mod allready exist ?
https://ludeon.com/forums/index.php?topic=32497.0

I had seen this when I went to see if something already existed but this mod is complicated and involved, I want to make something simple to use. Equip a piece of gear and continue on

Quote
No. There are way better solutions for the "ranged pawn can't carry melee weapons" conundrum. Your idea is inferior in execution and planning. Nevertheless,
Fair enough, but what would you say are some of the better solutions to this issue, what would make this a better idea in your eyes?

9
Mods / [Mod Idea Feedback] Improved Melee for ranged weapon holders
« on: July 11, 2017, 11:18:27 AM »
I am thinking of making a mod that would create a new gear item for pawns to wear. It would be a belt with a knife on it and it would allow pawns that are using a ranged weapon to have this knife to use if they are engaged in melee combat instead of just punching. It would give a bit of an edge to pawns if they are attacked by wild animals or enemy pawns.

I need some feedback on the idea though as I have lots of thoughts but I would like to know if others have similar thoughts.

1. Should pawns need to meet a minimum melee combat level before they are allowed to use this knife belt? Should there be any other restrictions?
2. What would you like to see the gear look like? (I would love a few test images if any graphic designers wanna draw up examples, I am not an impressive artist)
3. Would you use this mod if it worked as suggested?

10
Releases / Re: [A16] Extended Turrets Mod --Alpha 17b Update--
« on: June 25, 2017, 11:53:10 AM »
It sounds like some how the version of the mod you are using hasn't updated from the workshop. That was one of the problems I fixed when I updated the mod. One way to fix it might be to unsubscribe from the mod on steam and then run the game, make sure it is gone then close the game and subscribe again and try.

I only mentioned steam because I checked the comments section for a solution or people having the same issue as me. So I wondered if the version available at Nexus differs from the steam version (as I didn't see people complaining with that version).
I'm using the version available at Nexus. There's no other a17 version on Nexus for me to try and I never use steam for modded playthroughs, so I couldn't know if they're different versions. Maybe you could check?

Thanks for replying :D

I am sorry, I was out when I read your first message so I must have misunderstood. If you PM an error report from the console window I can help you better, it sounds like somehow you are still using the old Laser.dll

11
Help / Re: A quick way to check for targets in a radius (C#)
« on: June 25, 2017, 11:29:22 AM »
Hey guys, I just wanted to thank you again. I got my code working thanks to you guys! I hope that I will have finished the addition to my turret mod soon and then I can show you guys

12
Releases / Re: [A16] Extended Turrets Mod --Alpha 17b Update--
« on: June 24, 2017, 02:18:26 PM »
I am only one person and I cannot guarantee there are no bugs so if anyone has any problems please let me know.
I keep getting a "Could not find a type named LaserBeam.Charger" error and both the turret and weapon lazers refuse to work. Why has no one complained? Is my version the only one erroring? :(
I mean on steam, because here no one has replied so far. Maybe Steam and Nexus versions aren't the same?

It sounds like some how the version of the mod you are using hasn't updated from the workshop. That was one of the problems I fixed when I updated the mod. One way to fix it might be to unsubscribe from the mod on steam and then run the game, make sure it is gone then close the game and subscribe again and try.

I am sorry that you are having this problem but I really hope that helps

13
Help / Re: A quick way to check for targets in a radius (C#)
« on: June 23, 2017, 01:48:57 PM »
You are all best, thank you very much. I am going to try again tonight and see what I can mange. I am hoping to make something awesome

14
Help / Re: A quick way to check for targets in a radius (C#)
« on: June 22, 2017, 10:15:48 PM »
Query the turret's Map, then request MapPawns from that. Then you can use something like FindAll (iirc) to return a collection of pawns matching the specific criteria you define.

The only part of that I don't understand how to do is the first part. Would use something like, base.Map then use get MapPawns? I think I understand the rest of that though


15
Help / (SOLVED) A quick way to check for targets in a radius (C#)
« on: June 22, 2017, 08:19:20 PM »
I am working on some code and I have attempted a few different methods of detecting if there are enemies withing a 3.1f radius including mimicking part of the turret code but I cannot successfully get the building to check if there are enemies around.

Does anyone happen to have a method to do this? If you would you mind pointing me in the right direction or sharing a snippet of code?

Pages: [1] 2 3 ... 16