SphereCommunity
[Healing Script]Spell Back into PLayer cast - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: [Healing Script]Spell Back into PLayer cast (/Thread-Healing-Script-Spell-Back-into-PLayer-cast)



[Healing Script]Spell Back into PLayer cast - Paulo_BR - 02-27-2013 06:21 PM

Help Me this script!!

Allways some player cast spell and use healing at the same time, the spell come back to player!

And i not see this error in the script!

Help me plesE!!!

Code:
[typedef T_BANDAGE]
on=@DClick
  IF (<SRC.FINDID.i_memory_healer>)
        SRC.SYSMESSAGE @95,,1 Voce nao pode se curar ainda.
        RETURN 1
    ENDIF
    IF (<CONT>!=<SRC.FINDLAYER(21).UID>)
      SRC.SYSMESSAGE @95,,1 Bandages tem que estar na bag para usar.
      RETURN 1
    ENDIF
    SRC.SYSMESSAGE @95,,1 Quem voce gostaria de curar?
    TARGET
    RETURN 1

on=@Targon_Char
if (<src.targ.distance> <= <def0.TargMaxDistance>)
    if (<def0.AllowReadyBandage>)
        if (<src.findid(i_memory_healer).uid>)
            src.findid(i_memory_healer).remove
        endif
    endif
    if (<argo.flags> & statf_dead)
        if (<def0.EnableResurrect>)
            if (<src.tag0.pericia_curandeiro> >= 1) && (<src.tag0.pericia_clerigo> == 1)
                if (<src.<def0.FirstSkillResurrect>> >= <def0.FirstSkillAmount>)
                    if (<src.<def0.SecondSkillResurrect>> >= <def0.SecondSkillAmount>)
                        if (<src.rescount i_bandage> >= <def0.ResurrectConsume>)
                            
                            argo.sysmessage @<def0.MessageColor> <src.name> esta tentando te ressucitar com bandagens.
                            src.sysmessage @<def0.MessageColor> Voce esta tentando ressucitar <argo.name> com bandagens.
                            
                            src.consume <def0.ResurrectConsume> i_bandage
                            serv.newitem = i_memory_healer
                            new.cont = <src>
                            new.link = <argo.uid>
                            new.more = 1
                            new.timer = <def0.ResurrectDelay>
                            if (!<new.timer>)
                                new.trigger = @Timer
                            endif
                            if (<def0.HealInterrupt>)
                                src.events +e_heal_interrupt
                            endif
                        endif
                    else
                        src.sysmessage Voce nao tem skill suficiente para isso.
                    endif
                endif
            else
                src.sysmessage @07a1 Para ressar com bandagens, voce precisa da pericia "curandeiro" e "clerigo"
            endif
        endif
    else
        if (<src.targ.hits> < <src.targ.maxhits>)
            if (<src.targ.uid> == <src.uid>)
                src.sysmessage @<def0.MessageColor> Voce aplica bandagem em voce.
            else
                argo.sysmessage @<def0.MessageColor> <src.name> aplicou bandagem em voce.
                src.sysmessage @<def0.MessageColor> Voce aplicou bandagem no alvo.
            endif
            if (<def0.SkillCancel>)
                src.action = -1
            endif
            src.consume 1 i_bandage
            src.sound = 058
            serv.newitem = i_memory_healer
            new.cont = <src>
            new.link = <argo.uid>
            new.timer = <def0.BandageDelay>
            if (!<new.timer>)
                new.trigger = @Timer
            endif
            if (<def0.HealInterrupt>)
                src.events +e_heal_interrupt
            endif
        else
            src.sysmessage @<def0.MessageColor> O alvo nao precisa ser curado.
        endif
    endif
else
    src.sysmessage @<def0.MessageColor> Esta muito longe.
endif
return 1

Code:
[defname def_bandage]
AllowReadyBandage    1    // Allow players to 'ready' bandages?
BloodyBandageAtFail    1    // Bloody bandages at failure or success?
BandageDelay        4    // Delay for healing/curing.
EnableFail        1    // Enable/disable failing.
CurePoison        0    // Can poison be cured with a bandage?
HealCriminal        1    // Healing criminals is a crime?
HealInterrupt        0    // Healing interruption.
MessageColor        95    // Color of the sysmessages.
SkillCancel        0    // Cancel used skill(s) when bandage is applied?
TargMaxDistance        3    // Maximum distance from target.
UseFromGround        0    // Can bandages be used from the ground?


[defname def_bandage_resurrect]
EnableResurrect        1    // Allow resurrection?
FirstSkillAmount    800    // First skill amount required for resurrection.
FirstSkillResurrect    healing    // First skill check for resurrection.
ResurrectConsume    2     // Amount of bandages consumed at resurrection.
ResurrectDelay        4    // Delay for resurrection.
SecondSkillAmount    1000     // Second skill amount required for resurrection.
SecondSkillResurrect    anatomy    // Second skill check for resurrection.

[itemdef i_memory_healer]
id = i_memory
name = Healing Memory Object
weight = 0
type = t_eq_script

