Ludeon Forums

Ludeon Forums

  • August 11, 2020, 08:04:53 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.

Topics - Kilroy232

Pages: [1] 2
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
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

3
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?

4
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?

5
Help / Adding a prerequisite to a XML patch
« on: June 18, 2017, 12:55:56 PM »
Is it possible to have a patch that has a prerequisite that you have to research before the patch is applied?

6
Help / Modified Version of DeepDrill advice?
« on: September 20, 2016, 03:28:34 PM »
So having had a good look the DeepDrill building doesn't have a thingClass tag in the XML code, it has <compClass>CompDeepDrill</compClass> and I am not quite sure how that difference effects the building.

I am looking to make a building similar to the DeepDrill where this new drill would not look for resources below the surface at all but instead would just constantly produce a new resource I am working on, oil. The new Drill would still track progress and spit out s produce after so much progress but instead of then looking for a new Resource Lump in would just skip that step and start on more of the infinite oil supply.

This leads to my question, should I just create a building that has a thing class that does what I want or should I continue using the compClass and modify that?

7
Mods / 'ship cracker' C# possibility?
« on: September 11, 2016, 09:19:33 PM »
despite my knowledge in C# I know how to program human machine interfaces not games.

Right now I am just looking to ask how hard it would be to write code to make it so that structure can only be built on top of another structure. I want to make a 'ship cracker', an IED that would destroy a fallen ship piece in one quick blow so that the mechs would be free to ambush at base.

The other way that I could implement this idea if the first is too hard is to make the 'ship cracker' a function that would be available when you selected the ship piece (after the necessary research) just like deconstruction and an explosive would be constructed and detonated.

8
This is the error message I am getting, if anyone understands this I would love a little help on this one. Thank you!




UPDATE - trying to load a game anyway results in these errors.
There is something in my mod (the current version available for download if you feel like looking through it) that is making it so all items have the same value as wood... literally making every item in the game wood.

If I deconstruct metal, stone or anything I get wood.


9
Help / Problems decompiling code
« on: April 28, 2016, 10:48:06 PM »
When decompiling C# code for the sunlamp I am getting sections that don't make any sense or simply do not work when I put them back into visual studios.

I understand that the software I use to view and decompile it doesn't read the Assembly-CSharp.ddl perfectly and that it is up to me to interpolate some of it but what can you do if you can't make sense of it?

I don't know that I can or should post the C# file that I retrieved from the Assembly-CSharp.ddl so I will start with this and see where people might suggest going

10
Outdated / [A13] Power Efficient Lights v1.0
« on: April 25, 2016, 03:01:01 PM »
Power Efficient Lights

Description:
A simple mod that adds power efficient lights to the game. Includes a new research project and textures for the game for the power efficient standing lamp, as well as red, green and blue standing lamps. All power efficient lights run at 75w as apposed to the original 150w


Sub Topic
If people enjoy this little addition to the RimWorld game I would be interested in making more of the machines in the game power efficient or able to produce more power respectively.

Author/Mod Team
Kilroy232

Download



How to install:
- Unzip the contents and place them in your RimWorld/Mods folder.
- 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

11
Help / Games tries to load a Core .xml while loading a mod .xml
« on: April 15, 2016, 12:02:29 PM »
Has anyone happen to run into this problem? I have been trying for a while now to fix the problem but I am not sure what the problem is (there could possibly be something new I missed).

Originally it was saying my Research.xml was causing the error so I removed it to test but
 it just picks another .xml from my mod to throw the exception with (there could possible be something wrong with my file structure). Also I looked through the Biomes_Arid.xml and the World_oneshots_turrets.xml (A SoundDefs file also throwing the error) but I couldn't find any conflicts.

I won't post the Biomes_arid.xml code because if you own the game you have it, but here is the code for an xml that it claims is causing an error.

Code For the World_oneshots_turrets.xml
Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<DefPackage-SoundDef>

<SoundDef>
    <defName>StandardRound</defName>
    <eventNames />
    <maxSimultaneous>1</maxSimultaneous>
    <subSounds>
      <li>
        <grains>
          <li Class="AudioGrain_Clip">
            <clipPath>StandardTurret/9mm_Single</clipPath>
          </li>
        </grains>
        <volumeRange>
          <min>50</min>
          <max>50</max>
        </volumeRange>
        <pitchRange>
          <min>0.8304348</min>
          <max>1.105978</max>
        </pitchRange>
</li>
</subSounds>
</SoundDef>

<SoundDef>
    <defName>SniperRound</defName>
    <eventNames />
    <maxSimultaneous>1</maxSimultaneous>
    <subSounds>
      <li>
        <grains>
          <li Class="AudioGrain_Clip">
            <clipPath>SniperTurret/50Cal</clipPath>
          </li>
        </grains>
        <volumeRange>
          <min>50</min>
          <max>50</max>
        </volumeRange>
        <pitchRange>
          <min>0.8304348</min>
          <max>1.105978</max>
        </pitchRange>
</li>
</subSounds>
</SoundDef>

<SoundDef>
    <defName>IncediaryRound</defName>
    <eventNames />
    <maxSimultaneous>1</maxSimultaneous>
    <subSounds>
      <li>
        <grains>
          <li Class="AudioGrain_Clip">
            <clipPath>IncendiaryTurret/Bren_LMG</clipPath>
          </li>
        </grains>
        <volumeRange>
          <min>50</min>
          <max>50</max>
        </volumeRange>
        <pitchRange>
          <min>0.8304348</min>
          <max>1.105978</max>
        </pitchRange>
</li>
</subSounds>
</SoundDef>

