Jump to content

Regeneration and General Damage Reduction Modlet


Amineri

Recommended Posts

So, I've been working on a modlet to give aliens the ability to regenerate, as well as giving damage reduction in a more general way. I think I'm almost there.

 

It will work by adding a fixed amount of hp back to the designated alien(s) at the end of their turn (unless they're dead). I could use some assistance (if anyone is willing) to test something out, though.

 

The plan is to use two Ability designations that are still in the game, but appear to be no longer used. They are:

 

 

eAbility_ReanimateAlly
eAbility_ReanimateEnemy
The plan is to use the ReanimateEnemy flag to designate units that can regenerate, and the ReanimateAlly flag to designate units with damage reduction.
Can anyone help me gather evidence that giving these flags to aliens doesn't generate any form of interesting / unusual behavior?
Thank you so much ^_^
P.S. Regenerating Chryssalids -- I get excited at the added terror xD
Link to comment
Share on other sites

<p>I don't have much time left to research or play lately, but I'll give it a try if I recall to set the aliens properly. So that flag we should give em in the ini file, right?</p>

<p> </p>

<p>Have you found by chance if any of this unit abilities can store a value instead of just being a flag?, or by chance does the game recognize if a unit has the same tag twice? Just thinking that if possible it'd be nice to have different regeneration and/or damage reduction rates... it'd open a few nasty combinations...</p>

<p> </p>

<p>what about the opposite, units that receive a critical hit start bleeding out 1hp per turn until healed or dead, both player and alien units? Just throwing in some ideas. Also, since you're dealing with damage and abilities, have you found some code left for the HEAT Rockets ability? I play with separate rocketeer and machinegunner, but it'd be nice to have both abilities available so the rocketeer soldier could have heat rockets (or heat explosives, that'd be ok too) but not heat ammo, and vice versa.</p>

<p> </p>

<p>edit: sry, that went far off topic. I've set every alien with both abilities, I'll let you know if I come across something unusual.</p>

Edited by anUser
Link to comment
Share on other sites

  • 2 weeks later...

I have a new version of the hex code for OnTakeDamage (what the tank DR modlet modifies).

 

It doesn't change the Tank-specific DR in any functional way (I recoded it to save a few bytes), but adds the possibility of applying additional DR to other units, or based upon time passing in the game. It works by "taking over" an unused class variable (m_iCoverBits) to use as the units "generic" DR.

 

Decompiled code looks like so:

// End:0x185
if(XComGameReplicationInfo(class'Engine'.static.GetCurrentWorldInfo().GRI).m_kGameCore.CharacterHasProperty(GetCharacter().m_kChar.iType, 3))
{
// End:0x157
if((kDamageDealer != none) && kDamageDealer.GetCharacter().HasUpgrade(91))
{
iDamage *= float(XComGameReplicationInfo(class'Engine'.static.GetCurrentWorldInfo().GRI).m_kGameCore.2);
}
iDamage = Max(iDamage - Max(((GetUnitMaxHP()) + 6) / 10, 0), 1);
}
// End:0x224
if(IsShredded())
{
iDamage += int(float(iDamage) * XComGameReplicationInfo(class'Engine'.static.GetCurrentWorldInfo().GRI).m_kGameCore.m_kAbilities.0.330);
}
iDamage = Max(iDamage - m_iCoverBits, 1);
iDamage
// End:0x303

 

Order of taking damage is:

1) HEAT bonus (if any) applied

2) Tank-specific DR applied

3) Shredding bonus damage applied

4) Generic DR applied

 

To use generic DR you have to set the m_iCoverBits variable somewhere else in the code. If you never set it, then only the tank DR will be applied. The best place I've seen is in XGUnit >> UpdateEquipment. This function only updates weapons overheat increment, and so can be completely rewritten. It is also good for setting regen variables that way.

 

New hex code for applying tank-only DR -and- generic DR:

Applied to XcomGame.upk

 

 

 

