• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

saved key in hashtable issue

Status
Not open for further replies.
The title is meh.

The spell's purpose.
-First use: Store the target of the ability
-Second use: Move the stored unit to the target point of the ability

Triggers:

  • Allocate Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Allocate
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • uAllocate_Unit Not equal to No unit
        • Then - Actions
          • Hashtable - Save Handle Of(Target point of ability being cast) as 0 of iAllocateKey_Unit in hashAllocate
          • Unit Group - Add uAllocate_Unit to ugAllocate_Group
          • Trigger - Turn on Allocate Move <gen>
          • Set uAllocate_Unit = No unit
        • Else - Actions
          • Set uAllocate_Unit = (Target unit of ability being cast)
          • Set iAllocateKey_Unit = (Key (Target unit of ability being cast))
  • Allocate Move
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in ugAllocate_Group and do (Actions)
        • Loop - Actions
          • Set pTemp_Point_1 = (Position of (Picked unit))
          • Set pTemp_Point_2 = (pTemp_Point_1 offset by 30.00 towards (Angle from pTemp_Point_1 to (Load 0 of iAllocateKey_Unit in hashAllocate)) degrees)
          • Unit - Move (Picked unit) instantly to pTemp_Point_2
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between pTemp_Point_2 and (Load 0 of iAllocateKey_Unit in hashAllocate)) Less than or equal to 31.00
            • Then - Actions
              • Unit Group - Remove (Picked unit) from ugAllocate_Group
            • Else - Actions
          • Custom script: call RemoveLocation (udg_pTemp_Point_1)
          • Custom script: call RemoveLocation (udg_pTemp_Point_2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in ugAllocate_Group) Less than or equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
The unit gets stored, and the unit gets moved.
The problem is that it fails to get the stored point so the unit will move to the default location (mid map).

What am I missing?
 
Level 5
Joined
Jan 27, 2014
Messages
164
Somehow, to me, the else statement in your first trigger seems pretty redundant.
Perhaps there are other triggers involved for that though.

In your first trigger,
Hashtable - Save Handle Of(Position of (Target unit ability being cast)) as 0 of (Key(Target unit ability being cast)) in hashAllocate

In your second trigger,
Change all your iAllocateKey_Unit to 'Key(Picked unit))'.

Then again, I don't think this will solve your problem.
Cos I still don't understand the then/else statements in your first trigger.
Not sure how you stored the unit key and unit variable.
 
why not just save the X,Y instead?

like

  • Custom script: set udg_X = GetSpellTargetX
  • Custom script: set udg_Y = GetSpellTargetY
  • Hashtable - Save X as 0 of iAllocateKey_Unit in hashAllocate
  • Hashtable - Save Y as 1 of iAllocateKey_Unit in hashAllocate
X and Y are reals btw

then
  • Set X = Load 0 of iAllocateKey_Unit in hashAllocate
  • Set Y = Load 1 of iAllocateKey_Unit in hashAllocate)
  • Custom script: set udg_pTemp_Point = Location(udg_X,udg_Y)
  • Set pTemp_Point_1 = (Position of (Picked unit))
  • Set pTemp_Point_2 = (pTemp_Point_1 offset by 30.00 towards (Angle from pTemp_Point_1 to (pTemp_Point) degrees)
    • Unit - Move (Picked unit) instantly to pTemp_Point_2
then also remove pTemp_Point
 
I was sooo hoping no one would answer this thread. I'll get to that.

The if/then/else is to check what phase the ability is in.
The spell's purpose.
-First use: Store the target of the ability
-Second use: Move the stored unit to the target point of the ability

If no unit is stored I need to store the target unit of the ability.
If that has already been done, then I need to store the point of the ability.
So first you use the ability on a unit, then you use it at some point. That way the stored unit will be moved to the second target of the ability.

Now to why I was hoping no one would answer.
I figured this out literally seconds after I posted.

I didn't create a hashtable and didn't set the hashAllocate variable... wow... -.-
 
Status
Not open for further replies.
Top