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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top