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

Very Simple Respawn System

Status
Not open for further replies.
Level 37
Joined
Aug 14, 2006
Messages
7,601
Hey.

I'm requesting a very simple neutral hostile respawn system that respawns specific enemies only. The trigger should be leakless and GUI so that I can understand something about it. It will be used for a campaign.

I have my own but it doesn't work correctly so that's why I'm requesting this one. It should be somewhat same as this:

  • Lava Monster Respawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Lava Monster
    • Actions
      • Wait 30.00 seconds
      • Unit - Create 1 (Unit-type of (Dying unit)) for Neutral Hostile at (Position of (Dying unit)) facing Default building facing degrees
      • Unit - Set level of Permanent Immolation (Lava Monster) for (Last created unit) to Difficulty_Spell_Level
      • Special Effect - Create a special effect attached to the origin of (Last created unit) using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
      • Special Effect - Destroy (Last created special effect)
There can be different enemies with different respawn times. There are about 1 to 5 different enemies that will use this system. Also I might turn on/off respawn for specific enemies.

Rep + credits for the helper.
 
Level 9
Joined
Dec 26, 2010
Messages
475
Try this
  • Lava Monster Respawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Lava Monster
    • Actions
      • Set Unit = Dying Unit
      • Wait 30.00 seconds
      • Unit - Create 1 Unit for Neutral Hostile at (Position of (Dying unit)) facing Default building facing degrees
      • Unit - Set level of Permanent Immolation (Lava Monster) for (Last created unit) to Difficulty_Spell_Level
      • Special Effect - Create a special effect attached to the origin of (Last created unit) using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
      • Special Effect - Destroy (Last created special effect)
 
Level 9
Joined
Dec 26, 2010
Messages
475
How About This?

  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Spider Crab Shorecrawler
    • Actions
      • Unit Group - Add (Dying unit) to CreepGroup
      • Wait 10.00 seconds
      • Unit Group - Pick every unit in CreepGroup and do (Actions)
        • Loop - Actions
          • Unit Group - Remove (Picked unit) from CreepGroup
          • Unit - Create 1 (Unit-type of (Picked unit)) for Neutral Hostile at (Position of (Picked unit)) facing Default building facing degrees
          • Unit - Set level of Immolation for (Picked unit) to 1
          • Special Effect - Create a special effect attached to the origin of (Picked unit) using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
          • Special Effect - Destroy (Last created special effect)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
http://www.hiveworkshop.com/forums/pastebin.php?id=u4vzz1

*No leaks
*Supports revive even if the triggering unit gets removed
*Revives the unit where it was originally positioned, not where it died

Add the special effect, unit types and ability level setting yourself. rtime is the time after which a unit gets revived.

In the init trigger, you can add a unit type if/then/else inside the unit group loop, so it doesn't store data for units that are not supposed to be revived.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
@Marc - the original one would work fine, just use Triggering unit instead of dying unit...

It's not a good idea to revive a unit where it died. In RPGs you can lure units to towns for example, and then they fight guards there endlessly. Also, one must think of the case where the revive time is longer than decay time of bones. The unit won't exist after the decay time is over, therefore calling <position of triggering unit> returns null.

Two triggers? Excellent.

What does this do? Does it have a purpose?

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Triggering unit) Not equal to No unit
    • Then - Actions
      • Unit - Remove (Triggering unit) from the game
    • Else - Actions

Units have decay time. If the new unit should be created before the bones of the old have disappered, it will remove the old unit.
 
Level 37
Joined
Aug 14, 2006
Messages
7,601
Okay, let's see...

When I imported the system to the campaign it didn't work. When I tried to fix the case it gave me this:

