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

Spawn Glich

Status
Not open for further replies.
Level 17
Joined
Jun 17, 2010
Messages
2,275
  • Footmen Spawn
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • For each (Integer B) from 1 to (Number of players in (All players controlled by a User player)), do (Actions)
        • Loop - Actions
          • For each (Integer A) from 1 to (Number of players in (All players matching (((Player((Integer B))) slot status) Equal to Is playing))), do (Actions)
            • Loop - Actions
              • Unit - Create (Integer A) Footman for (Player((Integer A))) at Spawn_Point[0] facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_Spawn_Point[0])
Its supposed to create 1 of for each player, it has mutliple glitches like if someone goes gray it doesnt spawn for him, it spawns like 10 units for each color, and spawns for colors not in the game.
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
Doesn't work because you loop from 1 to number of players.
Imagine situation: There are players 1,2 and 5.
It would loop from 1 to 3 which bugs,obviously.
Use:
  • Player Group - Pick every player in (All players matching (((Matching player) controller) Equal to User)) and do (Actions)
    • Loop - Actions
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
Just use:
  • Footmen Spawn
  • Events
    • Time - Elapsed game time is 1.00 seconds
  • Conditions
  • Actions
    • Player Group - Pick every player in (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing))) and do (Actions)
    • Loop - Actions
      • Unit - Create (Integer A) Footman for (Player((Integer A))) at Spawn_Point[0] facing Default building facing degrees
    • Custom script: call RemoveLocation(udg_Spawn_Point[0])
 
Level 17
Joined
Jun 17, 2010
Messages
2,275
  • Riflemen Uniform
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
      • (Item-type of (Item being manipulated)) Equal to Riflemen Uniform
    • Actions
      • Set UnitVariable[(Player number of (Owner of (Triggering unit)))] = (Triggering unit)
      • Set Spawn_Point[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
      • Unit - Remove (Triggering unit) from the game
      • Set Spawn_Point[11] = Spawn_Point[(Player number of (Owner of (Triggering unit)))]
      • Unit - Create 1 Footman (Uniform) for (Owner of (Triggering unit)) at Spawn_Point[11] facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_Spawn_Point[11])
      • Hero - Create Riflemen Uniform and give it to UnitVariable[(Player number of (Owner of (Triggering unit)))]
      • Selection - Select UnitVariable[(Player number of (Owner of (Triggering unit)))] for (Owner of (Triggering unit))
Now this doesnt work, it makes 5 riflemen for every person when they pick it up, then it drops the item on the ground, and doesnt select the rifleman.
 
  • Riflemen Uniform
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
      • (Item-type of (Item being manipulated)) Equal to Riflemen Uniform
    • Actions
      • Set UnitVariable[(Player number of (Owner of (Triggering unit)))] = (Triggering unit)
      • Set Spawn_Point[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
      • Unit - Remove (Triggering unit) from the game
      • Set Spawn_Point[11] = Spawn_Point[(Player number of (Owner of (Triggering unit)))]
      • Unit - Create 1 Footman (Uniform) for (Owner of (Triggering unit)) at Spawn_Point[11] facing Default building facing degrees
      • Set UnitVariable[(Player number of (Owner of (Triggering unit)))] = (Last Created Unit)
      • Custom script: call RemoveLocation(udg_Spawn_Point[11])
      • Hero - Create Riflemen Uniform and give it to UnitVariable[(Player number of (Owner of (Triggering unit)))]
      • Selection - Select UnitVariable[(Player number of (Owner of (Triggering unit)))] for (Owner of (Triggering unit))
Now this doesnt work, it makes 5 riflemen for every person when they pick it up, then it drops the item on the ground, and doesnt select the rifleman.

1. It is acting as a kind of recursive event. Luckily, a hero has only 6 slots so the trigger only fires 6 times. Basically, when you do this:
  • Hero - Create Riflemen Uniform and give it to UnitVariable[(Player number of (Owner of (Triggering unit)))]
It is starting this event all over again:
  • Unit - A unit Acquires an item
He keeps getting the rifleman uniform. This will result in the trigger to fire over and over until the unit's inventory is full, and then because of that you will have multiple riflemen and one item on the ground.

The fix is to make a dummy item to give that has the same name as the rifleman uniform, so that it won't fire the event again.

2. The selection doesn't work because the variable isn't set to the unit.
Add this after the creation of the rifleman:
  • Set UnitVariable[(Player number of (Owner of (Triggering unit)))] = (Last Created Unit)
And move this:
  • Unit - Remove (Triggering unit) from the game
To the bottom of the trigger.

That should fix the problems, hopefully. :)
 
Status
Not open for further replies.
Top