• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] MUI? Question

Status
Not open for further replies.

Deleted member 177737

D

Deleted member 177737

Hey,

As a system for my RPG systems pack that I've been working on for the past month or so I was thinking of creating a system that will "flow?" like this:

-Unit dies
-Unit is replaced with "body" unit (this part has been done by me)
-Wait 60 seconds
-Remove "Body" Units Corpse (I use a 2nd unit as the corpse for a searching system)

But I currently have no idea how to make this in a way where each individual unit that dies has its own individual timer that waits 60 seconds. The closest I've been able to make was a trigger that added every killed unit to a "DeadBody" group. After the first unit is killed it set off a timer which removed all bodies in the "DeadBody" group, but I realized that this could remove bodies before the player would have a chance to use the "Search" system on the "Dead Body".

So what I'm asking is does anyone know a way I could set each killed unit to its own individual timer which will remove the "Dead Body" unit after it expires?
(I need it to work for a minimum of 20 units at once)

I can do this myself but the way I would end up setting it up would require 20 timer variables and 20 triggers, one for each timer...

+rep & full credits for your help in creating the system
 
Last edited by a moderator:
Level 8
Joined
Jul 3, 2011
Messages
251
Here is a solution to your problems, let me know if you have any trouble.

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set hash = (Last created hashtable)
      • Set Units = (Units of type Mortar Team)
  • Start
    • Events
      • <Corpse Event Here>
    • Conditions
      • <Possible Corpse Condition Here>
    • Actions
      • <Corpse Creation Here>
      • Hashtable - Save 60 as 0 of (Key (Last created unit)) in hash
      • Unit Group - Add (Last created unit) to Units
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Units) Equal to 1
        • Then - Actions
          • Trigger - Turn on Loop <gen>
        • Else - Actions
  • Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Units) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Unit Group - Pick every unit in Units and do (Actions)
            • Loop - Actions
              • Set i = (Key (Picked unit))
              • Set i2 = (Load 0 of i from hash)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • i2 Equal to 0
                • Then - Actions
                  • Unit Group - Remove (Picked unit) from Units
                  • Unit - Remove (Picked unit) from the game
                  • Hashtable - Clear all child hashtables of child i in (hash)
                • Else - Actions
                  • Hashtable - Save (i2 - 1) as 0 of i in hash
 
Last edited:

Deleted member 177737

D

Deleted member 177737

All the problems I had attempting to insert your triggers into mine are explained in comments in the areas where I had a lot of trouble in the pictures below.

