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

[Solved] Hatching eggs

Status
Not open for further replies.
Hi everyone, I'm trying to make a zerg-like egg training sistem, but i have problems with the second condition and with the rally point. What am I doing wrong here?
  • Penguin Worker
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Penguin Worker
    • Actions
      • Set PenguinWorker = (Trained unit)
      • Set egg = (Position of PenguinWorker)
      • Set rallypointpenguin = (Rally-Point of PenguinWorker as a point)
      • Unit - Create 1 dummy penguin worker egg for Neutral Passive at egg facing 0.00 degrees
      • Unit - Order (Last created unit) to Neutral - Parasite (Trained unit)
      • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
      • Custom script: call RemoveLocation (udg_egg)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (PenguinWorker has buff Hatching (Minion)) Equal to False
        • Then - Actions
          • Unit - Replace PenguinWorker with a Penguin Worker using The old unit's relative life and mana
          • Unit - Order (Last replaced unit) to Attack-Move To rallypointpenguin
          • Sound - Play Penguin___u <gen>
          • Custom script: call RemoveLocation (udg_rallypointpenguin)
        • Else - Actions
Thx +rep
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,596
thx now the only problem is with the second condition , the egg will hatch immediately maybe is because of the buff?
If the condition is being met and the actions are running then that means the unit doesn't have the buff yet:
  • (PenguinWorker has buff Hatching (Minion)) Equal to False
What are you trying to do exactly? Is the worker supposed to spawn from the egg 3 seconds later?
If yes, then you can't or better yet shouldn't try to detect that inside of this trigger. Instead, detect when the egg dies using another trigger.
The Event "A unit dies" comes to mind. Then you can detect if there was a (Killing unit) or not, to determine whether or not the egg should spawn a worker.

Also, this line should be changed from this:
  • Unit - Order (Last created unit) to Neutral - Parasite (Trained unit)
To this, since you have a variable set to the (Trained unit) already:
  • Unit - Order (Last created unit) to Neutral - Parasite PenguinWorker
 
Last edited:
If the condition is being met and the actions are running then that means the unit doesn't have the buff yet:
  • (PenguinWorker has buff Hatching (Minion)) Equal to False
What are you trying to do exactly? Is the worker supposed to spawn from the egg 3 seconds later?
If yes, then you can't or better yet shouldn't try to detect that inside of this trigger. Instead, detect when the egg dies using another trigger.
The Event "A unit dies" comes to mind. Then you can detect if there was a (Killing unit) or not, to determine whether or not the egg should spawn a worker.

Also, this line should be changed from this:
  • Unit - Order (Last created unit) to Neutral - Parasite (Trained unit)
To this, since you have a variable set to the (Trained unit) already:
  • Unit - Order (Last created unit) to Neutral - Parasite PenguinWorker
Hi Uncle so what i want to make is : you will be able to train penguins that will spawn in 0 seconds as eggs but you will need to wait until those eggs will hatch, also those eggs will have as much hp as the hatched unit like penguin worker egg= 210 hp and penguin worker = 210 hp. So if you attack the egg the hatched unit will be injured too. That is why i used
  • [IMG] Unit - Replace PenguinWorker with a Penguin Worker using The old unit's relative life and mana
Update: like this
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,596
Here's how you could do it using a Unit Indexer and a hidden Channel ability:
  • Spawn Egg
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • ADD YOUR OWN TRAINED UNIT-TYPE CONDITIONS HERE
    • Actions
      • -------- Set trained unit variables: --------
      • Set VariableSet ES_HatchedUnit = (Trained unit)
      • Set VariableSet ES_Point = (Position of ES_HatchedUnit)
      • -------- --------
      • -------- Create the egg at the position of the trained unit: --------
      • Unit - Pause ES_HatchedUnit
      • Unit - Hide ES_HatchedUnit
      • Unit - Create 1 Egg for (Owner of ES_HatchedUnit) at ES_Point facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_ES_Point)
      • -------- --------
      • -------- Link the egg to it's hatched unit: --------
      • Set VariableSet ES_Egg = (Last created unit)
      • Set VariableSet ES_LinkedUnit[(Custom value of ES_Egg)] = ES_HatchedUnit
      • -------- --------
      • -------- Modify the egg unit: --------
      • Unit - Set Max HP of ES_Egg to (Max HP of ES_HatchedUnit)
      • Unit - Set life of ES_Egg to 100.00%
      • Unit - Add a 3.01 second Generic expiration timer to ES_Egg
      • Unit - Order ES_Egg to Orc Blademaster - Wind Walk.
  • Hatch Egg
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Egg
    • Actions
      • Set VariableSet ES_Egg = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (ES_Egg is alive) Equal to True
        • Then - Actions
          • -------- The egg succesfully hatched: --------
          • Set VariableSet ES_HatchedUnit = ES_LinkedUnit[(Custom value of ES_Egg)]
          • Unit - Set life of ES_HatchedUnit to (Life of ES_Egg)%
          • Unit - Unpause ES_HatchedUnit
          • Unit - Unhide ES_HatchedUnit
        • Else - Actions
          • -------- The egg was killed before it could hatch: --------
Variables:
ES_Egg = Unit
ES_HatchedUnit = Unit
ES_LinkedUnit = Unit (array)
ES_Point = Point

