• 🏆 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] Me again! Periodic spawning of a unit after purchase

Status
Not open for further replies.
Level 3
Joined
May 12, 2012
Messages
59
what up people me again with another crappy issue i got. im trying to set up a trigger that when a unit finishes being trained it stores the unit to be spawned after a periodic event in another trigger, right now i have it set up as a game cache. like this

  • Untitled Trigger 001
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • ((Triggering player) is in Marines) Equal to True
    • Actions
      • Game Cache - Store (Trained unit) as (StoredUnit + 1) of StoredUnit in GameCache
Right now it doesnt even store the unit properly if at all
Then

  • Drop Ship
    • Events
      • Time - Elapsed game time is 120.00 seconds
      • Time - Every 900.00 seconds of game time
    • Conditions
    • Actions
      • Sound - Play ImmolationTarget1 <gen> at 100.00% volume, attached to (Random unit from DropShip)
      • Animation - Change (Random unit from DropShip) flying height to 200.00 at 650.00
      • Wait 1.50 seconds
      • Animation - Change (Random unit from DropShip) flying height to 30.00 at 130.00
      • Wait 15.00 seconds
      • Sound - Play Loading <gen> at 100.00% volume, attached to (Random unit from DropShip)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load StoredUnit of StoredUnit from GameCache) Equal to 0
        • Then - Actions
          • Do nothing
        • Else - Actions
          • For each (Integer A) from 1 to (Length of StoredUnit), do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load StoredUnit of StoredUnit from GameCache) Equal to 0
                • Then - Actions
                  • Game Cache - Clear GameCache
                • Else - Actions
                  • Game Cache - Restore StoredUnit of StoredUnit from GameCache for (Owner of (Last restored unit)) at (Position of (Triggering unit)) facing (Position of (Triggering unit))
The end of this trigger isnt done, its just decorate additional crap, but the restore unit function doesnt work at all, dont know why, dont even know if its because its not even sotring them
 
Last edited:
Level 3
Joined
May 12, 2012
Messages
59
Update:

so i went through and looked at what people were suggesting for other peoples triggers and came across hashtables. thoes look like they will work but im not to familiar ith em, read through a few tutorials on em and loaded a tutorial map to no avail.

if anyone has any sudjestions to fix this stupid issue thad be appriciated.

all i need it to do is that when a player purchases a marine team unit like a soldier maurader or synthetic it removes that unit and stores its value and data somehow to be retreived and placed when the drop ship lands every 10 min.

now that you have the idea a solution would rock
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Save the Unit Type of the trained unit into a Unit-Type array and set the array index to +1 every time a unit is trained (When you train your first unit, the array will be 1, when you train the second, the array will be 1+1, then 2+1, then 3+1, and so on). When the ship arrives, just "For each integer A from 1 to Index do "Create 1 UnitTypeVariable[index] at point"
 
Level 3
Joined
May 12, 2012
Messages
59
what am i saving it as? i understand what your saying but is it a hashtable or a cache? like i said i JUST started looking at hashtables
 
Level 3
Joined
May 12, 2012
Messages
59
mkay, built that trigger and i seem to have the exact same issue as before, although now the drop ship works awesome and leaves now.... but considering it does leave i dont think its storing the unit data and adding it as a plus 1

heres what i put it in as
  • Send To Ship
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • ((Triggering player) is in Marines) Equal to True
    • Actions
      • Set StoredUnit[(Unit_being_stored + 1)] = (Trained unit-type)
      • Unit - Remove (Trained unit) from the game
then to retrieve it i have the below in another long trigger (its decorative BS so i didnt include it)

  • For each (Integer A) from 1 to Unit_being_stored, do (Actions)
    • Loop - Actions
      • Unit - Create 1 StoredUnit[Unit_being_stored] for (Owner of (Triggering unit)) at (Position of (Random unit from DropShip)) facing (Random angle) degrees
      • Set Unit_being_stored = (Unit_being_stored - 1)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
No :)

Create 1 Integer variable: "UnitCount"
Create 1 Unit-Type variable array

Unit - A unit Finishes training a unit
((Triggering player) is in Marines) Equal to True
Set UnitCount = UnitCount + 1
Set StoredUnit[UnitCount] = (Trained unit-type)

Then For each (Integer A) from 1 to UnitCount, do (Actions)
Unit - Create 1 Soldier[Integer A] for (Owner of (Triggering unit)) at (Position of (Random unit from DropShip)) facing (Random angle) degrees
 
Level 3
Joined
May 12, 2012
Messages
59
nope

i guess warcraft just hates me, made sure three times that it was exactly as you posted it and still to my disbelief..... failure lol, im not at all surprised as the curse of my maps continues on, every time im at the last step it bombs
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Actually, your trigger was fine, the only thing you need to remove is the " Set Unit_being_stored = (Unit_being_stored - 1)" inside the loop and will look just like mine.
 
Level 3
Joined
May 12, 2012
Messages
59
still nope :p does it work for you? im assuming it does, but does it work the way i described it? im training a unit doesnt matter what kind and i want that unit removed from the game with its data stored to create it later on after another trigger gets halfway finished. if it does, how do you fix the fact that the intiger array is still at whatever you trained it to and will keep going up? (the drop ship leaving is dependant on that array equaling zero so i know its not cause it no longer leaves)

its unfortunate but this spawning ability is required for this group to balance them out compared to all the other spicies, i dont wanna go through and rebalance and regigger everything cause this doesnt work:vw_sad:
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
A unit is trained
-->
Set Index = Index + 1
Set Soldiers[Index] = Unit type of Trained Unit

It will increase the array by 1 everytime you train a unit. If this is a periodic thing, which happens every 10 minutes spawning the stored units, then, after spawning, you do "For each integer A from 1 to Index do" -> Custom Script: set udg_Soldiers[bj_forLoopAIndex] = null

It will clean all the array, and set the Index again to 0, and the process will start over.
 
Level 3
Joined
May 12, 2012
Messages
59
good news

well the custom script set it to zero so it only spawned JUST one unit so i scrapped that and used a variable.... now it works, makes the units (ALL of them, no matter the type) and gives them their starting item and then as icing even flys away afterward..... and i would not have figured it out at all if you didnt have an ENORMOUS amount of patience saying the same thing over and over lol. much appriciated, now i can find people to test it add their input and upload it:goblin_yeah:
 
Status
Not open for further replies.
Top