Before:
0B 07 58 00 9B 38 3A 19 01 E9 F9 FF FF 09 00 AB FE FF FF 00 01 AB FE FF FF 38 3A 24 00 16 07 58 00 82 9A 00 98 B4 00 00 1D 40 42 0F 00 16 18 0B 00 2D 01 74 AF 00 00 16 14 2D 00 89 B4 00 00 27 07 AF 01 82 77 00 96 B4 00 00 2A 16 18 38 00 19 19 00 96 B4 00 00 0A 00 63 B4 00 00 00 1B 7B 31 00 00 00 00 00 00 16 0C 00 EA A2 00 00 00 1B B8 36 00 00 00 00 00 00 2C 5B 16 16 07 AF 01 19 19 2E FE 2C 00 00 19 12 20 4F FE FF FF 0A 00 D8 F9 FF FF 00 1C F6 FB FF FF 16 09 00 98 F9 FF FF 00 01 98 F9 FF FF 09 00 F0 2C 00 00 00 01 F0 2C 00 00 3E 00 97 0F 00 00 00 1B 0D 10 00 00 00 00 00 00 35 D3 0D 00 00 D5 0D 00 00 00 00 19 1B 7B 31 00 00 00 00 00 00 16 09 00 C3 A2 00 00 00 01 C3 A2 00 00 2C 03 16 9F 00 98 B4 00 00 38 3F 19 19 2E FE 2C 00 00 19 12 20 4F FE FF FF 0A 00 D8 F9 FF FF 00 1C F6 FB FF FF 16 09 00 98 F9 FF FF 00 01 98 F9 FF FF 09 00 F0 2C 00 00 00 01 F0 2C 00 00 02 00 F0 2C 00 00 00 2C 02 16 07 4E 02 1B 4F 3E 00 00 00 00 00 00 16 A1 00 98 B4 00 00 38 44 AB 38 3F 00 98 B4 00 00 19 19 19 2E FE 2C 00 00 19 12 20 4F FE FF FF 0A 00 D8 F9 FF FF 00 1C F6 FB FF FF 16 09 00 98 F9 FF FF 00 01 98 F9 FF FF 09 00 F0 2C 00 00 00 01 F0 2C 00 00 09 00 92 0F 00 00 00 01 92 0F 00 00 05 00 92 0F 00 00 00 1E C3 F5 A8 3E 16 16
After:
07 85 01 19 19 2E FE 2C 00 00 19 12 20 4F FE FF FF 0A 00 D8 F9 FF FF 00 1C F6 FB FF FF 16 09 00 98 F9 FF FF 00 01 98 F9 FF FF 09 00 F0 2C 00 00 00 01 F0 2C 00 00 3E 00 97 0F 00 00 00 1B 0D 10 00 00 00 00 00 00 35 D3 0D 00 00 D5 0D 00 00 00 00 19 1B 7B 31 00 00 00 00 00 00 16 09 00 C3 A2 00 00 00 01 C3 A2 00 00 2C 03 16 07 57 01 82 77 00 96 B4 00 00 2A 16 18 38 00 19 19 00 96 B4 00 00 0A 00 63 B4 00 00 00 1B 7B 31 00 00 00 00 00 00 16 0C 00 EA A2 00 00 00 1B B8 36 00 00 00 00 00 00 2C 5B 16 16 9F 00 98 B4 00 00 38 3F 19 19 2E FE 2C 00 00 19 12 20 4F FE FF FF 0A 00 D8 F9 FF FF 00 1C F6 FB FF FF 16 09 00 98 F9 FF FF 00 01 98 F9 FF FF 09 00 F0 2C 00 00 00 01 F0 2C 00 00 02 00 F0 2C 00 00 00 2C 02 16 0F 00 98 B4 00 00 FA 93 00 98 B4 00 00 FA 91 92 1B 32 35 00 00 00 00 00 00 16 2C 06 16 2C 0A 16 2C 00 16 16 26 16 07 24 02 1B 4F 3E 00 00 00 00 00 00 16 A1 00 98 B4 00 00 38 44 AB 38 3F 00 98 B4 00 00 19 19 19 2E FE 2C 00 00 19 12 20 4F FE FF FF 0A 00 D8 F9 FF FF 00 1C F6 FB FF FF 16 09 00 98 F9 FF FF 00 01 98 F9 FF FF 09 00 F0 2C 00 00 00 01 F0 2C 00 00 09 00 92 0F 00 00 00 01 92 0F 00 00 05 00 92 0F 00 00 00 1E C3 F5 A8 3E 16 16 0F 00 98 B4 00 00 FA 93 00 98 B4 00 00 01 64 AF 00 00 16 26 16 00 98 B4 00 00

