• 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.

SpellMirror v1.0

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
Simple spell on jass
Hero can Reflect spell back to caster

Here Trigger

JASS:
globals
integer MirrorSkill = 'A000' // Skill Activator
integer MirrorBuff = 'B000' // Buff
integer DummyID = 'h000' // Dummy Unit
endglobals


function Trig_Mirror_System_Conditions takes nothing returns boolean
    return GetUnitAbilityLevel(GetSpellTargetUnit(), MirrorBuff) > 0
endfunction


function Trig_Mirror_System_Actions takes nothing returns nothing
    local unit MirroredTarget = GetSpellTargetUnit()
    local unit MirrorCaster = GetSpellAbilityUnit()
    local unit = MirrorDummy
    local real XOC = GetUnitX(MirroredTarget)
    local real YOC = GetUnitY(MirroredTarget)
    local integer chance = 50 // Chance to reflect skill back
    local integer SpelledMirror
    local string order = OrderId2StringBJ(GetUnitCurrentOrder(MirrorCaster))
    if (GetRandomInt(1,100) <= chance ) then
    set SpelledMirror= GetSpellAbilityId()
    set MirrorDummy = CreateUnit(GetOwningPlayer(MirroredTarget),DummyID,XOC,YOC,0.)
    call UnitAddAbility(MirrorDummy,SpelledMirror)
    call IssueTargetOrder(MirrorDummy,order,MirrorCaster)
    call UnitApplyTimedLife(MirrorDummy,'BTLF',1.0)
    else
    endif
endfunction

//===========================================================================
function InitTrig_Mirror_System takes nothing returns nothing
    set gg_trg_Mirror_System = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Mirror_System, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Mirror_System, Condition( function Trig_Mirror_System_Conditions ) )
    call TriggerAddAction( gg_trg_Mirror_System, function Trig_Mirror_System_Actions )
endfunction


Keywords:
spell,mirror,spellmirror,reflect,return,buff,
Contents

MirrorSystem (Map)

Reviews
17:05, 6th Apr 2011 Bribe: Such a spell is found too common, in fact there are already sooo many of this type floating around, already written as optimally as possible.

Moderator

M

Moderator

17:05, 6th Apr 2011
Bribe:

Such a spell is found too common, in fact there are already sooo many of this type floating around, already written as optimally as possible.
 
The only issues:

-Readability sux but it doesn't affect functionality
-Your functions reveal that you only converted GUI to JASS
-OrderId2StringBJ is a BJ and could be replaced with a native.
-"chance should be a global constant or just a normal global that differs with ability level.

You did ... ok?
I don't want to ruin your rating, so i'll wait until you improve.
Good luck :)
 
Level 11
Joined
Sep 30, 2009
Messages
698
call UnitApplyTimedLife(MirrorDummy,'BTLF',1.0)

What if the spell is channeling? Or if the casting time is greater than 1 second?

Also you leak two unit variables and the third leaks and has a typo.

And also this really looks like converted GUI with maybe some jass work. It is way to simple to be approved here. Such a spell would anyway work only good if all spells would be triggered.
 
Level 6
Joined
Aug 20, 2009
Messages
95
You just converted this... And, as stated above, it wouldn't work for custom abilities. You could always MAKE it work, by adding in a triggers space, for example.
JASS:
globals
integer STORMBOLT = 'A000'
trigger STORMTRIGGER = CastStormbolt
//Then later on...
function OnCast takes nothing returns nothing
     call ExecuteFunc(function STORMTRIGGER)
Although I'd recommend storing the abilities as an array and then looping through them to see which one. But my point is, run the triggers for the custom spells as the caster having it. Or, Better yet, get a damage detection, detect if the unit is HURT from the spell, and just add the ability (Whatever it is) to the caster, and then just order him to use it.
 
Level 9
Joined
Dec 12, 2007
Messages
489
@illegalpie: i do believe this will work for custom abilities,
it is just limited to unit targetting ability, either custom or default ability.
but i'm haven't tested if it will work with the Channel spell.

and as Axarion said, i doubt this will work perfectly with channeling spell.
just asking, how about spell blocking ability? will it work perfectly with it?
guess not, hehe

and yes, i do think this is too simple for this kind of thing, and
i do believe i've seen this kind of ability too with the same simplicity.

and for information, you uses global vars declaration, which means your submission is now
categorized as VJass not JASS anymore.
and please admit it, your function name and empty "else" shows that it is a converted GUI,
with few edits around.

thank you
 
Last edited:
Top