1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  4. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  5. The results are out! Check them out.
    Dismiss Notice
  6. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  7. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  8. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Respawning creeps problems (Not retarted)

Discussion in 'Map Development' started by Smileynator, Jan 26, 2011.

  1. Smileynator

    Smileynator

    Joined:
    Jan 24, 2011
    Messages:
    24
    Resources:
    0
    Resources:
    0
    Ok so lets state what happens first.
    I have a ORPG map with a friend of mine, and since the very start we had a VERY basic script to re-spawn the creeps.
    it basicly does this:

    Map init:
    Create a custom number for every unit (for later use) on the WHOLE map.
    Saving there unit type in a variable array, and there position of creation (We do not want creeps re-spawning where they die right?)

    If creepy dies:
    Wait 60seconds (just example time)
    Unit - Create 1 UnitType_Mob[(Custom value of (Triggering unit))] for (Triggering player) at Position_Mob[(Custom value of (Triggering unit))] facing (Random angle) degrees

    Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))

    This works perfectly! BUT If one was to remove the units corpse. The ''triggering unit'' (or dieing unit for that matter, shouldn't matter at all.) Gets removed after the ''wait'' command, and the game forgets what mob and for what player it should be created.

    So i tried to work AROUND that problem.. by saving the owning player and the triggering unit into 2 array's then wait 60 seconds, and then recalling the correct array number (meaning i would be limited to a certain amount of dead units at the same time before this goes wrong. But it should work at the least)

    However. once again, if the units CORPSE gets removed before the waiting time the unit TYPE and the owning player are saved to the variable array. but after the 60second wait, the game once more forgets what is in those variables (though the same system i scripted without removing the corpse works just fine, so the variable saving works!)

    Ill post the text version here, and hope you get what i am doing wrong (or the game is):

    MAP INI:
    Code (Text):
    Mob Position
        Events
            Time - Elapsed game time is 1.00 seconds
        Conditions
        Actions
            Unit Group - Pick every unit in (Units in (Entire map)) and do (Actions)
                Loop - Actions
                    Set RespawnInteger = (RespawnInteger + 1)
                    Unit - Set the custom value of (Picked unit) to RespawnInteger
                    Set Point_Mob[RespawnInteger] = (Position of (Picked unit))
                    Set UnitType_Mob[RespawnInteger] = (Unit-type of (Picked unit))
     
    (saving unit type might be a bit overkill but i was testing around)


    WHEN UNIT DIES:
    Code (Text):
    Mob Respawn Copy
        Events
            Unit - A unit owned by Player 4 (Purple) Dies
            Unit - A unit owned by Player 8 (Pink) Dies
            Unit - A unit owned by Neutral Hostile Dies
        Conditions
            ((Triggering unit) is Summoned) Equal to False
            (Unit-type of (Triggering unit)) Not equal to Town Hall
        Actions
            Set DeathMemoryNumber = (DeathMemoryNumber + 1)
            Game - Display to (All players) the text: (String(DeathMemoryNumber))
            If (DeathMemoryNumber Equal to 4) then do (Set DeathMemoryNumber = 0) else do (Do nothing)
            Set DeathMemoryPlayer[DeathMemoryNumber] = (Owner of (Triggering unit))
            Set DeathMemoryUnit[DeathMemoryNumber] = (Triggering unit)
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                If - Conditions
                    DeathMemoryNumber Equal to 0
                Then - Actions
                    Wait 30.00 seconds
                    Unit - Create 1 UnitType_Mob[(Custom value of DeathMemoryUnit[0])] for DeathMemoryPlayer[0] at Point_Mob[(Custom value of DeathMemoryUnit[0])] facing (Random angle) degrees
                    Unit - Set the custom value of (Last created unit) to (Custom value of DeathMemoryUnit[0])
                    Unit - Set (Last created unit) acquisition range to 200.00
                    Set DeathMemoryPlayer[0] = Emptyplayer
                    Set DeathMemoryUnit[0] = EmptyUnit
                Else - Actions
                    Do nothing
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                If - Conditions
                    DeathMemoryNumber Equal to 1
                Then - Actions
                    Wait 30.00 seconds
                    Unit - Create 1 UnitType_Mob[(Custom value of DeathMemoryUnit[1])] for DeathMemoryPlayer[1] at Point_Mob[(Custom value of DeathMemoryUnit[1])] facing (Random angle) degrees
                    Unit - Set the custom value of (Last created unit) to (Custom value of DeathMemoryUnit[1])
                    Unit - Set (Last created unit) acquisition range to 200.00
                    Set DeathMemoryPlayer[1] = Emptyplayer
                    Set DeathMemoryUnit[1] = EmptyUnit
                Else - Actions
                    Do nothing
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                If - Conditions
                    DeathMemoryNumber Equal to 2
                Then - Actions
                    Wait 30.00 seconds
                    Unit - Create 1 UnitType_Mob[(Custom value of DeathMemoryUnit[2])] for DeathMemoryPlayer[2] at Point_Mob[(Custom value of DeathMemoryUnit[2])] facing (Random angle) degrees
                    Unit - Set the custom value of (Last created unit) to (Custom value of DeathMemoryUnit[2])
                    Unit - Set (Last created unit) acquisition range to 200.00
                    Set DeathMemoryPlayer[2] = Emptyplayer
                    Set DeathMemoryUnit[2] = EmptyUnit
                Else - Actions
                    Do nothing
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                If - Conditions
                    DeathMemoryNumber Equal to 3
                Then - Actions
                    Wait 30.00 seconds
                    Unit - Create 1 UnitType_Mob[(Custom value of DeathMemoryUnit[3])] for DeathMemoryPlayer[3] at Point_Mob[(Custom value of DeathMemoryUnit[3])] facing (Random angle) degrees
                    Unit - Set the custom value of (Last created unit) to (Custom value of DeathMemoryUnit[3])
                    Unit - Set (Last created unit) acquisition range to 200.00
                    Set DeathMemoryPlayer[3] = Emptyplayer
                    Set DeathMemoryUnit[3] = EmptyUnit
                Else - Actions
                    Do nothing
     
    Variables i used:
    DeathMemoryPlayer[array] (saves owning player)
    DeathMemoryUnit[Array] (Saves unit.)
    DeathMemoryNumber (Saves the number were on, to make each time the code runs direct to one of the IF THEN ELSE parts in attempt to make it not confusd with the wait time)

    If someone gets that When a unit is killed and the corpse STAYS this program works. And if the unit dies and there is NO corpse (turned skeleton or exploded units for example) This fails and the DeathMemoryUnit simply goes BLANK after the waiting period. Id be VERY happy.

    Keep in mind:
    All variables were created, and not used in ANY other part of my codes.
    While testing the script i made sure NEVER to kill more then 2 or 3 mobs (to avoid the overwriting of number 1 when a 5th unit is dead at the same time.)

    I might write something confusing, if you got questions ask, ill be monitoring this thread.
     
  2. greasontim

    greasontim

    Joined:
    Oct 27, 2008
    Messages:
    1,176
    Resources:
    0
    Resources:
    0
    1. wrong section
    2. change the
    Code (Text):
     
    to
    if your using triggers
    or
    Code (vJASS):
     
    if your using JASS
     
  3. Smileynator

    Smileynator

    Joined:
    Jan 24, 2011
    Messages:
    24
    Resources:
    0
    Resources:
    0
    Triggers i bet, The visual way. I am not into pure text things. so i try to avoid it in warcraft 3.

    And ''map development'' seemed the most appropriate place. If someone knows where else to go, move it up there i guess?
     
  4. greasontim

    greasontim

    Joined:
    Oct 27, 2008
    Messages:
    1,176
    Resources:
    0
    Resources:
    0
    this would be a trigger issue and should be posted in the trigger section
    BTW changeing it over to the

    also lets everyone see the trigger the way it should be so can you change it please?
     
  5. Smileynator

    Smileynator

    Joined:
    Jan 24, 2011
    Messages:
    24
    Resources:
    0
    Resources:
    0
    I think ''moving'' a thread is up to an admin. and i would rather not double post the same thing.
    Unless i can move it myself. Ill be stuck for now.
     
  6. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,193
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    Trig



    • Mob Position
      • Events
        • Time - Elapsed game time is 1.00 seconds
      • Conditions
      • Actions
        • Unit Group - Pick every unit in (Units in (Entire map)) and do (Actions)
          • Loop - Actions
            • Set RespawnInteger = (RespawnInteger + 1)
            • Unit - Set the custom value of (Picked unit) to RespawnInteger
            • Set Point_Mob[RespawnInteger] = (Position of (Picked unit))
            • Set UnitType_Mob[RespawnInteger] = (Unit-type of (Picked unit))

    (saving unit type might be a bit overkill but i was testing around)



    • Mob Respawn Copy
      • Events
        • Unit - A unit owned by Player 4 (Purple) Dies
        • Unit - A unit owned by Player 8 (Pink) Dies
        • Unit - A unit owned by Neutral Hostile Dies
      • Conditions
        • ((Triggering unit) is Summoned) Equal to False
        • (Unit-type of (Triggering unit)) Not equal to Town Hall
      • Actions
        • Set DeathMemoryNumber = (DeathMemoryNumber + 1)
        • Game - Display to (All players) the text: (String(DeathMemoryNumber))
        • If (DeathMemoryNumber Equal to 4) then do (Set DeathMemoryNumber = 0) else do (Do nothing)
        • Set DeathMemoryPlayer[DeathMemoryNumber] = (Owner of (Triggering unit))
        • Set DeathMemoryUnit[DeathMemoryNumber] = (Triggering unit)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • DeathMemoryNumber Equal to 0
          • Then - Actions
            • Wait 30.00 seconds
            • Unit - Create 1 UnitType_Mob[(Custom value of DeathMemoryUnit[0])] for DeathMemoryPlayer[0] at Point_Mob[(Custom value of DeathMemoryUnit[0])] facing (Random angle) degrees
            • Unit - Set the custom value of (Last created unit) to (Custom value of DeathMemoryUnit[0])
            • Unit - Set (Last created unit) acquisition range to 200.00
            • Set DeathMemoryPlayer[0] = Emptyplayer
            • Set DeathMemoryUnit[0] = EmptyUnit
          • Else - Actions
            • Do nothing
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • DeathMemoryNumber Equal to 1
          • Then - Actions
            • Wait 30.00 seconds
            • Unit - Create 1 UnitType_Mob[(Custom value of DeathMemoryUnit[1])] for DeathMemoryPlayer[1] at Point_Mob[(Custom value of DeathMemoryUnit[1])] facing (Random angle) degrees
            • Unit - Set the custom value of (Last created unit) to (Custom value of DeathMemoryUnit[1])
            • Unit - Set (Last created unit) acquisition range to 200.00
            • Set DeathMemoryPlayer[1] = Emptyplayer
            • Set DeathMemoryUnit[1] = EmptyUnit
          • Else - Actions
            • Do nothing
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • DeathMemoryNumber Equal to 2
          • Then - Actions
            • Wait 30.00 seconds
            • Unit - Create 1 UnitType_Mob[(Custom value of DeathMemoryUnit[2])] for DeathMemoryPlayer[2] at Point_Mob[(Custom value of DeathMemoryUnit[2])] facing (Random angle) degrees
            • Unit - Set the custom value of (Last created unit) to (Custom value of DeathMemoryUnit[2])
            • Unit - Set (Last created unit) acquisition range to 200.00
            • Set DeathMemoryPlayer[2] = Emptyplayer
            • Set DeathMemoryUnit[2] = EmptyUnit
          • Else - Actions
            • Do nothing
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • DeathMemoryNumber Equal to 3
          • Then - Actions
            • Wait 30.00 seconds
            • Unit - Create 1 UnitType_Mob[(Custom value of DeathMemoryUnit[3])] for DeathMemoryPlayer[3] at Point_Mob[(Custom value of DeathMemoryUnit[3])] facing (Random angle) degrees
            • Unit - Set the custom value of (Last created unit) to (Custom value of DeathMemoryUnit[3])
            • Unit - Set (Last created unit) acquisition range to 200.00
            • Set DeathMemoryPlayer[3] = Emptyplayer
            • Set DeathMemoryUnit[3] = EmptyUnit
          • Else - Actions
            • Do nothing




    You can use this:

    • Init Respawn
      • Events
        • Time - Elapsed game time is 0.00 seconds
      • Conditions
      • Actions
        • Hashtable - Create a hashtable
        • Set rhash = (Last created hashtable)
        • Set rtime = 5.00
        • Custom script: set bj_wantDestroyGroup = true
        • Unit Group - Pick every unit in (Units owned by Neutral Hostile) 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()) )


    • Respawn
      • Events
        • Unit - A unit Dies
      • Conditions
        • (Owner of (Triggering unit)) Equal to Neutral Hostile
      • 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


    I'd also delay the respawn if there is a hero nearby.

    http://www.hiveworkshop.com/forums/pastebin.php?id=pl0ind
     
  7. Smileynator

    Smileynator

    Joined:
    Jan 24, 2011
    Messages:
    24
    Resources:
    0
    Resources:
    0
    *cough*Advanced*cough*
    This will give me some time to figure out.
    I downloaded the attached URL.
    Lets see if i can make any sense of this.
    You are positive that this would make mobs respawn even if there corpse would be removed?

    (Also, Delay respawn when hero is nearby? Noway. they got 3minutes after the mobs respawn. You either press on, or pull back in due time. If you take longer, fighting the same mobs again is your own punishment. My custom resurrection script is not there for no reason.)

    http://www.hiveworkshop.com/forums/maps-564/ashenvale-orpg-187968/

    And thanks for the quick help :)
     
  8. Smileynator

    Smileynator

    Joined:
    Jan 24, 2011
    Messages:
    24
    Resources:
    0
    Resources:
    0
    @Maker,
    I cannot thank you enough.
    I just tested this out on that example map and even with all 4 mobs dead and a 3minute respawn this wasn't a problem. I do not fully understand WHAT you did besides store the data in hash. But it sure as hell works like a charm :) I will implement this in the next map release!