• 🏆 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] Creep wander & respawn

Status
Not open for further replies.
Level 2
Joined
Mar 4, 2012
Messages
8
Hi guys,
I'm using this system to make creeps respawn : Creep Respawn (GUI) and this one to make them wander : Wander everything works fine except respawned creeps don't wander, i searched for hours a way to do this but failed. I'm fairly new to JASS and Warcraft III mapping so i'm sorry if this is dumb.

Here is the code i use to make creeps wander at map init, as i said it works fine with pre-placed creeps but don't work anymore when they respawn
JASS:
scope Demo initializer Init

    private function Hostiles takes nothing returns boolean
        local Wander wander = Wander.create(GetFilterUnit(), 300, 7.)
    
        set wander.random = 3
        set wander.order = "attack"
    
        return false
    endfunction

    private function Init takes nothing returns nothing
        call GroupEnumUnitsOfType(bj_lastCreatedGroup, UnitId2String('n006'), Filter(function Hostiles))
    endfunction
 
endscope

and the ones i use to make creeps respawn (Timber Wolf id is "n006")
  • MRS init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet MRS_Time = 90.00
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
        • Loop - Actions
          • Set VariableSet MRS_Integer = (MRS_Integer + 1)
          • Unit - Set the custom value of (Picked unit) to MRS_Integer
          • Set VariableSet MRS_Facing[MRS_Integer] = (Facing of (Picked unit))
          • Set VariableSet MRS_Point[MRS_Integer] = (Position of (Picked unit))
  • MRS update
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Timber Wolf
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
    • Actions
      • Set VariableSet MRS_Integer = (MRS_Integer + 1)
      • Unit - Set the custom value of (Triggering unit) to MRS_Integer
      • Set VariableSet MRS_Facing[MRS_Integer] = (Facing of (Triggering unit))
      • Set VariableSet MRS_Point[MRS_Integer] = (Position of (Triggering unit))
  • MRS update 2
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Timber Wolf
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
      • (Custom value of (Triggering unit)) Greater than 0
    • Actions
      • Wait MRS_Time seconds
      • Unit - Create 1 Timber Wolf for Neutral Hostile at MRS_Point[(Custom value of (Triggering unit))] facing MRS_Facing[(Custom value of (Triggering unit))] degrees
      • Special Effect - Create a special effect at (Position of (Last created unit)) using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
If someone can help me it would be greatly appreciated!
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,058
Before the first line in the last trigger:

call Wander[GetTriggerUnit()].destroy()



After the last line in the last trigger:

call Wander.create(bj_lastCreatedUnit, 300, 7.)
set Wander[bj_lastCreatedUnit].random = 3
set Wander[bj_lastCreatedUnit].order = "attack"
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,058
There is no need to call destroy manually. The system does that automatically upon death.

That is also the reason for the system to not work with respawned units without setting up
the Wander system for these units again.
Good to know, I didn't check the library. Changing the .source unit variable from readonly to alterable would also make this solution simpler, too.
 
Status
Not open for further replies.
Top