Trigger Trouble!

Xebarsis

New Member
Reaction score
7
In my game, if you die you will receive a new random unit. There's a trigger in the game that pauses the trigger that gives new units, picks every alive unit, kills them, removes the picked units, turns the trigger back on that gives new units, and then a dummy unit is spawned for each player affected by the trigger and kills the dummy which causes a new unit spawn.

The trigger works fine except when a unit has an ankh or reincarnation and dies moments before the trigger starts. What ends up happening is the unit with an ankh dies, the trigger starts and all units are killed, but then the trigger doesn't pick the unit with an ankh or reincarnation because it's not actually considered dead... so then the player now has 2 units even though you're only allowed 1 unit at a time in the game. Here's my trigger:

Code:
        Game - Display to (All players) the text: Random Event activa...
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                SlainEvent Equal to 0
            Then - Actions
                Set SlainEvent = 1
                Unit - Pause all units
                Trigger - Turn off Spawner Determiner <gen>
                Set Group = (Units in (Playable map area) matching (((Life of (Matching unit)) Greater than or equal to 1.00) and ((((Owner of (Matching unit)) controller) Equal to User) and (((Owner of (Matching unit)) slot status) Equal to Is playing))))
                Sound - Play TrollbatriderPissed5 <gen>
                Wait 1.00 seconds
                Game - Display to (All players) the text: |CFFFF0303All playe...
                Unit Group - Pick every unit in Group and do (Actions)
                    Loop - Actions
                        Unit - Explode (Picked unit)
                Wait 2.00 seconds
                Trigger - Turn on Spawner Determiner <gen>
                Unit Group - Pick every unit in Group and do (Actions)
                    Loop - Actions
                        Unit - Remove (Picked unit) from the game
                Custom script:   call DestroyGroup(udg_Group)
                For each (Integer A) from 1 to 12, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ((Player((Integer A))) slot status) Equal to Is playing
                            Then - Actions
                                Set ThePoint = (Center of (Playable map area))
                                Unit - Create 1 Dummy Killer for (Player((Integer A))) at ThePoint facing Default building facing degrees
                                Unit - Set the custom value of (Last created unit) to 1
                                Unit - Kill (Last created unit)
                            Else - Actions
                Custom script:   call DestroyGroup(udg_Group)
                Set SlainEvent = 0
                Unit - Unpause all units
                Custom script:   call RemoveLocation (udg_ThePoint)
            Else - Actions
                Trigger - Run (This trigger) (checking conditions)

If you don't want to read the whole thing, my main concern is this line:

Code:
Set Group = (Units in (Playable map area) matching (((Life of (Matching unit)) Greater than or equal to 1.00) and ((((Owner of (Matching unit)) controller) Equal to User) and (((Owner of (Matching unit)) slot status) Equal to Is playing))))

I want Group to = Every alive player that is a user, including units that are in the process of reincarnating. I would make it pick every unit, including dead ones, but I want to leave corpses on the ground so that players can use animate dead or raise dead, etc. I've also tried making it say matching unit is alive equal to true, but the results are the same.
 

Samael88

Evil always finds a way
Reaction score
181
Why don't you just add a debug to the trigger, like this:
Code:
if Unit has ank of reincarnation
then (no need to set anything here what I know)
else Do whatever you do now

Sorry if the code is a little bad, it is freehand:p
 

Septimus

New Member
Reaction score
58
So, the problem here is the unit with ankh ? Why not use if/then/else condition for it ?

If unit have xxx ankh then ignore it or else execute it.
 

C0mput3r

New Member
Reaction score
20
Try to add units with ankhs to a variable to be able to check, when a unit dies, is it one of the units that had an ankh? If yes, then do not run the recieve random unit trigger. And after it dies and gets resurrected, remove it from the variable, (best to use a unit group variable i guess)


Or you can use custom values if they arent in use by ur map already.

When a unit obtains an ankh, add 1 to its custom value.
When a unit dies and its custom value is 1 or higher, subtract one custom value.


