Change Hero Proper name during Metamorphosis

Level 8
Joined
Jul 22, 2015
Messages
123
I tried to change hero name using GUI/Trigger, it work fine when transforming, but the problem after Metamorphosis duration ended the hero name unchanged to previous one. Please i need help :(
  • Demonorphosis
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Demonorphosis
    • Actions
      • Set DemonoInt[0] = (DemonoInt[0] + 1)
      • Set DemonoUser[DemonoInt[0]] = (Triggering unit)
      • Set DemonoRealName[DemonoInt[0]] = (Proper name of DemonoUser[DemonoInt[0]])
      • Hero - Set Name of DemonoUser[DemonoInt[0]] to Albedo
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DemonoInt[0] Equal to 1
        • Then - Actions
          • Trigger - Turn on DemonorphosisRun <gen>
        • Else - Actions
  • DemonorphosisRun
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • For each (Integer DemonoInt[1]) from 1 to DemonoInt[0], do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of DemonoUser[DemonoInt[1]]) Equal to Priestess (Tinker Evolution)
            • Then - Actions
              • Game - Display to (All players) the text: DemonoRealName[DemonoInt[1]]
              • Hero - Set Name of DemonoUser[DemonoInt[1]] to DemonoRealName[DemonoInt[1]]
              • Set DemonoUser[DemonoInt[1]] = DemonoUser[DemonoInt[0]]
              • Set DemonoRealName[DemonoInt[1]] = DemonoRealName[DemonoInt[0]]
              • Set DemonoInt[1] = (DemonoInt[1] - 1)
              • Set DemonoInt[0] = (DemonoInt[0] - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DemonoInt[0] Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • Game - Display to (All players) the text: DemonoRealName[DemonoInt[1]]
 
It is likely because "A unit Starts the effect of an ability" runs twice for metamorphosis: once for when you morph, and then once when you unmorph. So when he unmorphs, it will run the "Demonorphosis" logic again (it'll store his real name as "Albedo" since "DemonorphosisRun" hasn't run to revert his name yet). And that later causes issues when "DemonorphosisRun" fires, as it will first change his name back to his real name, and then to "Albedo" (since it got triggered when he "unmorphed").

I recommend doing two things:
  1. Use the "Finishes casting ability" event so that you can change the name once the morph is finished
  2. Add a condition to check that the unit-type of the triggering unit is the morphed form to make sure this only runs when you morph (not on the "unmorph")
  • Demonorphosis
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Demon Hunter (Demon Form)
      • (Ability being cast) Equal to Demonorphosis
    • Actions
      • Set VariableSet DemonoInt[0] = (DemonoInt[0] + 1)
      • Set VariableSet DemonoUser[DemonoInt[0]] = (Triggering unit)
      • Set VariableSet DemonoRealName[DemonoInt[0]] = (Proper name of DemonoUser[DemonoInt[0]])
      • Hero - Set Name of DemonoUser[DemonoInt[0]] to Albedo
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DemonoInt[0] Equal to 1
        • Then - Actions
          • Trigger - Turn on DemonorphosisRun <gen>
        • Else - Actions
Then it should work as you expect!
 
Level 8
Joined
Jul 22, 2015
Messages
123
It is likely because "A unit Starts the effect of an ability" runs twice for metamorphosis: once for when you morph, and then once when you unmorph. So when he unmorphs, it will run the "Demonorphosis" logic again (it'll store his real name as "Albedo" since "DemonorphosisRun" hasn't run to revert his name yet). And that later causes issues when "DemonorphosisRun" fires, as it will first change his name back to his real name, and then to "Albedo" (since it got triggered when he "unmorphed").

I recommend doing two things:
  1. Use the "Finishes casting ability" event so that you can change the name once the morph is finished
  2. Add a condition to check that the unit-type of the triggering unit is the morphed form to make sure this only runs when you morph (not on the "unmorph")
  • Demonorphosis
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Demon Hunter (Demon Form)
      • (Ability being cast) Equal to Demonorphosis
    • Actions
      • Set VariableSet DemonoInt[0] = (DemonoInt[0] + 1)
      • Set VariableSet DemonoUser[DemonoInt[0]] = (Triggering unit)
      • Set VariableSet DemonoRealName[DemonoInt[0]] = (Proper name of DemonoUser[DemonoInt[0]])
      • Hero - Set Name of DemonoUser[DemonoInt[0]] to Albedo
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DemonoInt[0] Equal to 1
        • Then - Actions
          • Trigger - Turn on DemonorphosisRun <gen>
        • Else - Actions
Then it should work as you expect!
Thanks to replies and it worked as expected!!
 
Top