The Egg unit has a hidden Channel ability with these settings that is used to detect when it's finished hatching:
Follow Through Time = 3 seconds
Disable Other Abilities = True
Base Order Id = Windwalk
Art - Button Position X/Y = 0,-11

Notes about the Egg unit:
Set the Egg unit's Art - Animation - Cast Point/Backswing to 0.00.
I gave my Egg the Ward classification but that's probably not necessary.
You can use this one Egg for every single trained unit in your map if you wanted to.
If different units have different hatch times then you'd need to modify the Channel abilities Follow Through Time in the Spawn Egg trigger as well as it's Expiration timer to match the desired time. This can be done through triggers, you shouldn't need more than 1 Egg and 1 Hatch ability.
The expiration timer on the Egg is not intended to do anything besides show the time remaining. The egg SHOULD die right before the timer expires.
 

Attachments

  • Egg System 2.w3m
    22.6 KB · Views: 5
Last edited:
Here's how you could do it using a Unit Indexer and a hidden Channel ability:
  • Spawn Egg
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • ADD YOUR OWN TRAINED UNIT-TYPE CONDITIONS HERE
    • Actions
      • -------- Set trained unit variables: --------
      • Set VariableSet ES_HatchedUnit = (Trained unit)
      • Set VariableSet ES_Point = (Position of ES_HatchedUnit)
      • -------- --------
      • -------- Create the egg at the position of the trained unit: --------
      • Unit - Pause ES_HatchedUnit
      • Unit - Hide ES_HatchedUnit
      • Unit - Create 1 Egg for (Owner of ES_HatchedUnit) at ES_Point facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_ES_Point)
      • -------- --------
      • -------- Link the egg to it's hatched unit: --------
      • Set VariableSet ES_Egg = (Last created unit)
      • Set VariableSet ES_LinkedUnit[(Custom value of ES_Egg)] = ES_HatchedUnit
      • -------- --------
      • -------- Modify the egg unit: --------
      • Unit - Set Max HP of ES_Egg to (Max HP of ES_HatchedUnit)
      • Unit - Set life of ES_Egg to 100.00%
      • Unit - Add a 3.01 second Generic expiration timer to ES_Egg
      • Unit - Order ES_Egg to Orc Blademaster - Wind Walk.
  • Hatch Egg
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Egg
    • Actions
      • Set VariableSet ES_Egg = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (ES_Egg is alive) Equal to True
        • Then - Actions
          • -------- The egg succesfully hatched: --------
          • Set VariableSet ES_HatchedUnit = ES_LinkedUnit[(Custom value of ES_Egg)]
          • Unit - Set life of ES_HatchedUnit to (Life of ES_Egg)%
          • Unit - Unpause ES_HatchedUnit
          • Unit - Unhide ES_HatchedUnit
        • Else - Actions
          • -------- The egg was killed before it could hatch: --------
Variables:
ES_Egg = Unit
ES_HatchedUnit = Unit
ES_LinkedUnit = Unit (array)
ES_Point = Point

The Egg unit has a hidden Channel ability with these settings that is used to detect when it's finished hatching:
Follow Through Time = 3 second
Disable Other Abilities = True.
Base Order Id = Windwalk
Art - Button Position X/Y = 0,-11

Notes about the Egg unit:
Set the Egg unit's Art - Animation - Cast Point/Backswing to 0.00.
I gave my Egg the Ward classification but that's probably not necessary.
You can use this one Egg for every single unit in your map if you set the triggers up properly.
The expiration timer on the Egg is not intended to do anything besides show the time remaining. The egg SHOULD die before the timer expires.
Thx Uncle for your help
Update is working perfectly thx again Uncle and now i don't need to create a rally point anymore
  • Penguin Worker Copy 2
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Penguin Worker
    • Actions
      • Set PenguinWorker = (Trained unit)
      • Set PenguinWorkerPoint = (Position of PenguinWorker)
      • Unit - Pause PenguinWorker
      • Unit - Hide PenguinWorker
      • Unit - Create 1 Penguin Worker Egg for (Owner of PenguinWorker) at PenguinWorkerPoint facing (Position of PenguinWorker)
      • Custom script: call RemoveLocation (udg_PenguinWorkerPoint)
      • Set PenguinWorkerEgg = (Last created unit)
      • Set PenguinWorkerArray[(Custom value of PenguinWorkerEgg)] = PenguinWorker
      • Unit - Set Max HP of PenguinWorkerEgg to (Max HP of PenguinWorker)
      • Unit - Set life of PenguinWorkerEgg to 100.00%
      • Unit - Add a 12.01 second Generic expiration timer to PenguinWorkerEgg
      • Unit - Order PenguinWorkerEgg to Orc Blademaster - Wind Walk
  • Penguin Worker Copy
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Penguin Worker Egg
    • Actions
      • Set PenguinWorkerEgg = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (PenguinWorkerEgg is alive) Equal to True
        • Then - Actions
          • Set PenguinWorker = PenguinWorkerArray[(Custom value of PenguinWorkerEgg)]
          • Unit - Set life of PenguinWorkerEgg to (Life of PenguinWorkerEgg)%
          • Unit - Unpause PenguinWorker
          • Unit - Unhide PenguinWorker
          • Sound - Play Penguin___u <gen>
        • Else - Actions
 
Last edited:
Status
Not open for further replies.
Top