Note: Some people have had difficulty with this hex code change, in a way that I have not been able to replicate. Any feedback on how this is working would be really useful.
--------------------------------------------------------------------------------------------------------
Unit Regeneration works in a similar way. A XGUnit class variable m_iTracerBeamCtr (was used for a removed ability) was re-purposed to hold the unit's regeneration.
This is applied in the function OnEndTurnHook(), which runs for each unit at the end of the turn, in the following bit of code:

 

SetUnitHP(Min(GetUnitHP() + m_iTracerBeamCtr), GetUnitMaxHP());
This causes each unit to regain "m_iTracerBeamCtr" HP at the end of each turn, up to its maximum health.
As with the generalized damage reduction, code to set m_iTracerBeamCtr for each unit be written elsewhere (UpdateEquipment works for both).
Hex code for regeneration effects:
apply to XcomGame.upk

before:
BD 00 00 00 81 00 00 00 07 1A 00 97 01 AC 30 00 00 25 16 A6 01 AC 30 00 00 16 07 80 00 97 01 CC 30 00 00 25 16 A6 01 CC 30 00 00 16 07 80 00 98 01 CC 30 00 00 25 16 19 19 2E CF 37 00 00 01 09 31 00 00 09 00 0E 36 00 00 00 01 0E 36 00 00 0A 00 00 00 00 00 00 1C 5D FB FF FF 16
after:
A1 00 00 00 81 00 00 00 07 1A 00 97 01 AC 30 00 00 25 16 A6 01 AC 30 00 00 16 07 64 00 97 01 CC 30 00 00 25 16 1B 25 63 00 00 00 00 00 00 F9 93 92 92 1B 2F 35 00 00 00 00 00 00 16 01 CC 30 00 00 16 A7 2C 03 16 16 2C 01 16 1B 32 35 00 00 00 00 00 00 16 16 16 0B 0B 0B 0B 0B 0B

Johnnylump and I have been working on UpdateEquipment modifications, and how to get time information from the strategy game to the tactical game, so that these variables can be set taking into account how much in-game time has passed.
More updates to follow.
Update: finally figured out how to pass the number of elapsed days from the strategy game to the tactical game. Info is in a thread here:
This info can be used to set regeneration and DR amounts per alien base on elapsed time. Good luck, Commander!

 

Edited by Amineri
Link to comment
Share on other sites

Nice. I assume the regeneration effect wil affect every unit, including mine, right? I've seen there's little room for additions in that function, perhaps you could make it so instead of that variable it reads whether the unit has certain ini property, or is there some other way to set which units have regeneration and which don't? If it were possible to get the extra HP value from DGC.ini's BalanceMods_Whatever and make aliens regenerate that amount per turn that would be awesome.

 

I implemented your damage reduction modlet a few days ago and it seems to work so I'm not touching that for a while :p I defenitively need a hex version converter...

Link to comment
Share on other sites

Oh, hahahahahahahahahaha --- sorry xD

 

No no no, regeneration is only for aliens, silly rabbit ^_^

 

In theory XCOM Soldiers / SHIVs could regenerate too, I suppose, if the m_iTracerBeamCtr variable were set for them. At base, all units are variable of type XGUnit, which is where that class variable lives. But each individual unit has its own copy of that variable. In theory you could do something like rand(2) + 2, and every unit would have a random amount from 2 - 4.

 

But where is the fun in making XCOM regen? Makes no sense, no sense at all....

 

I have thought about being able to set regen based on "ini file" settings. The best candidate I've seen is "CritWoundChance", which is zero for all unit types and does not appear to be used anywhere for anything. (it is distinct from CritHitChance, which is definitely used). I haven't pursued this very far, because I feel that the "inverted difficulty curve" currently present means that we need to make the game slightly easier in the beginning, and much harder toward the end.

 

