Spider Spawn from Egg. Help Plz!

CroMoX

New Member
Reaction score
2
Hey guys, I've been trying to make a trigger, where a Hero walks near a Spider Egg, and if they get in range by 300, the egg dies and creates a Tiny Spider.

Note: I have a respawn trigger so using

unit.gif
Unit - A unit comes within 256.00 of Spider Egg 0084 <gen>

Will not work, since I want the eggs to respawn so this trigger can happen multiple times.

I did get a code from the Hiveworkshop, but it doesn't work;

Code:
Spider Egg
    Events
        Time - Every 0.20 seconds of game time
    Conditions
    Actions
        Set Eggs_Unitgroup = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Spider Egg) and (((Matching unit) is alive) Equal to True)))
        Unit Group - Pick every unit in Eggs_Unitgroup and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Number of units in (Units within 325.00 of (Position of (Picked unit)))) Equal to 0
                    Then - Actions
                        Unit - Kill (Matching unit)
                        Unit - Create 1 Tiny Spider for (Owner of (Matching unit)) at (Position of (Matching unit)) facing Default building facing degrees
                    Else - Actions
 

Juggernaut

I don't know what to change it to
Reaction score
33
Do it this way:
Code:
Untitled Trigger 001
    Events
        Time - Every 0.20 seconds of game time
    Conditions
    Actions
        Set Temp_Group = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Peasant) and (((Matching unit) is alive) Equal to True)))
        Unit Group - Pick every unit in Temp_Group and do (Actions)
            Loop - Actions
                Set Temp_Point = (Position of (Picked unit))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Number of units in (Units within 300.00 of Temp_Point matching ((((Matching unit) is alive) Equal to True) and ((Unit-type of (Matching unit)) Not equal to Peasant)))) Greater than or equal to 1
                    Then - Actions
                        Unit - Kill (Picked unit)
                        Unit - Create <<<your unit>>>
                        Custom script:   call RemoveLocation(udg_Temp_Point)
                        Custom script:   call DestroyGroup(udg_Temp_Group)
                    Else - Actions
                        Custom script:   call RemoveLocation(udg_Temp_Point)
                        Custom script:   call DestroyGroup(udg_Temp_Group)
First of all use variables, and remove them in the end, to prevent leaks.
Then when checking for units in range of the egg we check that the picked unit is not the egg itself so we exlude it here: ((Unit-type of (Matching unit)) Not equal to Peasant))))
Where peasant is the egg.
 

CroMoX

New Member
Reaction score
2
Thank you it works. Just one question; what do I add so the eggs only destroy when a hero walks near them?
 

Solu9

You can change this now in User CP.
Reaction score
216
If - Conditions
(Number of units in (Units within 300.00 of Temp_Point matching ((((Matching unit) is alive) Equal to True) and ((Unit-type of (Matching unit)) EQUAL TO HERO)))) Greater than or equal to 1
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top