[Need Help] - $5 on Paypal if you help me - Enable/disable ability on unit summon/death

Level 2
Joined
Sep 13, 2021
Messages
9
Goal:
Make Rexxar from Heroes of the storm that has summon Misha as Q ability and E as mend pet ability that heals Misha.

What I need help with:
1. Disable mend pet for Rexxar when Misha is dead(not hide) only disable.
2. Enable mend pet for Rexxar when Misha is summoned back again with Q.

What I'm able to do:
1. Disable mend pet when Misha dies
Not able to re-enable it correctly (sometimes it works sometimes it doesn't).

I'm pulling my hair out and I agree to pay someone as long as they give me a working and somewhat clean solution to this. I'm also attaching screenshots of what I've tried so far.

Disable Trigger:
  • Disable Mend Pet
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to (Random unit from (Units owned by (Owner of (Triggering unit)) of type Misha (Level 1)))
    • Actions
      • Player - Disable Mend Pet for (Owner of (Triggering unit))
      • Unit - For (Random unit from (Units owned by (Owner of (Triggering unit)) of type Rexxar)), Ability Mend Pet , Disable ability: True, Hide UI: False
Enable Trigger:

  • Enable Mend Pet
    • Events
      • Unit - A unit Is rescued
      • Unit - A unit Finishes casting an ability
      • Unit - A unit Spawns a summoned unit
      • Unit - A unit Finishes training a unit
      • Unit - A unit Stops casting an ability
      • Unit - A unit Begins casting an ability
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • (Ability being cast) Equal to Summon Misha (Rexxar)
      • And - All (Conditions) are true
        • Conditions
          • (Triggering unit) Equal to (Random unit from (Units owned by (Owner of (Triggering unit)) of type Rexxar))
          • MishaLiving Equal to False
          • (Triggering unit) Equal to (Random unit from (Units owned by (Owner of (Triggering unit)) of type Misha (Level 1)))
          • (Unit-type of (Summoning unit)) Equal to Rexxar
      • (Unit-type of (Summoning unit)) Equal to Rexxar
      • (Ability being cast) Equal to Summon Misha (Rexxar)
      • (Unit-type of (Summoned unit)) Equal to Misha (Level 1)
      • (Summoned unit) Equal to (Random unit from (Units owned by (Owner of (Triggering unit)) of type Misha (Level 1)))
    • Actions
      • Player - Enable Mend Pet for (Owner of (Triggering unit))
      • Unit - For (Random unit from (Units owned by (Owner of (Triggering unit)) of type Rexxar)), Ability Mend Pet , Disable ability: False, Hide UI: False
      • Player - Enable Mend Pet for (Owner of (Triggering unit))
      • Unit - For (Random unit from (Units owned by (Owner of (Triggering unit)) of type Rexxar)), Ability Mend Pet , Disable ability: False, Hide UI: False
 

Attachments

  • Disable mend.JPG
    Disable mend.JPG
    75.5 KB · Views: 13
  • Enable mend.JPG
    Enable mend.JPG
    126.6 KB · Views: 16
Last edited:
Level 20
Joined
Sep 26, 2009
Messages
2,142
First of all, you should start using variables. My guess is that at most there can be 1 Rexxar unit per player. In that case, you can use MPI-approach - use a unit array variable and store reference to each Rexxar unit under the index of its owning player.

Next, I would replace all the "(Random unit from (Units owned by (Owner of (Triggering unit))" conditions, since they cause memory leaks
  • When referring to Rexar, use the variable
  • When referring to Misha, I think just checking the unit-type should be enough.
  • Also, I am unsure of this, but I think the "random unit from group" will also pick dead units (so you may end up picking dead Misha)
Assuming that the Misha unit can only ever be summoned by Rexxar unit, you can use the "Unit enters region" event to detect when unit was created (and thus entered the map).

  • Misha Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Misha (Level 1)
    • Actions
      • Unit - For RexxarUnits[(Player number of (Triggering player))], Ability Heal, Disable ability: True, Hide UI: False
  • Misha Spawns
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Misha (Level 1)
    • Actions
      • Unit - For RexxarUnits[(Player number of (Triggering player))], Ability Heal, Disable ability: False, Hide UI: False

The only thing missig is how to assign the Rexxar unit RexxarUnits[] array variable, but that depends on the trigger that spawns the Rexxar unit.
For example if in your trigger the (Triggering unit) is Rexxar, you can assign him to the array the following way:
  • Set VariableSet RexxarUnits[(Player number of (Owner of (Triggering unit)))] = (Triggering unit)
 
Level 2
Joined
Sep 13, 2021
Messages
9
I've copied 1-1 of what you suggested it, makes sense. However, it's not even disabling the ability anymore... 😭

  • Disable Mend Pet
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Misha (Level 1)
    • Actions
      • Unit - For RexxarUnits[(Player number of (Triggering player))], Ability Mend Pet , Disable ability: True, Hide UI: False

  • Enable Mend Pet
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Misha (Level 1)
    • Actions
      • Unit - For RexxarUnits[(Player number of (Triggering player))], Ability Mend Pet , Disable ability: False, Hide UI: False

For populating the array and to keep things simple for now I'm just adding generated Rexxar for player 1 to the array on map initialization and then disabling mend pet because Misha was never summoned (Although this action doesn't work either).

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Use melee time of day (for all players)
      • Melee Game - Limit Heroes to 1 per Hero-type (for all players)
      • Melee Game - Give trained Heroes a Scroll of Town Portal (for all players)
      • Melee Game - Set starting resources (for all players)
      • Melee Game - Remove creeps and critters from used start locations (for all players)
      • Melee Game - Create starting units (for all players)
      • Melee Game - Run melee AI scripts (for computer players)
      • Melee Game - Enforce victory/defeat conditions (for all players)
      • Set VariableSet RexxarUnits[(Player number of (Owner of Rexxar 0151 <gen>))] = Rexxar 0151 <gen>
      • Unit - For RexxarUnits[(Player number of (Owner of Rexxar 0151 <gen>))], Ability Mend Pet , Disable ability: True, Hide UI: False

