Unit won't Die

rodead

Active Member
Reaction score
42
i got a code for a mini Escape and it looks like this:
the only problem is the unit won't die and i don't know why so could you guys help me out?
Code:
Quest 2 Die 2
    Events
        Time - Every 0.05 seconds of game time
    Conditions
    Actions
        For each (Integer A) from 1 to 8, do (Actions)
            Loop - Actions
                Set Quest_2_Loc[(Integer A)] = (Position of Quest2Unit[(Integer A)])
                Set UnitGroup[(Integer A)] = (Units within 75.00 of Quest_2_Loc[(Integer A)] matching ((Unit-type of 


(Matching unit)) Equal to Footman))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[1]) Greater than 0
                Killbandits[1] Less than 5
            Then - Actions
                Unit - Kill Quest2Unit[1]
                Wait 2.00 seconds
                Hero - Instantly revive Quest2Unit[1] at (Center of Quest 2 <gen>), Hide revival graphics
                Camera - Pan camera for (Owner of Quest2Unit[1]) to (Center of Quest 2 <gen>) over 0.00 seconds
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Number of units in UnitGroup[1]) Greater than 0
                        Killbandits[1] Greater than or equal to 5
                    Then - Actions
                        Unit - Kill Quest2Unit[1]
                        Wait 2.00 seconds
                        Hero - Instantly revive Quest2Unit[1] at (Center of Kill Robbers <gen>), Hide revival graphics
                        Camera - Pan camera for (Owner of Quest2Unit[1]) to (Center of Kill Robbers <gen>) over 0.00 seconds
                    Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[2]) Greater than 0
                Killbandits[2] Less than 5
            Then - Actions
                Unit - Kill Quest2Unit[2]
                Wait 2.00 seconds
                Hero - Instantly revive Quest2Unit[2] at (Center of Quest 2 <gen>), Hide revival graphics
                Camera - Pan camera for (Owner of Quest2Unit[2]) to (Center of Quest 2 <gen>) over 0.00 seconds
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[2]) Greater than 0
                Killbandits[2] Greater than or equal to 5
            Then - Actions
                Unit - Kill Quest2Unit[2]
                Wait 2.00 seconds
                Hero - Instantly revive Quest2Unit[2] at (Center of Kill Robbers <gen>), Hide revival graphics
                Camera - Pan camera for (Owner of Quest2Unit[2]) to (Center of Kill Robbers <gen>) over 0.00 seconds
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[3]) Greater than 0
                Killbandits[3] Less than 5
            Then - Actions
                Unit - Kill Quest2Unit[3]
                Wait 2.00 seconds
                Hero - Instantly revive Quest2Unit[3] at (Center of Quest 2 <gen>), Hide revival graphics
                Camera - Pan camera for (Owner of Quest2Unit[3]) to (Center of Quest 2 <gen>) over 0.00 seconds
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[3]) Greater than 0
                Killbandits[3] Greater than or equal to 5
            Then - Actions
                Unit - Kill Quest2Unit[3]
                Wait 2.00 seconds
                Hero - Instantly revive Quest2Unit[3] at (Center of Kill Robbers <gen>), Hide revival graphics
                Camera - Pan camera for (Owner of Quest2Unit[3]) to (Center of Kill Robbers <gen>) over 0.00 seconds
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[4]) Greater than 0
                Killbandits[4] Less than 5
            Then - Actions
                Unit - Kill Quest2Unit[4]
                Wait 2.00 seconds
                Hero - Instantly revive Quest2Unit[4] at (Center of Quest 2 <gen>), Hide revival graphics
                Camera - Pan camera for (Owner of Quest2Unit[4]) to (Center of Quest 2 <gen>) over 0.00 seconds
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[4]) Greater than 0
                Killbandits[4] Greater than or equal to 5
            Then - Actions
                Unit - Kill Quest2Unit[4]
                Wait 2.00 seconds
                Camera - Pan camera for (Owner of Quest2Unit[4]) to (Center of Kill Robbers <gen>) over 0.00 seconds
                Hero - Instantly revive Quest2Unit[4] at (Center of Kill Robbers <gen>), Hide revival graphics
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[5]) Greater than 0
                Killbandits[5] Less than 5
            Then - Actions
                Unit - Kill Quest2Unit[5]
                Wait 2.00 seconds
                Hero - Instantly revive Quest2Unit[5] at (Center of Quest 2 <gen>), Hide revival graphics
                Camera - Pan camera for (Owner of Quest2Unit[5]) to (Center of Quest 2 <gen>) over 0.00 seconds
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[5]) Greater than 0
                Killbandits[5] Greater than or equal to 5
            Then - Actions
                Unit - Kill Quest2Unit[5]
                Wait 2.00 seconds
                Camera - Pan camera for (Owner of Quest2Unit[5]) to (Center of Kill Robbers <gen>) over 0.00 seconds
                Hero - Instantly revive Quest2Unit[5] at (Center of Kill Robbers <gen>), Hide revival graphics
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[6]) Greater than 0
                Killbandits[6] Less than 5
            Then - Actions
                Unit - Kill Quest2Unit[6]
                Wait 2.00 seconds
                Hero - Instantly revive Quest2Unit[6] at (Center of Quest 2 <gen>), Hide revival graphics
                Camera - Pan camera for (Owner of Quest2Unit[6]) to (Center of Quest 2 <gen>) over 0.00 seconds
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[6]) Greater than 0
                Killbandits[6] Greater than or equal to 5
            Then - Actions
                Unit - Kill Quest2Unit[6]
                Wait 2.00 seconds
                Camera - Pan camera for (Owner of Quest2Unit[6]) to (Center of Kill Robbers <gen>) over 0.00 seconds
                Hero - Instantly revive Quest2Unit[6] at (Center of Kill Robbers <gen>), Hide revival graphics
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[7]) Greater than 0
                Killbandits[7] Less than 5
            Then - Actions
                Unit - Kill Quest2Unit[7]
                Wait 2.00 seconds
                Hero - Instantly revive Quest2Unit[7] at (Center of Quest 2 <gen>), Hide revival graphics
                Camera - Pan camera for (Owner of Quest2Unit[7]) to (Center of Quest 2 <gen>) over 0.00 seconds
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[7]) Greater than 0
                Killbandits[7] Greater than or equal to 5
            Then - Actions
                Unit - Kill Quest2Unit[7]
                Wait 2.00 seconds
                Camera - Pan camera for (Owner of Quest2Unit[7]) to (Center of Kill Robbers <gen>) over 0.00 seconds
                Hero - Instantly revive Quest2Unit[7] at (Center of Kill Robbers <gen>), Hide revival graphics
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[8]) Greater than 0
                Killbandits[8] Less than 5
            Then - Actions
                Unit - Kill Quest2Unit[8]
                Wait 2.00 seconds
                Hero - Instantly revive Quest2Unit[8] at (Center of Quest 2 <gen>), Hide revival graphics
                Camera - Pan camera for (Owner of Quest2Unit[8]) to (Center of Quest 2 <gen>) over 0.00 seconds
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup[8]) Greater than 0
                Killbandits[8] Greater than or equal to 5
            Then - Actions
                Unit - Kill Quest2Unit[8]
                Wait 2.00 seconds
                Camera - Pan camera for (Owner of Quest2Unit[8]) to (Center of Kill Robbers <gen>) over 0.00 seconds
                Hero - Instantly revive Quest2Unit[8] at (Center of Kill Robbers <gen>), Hide revival graphics
            Else - Actions
        