<SoundDef>
    <defName>HeavyRound</defName>
    <eventNames />
    <maxSimultaneous>1</maxSimultaneous>
    <subSounds>
      <li>
        <grains>
          <li Class="AudioGrain_Clip">
            <clipPath>HeavyTurret/Heavy(M4A1)</clipPath>
          </li>
        </grains>
        <volumeRange>
          <min>50</min>
          <max>50</max>
        </volumeRange>
        <pitchRange>
          <min>0.8304348</min>
          <max>1.105978</max>
        </pitchRange>
</li>
</subSounds>
</SoundDef>

<SoundDef>
    <defName>MissileLaunch</defName>
    <eventNames />
    <maxSimultaneous>1</maxSimultaneous>
    <subSounds>
      <li>
        <grains>
          <li Class="AudioGrain_Clip">
            <clipPath>TOWLauncher/missile</clipPath>
          </li>
        </grains>
        <volumeRange>
          <min>50</min>
          <max>50</max>
        </volumeRange>
        <pitchRange>
          <min>0.8304348</min>
          <max>1.105978</max>
        </pitchRange>
</li>
</subSounds>
</SoundDef>

<SoundDef>
    <defName>StunRound</defName>
    <eventNames />
    <maxSimultaneous>1</maxSimultaneous>
    <subSounds>
      <li>
        <grains>
          <li Class="AudioGrain_Clip">
            <clipPath>StunTurret/Discharge</clipPath>
          </li>
        </grains>
        <volumeRange>
          <min>50</min>
          <max>50</max>
        </volumeRange>
        <pitchRange>
          <min>0.8304348</min>
          <max>1.105978</max>
        </pitchRange>
</li>
</subSounds>
</SoundDef>

</DefPackage-SoundDef>

Lastly I cannot read all of the debugging code but I didn't see anything too useful in it, no specified lines of code or anything

12
Mods / Rocket Artillery
« on: February 22, 2016, 12:27:15 AM »
So sitting at home brain storming some new weapons for RimWorld because that is kind of what I know.

What do you guys think about a Rocket Artillery security building? You would have to construct a group of 6 "dumb" missiles at a time at the same work bench that you would construct mortar shells. The artillery building itself would be similar to the vanilla artillery building but will require a small amount of power for the rocket pod to be able to rotate and the rocket artillery will have longer load times (I may even be able to make it so that load time depends on shooting skill).
Once loaded and manned the artillery will locate a target and fire all six rockets in a single volley. The accuracy of the area of effect will be higher than the vanilla artillery but each individual rockets accuracy is low meaning that each rocket will land in a different location in the area of effect.
It should be noted as well that each rockets blast radius will be smaller than the artillery shell.



13
Help / Exception Parsing DLL Modding Error
« on: March 13, 2015, 02:27:11 AM »
So this is my first really crack at using C# to mod the game. I the tutorial posted as best I could and the C++ that I learned in university.

I thought I had everything right but I am getting an error I am not familiar with... I can post source code if necessary.
Image of the error message is bellow

Edit: Sorry I keep posting after work and I am really tired so I am not thinking this through 100%

XML Files: https://www.dropbox.com/s/7153cudo5397vs6/Turrets%20Pack.zip?dl=0
I am trying to mimic the action preformed when you research gun turret cooling but with turrets that have been added via mod.

[attachment deleted due to age]

14
Help / Extending Stun Effect
« on: March 11, 2015, 10:09:19 PM »
I would simply like to know if it is possible to make the stun effect found in the game last longer

15
Releases / [1.0] Extended Turrets Mod --1.0 Release Update--
« on: October 10, 2014, 06:34:21 PM »
 Extended Turrets Mod



Description:
An update for interested users, I have uploaded the mod to steam's workshop under the name "Extended Turrets Mod" for easier access and use for everyone on steam. As well as that I have updated the Nexus Mods page for the users who do not have or use steam. I hope that everyone continues to enjoy this mod and that your colonies stay safe and secure!
Extended Turrets Mod on Steam

This mod adds five new auto-turrets to game making it easier to defend your colony. There are also new research projects for the turrets along with custom sounds and textures.
This mod is meant for use in the later stages of the game and so to accommodate this each turret requires a hefty amount of research, resources and build time.

Notes:
Some features that can be expected in the future are some more research projects that will provide minor tweaks and improvements to the existing turrets.
I will continue to provide minor fixes and work on larger features for the mod.
!! I have not made any changes recently, just updated this page. You can expect updates soon and I am always happy to receive suggestions or told told about problems people are having.

Changes For Version 1.8.0:
-Updated for the Alpha 18 version of Rimworld

Turrets:
1. Standard Turret
This turret is as the name suggests, an improved version if the improvised turret. The turret fires in bursts of four with reduced cooldown time and increased health.

2. Long Range Turret
This turret is an improvised turret that has been fitted with an M-24 sniper rifle. A single high powered round is fired before cooldown, but the range and accuracy of the turret make up for the slow rate of fire, sometimes less is more.

3. Laser Turret
A complex assembly of lenses and electronics, this turret focuses a beam of high energy light at the enemy to deal damage with perfect accuracy but with pauses between charges.

5. Energy Turret
This is the tip top of the charts. This turret has it all, high rate of fire, high damage and high max health. Instead of using conventional projectiles this turret is able to convert electricity into an almost pure form of energy.

Download:




Install:
To install this mod you simply but the directory folder (the folder containing the About, Def, Texture... etc. folders) into your mods folder. In game select the mods menu and select the Turret Pack mod.
This mod does not require a new colony, you can start using it at any point and any update unless specified will not require a new colony.

Credit:
All of the new textures and the C# code for the 'lazer' turret are the work of mrofa. He has contributed lots of his time helping me put some more detail into this mod, he deserves a lot if credit for his skill I cannot thank him enough.

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

Pages: [1] 2