You must be logged in to post messages.
Please login or register

Scenario Design
Moderated by Yeebaagooon, nottud

Hop to:    
loginhomeregisterhelprules
Bottom
Topic Subject: New Trigger: Modify Protounit Absolute Player Range
posted 23 September 2017 08:28 AM EDT (US)   
Hi everyone - just figured out a way to make a Modify Protounit that can set the value of a field rather than add or subtract from it. It works by abusing the loss of precision with high numbers causing many values to become the same value - something that happens when you add a large number to a small number.

With this trick adding and subtracting a very large number will give the result of zero. As a result this then allows the value to be set to whatever you like regardless of the starting value. This will not work with every field but the majority of fields do seem to work including:

  • Hitpoints
  • LOS
  • Speed
  • Lifespan
  • Attack
  • Cost

    And probably several others. Some fields like population count does work - might relate make adjustments to make it work for those fields too but thought it was worth releasing anyway in its current state in case anyone finds it useful.

    <Effect name="Modify Protounit Absolute player range">
    <Param name="ProtoUnit" dispName="$$22449$$ProtoUnit" varType="protounit">Anubite</Param>
    <Param name="p1" dispName="lowest player" varType="player">1</Param>
    <Param name="p2" dispName="highest player" varType="player">4</Param>
    <Param name="Field" dispName="$$23943$$Field" varType="pufield">0</Param>
    <Param name="Amount" dispName="Amount" varType="float">1.0</Param>
    <Command>trQuestVarSet("PlayerID", %p1%);</Command>
    <Command>while(%p2%>=trQuestVarGet("PlayerID")) {</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>trQuestVarSet("PlayerID", trQuestVarGet("PlayerID")+1);}</Command>
    </Effect>

    [This message has been edited by nottud (edited 09-23-2017 @ 08:31 AM).]

  • Replies:
    posted 23 September 2017 09:08 AM EDT (US)     1 / 16  
    Can I worship you ?
    posted 23 September 2017 02:26 PM EDT (US)     2 / 16  
    You advanced to the Scenario Making Age through the Trickery of nottud.

    Thankya!


    Great Effect! What I tried immediately was setting the Pop Count to zero, since you're not allowed to put it down to zero if the unit does start with a higher value. That doesnt work sadly, but still, great Effect.

    Azarath Metrion Zinthos

    Steam: Order of Azarath
    Twitch: twitch.tv/orderofazarath
    Discord: Azarath @ https://discord.gg/3ENKJeb

    [This message has been edited by Izalith (edited 09-23-2017 @ 02:33 PM).]

    posted 23 September 2017 03:16 PM EDT (US)     3 / 16  
    Awesome.

    ______________________________________ Yeebaagooon ______________________________________
    ____________________ AoMH Seraph ____________________
    "You can't trust yeebaagooon to lead a rebelion, He would send everyone to steal mirrors so he could bask in his own brilliance." - Out Reach
    "Yeebaagooon had never seen a more handsome man in all his life. He couldn't control himself, He needed to act. Gripping the mirror in his strong arms he kissed the figure before him..." - Out Reach
    AoMH: Unfinished Scenarios|Singleplayer: Codename Ripto|Multiplayer: Minigames Z|CSC 7
    Ex Seraphs Dictator, Spore Heaven Seraph
    posted 23 September 2017 04:18 PM EDT (US)     4 / 16  
    Izalith: Use my infinite population triggers.
    posted 23 September 2017 04:21 PM EDT (US)     5 / 16  
    Damn, this is phenomenal.

    I'm guessing you could probably do this with two triggers, one for the high number and one for the value.

    posted 23 September 2017 04:38 PM EDT (US)     6 / 16  
    Yes you can use standard modify protounit triggers with the values I put in the code above - this means you can simply use existing modify protounit triggers to do it without installing the above code. (Especially useful if you say want to apply to say all units)

    [This message has been edited by nottud (edited 09-23-2017 @ 04:39 PM).]

    posted 23 September 2017 05:15 PM EDT (US)     7 / 16  
    I'm thinking at one excellent use :
    If you don't want a unit stat to change, such as time recharge if it is possible, you just have to put the trigger on loop !
    Or with a timer of 1 second even if i think that this effect is very Light on the processing
    posted 23 September 2017 05:41 PM EDT (US)     8 / 16  
    Oh wow, this is clever. This also reminds me of the modify protounit effects I created a while ago which can also set stats to an absolute value (and modify stats by a percentage): I talk about it here. But it's not fail-safe compared to your method.

    (I don't mean to hijack the thread - I just thought it was relevant )

    What are the key ingredients to make a popular RPG? To find out, read the results of the RPG survey.
    Want to create an advanced patrol/pathfinding system? Have a look at the powerful Pathfinding triggers.
    Games I'm playing: The Witness [80%] Chivalry: Medieval Warfare [20%]
    posted 23 September 2017 06:34 PM EDT (US)     9 / 16  
    Cool - if you find a way to somehow make a percentage version work I am interested.

    @eine_gurkensalad: Nice - was something I wondered myself. I don't know if the temporary high value makes any difference to simply setting the stat directly. If it did I could imagine some amusing bugs happening say with unit speed.

    A nice use which is pretty simple to me is it provides a good way to remove civ bonuses/differences easily. E.g. If you want towers to cost exactly 200 gold for everyone all you need to do now is set the wood cost to zero and the gold cost to 200. No more messing around checking if players are certain civs and such.

    Another thought I had generally which I have not tried yet but I would imagine a similar trick could be used to make a "set resource" trigger too without worrying about accidentally setting the resource count of a player negative. EDIT: Confirmed the trick works for resources too.

    [This message has been edited by nottud (edited 09-23-2017 @ 06:39 PM).]

    posted 24 September 2017 03:22 AM EDT (US)     10 / 16  
    So does it work with recharge time ?
    Because in my civ some myth units have a reduced recharge time. But let's say there is the cerberus tail relic it will impact too much because of the base percent process
    posted 24 September 2017 04:47 AM EDT (US)     11 / 16  
    Not looked at recharge time but I can't think of a rwason why it would not work. As for countering relics can't you just use the timer you mentioned earlier?
    posted 24 September 2017 05:50 AM EDT (US)     12 / 16  
    I don't see the relation between the timer and the relics...
    posted 26 September 2017 02:01 AM EDT (US)     13 / 16  
    I made a set unit cost trigger in the past that used kb commands to determine the cost of the protounit. That could be used to modify the cost by a percentage I think quite easily.
    posted 26 September 2017 06:49 AM EDT (US)     14 / 16  
    Oh maybe I wasn't clear enough, but I did make a percentage version of the modify protounit effect. The only limitations* are that researched technologies and god bonuses that alter the stat values aren't accounted for (such as the medium/heavy/champion technologies and hades' extra attack for archers and hitpoints for buildings). AFAIK, there's no command in the game that lets you retrieve the actual unit's stat values. So as a workaround, the designer would have to create a seperate trigger that detects newly researched stat-altering technologies and then update the stats with a special effect that keeps track of the actual unit's stats.

    * For me it isn't really a limitation because I only wanted a modify percentage effect to modify the units' base statistics by a percentage value. Thematically, it wouldn't make much sense if e.g. the "Bronze weapons" upgrade suddenly becomes more effective.

    What are the key ingredients to make a popular RPG? To find out, read the results of the RPG survey.
    Want to create an advanced patrol/pathfinding system? Have a look at the powerful Pathfinding triggers.
    Games I'm playing: The Witness [80%] Chivalry: Medieval Warfare [20%]

    [This message has been edited by Lewonas (edited 09-26-2017 @ 06:51 AM).]

    posted 26 September 2017 08:02 AM EDT (US)     15 / 16  
    I may have had that issue with my trigger (I was not interested). I used it to set the gold unit cost of each unit to its protounit ID so I could check which unit was the last to be killed. I think I have also had issues with setting the favour cost of Kronos myth units to 0.
    posted 26 September 2017 09:12 PM EDT (US)     16 / 16  
    You are a mad genius and you must be stopped.

    "I NED MOAR RANGE" Pubby8

    [This message has been edited by pBiggZ (edited 09-26-2017 @ 09:13 PM).]

    Age of Mythology Heaven » Forums » Scenario Design » New Trigger: Modify Protounit Absolute Player Range
    Top
    You must be logged in to post messages.
    Please login or register
    Hop to:    
    Age of Mythology Heaven | HeavenGames