![](https://aom.heavengames.com/forums/posticon.gif)
For anyone that has used my original modify protounit absolute http://aom.heavengames.com/cgi-bin/forums/display.cgi?action=ct&f=13,29917,0,all there was an issue where some fields that are integer based would not work. I have discovered a second exploit which abuses integer overflow that allows integer fields to be set now too. Below is a modified improved version which should now work with every field. ![](http://aom.heavengames.com/forums/smile.gif)
As for how it works - I am not really sure but essentially if you overflow the integer field it seems to go to the same value regardless by how much, then I just need to normalise to 0 before setting the actual value.
NOTE: I don't know if this improvement will work in the non EE version as the handling of overflow may be different.
![](http://aom.heavengames.com/forums/smile.gif)
<Effect name="Modify Protounit Absolute player range">
<Param name="ProtoUnit" dispName="$$22449$$ProtoUnit" varType="protounit"> Anubite< /Param>
<Param name="p1" dispName="lowest player" VarType="string"> 1< /Param>
<Param name="p2" dispName="highest player" VarType="string"> 4< /Param>
<Param name="Field" dispName="$$23943$$Field" varType="pufield"> 0< /Param>
<Param name="Amount" dispName="Amount" VarType="string"> 1.0< /Param>
<Command> trQuestVarSet("PlayerID", %p1%);< /Command>
<Command> while(%p2%> =trQuestVarGet("PlayerID")) {< /Command>
<Command> if(%Field% == 6){< /Command>
<Command> trModifyProtounit("%ProtoUnit%", 1*trQuestVarGet("playerID"), %Field%, -9999999999999999999.0);< /Command>
<Command> trModifyProtounit("%ProtoUnit%", 1*trQuestVarGet("playerID"), %Field%, %Amount% - 1);< /Command>
<Command> } else if(%Field% == 5 | | %Field% == 7 | | %Field% == 10 | | %Field% == 13){< /Command>
<Command> trModifyProtounit("%ProtoUnit%", 1*trQuestVarGet("playerID"), %Field%, 2147483648.0);< /Command>
<Command> trModifyProtounit("%ProtoUnit%", 1*trQuestVarGet("playerID"), %Field%, 2147483648.0);< /Command>
<Command> trModifyProtounit("%ProtoUnit%", 1*trQuestVarGet("playerID"), %Field%, %Amount%);< /Command>
<Command> } else {< /Command>
<Command> trModifyProtounit("%ProtoUnit%", 1*trQuestVarGet("playerID"), %Field%, 9999999999999999999.0);< /Command>
<Command> trModifyProtounit("%ProtoUnit%", 1*trQuestVarGet("playerID"), %Field%, -9999999999999999999.0);< /Command>
<Command> trModifyProtounit("%ProtoUnit%", 1*trQuestVarGet("playerID"), %Field%, %Amount%);< /Command>
<Command> }< /Command>
<Command> trQuestVarSet("PlayerID", trQuestVarGet("PlayerID")+1);}< /Command>
</Effect>
As for how it works - I am not really sure but essentially if you overflow the integer field it seems to go to the same value regardless by how much, then I just need to normalise to 0 before setting the actual value.
NOTE: I don't know if this improvement will work in the non EE version as the handling of overflow may be different.
[This message has been edited by nottud (edited 01-06-2019 @ 07:39 AM).]