• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

A de-buff that increases bounty?

Status
Not open for further replies.
Level 3
Joined
Nov 15, 2010
Messages
30
Greetings all.

I'm working on a map and I want to make an ability that adds a de-buff to an enemy unit that whenever it its killed it gives +X% more gold and/or lumber when killed, can anyone point me out to a trigger just like that?
 
Moin moin =)

I would do it like: If someone cast the spell (with the debuff) on a target, add this unit into a unitgroup. Now if a unit die and if the unit is in this unit group then bonus gold.

To remove the unit from the group, when it hasn't the buff anymore to, every 0.05 seconds, pick every unit in this unit group without the buff and remove this unit out of the group.

  • AddUnit
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Soul Burn
    • Actions
      • Unit Group - Add (Target unit of ability being cast) to TempGroup
  • DieUnit
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in TempGroup) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from TempGroup
      • -------- Bounty actions here --------
  • CheckUnit
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Soul Burn) Equal to False
            • Then - Actions
              • Unit Group - Remove (Picked unit) from TempGroup
            • Else - Actions
      • Custom script: call DestroyGroup(udg_TempGroup)
I bet there are easier ways, but this is simple and the problem you can't check if the dieing unit had a buff =(

Greetings and Peace
Dr. Boom
 
However there is no concrete method for determining how much bounty was given by a dying unit. The amount is randomized using Object Editor specified values and it is not surfaced to the user in any way.
 
However there is no concrete method for determining how much bounty was given by a dying unit. The amount is randomized using Object Editor specified values and it is not surfaced to the user in any way.

Oh dang, too much hassle for just one spell, i guess ill go the lazy way and give it a custom pillage skill :/.

I've seen similar skills in two games: Enfo's team survival's Odo the Trader and in Element Tower defense, the gold mine-type line. I wanted something like the one in element, but i guess pillage will do.

thanks for answering me this question.
 
Well, you could use a little workaround. There is a player changes value event. I just tested this and found that it triggers before the unit's death event. But there's still the unit life event that fires before either. You can use this to save the previous values and compare them to the new ones.

gold and lumber are integer array variables, no preset value necessary

register bounty dropping units:

  • Events
    • Map initialization
  • Conditions
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units in (Entire map) matching ((Gives Bounty is on for (Owner of (Matching unit))) Gleich True)) and do (Actions)
      • Loop - Actions
        • Trigger - Add to after <gen> the event (Einheit - (Picked unit) Dies)
        • Trigger - Add to before <gen> the event (Einheit - (Picked unit)'s life becomes Equal to 0.00)
register late-comers that are not already standing on the map upon init:

  • Events
    • Unit - A unit enters (Entire map)
  • Conditions
    • (Gives Bounty is on for (Owner of (Triggering unit))) Gleich True
  • Actions
    • Trigger - Add to after <gen> the event (Unit - (Triggering unit) Dies)
    • Trigger - Add to before <gen> the event (Unit - (Triggering unit)'s life becomes Equal to 0.00)
unit life event, trigger is named "before":

JASS:
function Trig_before_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_DEAD)//UNIT_TYPE_DEAD is not available in GUI
endfunction

function Trig_before_Enum takes nothing returns nothing
    set udg_gold[GetConvertedPlayerId(GetEnumPlayer())] = GetPlayerState(GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD)
    set udg_lumber[GetConvertedPlayerId(GetEnumPlayer())] = GetPlayerState(GetEnumPlayer(), PLAYER_STATE_RESOURCE_LUMBER)
endfunction

function Trig_before_Actions takes nothing returns nothing
    //don't know the killing unit on this event, so just brute-save all previous values
    call ForForce( GetPlayersAll(), function Trig_before_Enum )
endfunction

//===========================================================================
function InitTrig_before takes nothing returns nothing
    set gg_trg_before = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_before, Condition( function Trig_before_Conditions ) )
    call TriggerAddAction( gg_trg_before, function Trig_before_Actions )