And change your trigger's conditions to check if the dying unit's custom value is 0.


Im curious:p whats this code for?
Code:
For each (Integer A) from 1 to 12, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ((Player((Integer A))) slot status) Equal to Is playing
                            Then - Actions
                                Set ThePoint = (Center of (Playable map area))
                                Unit - Create 1 Dummy Killer for (Player((Integer A))) at ThePoint facing Default building facing degrees
                                Unit - Set the custom value of (Last created unit) to 1
                                Unit - Kill (Last created unit)
                            Else - Actions
 

Xebarsis

New Member
Reaction score
7
So, the problem here is the unit with ankh ? Why not use if/then/else condition for it ?

If unit have xxx ankh then ignore it or else execute it.

If that does work, how will I do the same for a unit that has reincarnation and is currently in the process of reincarnating?

C0mput3r: By the way that dummy killer trigger is so that the trigger that detects dying units will run and give each player a new unit; that's all. Also, as you can see I already have a custom value system in my game so I can't use that idea.
 

Samael88

Evil always finds a way
Reaction score
181
That is a bit more tricky, but I guess you can have it like this:
Code:
Or multiple conditions:
If unit has ank
or
If unit has a reincarnation ability

That should do the trick:thup:
 

C0mput3r

New Member
Reaction score
20
Code:
Respawn Units
    Events
        Unit - A unit Dies
    Conditions
        ((Owner of (Triggering unit)) controller) Equal to User
        ((Owner of (Triggering unit)) slot status) Equal to Is playing
    Actions
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Or - Any (Conditions) are true
                            Conditions
                                (Item-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to Ankh of Reincarnation
                                ((Triggering unit) is in ReincarnationCoolingDown) Equal to True
                    Then - Actions
                        -------- dont do anything --------
                    Else - Actions
                        -------- ur actions here --------

Code:
Add hero to Recarnation List
    Events
        Unit - A unit Learns a skill
    Conditions
        (Learned Hero Skill) Equal to Reincarnation (Cairne)
    Actions
        Unit Group - Add (Triggering unit) to HeroWithReincarnation

Code:
Hero with Reincarnation Dies
    Events
        Unit - A unit Dies
    Conditions
        ((Triggering unit) is in HeroWithReincarnation) Equal to True
    Actions
        Custom script:   local unit udg_localUnit
        Set localUnit = (Triggering unit)
        Custom script:   call GroupAddUnitSimple( udg_localUnit, udg_ReincarnationCoolingDown )   
        Wait 360.00 seconds
        -------- however long the cooldown of ur reincarnate is --------
        Custom script:   call GroupRemoveUnitSimple( udg_localUnit, udg_ReincarnationCoolingDown )
        Custom script:   set localUnit = null

These are the GUI ver of the custom scripts. Cause, locals must be done in raw Jass and blah blah blah... :( (hate that inconveniance)
Unit Group - Add localUnit to ReincarnationCoolingDown
Unit Group - Remove localUnit from ReincarnationCoolingDown


These are based on ideas from everyone's posts here =D
I just tried to compile it.. sorta
 

Xebarsis

New Member
Reaction score
7
Thank you very much for your suggestions everyone! Here are the triggers I've added to make this all work:

Code:
Reincarnation Units
    Events
        Unit - A unit enters (Playable map area)
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Unit-type of (Entering unit)) Equal to Centaur Khagan
                (Unit-type of (Entering unit)) Equal to Cairne Bloodhoof
                (Unit-type of (Entering unit)) Equal to Ancient Wendigo
                (Unit-type of (Entering unit)) Equal to Akama
                (Unit-type of (Entering unit)) Equal to Makrura King
                (Unit-type of (Entering unit)) Equal to Ancient Sasquatch
    Actions
        Unit Group - Add (Triggering unit) to ReincarnationUnit

Code:
Reincarnation Death
    Events
        Unit - A unit Dies
    Conditions
        ((Triggering unit) is in ReincarnationUnit) Equal to True
    Actions
        Custom script:   local unit udg_localUnit
        Set localUnit = (Triggering unit)
        Custom script:   call GroupAddUnitSimple( udg_localUnit, udg_ReincarnationCoolingDown )
        Wait 240.00 seconds
        Custom script:   call GroupRemoveUnitSimple( udg_localUnit, udg_ReincarnationCoolingDown )
        Custom script:   set localUnit = null


Code:
Ankh Acquire
    Events
        Unit - A unit Acquires an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Ankh of Reincarnation
    Actions
        Unit Group - Add (Triggering unit) to ReincarnationUnit

Code:
Ankh Remove
    Events
        Unit - A unit Loses an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Ankh of Reincarnation
    Actions
        Wait 0.01 seconds
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Item-type of (Item carried by (Triggering unit) in slot 1)) Equal to Ankh of Reincarnation
            Then - Actions
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-type of (Item carried by (Triggering unit) in slot 2)) Equal to Ankh of Reincarnation
                    Then - Actions
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Item-type of (Item carried by (Triggering unit) in slot 3)) Equal to Ankh of Reincarnation
                            Then - Actions
                            Else - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        (Item-type of (Item carried by (Triggering unit) in slot 4)) Equal to Ankh of Reincarnation
                                    Then - Actions
                                    Else - Actions
                                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            If - Conditions
                                                (Item-type of (Item carried by (Triggering unit) in slot 5)) Equal to Ankh of Reincarnation
                                            Then - Actions
                                            Else - Actions
                                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                                    If - Conditions
                                                        (Item-type of (Item carried by (Triggering unit) in slot 6)) Equal to Ankh of Reincarnation
                                                    Then - Actions
                                                    Else - Actions
                                                        Unit Group - Remove (Triggering unit) from ReincarnationUnit


