• 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.

Unit dies = reward player? {giving player gold for killing units}

Status
Not open for further replies.
Level 3
Joined
Jan 28, 2009
Messages
42
Ok this is what i have so far:
  • Events
    • Player - Player 1 (Red) types a chat message containing test as A substring
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Number of units in (Units of type test13)) Equal to 0
      • Then - Actions
        • Unit - Create 1 test13 for Player 5 (Black) at (Center of test12 <gen>) facing Default building facing degrees
      • Else - Actions
How do i do so when "test13" dies.. every player in the game will be rewarded with 10 gold (I do not have the unit placed anywhere on map)
 
Level 12
Joined
Mar 26, 2005
Messages
790
make unit group as a variable (VARIABLE)

and after you create that unit

Unit group-Add unit-Add last created unit to VARIABLE



and

E:unit dies
C:Bolean comparison-Unit-Unit is in unit group (dying unit is in VARIABLE)
A:give 10gold etc etc
 
Level 36
Joined
Feb 5, 2009
Messages
4,630
Dude, this seems easy to me. Make a trigger that has the event 'generic unit event: A unit dies'. For the condition, check the unit type for your 'test13' with the condition involving the triggering unit (although you could have 'dying unit' alternatively, I suppose). Then for the action... I'm really just repeating what Restor said.
On another note, I can't help but notice this 'unit' is created every time you type test. If you just want to make it you get gold every time you type 'test', why don't you just replace all that unit crap with 'player - add property' and make it, as you want, add 10 gold to each player individually? I think you may have been asking the wrong question the whole time, especially seeing as how nobody would call a unit 'test13'. Well, no one who's maps I've seen been downloaded, anyway.
 
Level 3
Joined
Jan 28, 2009
Messages
42
make unit group as a variable (VARIABLE)

and after you create that unit

Unit group-Add unit-Add last created unit to VARIABLE



and

E:unit dies
C:Bolean comparison-Unit-Unit is in unit group (dying unit is in VARIABLE)
A:give 10gold etc etc

Hmm..? Wouldnt i have to create the unit first to select the unit? :S The unit is nowhere on the map so.. how do i select it?
 
Level 36
Joined
Feb 5, 2009
Messages
4,630
wait a minute... how do you mean selecting the unit? I thought what you wanted was for all players to get 10 additional gold when a unit of a particular type died. To achieve that, you don't need the Boolean Comparison, you need a unit-type comparison (the boolean comparison that Restor suggests just doesn't seem to be an effective method, as you could just do a unit-type check). Using that unit-type comparison, you can then make it so that when that type of unit dies, all players get 10 additional gold. I don't know what you mean about selecting the unit... can you plz explain how that came into it? As for the trigger itself, can I ask you a question? What are you trying to accomplish? It looks like you want all players to get 10 additional gold when ever Player 1 types test (also, why only 10 gold? It seems like an extraordinarily small amount to be gaining from that...).
 
Level 36
Joined
Feb 5, 2009
Messages
4,630
Wait a minute... what is the purpose of selecting the unit? How did that even come into it? From your code, you are creating a unit in the centre of a region every time player 1 types in 'test'. And do you want it so that all players get 10 gold whenever they type this in? That's what it looks like. If that's why you're summoning the unit, there's no point to it then.
 
Level 4
Joined
Nov 9, 2008
Messages
112
try

event- unit dies
cond- unit type of dying unit(can be triggering unit) equal to (the "test12' unit type)

act- pick the player and give the gold to picked player


ps:correct me if i'm wrong
 
Level 36
Joined
Feb 5, 2009
Messages
4,630
try

event- unit dies
cond- unit type of dying unit(can be triggering unit) equal to (the "test12' unit type)

act- pick the player and give the gold to picked player


ps:correct me if i'm wrong

Yeah, small problem. You're giving the gold to a picked player, rather than the owner of the killing unit... besides, I think he wants the gold to go to all players, not just the owner of the killing unit.
 
Level 3
Joined
Jan 28, 2009
Messages
42
try

event- unit dies
cond- unit type of dying unit(can be triggering unit) equal to (the "test12' unit type)

act- pick the player and give the gold to picked player


ps:correct me if i'm wrong

the cond wont work cuz the unit is not spawned anywhere in map.. and i cant select it from the unit palette
 

Ham

Ham

Level 5
Joined
Jan 16, 2009
Messages
132
  • gold reward 10
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to test12
        • Then - Actions
          • Set PlayerGroup = (All players)
          • Player Group - Pick every player in PlayerGroup and do (Player - Add 10 to (Picked player) Current gold)
          • Custom script: call DestroyForce (udg_PlayerGroup)
        • Else - Actions
          • Do nothing
this should do what ur looking for, plus it have no leaks and you can add other units in else actions for other results

+rep if i helped you.
 
Last edited:
Level 3
Joined
Jan 28, 2009
Messages
42
Ham>

Hmm This is how it looks for me now
  • achmed die
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to test12
        • Then - Actions
          • Set PlayerGroup = (All players)
          • Player Group - Pick every player in PlayerGroup and do (Player - Add 1337 to (Picked player) Current gold)
          • Custom script: call DestroyGroup (udg_PlayerGroup)
        • Else - Actions
          • Do nothing
What am i doing wrong? I set up variables wrong?
Variable setup:
1:Click Variables in trigger editor.
2:Click New Variable
3:Select Player Group from the list (No array or anything selected)
4:Name the variable PlayerGroup
5:Click Ok
6:Save Map
7:Error "Cannot convert force to group" call DestroyGroup(udg_PlayerGroup)

Hmm..?
 

Ham

Ham

Level 5
Joined
Jan 16, 2009
Messages
132
My bad, i wrongly set the custom script, it actually is like this.

  • gold reward 10
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to test12
        • Then - Actions
          • Set PlayerGroup = (All players)
          • Player Group - Pick every player in PlayerGroup and do (Player - Add 10 to (Picked player) Current gold)
          • Custom script: call DestroyForce (udg_PlayerGroup)
        • Else - Actions
 
Status
Not open for further replies.
Top