Spell Spell Mirror

N

no0by

Guest
Ok so awhile ago I seen someone making a "spell reflecting" spell and I got inspired, And came up with this spell.

Spell Name: Spell Mirror
Activation Type: Passive, Aura
Hotkey: N/A
Discription:
Any enemy targeted spell has chance of being reflected to a random enemy hero.

Level 1 - 17% Chance.
Level 2 - 31% Chance.
Level 3 - 45% Chance.

Screen Shot:
spellmirrorrw4.jpg


Update1: Minor revision, Added an extra function so you can specify witch if any spells not to be reflected. Added abit more comments and readme (for those realy nooby)
Update2: Minor revision, Tweaked the spell abit and made the texttag 'float upwards' (I just learnt how to do it YAY)
Update3: Minor revision, Optimized code abit and added a new constant for attachment of the effect
Update4: Revised the way the spells are blocked, It will now let the unit cast the spell insted of ordering it to stop (might bug). Two new consants added one for the blocking item id (Rune of Spell Shield) and the other for witch unit the effect is attached.
 

Attachments

  • SPELLMIRRORv1.4.w3x
    26.7 KB · Views: 441
  • SPELLMIRRORv1.5.w3x
    27.9 KB · Views: 925
N

no0by

Guest
Thank you rayquaza218

Also if anyone wants to use it they have my permision as long as they DO NOT take credit for making the spell, I dont need a mention in you're map if you use it.
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
The entire 'creating triggers' thing can be replaced with this
Code:
//===========================================================================
function InitTrig_Spell_Mirror takes nothing returns nothing
    set gg_trg_Spell_Mirror=CreateTrigger()
    call Preload(SpellMirror_EffectS())
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Spell_Mirror,EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition(gg_trg_Spell_Mirror,Condition(function SpellMirror_MainCond))
    call TriggerAddAction(gg_trg_Spell_Mirror,function SpellMirror_Main)
endfunction
What you do now is just unnecessary.

Other than that: Good work :)
 

SFilip

Gone but not forgotten
Reaction score
633
All those setup functions that simply return a value should be turned intro constants. Why? Vexorian's optimizer inlines all constants so something like this
Code:
constant function GetDamage takes nothing returns real
    return 50.
endfunction

function PrintDamage takes nothing returns nothing
    call BJDebugMsg(R2S(GetDamage()))
endfunction
after optimization becomes
Code:
function PrintDamage takes nothing returns nothing
    call BJDebugMsg(R2S(50.))
endfunction
which is clearly more efficient.

call DestroyTrigger(GetTriggeringTrigger())
Really not needed in InitTrig_Spell_Mirror - Init isn't really running from a trigger so this does nothing.
Actually that whole part can be simplyfied as phyrex1an said ;)

Oh and you might also want to add a screenshot or something and I'll add it to the spell index.
 
N

no0by

Guest
You're right the return functions should be constants but I got some kind of error in WE that prevented me using them, Dont know why sorry I'll change them and see if it sticks.

The learn functions where originaly thought out for reducing lag by not executing the trigger if the hero/spell is never used in the game. Never the less I'll change that too.

As for the screen shot i'll see what I can do.
 

ayumilove

Youtube account suspended! youtube.com/ayumilove8
Reaction score
110
here is a screenshot which i made the hero run merry go around
until the frost nova of the Lich kills their own Warden hero

use my screenshot hehehe <3

3yv9.jpg
 
N

no0by

Guest
Thanks for the consideration ayumilove but I've made a much nicer screen shot.

Also I've Edited my first post with info about the spell and updated a new version of the map with changes made.
 

PhoenixICE

New Member
Reaction score
0
hmmm when i import the trigger i get a multitude of errors...ie/ expected name and a few others any idea why?
 

Tinki3

Special Member
Reaction score
418
I think you need to import the dummy unit(s)? If there are any.. Pretty sure there are though

And if there's anything else you need to import into your map then import that stuff as well.

The trigger might come up with errors because certain custom data might not be there. Custom data as in c. units, abilities.
 
N

no0by

Guest
You need to set afew constants for it to work

Code:
constant function SpellMirror_Caster takes nothing returns integer
    return 'u000' //Replace with rawcode of the unit (dummyunit)
endfunction

Code:
constant function SpellMirror_AbilityId takes nothing returns integer
    return 'A000' //Replace with rawcode of the ability (Spell Mirror)
endfunction

Code:
constant function SpellMirror_BuffId takes nothing returns integer
    return 'B000' //Replace with rawcode of the buff (Spell Mirror)
endfunction

And the custom script of you're map must contain

Code:
function CreateTextTagUnitEx takes unit u, string s, real size, real offset, real speed, real angle, integer red, integer blu, integer gre, integer trans, real life, real fade, boolean show, boolean permanent, boolean suspend returns texttag
    local texttag tt=CreateTextTag()
    local real vel=(speed*.071)/128
    local real xvel=vel*Cos(angle*bj_DEGTORAD)
    local real yvel=vel*Sin(angle*bj_DEGTORAD)
    call SetTextTagText(tt,s,(size*0.023)/10)
    call SetTextTagPos(tt,GetUnitX(u),GetUnitY(u),offset)
    call SetTextTagColor(tt,red,blu,gre,255-trans)
    call SetTextTagVisibility(tt,show)
    call SetTextTagPermanent(tt,permanent)
    call SetTextTagSuspended(tt,suspend)
    call SetTextTagVelocity(tt,xvel,yvel)
    if permanent!=true then
        call SetTextTagLifespan(tt,life)
        call SetTextTagFadepoint(tt,fade)
    endif
    return tt
endfunction

function RandomGroupUnit takes group g returns unit
    local integer i=1
    local integer r
    local unit z
    set bj_groupCountUnits=0
    call ForGroup(g,function CountUnitsInGroupEnum)
    set r=GetRandomInt(1,bj_groupCountUnits)
    loop
        set z=FirstOfGroup(g)
        exitwhen i==r
        call GroupRemoveUnit(g,z)
        set i=i+1
    endloop
    call DestroyGroup(g)
    set g=null
    return z
endfunction

Also make sure the dummyunit has mana e.g 1k atleast
 

PhoenixICE

New Member
Reaction score
0
no i can't even save the map, cause there is errors in the script i copied and set all the varaibles but still doesn't work it says all the constant functions are errors i dunno why...
 

rayquaza218

New Member
Reaction score
51
Pheonix, u probably didn't import variables? I usually import everything in tis order.

Abilities.
units
Variables
trigger.

always works, if some parts are faded out just click it and hit OK, it should work
 
N

no0by

Guest
I had the same problem when making the spell... Try and remove the constants (just remove the constant bit of each function) save then add them back in.
 
G

Gman15100

Guest
im getting two errors i imported everythign and put in all the data im egtting these...

line 659 : expected a name
Code:
set tu=RandomGroupUnit(g) // THIS WILL destroy the group for you (still needs a null tho)

line 673: Expected a function name
call
Code:
CreateTextTagUnitEx(mu,SpellMirror_String(),10.,5.,64.,90.,SpellMirror_SRed(),SpellMirror_SBlu(),SpellMirror_SGre(),64,2.,1.5,true,false,false)

i tryed everything i could but i didnt want to mess around with the lines them selves since im only learning jass now.. i most the basic idea and tweak stuff but i didnt wanna mess with that. I just retyped msot of it exactly to see if it would work but obivously it didn't thanks if u can help.
 
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