For each (Integer A) from 1 to 8, do (Actions)
            Loop - Actions
                Custom script:   call DestroyGroup (udg_UnitGroup[bj_forLoopAIndex])
                Custom script:   call RemoveLocation (udg_Quest_2_Loc[bj_forLoopAIndex])

Edit: i made the code better but still got the same problem hope it is now oke and without leaks.

thanks in advanced and +rep
 
C

Calidus

Guest
Just one question, are you sure you've set the variables properly? Looks pretty clean to me though..
 

Ashcat

Hellooo
Reaction score
68
Hmm, well are all the Quest2Unit[X] variables or KillBandit[X] variables set correctly? That might be a problem if they arent set correctly in some other trigger. Thats the only problem I can see. :l
 
M

Maelstrom_

Guest
Im not sure about the question you asked but you can make that trigger 1/8th of its current size by using a Integer A loop action. :)
 

Pyrogasm

There are some who would use any excuse to ban me.
Reaction score
134
You also leak 800 locations per second with this trigger. The first 8 lines all leak "Position of (...)".
 

rodead

Active Member
Reaction score
42
well i know it leaks but the problem s the unit won't die and yes i set all the values correctly. quest 2 is set in the beginning when the unit is sold

Code:
Set Player Red
    Events
        Unit - A unit Sells a unit
    Conditions
        (Owner of (Selling unit)) Equal to Player 1 (Red)
    Actions
        Set Quest2Unit[1] = (Sold unit)
        Unit - Remove Unit Selector 0061 <gen> from the game

but thanks for pointing the leaks out Pyrogasm
 

Darg

Administrator
Reaction score
49
Is this for a map you plan to release?

Every 0.01 seconds game time you do all that?

I hope this is for experimentation purposes....this is a "dangerous" trigger to put into a multiplayer map.

1) For now, change the 0.01 seconds thing to, say, every 5 seconds

2) I noticed you're killing the units and then reviving them straight away - it doesn't even have a chance to go through the death animations, and so it's impossible to determine if anyone is really dying or not .... you need to add a wait in between the kill and revive in order to let the animation take its course e.g. "wait 3 seconds". If that still doesn't work, then that means your Quest2Unit array isn't assigned to any units.

