SphereCommunity
Can cast spells under map - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Can cast spells under map (/Thread-Can-cast-spells-under-map)

Pages: 1 2


RE: Can cast spells under map - Coruja - 10-14-2017 08:20 AM

best way to fix this is on sphere source code. On sphere 56d this is already fixed by default, but on old 56b the only way to fix it is using workaround on scripts

maybe the script above will be able to fix it, you just need to replace TIMERF 1,Z=<SRC.Z> with TIMERF 1,FIX. But keep in mind that this is an workaround, it will create the field on wrong position and then after 1 second it will call an ".fix" on item adjusting Z to correct value


RE: Can cast spells under map - escribano - 10-14-2017 08:45 AM

I've posted this some time ago:

Code:
[FUNCTION f_fix_z]
local.z = <z>
local.tz = <serv.map(<p.x>,<p.y>).terrain.z>

if (<abs <eval (<local.z> - <local.tz>)>> < 10)
    z <local.tz>
else
    local.z <local.tz>
    for x 1 <serv.map(<p.x>,<p.y>).statics>
        if (<abs <eval (<local.z> - <serv.map(<p.x>,<p.y>).statics.<local.x>.z>)>> < 10)
            local.z <serv.map(<p.x>,<p.y>).statics.<local.x>.z>
        endif
    endfor

    z <local.z>
endif

I don't really know if it's the best and accurate code to do this... loot it's simple, but you can have an idea Smile

Adding a tiny explanation:

This code checks the TERRAIN of the "actual item position" (ignoring its own Z), it the item is too "closer" to the terrain the fixed Z will be set as the TERRAIN Z point.

If the actual position is distant to the terrain the code will seek the closet STATIC item at the position to define the Z point...

There are a lot of code needed to make this work properly, need to check the item "height", floors and so...

And think now of the initial problem.... u can check if the spell is called "under" the TERRAIN...

Triggering it you can cancel the casting, or... use the code to fix the spell position Smile


RE: Can cast spells under map - Russian - 10-14-2017 05:23 PM

It's a live!
Code:
IF (<ARGN>==24) || (<ARGN>==28) || (<ARGN>==39) || (<ARGN>==47) || (<ARGN>==50)
    //Если кастует на земле
    IF !(<SERV.MAP(<SRC.TARGP.X>,<SRC.TARGP.Y>).TERRAIN.Z>==<SRC.TARGP.Z>) && (<SERV.MAP(<SRC.TARGP.X>,<SRC.TARGP.Y>).STATICS.1.ID>==0)
    SERV.LOG [<SRC.NAME> <SRC.UID> Z:<SRC.TARGP.Z>] try to cast <SERV.SPELL.<ARGN>.NAME> [to Z: <SERV.MAP(<SRC.TARGP.X>,<SRC.TARGP.Y>).TERRAIN.Z>]
    SRC.SYSMESSAGE @0486 Вне поля видимости.
    RETURN 1
    ENDIF
    //Если кастует на статике
    IF !(<SERV.MAP(<SRC.TARGP.X>,<SRC.TARGP.Y>).STATICS.1.Z>==<SRC.TARGP.Z>) && !(<SERV.MAP(<SRC.TARGP.X>,<SRC.TARGP.Y>).STATICS.1.ID>==0)
    SERV.LOG [<SRC.NAME> <SRC.UID> Z:<SRC.TARGP.Z>] try to cast <SERV.SPELL.<ARGN>.NAME> [to Z: <SERV.MAP(<SRC.TARGP.X>,<SRC.TARGP.Y>).STATICS.1.Z>]
    SRC.SYSMESSAGE @0486 Вне поля видимости.
    RETURN 1
    ENDIF
ENDIF
Thanks to all! Big thanks to escribano, he said true: !(<SERV.MAP(<SRC.TARGP.X>,<SRC.TARGP.Y>).TERRAIN.Z>==<SRC.TARGP.Z>)


RE: Can cast spells under map - escribano - 10-16-2017 11:01 PM

Glad I helped!

As I always said, there is nothing that can't be done in sphere Tongue

Also thanks for posting the solution to the community!
Don't forget to like the post I helped!