SphereCommunity
Aura Spell - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Aura Spell (/Thread-Aura-Spell)



Aura Spell - Seron - 03-20-2014 07:21 PM

Greetings,

I have recently tried to make a Aura kind of spell (Think Paladin from Diablo 2). An area of effect around a character which buffs players as long as they stay inside of the area. Also it should move with the caster.

I decided to try this using multiregion:

Code:
[SPELL 425]
DEFNAME=s_siegesrausch
NAME=Siegesrausch
SOUND=044b
RUNES=
CAST_TIME=0.5
RESOURCES=
RUNE_ITEM=5578
SCROLL_ITEM=I_SCROLL_X_RED
FLAGS=SPELLFLAG_GOOD
EFFECT_ID=0
EFFECT=0
DURATION=0
MANAUSE=5
SKILLREQ=Magery 1.0
INTERRUPT=0.0,0.0

ON=@Start
if (<restest 1 i_rune_kaiserbanner>)
consume i_rune_kaiserbanner
endif

if (<restest 1 i_rune_siegesrausch>)
consume i_rune_siegesrausch
return 1
endif

ON=@Success
NEWITEM i_rune_siegesrausch
EQUIP <ACT.UID>

SERV.NEWITEM i_siegesrausch
NEW.P=<P>
NEW.LINK=<UID>
NEW.REGION.EVENTS +r_siegesrausch
NEW.TIMERF 1,REGION.FLAGS=0
REF1=<NEW.UID>
ACT.LINK=<NEW.UID>
RETURN 0

[ITEMDEF i_rune_siegesrausch]
ID=8323
TYPE=t_eq_script
NAME=Rune_siegesrausch

ON=@equip
timer=1

ON=@timer
timer=1
link.p=<cont.p>
cont.effect 3,14202,1,21
return 1

ON=@unequip
SRC.SYSMESSAGE @0481,,1 Du beendest Siegesrausch.
LINK.REMOVE

[ITEMDEF i_siegesrausch]
ID=i_memory
NAME=Siegesrausch
TYPE=T_MULTI
VALUE=1
MULTIREGION=-4,-4,5,5

ON=@CREATE
ATTR=08010|attr_decay
TIMER=60

[REGIONTYPE r_siegesrausch]
ON=@Enter
IF (<SRC.ISPLAYER>) && !(<SRC.ISGM>)
SRC.SYSMESSAGE @0481,,1 Du stehst unter dem Effekt von 'Siegesrausch'
src.effect 3,i_fx_bless_effect,1,16,0,0,2
src.events +e_siegesrausch
endif

ON=@EXIT
IF (<SRC.ISPLAYER>) && !(<SRC.ISGM>)
SRC.SYSMESSAGE @0481,,1 Der Effekt von 'Siegesrausch' lässt nach...
src.events -e_siegesrausch
endif

This works more or less as intended. However it inteferes with events from existing region. Not just @enter or @exit events but also antimagic flags.

My question would be: Is there a way to nest a region inside a region so that they do not interefere with each other? Or maybe a better way to do the whole 'aura' thing (hopefully without lots of timer and forchars)?

I was thinking about ROOMDEF but apparently you can not use @Enter/@Exit Trigger on that one.


RE: Aura Spell - Alaric - 03-20-2014 11:00 PM

and @regionenter trigger being constantly on player and checking whether it is the spell region doesn't work?

But I personally think that this is not that good idea. Well, it is good in theory, but totem with forcycle ticking every second, giving memory item and refreshing timer would be easier and cleaner.

Since with region you have to check more stuff. And if there are some shitty things - the region disappears, enter/exit triggers doesn't work always properly (just my experience, sometimes it fired, sometimes not and i had to check and check). With this temporary item ticking you don't have to check where you are, if you left the region and those shits. The only check would be "does memory item exist?" No? => create one, Yes? refresh timer/set it to 2.
If the totem item disappears, no worries, the memory item removes itself very soon. No additional checks and operations.

E: ticking every 2 seconds might be good too if you want to minimalize servers work. But no more. I would also set memory timer a bit higher than ticking time. It is actually you wanted to avoid, but this is the best way I know. No bugs, no stupid checks, short code, does what you want.


RE: Aura Spell - Shidhun - 03-20-2014 11:33 PM

Try it with something like this :
Code:
[Spell 425]
DEFNAME=s_siegesrausch
NAME=Siegesrausch
RUNES=
CAST_TIME=0.5
RESOURCES=i_reag_mandrake_root //Reagents ?
RUNE_ITEM=5578
SCROLL_ITEM=i_scroll_x_red
FLAGS=SPELLFLAG_SCRIPTED|SPELLFLAG_TARG_CHAR
EFFECT_ID=0
EFFECT=0
MANAUSE=5
SKILLREQ=MAGERY 50.0
INTERRUPT=100.0,1.0

ON=@SELECT
    ARGN1 42

ON=@EFFECT
CALL f_spell_siegesrausch
RETURN 0

[FUNCTION f_spell_siegesrausch]
IF (<ISITEM>)
    IF (<CONT>)
        RETURN 1
    ENDIF
ENDIF
IF (<SRC.ACTION>==Skill_Magery)&&(<ARGN1>==<SRC.ACTARG1>)
    IF (<SRC.FINDID(I_spelleffect_siegesrausch)>)
        SRC.FINDID(I_spelleffect_siegesrausch).remove
    ENDIF
ENDIF
LOCAL.Wirkung <EVAL (20*<ARGN2>)/1000> // Strength of the effect
SERV.NEWITEM I_spelleffect_siegesrausch
NEW.MORE2=<LOCAL.Wirkung>
NEW.MORE1=<EVAL <ARGN2>/100> // How often should the effect occur?
EQUIP <NEW.UID>

[ITEMDEF i_spelleffect_siegesrausch]
ID=i_rune_bless
LAYER=56
TYPE=t_eq_script

ON=@EQUIP
    ATTR=026
    TIMER=7
    
ON=@TIMER
    IF (<MORE1>)
        LOCAL.Wirkung <MORE2>
        SOUND snd_spell_bless
        MORE1 -= 1
        CONT.effect 3,i_fx_bless_effect,1,16,0,0,2
        LOCAL.UID = <CONT.UID>
        FORCHARS 4
            IF (<HITS> <= <MAXHITS>)&&!(<FLAGS>&02003)
                EFFECT 3,i_fx_heal_effect,0,28,0,2535,3
                SPELLEFFECT s_bless,<local.wirkung>
            ENDIF
        ENDFOR
        TIMER={8 13} // Intervall
    ELSE
        REMOVE
    ENDIF
    RETURN 1

It is only a part of one of our spells (other effect), and i haven't tested it. But it should give you an Idea how to create your spell[/php]


RE: Aura Spell - Seron - 03-21-2014 05:37 AM

@Alaric: Hmm might be the only valid solution. With a REGION it seemed to be more effective and smoother than memoryitems and timers but oh well...

@Shidhun: This might work for something like you did (a recurring effect) but i think it wouldnt work for something that is gets set when you enter the aura and removed when you leave the aura. Like raising resistances for example. You dont really want them to jump up and down all the time.