98984d1299452558-very-simple-respawn-system-error.jpg


  • Lava Monster Respawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Lava Monster (Chapter 6 Basic Enemy)
    • Actions
      • Custom script: local integer utype = GetUnitTypeId(GetTriggerUnit())
      • Custom script: local player p = GetOwningPlayer(GetTriggerUnit())
      • Custom script: local real x = LoadReal( udg_rhash , GetHandleId(GetTriggerUnit()) , StringHash("x") )
      • Custom script: local real y = LoadReal( udg_rhash , GetHandleId(GetTriggerUnit()) , StringHash("y") )
      • Custom script: local real facing = LoadReal( udg_rhash , GetHandleId(GetTriggerUnit()) , StringHash("facing") )
      • Custom script: call FlushChildHashtable( udg_rhash , GetHandleId(GetTriggerUnit()))
      • Wait rtime seconds
      • Custom script: set bj_lastCreatedUnit = CreateUnit( p , utype , x , y , facing )
      • Custom script: call SaveReal( udg_rhash , GetHandleId(bj_lastCreatedUnit) , StringHash("x") , x )
      • Custom script: call SaveReal( udg_rhash , GetHandleId(bj_lastCreatedUnit) , StringHash("y") , y )
      • Custom script: call SaveReal( udg_rhash , GetHandleId(bj_lastCreatedUnit) , StringHash("facing") , facing )
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Not equal to No unit
        • Then - Actions
          • Unit - Remove (Triggering unit) from the game
        • Else - Actions
      • Custom script: set p = null
  • After Settings
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- === RESPAWN === --------
      • Hashtable - Create a hashtable
      • Set rhash = (Last created hashtable)
      • Set rtime = 30.00
      • Unit Group - Pick every unit in (Units of type Lava Monster (Chapter 6 Basic Enemy)) and do (Actions)
        • Loop - Actions
          • Custom script: call SaveReal( udg_rhash , GetHandleId(GetEnumUnit()) , StringHash("x") , GetUnitX(GetEnumUnit()) )
          • Custom script: call SaveReal( udg_rhash , GetHandleId(GetEnumUnit()) , StringHash("y") , GetUnitY(GetEnumUnit()) )
          • Custom script: call SaveReal( udg_rhash , GetHandleId(GetEnumUnit()) , StringHash("facing") , GetUnitFacing(GetEnumUnit()) )
I also use this trigger. Does it make this bug?

  • Lava Monster Explode
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Lava Monster (Chapter 6 Basic Enemy)
    • Actions
      • Set TempLoc = (Position of (Dying unit))
      • Set TempGroup2 = (Units owned by Neutral Hostile)
      • Set TempGroup = (Units within 200.00 of TempLoc matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is in TempGroup2) Equal to True) and (((Matching unit) has buff Invulnerable) Equal to False))))
      • Set TempReal = (200.00 + ((Real(Difficulty_Spell_Level)) x 100.00))
      • Item - Create Fire Heart at TempLoc
      • Special Effect - Create a special effect at TempLoc using Abilities\Spells\Other\Doom\DoomDeath.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Unit - Cause BOSS2 to damage (Picked unit), dealing TempReal damage of attack type Spells and damage type Normal
          • Special Effect - Create a special effect attached to the head of (Picked unit) using Abilities\Spells\Items\AIfb\AIfbSpecialArt.mdl
          • Special Effect - Destroy (Last created special effect)
      • Custom script: call DestroyGroup(udg_TempGroup2)
      • Custom script: call DestroyGroup(udg_TempGroup)
      • Custom script: call RemoveLocation(udg_TempLoc)
EDIT: Suddenly no more that screen and the system started to work. THANKS ONCE AGAIN, MAKER FOR THIS SIMPLE, YET VERY USEFUL SYSTEM!
 

Attachments

  • ERROR.jpg
    ERROR.jpg
    423.1 KB · Views: 181
