• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Hashtable Load Player Problem

Status
Not open for further replies.
Level 10
Joined
Sep 25, 2013
Messages
521
Ive created a system in which a unit moves continually in one direction for a duration and kills every unit in its path. While the unit is moving, the player looses control of that unit.

I have 2 separate versions of this unit. Version 1 has a collision size and does not kill units in its way. Version 2 has its collision size set to 0 so it can move through units easily and crush them.

In the trigger, when the unit casts it ability, "Rampage", the Version 1 unit is replaced by the Version 2 unit and then its ownership is changed to neutral extra and it is ordered to move to the target point of the casting ability.

The problem arises when the duration runs out and I want to return the unit to its original owner after returning that unit to a Version 1 unit. The unit changes it ownership to neutral extra instead of the saved player value.

  • Mamukil Rampage Cast
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Rampage (Mamukil)(Newer Yet)
    • Actions
      • Set MamukilTargetPoint = (Position of (Target unit of ability being cast))
      • Hashtable - Save Handle Of(Owner of (Triggering unit)) as 2 of (Key (Triggering unit)) in MamukilPlayerHashtable
      • Unit - Replace (Triggering unit) with a Rampaging Mamukil |c00FFFF00(Elite)|r (Haradrim) using The old unit's relative life and mana
      • Set RampagePoint = (MamukilTargetPoint offset by 1000.00 towards (Angle from (Position of (Triggering unit)) to MamukilTargetPoint) degrees)
      • Unit - Change ownership of (Last replaced unit) to Neutral Extra and Retain color
      • Unit - Order (Last replaced unit) to Move To RampagePoint
      • Unit Group - Add (Last replaced unit) to MamukilUnitGroup
      • Hashtable - Save 7 as 1 of (Key (Last replaced unit)) in MamukilHashtable
  • Mamukil Rampage
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in MamukilUnitGroup and do (Actions)
        • Loop - Actions
          • Set MamukilRemainingTime = (Load 1 of (Key (Picked unit)) from MamukilHashtable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MamukilRemainingTime Greater than 0
            • Then - Actions
              • Hashtable - Save (MamukilRemainingTime - 1) as 1 of (Key (Picked unit)) in MamukilHashtable
              • Special Effect - Create a special effect attached to the origin of (Picked unit) using Objects\Spawnmodels\Undead\ImpaleTargetDust\ImpaleTargetDust.mdl
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • Unit - Change ownership of (Picked unit) to (Load 2 of (Key (Picked unit)) in MamukilPlayerHashtable) and Change color
              • Unit - Replace (Picked unit) with a Mamukil |c00FFFF00(Elite)|r (Haradrim) using The old unit's relative life and mana
              • Hashtable - Clear all child hashtables of child (Key (Owner of (Picked unit))) in MamukilPlayerHashtable
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in MamukilUnitHashtable
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in MamukilHashtable
              • Custom script: call RemoveLocation (udg_RampagePoint)
              • Unit Group - Remove (Picked unit) from MamukilUnitGroup
Yes, there are two hashtables, and i could condense it into 1, thats not the problem though, I'll make that change once i figure this main issue out
 
Level 25
Joined
Sep 26, 2009
Messages
2,377
Try
  • Set player_var = (Load 2 of (Key (Picked unit)) in MamukiPlayerHashtable
  • Unit - Change ownership of (Picked unit) to player_var and Change color
From my personal experience, sometimes direct loading from hashtable doesn't work as expected, but I have never had this issue when I pre-loaded the value from hashtable into variable and used the variable instead.
 
Status
Not open for further replies.
Top