Bonus gold when killing a unit with specific spell?

mylemonblue

You can change this now in User CP.
Reaction score
7
I have several abilities that I want to grant bonus gold to the player if he/she kills a unit with that ability. e.g If a firebolt spell was the cause of death, the casting player gets 10 extra gold in addition to the normal bounty.

Well, at first I tried using the Chest of Gold ability, and that didn't work. (I tried adding it to the hero, should I have just forced a Gold Coin item into it's inventory?)

I then tried this trigger to give the bonus gold, but it doesn't work. Is this only possible in JASS, or am I doing something wrong? If it's JASS specific, some pointers here and there and I think I can handle it (I'm trying to make the transition from GUI to JASS anyway :cool: )

Trigger:
  • RaptorStrike Bonus
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • Multiple ConditionsAnd - All (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to (==) Raptor Strike
          • ((Target unit of ability being cast) is A structure) Equal to (==) False
          • (Level of Marker for (Target unit of ability being cast)) Equal to (==) 0
    • Actions
      • Custom script: local unit casting = GetSpellAbilityUnit()
      • Custom script: local unit targ = GetSpellTargetUnit()
      • Custom script: set udg_Caster = casting
      • Custom script: set udg_Temp_Unit = targ
      • Countdown Timer - Start spell_timer as a One-shot timer that will expire in 0.30 seconds
      • Set spell_timer = (Last started timer)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Integer((Life of Temp_Unit))) Equal to (==) 0
          • Then - Actions
            • Countdown Timer - Destroy spell_timer
            • Special Effect - Create a special effect attached to the overhead of Caster using UI\Feedback\GoldCredit\GoldCredit.mdl
            • Special Effect - Destroy (Last created special effect)
            • Player - Add (10 x (Level of Raptor Strike for Caster)) to (Owner of Caster) Current gold
            • Custom script: set targ = null
            • Custom script: set udg_Temp_Unit = null
            • Custom script: set udg_Caster = null
            • Custom script: set casting = null
          • Else - Actions
            • Do nothing
 

Carnerox

The one and only.
Reaction score
84
You could possibly work around this maybe.


JASS:
globals
    integer rawcode = 'A004' //'Fatal Blow' rawcode.
endglobals

function Trig_Fatal_Blow_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == rawcode)
endfunction

function Trig_Fatal_Blow_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit() //Caster.
    local unit target = GetSpellTargetUnit() //Target.
    local player casterowner = GetOwningPlayer(caster) //Owner of Caster.
    local real x = GetUnitX(target) //X of Target.
    local real y = GetUnitY(target) //Y of Target.
    local integer bonusgold = (75 * GetUnitAbilityLevel (caster, rawcode)) //Amount of bonus gold.
    local string sfx = "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" //Effect if killed.
    local texttag text
    
    if (GetRandomInt(1, 100) <= (3 + GetUnitAbilityLevel (caster, rawcode))) then //Chanec to instantly kill.
        call AdjustPlayerStateBJ (bonusgold, casterowner, PLAYER_STATE_RESOURCE_GOLD) //Adding bonus gold.
        call DestroyEffect(AddSpecialEffectTarget (sfx, target, "chest")) //Creating a special effect when killed.
        set text = CreateTextTag()
        call SetTextTagText (text, "|cffff0000Fatal Death!|r", 0.024)
        call SetTextTagPos (text, x, y, 0.00)
        call SetTextTagVelocity (text, 0.0355 * Cos(90. * bj_DEGTORAD), 0.0355 * Sin(90. * bj_DEGTORAD))
        call SetTextTagVisibility (text, true)
        call SetTextTagFadepoint (text, 1)
        call SetTextTagLifespan (text, 1.5)
        call SetTextTagPermanent (text, false)
        call KillUnit (target) //Killing the Target.
    else
    endif
    //Removing leaks.
    set text = null
    set caster = null
    set target = null
    set casterowner = null
endfunction

//===========================================================================
function InitTrig_Fatal_Blow takes nothing returns nothing
    local trigger fatalblow = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ (fatalblow, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition (fatalblow, Condition( function Trig_Fatal_Blow_Conditions))
    call TriggerAddAction (fatalblow, function Trig_Fatal_Blow_Actions)
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top