BTW is there a way to display the array contents as a text message during the game?
Thank you for your help, please let me know what I'm doing wrong.
 
Last edited:
Level 20
Joined
Sep 26, 2009
Messages
2,142
Who is the owner of the "Rexxar 0151 <gen>" unit when your Map initialization trigger is executed? Is it the same player who later tries to summon/dismiss Misha? My guess is that that's the issue - the important thing is that when you add Rexxar to the unit array, the owner of the unit must be the same player who will later control Rexxar.

To display array contents, you need to iterate over the array. In this case, since there's about 30 possible players (including neutrals), you can use a "For Each Integer A, Do Multiple Actions" loop action and set it to iterate 30 times.
Then you can use the "Game - Text Message (Auto timed)" action to display some text.

I tried the following trigger to show the content of the array:
  • Check
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 30, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: ((Name of (Player((Integer A)))) + ( + (Name of RexxarUnits[(Integer A)])))
The trigger reacts when Red player presses Esc key and it will iterate through index 1-30 in the RexxarUnits array and displaying the unit's name (if any unit is there) in a message.
The message itself is using 2x the "Concatenate string" option to show the Player's name, space as separator, and the name of the unit.
The (Integer A) refers to current iteration of the loop (it starts on number 1 and increments by 1 per iteration up to 30).

Actually, to make it simpler, I created a fresh map and added the triggers there. It is created on the latest patch.
When playing the map, you can see that Rexxar's Storm Bolt is disabled - when he summons Misha it is enabled and when Misha dies it becomes disabled again.
Note that the triggers only react to level 1 Misha, so if you increase the level of the Summon Misha ability, it won't work (but that's just adding more unit types to the conditions)
 

Attachments

  • rexxar_heal.w3m
    17.5 KB · Views: 10
Level 2
Joined
Sep 13, 2021
Messages
9
The owner is the same one as the owner of the generated rexxar. Thank you for including the map, I've found that your Rexxar already had Q and E leveled up, which is why it's working, I set them to 0 and your map behaves the same way mine does. I have no clue why it's doing that... How can I fix this?
 
Level 20
Joined
Sep 26, 2009
Messages
2,142
Ah, ok, that makes sense. Since you disable the ability, but the Rexxar unit has no such ability, it kind of breaks :D

This trigger will detect when Rexxar learns the first level of Storm Bolt and depending on whether Misha has or has not been summoned, it will either leave the Storm Bolt ability enabled or disable it.

  • Rexxar Learns Spell
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Storm Bolt
      • (Level of Storm Bolt for (Triggering unit)) Equal to 1
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units owned by (Triggering player) matching (((Unit-type of (Matching unit)) Equal to Misha (Level 1)) and (((Matching unit) is alive) Equal to True)).)) Equal to 0
        • Then - Actions
          • Unit - For RexxarUnits[(Player number of (Triggering player))], Ability Storm Bolt, Disable ability: True, Hide UI: False
        • Else - Actions
The custom script in the trigger is meant to destroy the unit group created in the following condition block, preventing memory leak.

Attaching the updated map as well
 

Attachments

  • rexxar_heal.w3m
    18.1 KB · Views: 9
Level 2
Joined
Sep 13, 2021
Messages
9
Things are looking better, I'm going to need to do further testing & might get back to you, now I need to figure out why mend pet doesn't cast if I issue move command right after pressing E. But you have helped me substantially, please either leave a email connected to Paypal here or DM me! :)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Attached a test map.

Play around with the test map first, and see if it's working as intended.

Press ESC key to kill Misha.

Questions;
1. Does your map allows one (1) player to control more than 1 Rexxar ?
2. Does your map allows more than one (1) Rexxar to be spawned by multiple players at the same time ?

If both of your answers are no, then you can just import that test map to yours.

Else, I might have to do a rework on the test map to support multiple instances.
 

Attachments

  • Summon Misha.w3m
    12.3 KB · Views: 9
Top