(I've never used a single hashtable trigger ever, so this was confusing as heck =/)
 

Attachments

  • 1.jpg
    1.jpg
    193.3 KB · Views: 65
  • 2.jpg
    2.jpg
    262 KB · Views: 114
  • 3.jpg
    3.jpg
    253.5 KB · Views: 61

Deleted member 177737

D

Deleted member 177737

I coulden't set up Maker's trigger because none of the "key" parts when making the trigger had the option for (TriggeringUnit), and I coulden't set up mckill2009's trigger because I can't use "GetTriggerUnit()" because the way the system needs to be set up requires something like "Get Last Created Unit".

Here is a better explanation of what I need...

Order of things happening:

-A Unit Dies
-Trigger checks through list (within the trigger) of possible units that this system works for
-Trigger finds out that unit works with system
-Trigger creates new specific "Body" unit for the specified dying unit
-Trigger plays last created unit's death animation (the "body" unit is the exact same as the dying unit, but it works with the searching system

The next few steps would be for saving the unit somehow and creating the timer, w/e else...

The trigger needs to work for all of the units in the map that are able to be "searched".
The "searching" system requires a "body" unit so the player can't just walk up to any living unit and use the search ability on it for some free items.

>.< The way my systems are set up is probably confusing to everyone, but they work.
 
i didnt notice the replaced thing, but in order to access your last created unit,
you should create a unit first using locals, then after the wait set it like this...

  • Event
    • Unit dies
  • Condition
    • ???
  • Actions
    • Custom script: local unit u = GetTriggerUnit()
    • Custom script: local unit lastcreatedunit = CreateUnit(GetTriggerPlayer(), 'YOURUNITID', GetUnitX(u), GetUnitY(u), 0)
    • Wait 60 seconds
    • //the UNITGLOBAL is a global variable in order to access the lastcreated unit outside this trigger
    • Custom script: set udg_UNITGLOBAL = lastcreatedunit
    • //do your GUI actions here for the udg_UNITGLOBAL (without waits)
    • Custom script: call RemoveUnit(u)
    • Custom script: set u = null
    • Custom script: set lastcreatedunit = null
 
The only thing I would change in your trigger mckill2009 is the second unit variable: lastcreatedunit. Why not use:
  • Custom script: set bj_lastCreatedUnit = CreateUnit(GetTriggerPlayer(), 'YOURUNITID', GetUnitX(u), GetUnitY(u), 0)
I'm not sure if event 'unit - dies' provides reference: (Triggering player), does it?
Meaby better is usage of GetOwningPlayer(GetTriggerUnit()) here.
 
Level 8
Joined
Jul 3, 2011
Messages
251
All the problems I had attempting to insert your triggers into mine are explained in comments in the areas where I had a lot of trouble in the pictures below.

(I've never used a single hashtable trigger ever, so this was confusing as heck =/)

You are saving the key of the unit not 60 as 0 of its key, a key is like a value that the game gives it, say for instance 2 units die, 1 has a key of 0 and 1 has a key of 1, it will save 60 as 0 of 0 and 0 of 1, in the last trigger, i and i2 are both integers, you must also set the group in the init trigger, if not set you will be adding units to nothing and therefore it will not work.
 

Deleted member 177737

D

Deleted member 177737

I attempted to re-make the trigger by Zaio with his new information but I still can't set (key (picked unit)), for some reason its not anywhere in the selections that I searched though.

I also tried mckill2009's new trigger but when I went to test the game it just went straight to the main menu, as far as I know that means there was something wrong with the way I put it in. (I think I was supposed to create the "global variable" in the variables editor, but there is no selection for global variables there.)

I've attached a picture of what the trigger now looks like. BTW thanks for all the help so far, everyone. I'll add all of your names to the credits.
 

Attachments

  • 4.jpg
    4.jpg
    238 KB · Views: 99
Level 37
Joined
Mar 6, 2006
Messages
9,243
Level 8
Joined
Jul 3, 2011
Messages
251
I attempted to re-make the trigger by Zaio with his new information but I still can't set (key (picked unit)), for some reason its not anywhere in the selections that I searched though.

I also tried mckill2009's new trigger but when I went to test the game it just went straight to the main menu, as far as I know that means there was something wrong with the way I put it in. (I think I was supposed to create the "global variable" in the variables editor, but there is no selection for global variables there.)

I've attached a picture of what the trigger now looks like. BTW thanks for all the help so far, everyone. I'll add all of your names to the credits.

Set Integer_Here = Hashtable - Get Handle ID - Key Value_Here - Click and scroll down to picked unit.
 

Deleted member 177737

D

Deleted member 177737

I've edited the trigger but its still going straight to the main menu.

  • DBR
    • Events
    • Conditions
    • Actions
      • Custom script: local unit u = GetTriggerUnit()
      • Custom script: local unit lastcreatedunit = CreateUnit(GetTriggerPlayer(), 'h00B', GetUnitX(u), GetUnitY(u), 0)
      • Wait 60.00 seconds
      • Custom script: set udg_UNITGLOBAL
      • -------- Evil Guard --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to Evil Guard (For testing search ability)
        • Then - Actions
          • Unit - Create 1 Evil Guard's Body (For testing search ability) for (Owner of (Dying unit)) at (Position of (Dying unit)) facing (Facing of (Dying unit)) degrees
          • Animation - Play (Last created unit)'s death animation
        • Else - Actions
      • Custom script: call RemoveUnit(u)
      • Custom script: set u = null
      • Custom script: set lastcreatedunit = null
I can't create a global variable for the unit (picture below of what I mean).

@Zaio I did what you said for your trigger but there is no dropdown menu where you said it should be. (picture included)
 

Attachments

  • 5.jpg
    5.jpg
    57.2 KB · Views: 85
  • 6.jpg
    6.jpg
    38.6 KB · Views: 54
Level 8
Joined
Jul 3, 2011
Messages
251
I've edited the trigger but its still going straight to the main menu.

  • DBR
    • Events
    • Conditions
    • Actions
      • Custom script: local unit u = GetTriggerUnit()
      • Custom script: local unit lastcreatedunit = CreateUnit(GetTriggerPlayer(), 'h00B', GetUnitX(u), GetUnitY(u), 0)
      • Wait 60.00 seconds
      • Custom script: set udg_UNITGLOBAL
      • -------- Evil Guard --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to Evil Guard (For testing search ability)
        • Then - Actions
          • Unit - Create 1 Evil Guard's Body (For testing search ability) for (Owner of (Dying unit)) at (Position of (Dying unit)) facing (Facing of (Dying unit)) degrees
          • Animation - Play (Last created unit)'s death animation
        • Else - Actions
      • Custom script: call RemoveUnit(u)
      • Custom script: set u = null
      • Custom script: set lastcreatedunit = null
I can't create a global variable for the unit (picture below of what I mean).

@Zaio I did what you said for your trigger but there is no dropdown menu where you said it should be. (picture included)

A key isnt in the variable list, it is an integer... Make an integer variable and set it as the key (picked unit)
 

Deleted member 177737

D

Deleted member 177737

If you are using any variable via variable editor it's already a global Yayoi ;<
Prefix 'udg_' immidiately shows that it's global from GUI variable editor, since you can declare globals in jass without even using VE (requires NewGen).

Change part with setting global unit variable to:
  • Custom script: set udg_UNITGLOBAL = u

Alright I've created the variable UNITGLOBAL (unit variable) and edited that one line of the trigger. The game now loads and allows me to test, but there is a bug.
The bug is that when I kill the "Evil Footman" the body instantly decays, no "body" is created. If the "body" is created its for some reason decaying to.

  • DBR
    • Events
    • Conditions
    • Actions
      • Custom script: local unit u = GetTriggerUnit()
      • Custom script: local unit lastcreatedunit = CreateUnit(GetTriggerPlayer(), 'h00B', GetUnitX(u), GetUnitY(u), 0)
      • Wait 60.00 seconds
      • Custom script: set udg_UNITGLOBAL = u
      • -------- Evil Guard --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to Evil Guard (For testing search ability)
        • Then - Actions
          • Unit - Create 1 Evil Guard's Body (For testing search ability) for (Owner of (Dying unit)) at (Position of (Dying unit)) facing (Facing of (Dying unit)) degrees
          • Animation - Play (Last created unit)'s death animation
        • Else - Actions
      • Custom script: call RemoveUnit(u)
      • Custom script: set u = null
      • Custom script: set lastcreatedunit = null
Its supposed to replace the "body" with
  • Unit - Create a permanent Fleshy (Unit-type of (Target unit of ability being cast)) corpse for Player 1 (Red) at (Position of (Target unit of ability being cast)) facing (Facing of (Target unit of ability being cast)) degrees
after the 60 seconds.
 
Level 7
Joined
Nov 19, 2007
Messages
253
In my opinion this is how this whole trigger should look
  • Untitled Trigger 002
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Custom script: set udg_Group=CreateGroup()
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Dying unit) is in Group) Equal to False
        • Then - Actions
          • Set tempLoc = (Position of (Dying unit))
          • Unit - Create 1 (Unit-type of (Dying unit)) for (Owner of (Dying unit)) at tempLoc facing (Facing of (Dying unit)) degrees
          • Unit - Add a 60.00 second Generic expiration timer to (Last created unit)
          • Unit - Make (Last created unit) Invulnerable
          • Animation - Play (Last created unit)'s death animation
          • Unit Group - Add (Last created unit) to Group
          • Unit - Remove (Dying unit) from the game
          • Custom script: call RemoveLocation(udg_tempLoc)
        • Else - Actions
  • Untitled Trigger 003
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Stop
I attached test map

