1. Head to the 33rd Modeling Contest Poll and drink to your heart's desire.
    Dismiss Notice
  2. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  4. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  5. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  6. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  7. 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.

Exchange Buffs Skill

Discussion in 'World Editor Help Zone' started by Narg666, Sep 19, 2010.

  1. Narg666

    Narg666

    Joined:
    Aug 30, 2009
    Messages:
    112
    Resources:
    0
    Resources:
    0
    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.
     
  2. BoneBreaker

    BoneBreaker

    Joined:
    Jun 26, 2005
    Messages:
    247
    Resources:
    0
    Resources:
    0
  3. GhostThruster

    GhostThruster

    Joined:
    Jul 24, 2009
    Messages:
    4,848
    Resources:
    34
    Models:
    7
    Icons:
    21
    Packs:
    1
    Skins:
    1
    Maps:
    3
    Spells:
    1
    Resources:
    34
    I can do this in GUI, but not JASS(unless I convert GUI to JASS after I finished).
     
  4. mckill2009

    mckill2009

    Joined:
    Mar 10, 2009
    Messages:
    4,696
    Resources:
    34
    Maps:
    5
    Spells:
    27
    JASS:
    2
    Resources:
    34
    looks like spell steal passive spell of the spellbreaker if im not mistaken...
     
    Last edited: Sep 21, 2010
  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
    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...
     
  6. Pharaoh_

    Pharaoh_

    Joined:
    Nov 6, 2008
    Messages:
    8,128
    Resources:
    11
    Icons:
    3
    Skins:
    1
    Spells:
    6
    Tutorials:
    1
    Resources:
    11
    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

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

    Attached Files:

  7. Lich Prince

    Lich Prince

    Joined:
    Mar 18, 2008
    Messages:
    724
    Resources:
    0
    Resources:
    0
    Finally, Pharaoh_ is back! =P