3) You're panning the camera to multiple locations all at once, it's only ever gonna do the last one and will effectively ignore the rest.
 

pandamoniuma

New Member
Reaction score
9
I think the problem might be you are trying to kill the unit and revive it in the same trigger. I have a method i use for situations like this, basically i store all the tasks i need to perform, and then perform those in another trigger later with a timer that expires in 0 seconds

create a unit arry of some size, lets say 50, and lets call it

UnitsRevived[50]

and an integer array to keep track of the number of units we need to revive, call it:

numUnitsRevived

now, somewhere you want to kill the unit and revive it, instead lets do this

Kill Unit
set numUnitsRevived = numUnitsRevived + 1
set UnitsRevived[numUnitsRevived] = Unit

then at the end of this trigger, do

Start Timer as a one-shot timer that will expire in 0 seconds

then in another trigger:

event - timer expires

if numUnitsRevived > 0, then

for each integer A from 1 to numUnitsRevived:
{
Hero - Revive UnitsRevived[Integer A]
}

set numUnitsRevived = 0



hope this helps, if it was confusing in anyway let me know
 

rodead

Active Member
Reaction score
42
well the map is a map for a contest and yes i am planning to release it but i got always problems with my triggers and darg may i ask why it is dangerous and what i need to improve to make it multiplayer

Edit: i edited the first Code so hope it is now better!
 

Darg

Administrator
Reaction score
49
Yea sorry, I wasn't too clear with what I said.... what I mean to say is that, making and testing your map by yourself is a very different ball game to running it on battle.net with multiple players....you have to take net lag and the speed of other people's comps into account. So with that in mind, it's always important to be thinking about how you can make your code run as efficiently as possible, in order to avoid potential multiplayer lag issues. As a general guide, if the game even hints at slowing down when you try it offline and by yourself, it's gonna cause a lot of grief when played online.

I learned this the hard way, and trust me, it wasn't pretty.

If I were to refer to your trigger there as an example, you need to ask yourself the question - "I have a trigger running every 0.05 seconds, but can I provide those who play my map with the same experience if I increase that value to, say, 0.10s, 0.20s, 0.50s or even greater? How high can I go before the effect of the trigger no longer reflects what I wanted it to do?"

In terms of your trigger code, think about how you can do more, with less.
 

Darg

Administrator
Reaction score
49
Anyway, back to your trigger....

I have one suggestion, you may want to add in separators into your trigger code, because it allows us to read it a bit faster. For example, I initially thought that your for loop went for the entire trigger, but eventually I realised it doesn't. Putting a separator after the for loop (before you start all the if statements) would have been awesome for readability.

Here's a question for you: What is the connection between the trigger for selling a unit and this trigger ? Is the idea that, when you sell a unit in the other trigger, that this trigger will kill the unit off ? If so, why not just put the code into the other trigger and run it there ?
 

rodead

Active Member
Reaction score
42
Well let me explain this further i am making an rpg with alot of cool quests and one of the quests is an mini escape. and the first trigger about when the unit is sold is t set the unit that must be killed when it enters the quest. also when a unit enter a new spot it must be revived there and i wanted to do it in one trigger and it was possible i tought.

well i invite you to test my map if you want my msn is [email protected]
and my battle.net name is rodead.com (on northerend)
 

Darg

Administrator
Reaction score
49
wow, took me a while to wonder where this thread went, eventually found it way back on page 3 hehe ......

anyway, I can't help because I haven't played War3 or touched the editor in nearly 2 years, and I'm not sure I even have the game installed on my computer anymore.

Question: what happens to a unit when it gets sold? what I mean is, does it stay on the map somewhere, or does it disappear?

Question: when you say "then a unit enter a new spot", is this spot one particular area of your map? If so, can't you just make it into a region and then change the event from being Every 0.05s to "A unit enters region", and then set out your actions based on that ?
 

rodead

Active Member
Reaction score
42
Question 1: answer is simple the game is an rpg and the unit that is being sold is and hero and it will stay ingame. and will never be removed.

Question 2: well the "new spot'' is a revive point when you enter it you get revived there.
 

Darg

Administrator
Reaction score
49
one way to figure out if, say, Quest2Unit[1] has anything in it is to use the selection highlight trigger action, which will flash a selection circle around the unit. I forget exactly what it's called, but look for it in the "Selection" actions.

The idea is to, as an experiment, comment out this stuff from the trigger:

Unit - Kill Quest2Unit[1]
Wait 2.00 seconds
Hero - Instantly revive Quest2Unit[1] at (Center of Quest 2 <gen>), Hide revival graphics

and instead do a selection highlight of Quest2Unit[1]. Now, when testing the map out, stare at the unit you think should be highlighted, and observe as the trigger gets executed. See if anything happens. If you don't see a selection circle flash around the unit, you can confirm that that is your problem.
 
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