Need help for first mod try, Personal Shields only for distance fighter

Started by Noa3, June 20, 2015, 05:40:50 PM

Previous topic - Next topic

Noa3

hi i want to create a shiel for people who have shooting weapons.

i have allready read some things about modding and understand the structure system and how to add smal things.
but if i look in the core mod in the Apparel_Shield.xml , i dont see a restriction only for melee fighters.

can someone pls help me with the code?

Apparel_Shield.xml :

<?xml version="1.0" encoding="utf-8" ?>
<Defs>

<ThingDef Name="ApparelShieldBase" Abstract="True">
<thingClass>Apparel</thingClass>
<category>Item</category>
<selectable>True</selectable>
<pathCost>10</pathCost>
<useHitPoints>True</useHitPoints>
    <graphicData>
      <onGroundRandomRotateAngle>35</onGroundRandomRotateAngle>
    </graphicData>
    <drawGUIOverlay>true</drawGUIOverlay>
    <statBases>
<MaxHitPoints>100</MaxHitPoints>
<Flammability>1.0</Flammability>
      <DeteriorationRate>1</DeteriorationRate>
      <SellPriceFactor>0.5</SellPriceFactor>
    </statBases>
<altitudeLayer>Item</altitudeLayer>
<alwaysHaulable>True</alwaysHaulable>
<tickerType>Never</tickerType>
<thingCategories>
<li>Apparel</li>
</thingCategories>
<comps>
<li>
<compClass>CompForbiddable</compClass>
</li>
      <li>
        <compClass>CompColorable</compClass>
      </li>
<li>
<compClass>CompQuality</compClass>
</li>
</comps>
</ThingDef>




<ThingDef ParentName="ApparelShieldBase">
<thingClass>PersonalShield</thingClass>
<defName>Apparel_PersonalShield</defName>
<label>personal shield</label>
<description>A single-person energy shield device. It will attempt to stop any rapidly-moving projectile or energy attack that comes from a distance. It does nothing against melee attacks or shots from point-blank range. It prevents firing out as well. </description>
    <graphicData>
      <texPath>Things/Pawn/Humanlike/Apparel/PersonalShield/PersonalShield</texPath>
      <graphicClass>Graphic_Single</graphicClass>
    </graphicData>
    <tickerType>Normal</tickerType>
<statBases>
<MarketValue>1200</MarketValue>
      <PersonalShieldRechargeRate>0.13</PersonalShieldRechargeRate>
      <PersonalShieldEnergyMax>1.1</PersonalShieldEnergyMax>
    </statBases>
<apparel>
<bodyPartGroups>
<li>Torso</li>
</bodyPartGroups>
<layers>
<li>Accessory</li>
</layers>
<commonality>1</commonality>
<tags>
<li>PersonalShield</li>
</tags>
</apparel>
    <colorGenerator Class="ColorGenerator_Options">
      <options>
        <li>
          <weight>10</weight>
          <only>RGBA(0.33,0.33,0.33,1)</only>
        </li>
        <li>
          <weight>10</weight>
          <only>RGBA(0.65,0.65,0.65,1)</only>
        </li>
        <li>
          <weight>6</weight>
          <min>RGBA(0.3,0.3,0.3,1)</min>
          <max>RGBA(0.5,0.5,0.5,1)</max>
        </li>
        <li>
          <weight>10</weight>
          <only>RGBA(0.9,0.9,0.9,1)</only>
        </li>
      </options>
    </colorGenerator>
</ThingDef>




</Defs>

skullywag

DLL only im afraid. I have a mod that does this ill be releasing with a load of other stuff ive done in the next few days.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Noa3

i want to avoid this the much i can :(.
but your right maybe

thx for anwser

skullywag

The personal shield class has this:


public override bool AllowVerbCast(IntVec3 root, TargetInfo targ)
{
if (targ.HasThing && targ.Thing.def.size != IntVec2.One)
{
return root.AdjacentTo8WayOrInside(targ.Thing);
}
return root.AdjacentTo8Way(targ.Cell);
}


to remove the restriction on firing from within the shield youd need to extend the class and override that method, as i said DLL only.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

isistoy

It's a virtual one, it's not that bad :) People would help you, if need be
<Stay on the scene like a State machine>

skullywag

I have the code if you need it infact the exact thing already exists in my omni defence mod, just use ilspy to grab it out of the dll.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Noa3

thank you very much, i will learn to mod and maybe use this later :)