on=@Create
attr = attr_invis|attr_decay

on=@Timer
if (<distance <link>> <= <def0.TargMaxDistance>)
    if (<cont.tag0.failrate> > 3)
        cont.tag0.failrate = 0
    else
        f_fail_healing
        if (<def0.BloodyBandageAtFail>)
            var.uid <cont.uid>
        TRY UID.<var.uid>.newitem i_bandage_bloody
        TRY UID.<var.uid>.new.cont <var.uid>
        endif
    endif
    doswitch <more>
        begin
            if (!<qval <link.flags> & statf_dead ? 1:0>) // Workaround for logical NOT issue.
                f_heal
            endif
        end
        begin
            if (<link.flags> & statf_dead)
                link.resurrect
            endif
        end
    enddo
    if (<def0.HealCriminal>)
        if (<link.kills> > <serv.murdermincount>) || (<link.flags> & statf_criminal) || (<link.brain> & brain_undead) || (<link.brain> & brain_monster)
      if (<cont.uid> != <link.uid>)
            cont.criminal = 1
     endif
        endif
    endif
    f_gain_healing
else
    cont.sysmessage @<def0.MessageColor> O alvo esta muito longe.
endif
if (<def0.HealInterrupt>)
    cont.events -e_heal_interrupt
endif
remove
return 1


[function f_heal]
if (<link.flags> & statf_poisoned)
    if (<def0.CurePoison>)
        link.findid(i_rune_poison).remove
    endif
else
    local.heal_val = <eval (<cont.healing> @ 2) / rand(40000,50000)>
    if (<link.isgm>)
       link.sysmessage @07a1 <eval <local.heal_val>>
    endif
    if (<link.tag0.pericia_curandeiro> >= 1)
        if (<link.tag0.pericia_curandeiro> == 1)
            float.bonus <floatval (<local.heal_val>/100)*20>
        elseif (<link.tag0.pericia_curandeiro> == 2)
            float.bonus <floatval (<local.heal_val>/100)*25>
        else
            float.bonus <floatval (<local.heal_val>/100)*35>
        endif
        if (<eval <local.heal_val> + <eval <float.bonus>/1000000>> > 0)
            link.sysmessage @07a1 Voce curou <eval <local.heal_val> + <eval <float.bonus>/1000000>> de vida
        endif
        link.hits += <local.heal_val> + <eval <float.bonus>/1000000>
    else
        link.hits += <local.heal_val>
        if (<eval <local.heal_val>> > 0)
            link.sysmessage @07a1 Voce curou <eval <local.heal_val>>  de vida
        endif
    endif
    
    if (<link.hits> > <link.maxhits>)
        link.hits = <link.maxhits>
    endif
endif
if (!<def0.BloodyBandageAtFail>)
    serv.newitem = i_bandage_bloody
    new.cont = <cont>
endif


[function f_fail_healing]
if (<def0.EnableFail>)
    local.failchance = <eval rand(1,900)>
    if (<local.failchance> > <cont.healing>)
        doswitch <cont.findid(i_memory_healer).more>
            cont.sysmessage @<def0.MessageColor> Voce aplicou as bandagens, mas nao conseguiu ajudar.
            cont.sysmessage @<def0.MessageColor> Voce falhou ao tentar ressucitar o alvo.
        enddo
        serv.newitem = i_bandage_bloody
        new.cont = <cont>
        cont.tag0.failrate += 1
        cont.findid(i_memory_healer).remove
    endif
endif


[function f_gain_healing]
if (<cont.healing> < 1000)
    cont.tag0.gainchance += 300
    if (<cont.tag0.gainchance> > <cont.healing>)
        cont.healing += 0.1
        cont.tag0.gainchance = 0
    endif
endif


[events e_heal_interrupt]
on=@GetHit
sysmessage @<def0.MessageColor> Seus dedos escorregam ao tentar aplicar a bandagem.
findid(i_memory_healer).remove
events -e_heal_interrupt
return 0

[EOF]

Thnkyou So much!


RE: [Healing Script]Spell Back into PLayer cast - Norlack - 02-27-2013 10:41 PM

I took a quick look to your script and I noticed that:
- under @TargOn_Char, to me, is better using ARGO instead of SRC.TARG
- the f_gain_healing function doesn't consider the skillcap and the skilllock
- your healing system heals both players and npcs (veterinary should do that)


RE: [Healing Script]Spell Back into PLayer cast - RanXerox - 02-28-2013 01:29 AM

This following code seems a bit sketchy because VAR is a *global* variable... if any other code users VAR.uid then the possibility of getting the wrong value exists. I suggest replacing VAR with LOCAL:

Code:
if (<def0.BloodyBandageAtFail>)
   var.uid <cont.uid>
   TRY UID.<var.uid>.newitem i_bandage_bloody
   TRY UID.<var.uid>.new.cont <var.uid>
endif



RE: [Healing Script]Spell Back into PLayer cast - Paulo_BR - 03-01-2013 03:19 PM

Maaaaaan, its works!!!! I replacing VAR with local and change src.targ for argo!!! Thanks guys!!!