• 🏆 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!

[Trigger] Need help removing a certain Variable Array.

Status
Not open for further replies.
Level 8
Joined
Sep 1, 2009
Messages
124
Hey uh, i need help with removing a Variable array, if anyone can help me that would be awesome... this is the trigger for starters:

  • Unequip
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Equip Manager
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Weapon Remove
        • Then - Actions
          • Unit - Remove WeaponBonus[(Player number of (Owner of (Triggering unit)))] from (Random unit from (Units owned by (Owner of (Triggering unit)) of type Villager))
          • Item - Create Weapons[(Player number of (Owner of (Triggering unit)))] at (Position of (Random unit from (Units owned by (Owner of (Triggering unit)) of type Villager)))
          • Unit - Order (Random unit from (Units owned by (Owner of (Triggering unit)) of type Villager)) to Right-Click (Last created item)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Shield Remove
            • Then - Actions
              • Unit - Remove ShieldBonus[(Player number of (Owner of (Triggering unit)))] from (Random unit from (Units owned by (Owner of (Triggering unit)) of type Villager))
              • Item - Create Shields[(Player number of (Owner of (Triggering unit)))] at (Position of (Random unit from (Units owned by (Owner of (Triggering unit)) of type Villager)))
              • Unit - Order (Random unit from (Units owned by (Owner of (Triggering unit)) of type Villager)) to Right-Click (Last created item)
            • Else - Actions
Now, after the first one Then - Actions, i need a custom script code to remove the Array for the owner of triggering unit. Since the:
  • Item - Create Weapons[(Player number of (Owner of (Triggering unit)))] at (Position of (Random unit from (Units owned by (Owner of (Triggering unit)) of type Villager)))
Would create the item in Weapons[(Player number of (Owner of (Triggering unit)))] array. I want the script to remove that array for that one specific person. I'll explain a little more:
When the unit picks up a item and uses Equip, the item in slot one is set to
  • Set Weapons[(Player number of (Owner of (Triggering unit)))] = (Item-type of (Item carried by (Triggering unit) in slot 1))
array for the person. After that the item is removed. Once you go to the Equipment part and remove it, it removes the weapon, but is still in the array, so you can continue removing the weapon forever. Can anyone help me with that? Just a custom script code to remove the array for the owner of the triggering unit. Thanks in advance! :spell_breaker:
 
Level 9
Joined
Nov 4, 2007
Messages
931
If its just the custom script you want for that just do
JASS:
set udg_Weapons[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = null
that should free up the array.
 
Level 8
Joined
Sep 1, 2009
Messages
124
um, i dont do jass, and isint it: call RemoveLocation(udg_Name[array]) thing? i tried that but it wouldint work.

  • Custom script: set udg_Weapons[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = null
Thats what i put in it, but it wouldint work >.< it said Type mismatch in assignment. no idea what that is.
 
Level 9
Joined
May 28, 2007
Messages
365
  • set udg_Weapons[GetPlayerId(GetOwningPlayer(GetTriggerUnit()))] = 0
I'm pretty sure your udg_Weapons is just an integer, so it can't be set to null.

Yes, you are leaking a location when you create the item, so you'll need to use a tempLocation there as well.

Also, I'm not sure if you are aware or not but you're creating an entire group just to pick a one unit from it. You are also leaking this unitGroup as well, so use some leak cleaning there as well.
 
Status
Not open for further replies.
Top