1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

A de-buff that increases bounty?

Discussion in 'Triggers & Scripts' started by Nemitri, Nov 15, 2010.

  1. Nemitri

    Nemitri

    Joined:
    Nov 15, 2010
    Messages:
    29
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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?
     
  2. Dr. Boom

    Dr. Boom

    Joined:
    May 1, 2008
    Messages:
    1,552
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    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
     
  3. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    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.
     
  4. Nemitri

    Nemitri

    Joined:
    Nov 15, 2010
    Messages:
    29
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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.
     
  5. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    you can save the bounty range of each unit type and then just give bonus bounty upon death...


    but

    for best results you will need to customize the bounty giving... and just set all OE bounties to 0...
     
  6. WaterKnight

    WaterKnight

    Joined:
    Aug 18, 2009
    Messages:
    4,033
    Resources:
    5
    Maps:
    1
    Tutorials:
    4
    Resources:
    5
    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":

    Code (vJASS):
    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.
     
  7. Dr. Boom

    Dr. Boom

    Joined:
    May 1, 2008
    Messages:
    1,552
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    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
     
  8. WaterKnight

    WaterKnight

    Joined:
    Aug 18, 2009
    Messages:
    4,033
    Resources:
    5
    Maps:
    1
    Tutorials:
    4
    Resources:
    5
    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: Nov 16, 2010
  9. Dr. Boom

    Dr. Boom

    Joined:
    May 1, 2008
    Messages:
    1,552
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Ok before I lose my mind here, I just will say something about the "do not destroy the unit group variable" ... so you want say it's good then if I create every 0.05 seconds a leak so 20 leaks in 1 second.

    Ok here we go, I need some holiday now!
     
  10. WaterKnight

    WaterKnight

    Joined:
    Aug 18, 2009
    Messages:
    4,033
    Resources:
    5
    Maps:
    1
    Tutorials:
    4
    Resources:
    5
    You do not create a new group everytime, you reuse the already existing one in TempGroup variable.

    I've made some additions to my previous post considering your edited points.
     
  11. Dr. Boom

    Dr. Boom

    Joined:
    May 1, 2008
    Messages:
    1,552
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    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
     
  12. defskull

    defskull

    Joined:
    Mar 27, 2008
    Messages:
    7,978
    Resources:
    17
    Spells:
    17
    Resources:
    17
    "Do not feed the troll(s)"
     
  13. Berb

    Berb

    Joined:
    Jan 21, 2006
    Messages:
    2,539
    Resources:
    2
    JASS:
    2
    Resources:
    2
    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: Nov 17, 2010