endfunction

unit death event:

  • after
    • Events
    • Conditions
    • Actions
      • Set gold[(Player number of (Owner of (Killing unit)))] = (((Owner of (Killing unit)) Current gold) - gold[(Player number of (Owner of (Killing unit)))])
      • Set lumber[(Player number of (Owner of (Killing unit)))] = (((Owner of (Killing unit)) Current lumber) - lumber[(Player number of (Owner of (Killing unit)))])
      • -------- - --------
      • Game - Display to (All players) the text: ((Name of (Owner of (Killing unit))) + ( got + ((String(gold[(Player number of (Owner of (Killing unit)))])) + ( gold from killing + (Name of (Triggering unit))))))
      • -------- - --------
      • ...Do what you want, you got killing unit, dying unit and the bounty (gold[number of owner of killing unit]), analog for lumber
If your map includes unit owner changes or if you reset a player's Gives Bounty state at runtime, this will need some adaptions.
 
Moin moin -_-

Waterknight: Sorry that I say that, but with your trigger: get the f**k out of here -_-
1) Leaks like hell
2) Complicated
3) Why let converted Jass?
4) Wont work correctly as he want it

Second: what's the problem about my way? I can't see that there is to much work for one spell. Ok it are 3 triggers, but anyway this is the GUI best way, for an Ability that is casted and gives a buff to the target and when this buffed unit dies, extra bounty for killing player. Isn't that what you want? =O

Greetings and Peace
Dr. Boom
 
He/She wants the bonus drop relative to the default one, so the default one must be known. Also your way of detecting the ending of the buff is very unclean and you should not destroy the group. You also do not know if the buff is applied to who on spell effect event.

edit: 1) I do not know whether specific unit events do leak, thats a rumor, but have not seen an actual test yet. Of course, it creates some new event object but who knows whether these are not destroyed when the unit vanishes or the trigger is removed.
"Leaks like hell" is anyway an exaggeration, I've had some thousand units over an hour (around 200 at a time) with more than 10 events each and did not see any difference. Of course, I could have used the generic unit death event above but avoiding leaks is not the only problem a mapmaker has to face. You should also limit unncessarily running triggers and code. Not only leaks do create performance slashes.

3) There seem to be a lot of GUI users here, you also posted yours in this fashion. Nonetheless, GUI does not provide UNIT_TYPE_DEAD and I wanted the selection to stay in the trigger's condition function, so I figured I'd let this one completly in Jass.

4) I offered a possibility to have the unit's drop at death event which thread starter needs. Afaik, there is no clean buff gain/lose event and it was not mentioned how/when the unit does possess the buff, so why bother with it? You can add the buff condition on my approach but, of course, I only provide hints and do not chew everything for him/her.
 
Last edited:
Again I don't want start to waste my time here, but you should now, that he wasn't the first who want create something like this, which don't make any necessary difference now.

IN EVERY CASE this solution was given and this worked and was a good method how you can handle something like that. Now you come up and get critics on it, while you give some s**t triggers for help?
It's ok, if you thing you are right, then you are right and that's the end of the story now and continue this discussion would be offtopic anyway and senseless at this point!

Greetings and Peace
Dr. Boom
 
I'm thinking maybe what you could try is setting up two triggers. The first one would trigger when a unit dies. The second one would trigger when a player's gold amount changes (this can be detected with the standard events). If trigger execution is done in some kind of order then you should be able to detect when a player's gold amount changes due to the bounty received from a specific unit. This would be the value of the bounty given.

Let me see if I can make this in the World Editor, and I'll post a test-map.

~ Edit ~
Sorry my antivirus has quarantined the RTC files that I need and the link at wc3c.net seems to be down at the moment. I will try to get this scripted out once I can get Jass NewGen Pack working properly.
 
Last edited:
Status
Not open for further replies.
Back
Top