With that in mind, I wanted time-based assignment of regen and DR to units, rather then "all-time" assignment. That said, this could be granted only to late-game units to make them tougher, but giving them more health / defense would do that also. That said, after JL finishes up the version of UpdateEquipment he's working on, I might mutate it further to read "CritWoundChance" -- it can also be easily combined with the time info to define which units regen and which don't.

 

I'm currently working on a way to bring the "count of days passed since game start" into the tactical game to allow making late-game difficulty ramp up.

Link to comment
Share on other sites

No no no, regeneration is only for aliens, silly rabbit ^_^

 

... just asking :whistling:

 

 

I'm currently working on a way to bring the "count of days passed since game start" into the tactical game to allow making late-game difficulty ramp up.

 

cool. It'd be nice if it were as you say and not just GetMonth(), I like really long games and it all gets weird when the year turns, I wouldn't like to face weaker aliens again after a year.

Link to comment
Share on other sites

Based on everything I've seen, I believe GetMonth() just returns the number of months since March 2015, so it doesn't cycle back at March 2016.

 

The problem is passing information about the state of the strategic game to the tactical game. There's a bottleneck for data that goes over, most or all of which the game uses and thus can't be changed, but I think Amineri is trying to sneak some information about time passed in the strategy game through some unused variable.

 

So far, the best I've managed is to test against technological advances discovered. The problem is that the player can of course control that, and it eliminates the strategic choices in preparing for alien advances.

 

All the same, I've managed to get some alien species to upgrade midgame with damage reduction and regeneration based on a particular tech advance -- currently plasma rifles, although I'm considering changing it to titan armor as to not punish the plasma rush strategy too much.

 

I'm planning to recode UpdateEquipment() more tightly to modify additional aliens.

Edited by johnnylump
Link to comment
Share on other sites

Based on everything I've seen, I believe GetMonth() just returns the number of months since March 2015, so it doesn't cycle back at March 2016.

 

Then it's my error of appreciation ... if when Amineri research is completed and if at least just one value could be sneaked into tactical game so the rest can be tunned in there... well then maybe that GetMonth() is all what's needed. If it's not asking much I'd love a bit of space where this is done to add a customizable factor, so you could count alien upgrades per "stages", each user setting those to 2, 3 or 4 months, etc.. well you get what I mean, a way to scale this for faster, most pressing games, or long, paused games.

 

updating alien items as well? that sounds great. Now that I've started a new game and heard again the description of thin men, the doctor saying that probably they played some role of infiltrated agents, I'd love to see *some* of them with "human" weapons. What about giving laser weapons to aliens and making so they have to be recovered from aliens prior to any research, just like with plasma weapons? It may be a nice way to increase number of alien weapon variety and make it possible to scale them with greater range of options. It's just a random thought, but as I writte it I like it more and more... gonna meditate about it :p

Edited by anUser
Link to comment
Share on other sites

So far I've tried using three different variables to try and sneak over the GetDays() count.

 

anUser is correct that GetMonth() returns just the current month, so when the in-game year rolls over to 2016, GetMonth() rolls over to return 1. This is the GetMonth() function in XGDateTime(). There is also a function called GetDay() defined in XGDateTime() that just returns the current day of the month -- the value rolls over every month.

 

The function GetDays() ((plural DayS instead of Day)) is defined in XGStrategy, and is defined:

 

function int GetDays()
{
return GEOSCAPE().m_kDateTime.DifferenceInDays(AI().m_kStartDate);
}

 

It also has a nice compact call (that decompiles as Game().GetDays()) that can be called from anywhere in the strategy game. It's only 29 bytes in hex, too. JL, you might look want to look into using it for your interceptor upgrades? Just a thought....

 

If you want to use it, it's:

 

 

 

Game().GetDays() hex: (29 bytes)
19 1B 4C 0E 00 00 00 00 00 00 16 0A 00 82 41 00 00 00 1B F2 0E 00 00 00 00 00 00 16

Unfortunately, it's not accessible from the tactical side of the game.
As JL said, I'm having to try and find a way to sneak it over by hijacking an existing data structure. Unfortunately, the totally unused variables have no address in the strategy side, so I keep getting unexpected side-effects. So far I've made it impossible to complete missions, and the spawning of extra civilians in terror missions is another good one.
But, the work goes on.
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...