Content: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Background: Slate Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate Marble
Pattern: Blank Waves Notes Sharp Wood Rockface Leather Honey Vertical Triangles
Welcome to Xbox Chaos: Modding Evolved

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Sign in to follow this  
Followers 0
Ingulit

Retail
How to change an object's starting health (Fusion Coils, Vehicles, etc)

3 posts in this topic

I have been pouring over the forums trying to find out how to make all fusion coils have more health, but I never found a discussion that had a definitive solution. Through some trial and error I managed to figure out how to do it, and I figured I'd post what I did here in case anyone else has difficulty with it.

 

Unfortunately this technique uses one of the ten object variables, so it isn't usable if one's gametype needs all of them. I tried to find ways around this (like analyzing the object's teleporter channel), but I couldn't get anything else to work.

 

The code is below!

 

-----------------------------------------------------------------

 

In your ObjectVariables, add or rename one of the values and set its default value to 0. Note that since 0 is the default value, if the object whose health you're changing dies and respawns, it will respawn with that variable's value being 0.

...<ObjectVariables>      <Numeric>        <Var networkState="HighPriority" name="ObjectNumeric0" varRefType="Int16">0</Var>        <Var networkState="HighPriority" name="ObjectNumeric1" varRefType="Int16">0</Var>        ...        <Var networkState="HighPriority" name="ObjectHealthHasBeenSet" varRefType="Int16">0</Var>        ...      </Numeric>      ...</ObjectVariables>...

Next add a trigger that loops through every object each tick:

...<!-- Sets the health of a fusion coil (or whatever has been given the compcoil_coil label) when it spawns --><Trigger execMode="OnObjectFilter" name="CoilHealthTrigger1" objectFilter="compcoil_coil">   <Elements>      <!-- Check the ObjectHealthHasBeenSet object variable, which is 0 by default -->      <!-- If it is still zero, that means its health hasn't been changed yet      -->      <E type="Condition" name="Comparison">         <Param type="VarReference" varRefKind="Custom" varRefType="Object.NumericVar" dataType="Iterator.Object">ObjectHealthHasBeenSet</Param>         <Param type="VarReference" varRefKind="Custom" varRefType="Int16">0</Param>         <Param type="ComparisonType">Equal</Param>      </E>      <!-- Set the coil's maximum health to be the value the user specified -->      <E type="Action" name="ObjectModifyMaximumBodyVitality">         <Param type="ObjectReference" varRefType="ExplicitObjectType" dataType="Iterator.Object" />         <Param type="OperationType">Set</Param>         <Param type="CustomReference" varRefType="UserDefinedOption">Coil Health</Param>      </E>      <!-- Set the coil's current health to 100. What this does is make the coil have 100% health,  -->      <!-- which will be the user-specified amount of health since we changed the max (100%) health -->      <E type="Action" name="ObjectModifyHealth">         <Param type="ObjectReference" varRefType="ExplicitObjectType" dataType="Iterator.Object" />         <Param type="OperationType">Set</Param>         <Param type="CustomReference" varRefType="Int16">100</Param>      </E>      <!-- Set the coil's ObjectHealthHasBeenSet variable to 1 so we know not to change its health again -->      <E type="Action" name="VariableOperation">         <Param type="VarReference" varRefKind="Custom" varRefType="Object.NumericVar" dataType="Iterator.Object">ObjectHealthHasBeenSet</Param>         <Param type="VarReference" varRefKind="Custom" varRefType="Int16">1</Param>         <Param type="OperationType">Set</Param>      </E>   </Elements></Trigger>...

NOTE: This trigger uses an OnObjectFilter trigger to loop through all the objects that have the specific filter; you could just as effectively simply loop through all objects and check to see if that object is the type you want instead.

 

And that's really all there is to it! It has worked for me with many types of explosives and vehicles thus far, though I haven't tested everything yet (notably I don't know if this works for Extraction pieces).

 

For as simple as this ended up being, it certainly put me through my paces to figure this out, haha! Hopefully this will help someone down the road :smile:

Edited by Ingulit
Pfeuff likes this

Share this post


Link to post
Share on other sites

6. If the health you want it to be set to is higher than normal, use ObjectSetMaximumBodyVitality, and then ObjectModifyHealth. Make sure these only run through for one tick. If the health is lower than normal, then just use ObjectModifyHealth.

-From your Misc Questions post lol Edited by AbandonedCashew

Share this post


Link to post
Share on other sites

-From your Misc Questions post lol

I saw that and I thank you for that post, though because I was not able to find how to only apply the health change once/what values to give BodyVitality/ModifyHealth I figured it would be good to provide this .xml code in case someone else wants to do this.

Edited by Ingulit
AbandonedCashew likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0