Code:
        Game - Display to (All players) the text: Random Event activa...
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                SlainEvent Equal to 0
            Then - Actions
                Set SlainEvent = 1
                Unit - Pause all units
                Trigger - Turn off Spawner Determiner <gen>
                Set Group = (Units in (Playable map area) matching (((Life of (Matching unit)) Greater than or equal to 1.00) and ((((Owner of (Matching unit)) controller) Equal to User) and (((Owner of (Matching unit)) slot status) Equal to Is playing))))
                [B][U]Unit Group - Add all units of ReincarnationUnit to Group[/U][/B]
                Sound - Play TrollbatriderPissed5 <gen>
                Wait 1.00 seconds
                Game - Display to (All players) the text: |CFFFF0303All playe...
                Unit Group - Pick every unit in Group and do (Actions)
                    Loop - Actions
                        Unit - Explode (Picked unit)
                Wait 2.00 seconds
                Trigger - Turn on Spawner Determiner <gen>
                Unit Group - Pick every unit in Group and do (Actions)
                    Loop - Actions
                        Unit - Remove (Picked unit) from the game
                Custom script:   call DestroyGroup(udg_Group)
                For each (Integer A) from 1 to 12, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                ((Player((Integer A))) slot status) Equal to Is playing
                            Then - Actions
                                Set ThePoint = (Center of (Playable map area))
                                Unit - Create 1 Dummy Killer for (Player((Integer A))) at ThePoint facing Default building facing degrees
                                Unit - Set the custom value of (Last created unit) to 1
                                Unit - Kill (Last created unit)
                            Else - Actions
                Custom script:   call DestroyGroup(udg_Group)
                Set SlainEvent = 0
                Unit - Unpause all units
                Custom script:   call RemoveLocation (udg_ThePoint)
            Else - Actions
                Trigger - Run (This trigger) (checking conditions)

All that's left now is the game claims this is an error:

Code:
Custom script:   set localUnit = null

"Expected a variable name." How do I get this last line to work?
 

Samael88

Evil always finds a way
Reaction score
181
If the variable is a User Defined Global, a variable you declare in the variable editor. Then you need to do this:
Code:
set [B]udg_[/B]YourVariableName = null
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top