• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Exchange Buffs Skill

Status
Not open for further replies.
Level 5
Joined
Aug 30, 2009
Messages
114
Hey, I want a system very hard to make...

I considerate myself a good jass scripter, but I need a system very over my capacities, I don`t even know if it is possible to do, but I need this help.

Can someone tell me if is possible to create a spell to exchange buffs?

I mean, for example:

Passive Skill
Whenever a unit with this skill is buffed negatively, it returns the buff back to its owner.

Cooldown of 5 seconds.

Well with this skill, if a unit with the passive skill is stunned, he takes the damage but the stun is dealt to its owner, that`s how I can`t use spell steal, because spell steal returns only some kinds of buffs and not all of them.

Or can be this:

Target Skill
Your hero exchange his negatives buffs with the positive buffs of your target.

Spell steal cannot be used, because it doesnt work with every kinds of buffs, only with a few of them.

Thank you.
 
looks like spell steal passive spell of the spellbreaker if im not mistaken...

this:
Spell steal cannot be used, because it doesnt work with every kinds of buffs, only with a few of them.

anyway if you can use vJASS, BoneBreaker's suggestion would be great, because Anitarf's Buff system can do wonders specially when mixed with other systems...
 
Ok, I made it. When you learn the Mirror Shield skill, your hero will be added to a unit group and then everytime a spell is casted (can work for Chain Lightning too type of spells, not only buff-giving spells; in order to avoid that, go to Trig_One_Conditions function and add the orders you don't want included. To retrieve the order of an ability, do this:
  • Tro
  • Events
    • Unit - A unit is issued an order targeting an object
  • Conditions
  • Actions
    • Custom script: call BJDebugMsg (I2S(GetIssuedOrderId()))
Mirror Shield:
  • Two
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Mirror Shield
    • Actions
      • Unit Group - Add (Triggering unit) to MirrorGroup
JASS:
function Trig_One_Conditions takes nothing returns boolean
    return GetIssuedOrderId() != 851971 and GetIssuedOrderId() != 851986 and GetIssuedOrderId() != 851990 and GetIssuedOrderId() != 851983 and GetUnitTypeId(GetTriggerUnit()) != 'H000' and IsUnitEnemy (GetTriggerUnit(), GetOwningPlayer(GetOrderTargetUnit())) and IsUnitInGroup (GetOrderTargetUnit(), udg_MirrorGroup)
endfunction

function StopCasting takes nothing returns nothing
    local unit u = LoadUnitHandle (udg_Hash, GetHandleId (GetTriggeringTrigger()), StringHash("dummy"))
    call UnitApplyTimedLife (u, 'BTLF', 0.01)
    call FlushChildHashtable (udg_Hash, GetHandleId(GetTriggeringTrigger()))
    call DestroyTrigger (GetTriggeringTrigger())
    set u = null
endfunction

function FakeCastTarget takes integer id, unit u, unit u2, integer i, boolean b returns nothing
    local player p = GetOwningPlayer (u2)
    local unit u1 = CreateUnit (p, 'H000', GetUnitX (u), GetUnitY(u), 0)
    local trigger t
    call ShowUnit (u1, false)
    call UnitAddAbility (u1, id)
    call IssueTargetOrderById (u1, i, u)
    if b == true then
        call UnitApplyTimedLife (u1, 'BTLF', 1)
    else
        set t = CreateTrigger()
        call TriggerRegisterUnitEvent (t, u, EVENT_UNIT_SPELL_ENDCAST)
        call TriggerRegisterUnitEvent (t, u, EVENT_UNIT_SPELL_FINISH)
        call TriggerAddAction (t, function StopCasting)
        call SaveUnitHandle (udg_Hash, GetHandleId (t), StringHash("dummy"), u1)
    endif
    set u1 = null
    set u = null
    set u2 = null
endfunction

function RetrieveSpell takes nothing returns nothing
    local trigger t = GetTriggeringTrigger()
    local integer abid = GetSpellAbilityId()
    local unit u = GetSpellTargetUnit()
    local real x
    local real y
    local unit u1 = GetTriggerUnit()
    local boolean b
    local integer i = LoadInteger (udg_Hash, GetHandleId (t), StringHash("order"))
    if GetTriggerEventId() == EVENT_UNIT_SPELL_EFFECT then
        set b = true
    else
        set b = false
    endif
    call FakeCastTarget (abid, u1, u, i, b)
    call FlushChildHashtable (udg_Hash, GetHandleId (t))
    call DestroyTrigger (t)
    set u = null
    set u1 = null
endfunction

function Trig_One_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local trigger t = CreateTrigger()
    local integer i = GetIssuedOrderId()
    call SaveUnitHandle (udg_Hash, GetHandleId(t), StringHash("init"), u)
    call TriggerRegisterUnitEvent (t, u, EVENT_UNIT_SPELL_EFFECT)
    call TriggerRegisterUnitEvent (t, u, EVENT_UNIT_SPELL_CHANNEL)
    call SaveInteger (udg_Hash, GetHandleId (t), StringHash("order"), i)
    call TriggerAddAction (t, function RetrieveSpell)
    set u = null
endfunction

//===========================================================================
function InitTrig_One takes nothing returns nothing
    set gg_trg_One = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_One, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
    call TriggerAddCondition( gg_trg_One, Condition( function Trig_One_Conditions ) )
    call TriggerAddAction( gg_trg_One, function Trig_One_Actions )
endfunction

Test Map:
 

Attachments

  • Mirror Shield.w3x
    19.5 KB · Views: 47
Status
Not open for further replies.
Top