How about

  • Monster Respawn setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Wait 2.00 seconds
      • Set tempGroup = (Units owned by Neutral Hostile matching (((Matching unit) is Summoned) Equal to False))
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to Coordinates_UnitGroup
      • Wait 1.00 seconds
      • Unit Group - Pick every unit in Coordinates_UnitGroup and do (Actions)
        • Loop - Actions
          • Set Mr_Answer = <Empty String>
          • Set Mr_Helper = (String((X of (Position of (Picked unit)))))
          • Set Mr_Helper2 = (String((Y of (Position of (Picked unit)))))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Substring(Mr_Helper, 1, 1)) Equal to -
            • Then - Actions
              • Set Mr_Answer = (Mr_Answer + -)
              • Set Mr_Helper = (Substring(Mr_Helper, 2, 15))
            • Else - Actions
              • Set Mr_Answer = (Mr_Answer + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Substring(Mr_Helper2, 1, 1)) Equal to -
            • Then - Actions
              • Set Mr_Answer = (Mr_Answer + 2)
              • Set Mr_Helper2 = (Substring(Mr_Helper2, 2, 15))
            • Else - Actions
              • Set Mr_Answer = (Mr_Answer + 1)
          • Set Blah = (Integer(Mr_Helper))
          • Set Mr_Helper = (String(Blah))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Length of Mr_Helper) Equal to 1
            • Then - Actions
              • Set Mr_Helper = (9000 + Mr_Helper)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Length of Mr_Helper) Equal to 2
            • Then - Actions
              • Set Mr_Helper = (900 + Mr_Helper)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Length of Mr_Helper) Equal to 3
            • Then - Actions
              • Set Mr_Helper = (90 + Mr_Helper)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Length of Mr_Helper) Equal to 4
            • Then - Actions
              • Set Mr_Helper = (9 + Mr_Helper)
            • Else - Actions
          • Set Mr_Helper = (Substring(Mr_Helper, 1, 4))
          • Set Blah = (Integer(Mr_Helper2))
          • Set Mr_Helper2 = (String(Blah))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Length of Mr_Helper2) Equal to 1
            • Then - Actions
              • Set Mr_Helper2 = (9000 + Mr_Helper2)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Length of Mr_Helper2) Equal to 2
            • Then - Actions
              • Set Mr_Helper2 = (900 + Mr_Helper2)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Length of Mr_Helper2) Equal to 3
            • Then - Actions
              • Set Mr_Helper2 = (90 + Mr_Helper2)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Length of Mr_Helper2) Equal to 4
            • Then - Actions
              • Set Mr_Helper2 = (9 + Mr_Helper2)
            • Else - Actions
          • Set Mr_Helper2 = (Substring(Mr_Helper2, 1, 4))
          • Set Mr_Answer = (Mr_Answer + (Substring(Mr_Helper, 1, 4)))
          • Set Mr_Answer = (Mr_Answer + (Substring(Mr_Helper2, 1, 4)))
          • Unit - Set the custom value of (Picked unit) to (Integer(Mr_Answer))
      • Unit Group - Remove all units from Coordinates_UnitGroup
      • Custom script: call DestroyGroup(udg_tempGroup)

  • Monster Respawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Dying unit) is Summoned) Equal to False
          • (Owner of (Dying unit)) Equal to Neutral Hostile
          • ((Dying unit) is Mechanical) Equal to False
    • Actions
      • Wait 90.00 seconds
      • Set Respawn_Helper = (String((Custom value of (Dying unit))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring(Respawn_Helper, 3, 3)) Equal to 9
        • Then - Actions
          • Set X = (Real((Substring(Respawn_Helper, 4, 6))))
        • Else - Actions
          • Set X = (Real((Substring(Respawn_Helper, 3, 6))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring(Respawn_Helper, 7, 7)) Equal to 9
        • Then - Actions
          • Set Y = (Real((Substring(Respawn_Helper, 8, 10))))
        • Else - Actions
          • Set Y = (Real((Substring(Respawn_Helper, 7, 10))))
      • Set X = (X x 10.00)
      • Set Y = (Y x 10.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring(Respawn_Helper, 3, 3)) Equal to 9
        • Then - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring(Respawn_Helper, 1, 1)) Equal to -
        • Then - Actions
          • Set X = (X - (X x 2.00))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring(Respawn_Helper, 2, 2)) Equal to 2
        • Then - Actions
          • Set Y = (Y - (Y x 2.00))
        • Else - Actions
      • Set tempPoint = (Point(X, Y))
      • Unit - Create 1 (Unit-type of (Dying unit)) for Neutral Hostile at tempPoint facing Default building facing degrees
      • Unit - Set the custom value of (Last created unit) to (Integer(Respawn_Helper))
      • Custom script: call RemoveLocation(udg_tempPoint)
Of course, you would change the conditions to fit what you want to respawn.
 
Status
Not open for further replies.
Top