Only problem is that unit which will be created will die again when timer ends. And I cant use Unit - Pause because then expiration timer doesnt work.
 

Attachments

  • test.w3x
    17 KB · Views: 30

Deleted member 177737

D

Deleted member 177737

In my opinion this is how this whole trigger should look
  • Untitled Trigger 002
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Custom script: set udg_Group=CreateGroup()
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Dying unit) is in Group) Equal to False
        • Then - Actions
          • Set tempLoc = (Position of (Dying unit))
          • Unit - Create 1 (Unit-type of (Dying unit)) for (Owner of (Dying unit)) at tempLoc facing (Facing of (Dying unit)) degrees
          • Unit - Add a 60.00 second Generic expiration timer to (Last created unit)
          • Unit - Make (Last created unit) Invulnerable
          • Animation - Play (Last created unit)'s death animation
          • Unit Group - Add (Last created unit) to Group
          • Unit - Remove (Dying unit) from the game
          • Custom script: call RemoveLocation(udg_tempLoc)
        • Else - Actions
  • Untitled Trigger 003
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Stop
I attached test map

Only problem is that unit which will be created will die again when timer ends. And I cant use Unit - Pause because then expiration timer doesnt work.

I guess the simpilest solution worked, I just re-added my old triggers and added the expiration timer to it. I don't mind that the bodies "re-die" but I might find a solution for that sometime.

I'm handing out rep and adding credits now. Thx.
 
Status
Not open for further replies.
Top