SphereCommunity
Strain. - Printable Version

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

Pages: 1 2


Strain. - Mordaunt - 08-17-2012 01:15 PM

Yes it's a strange title but bear with me.

Looking into changing the way my environmental script runs it's checks on players, currently it's this:

Code:
ON=@Environchange
        if <isplayer>
            f_environ_calc
            if <def.tempaffect>
                if !(<restest 1 i_tempaffect>)
                    serv.newitem i_tempaffect
                    new.equip
                endif
                local.layer=3
                for 14
                    if (<dlocal.layer>==8)
                        local.layer=12
                    elif (<dlocal.layer>==14)
                        local.layer=17
                    elif (<dlocal.layer>==18)
                        local.layer=19
                    elif (<dlocal.layer>==21)
                        local.layer=22
                    endif    
                    if (<findlayer(<dlocal.layer>)>)
                        tag0.temp = <fval <tag0.temp>+1.0>
                    endif
                    local.layer +=1
                endfor
                if (<tag0.temp> < 32.0)
                    tag0.temp = <fval (<tag0.temp> + <eval (<src.rescold>/2)*10)>)>
                elif (<tag0.temp> > 80.0)
                    tag0.temp = <fval (<tag0.temp> - <eval (<src.resfire>/2)*10)>)>
                endif
            endif
        endif

While this is a simple check to see what the current region temperature is and a check to see what the player is wearing it does create problems on a populated server with the @environchange trigger firing quite often (something I was never encountered on my private test server)

This script already runs a seperate timekeeping function under the f_onserver_timer function firing each minute. Would including a player check under this timer create a bunch of lag?
That's my question

And my noob question of the day because it's slipped my mind....

someone please remind me what value fval returns.Blush

[EDIT:]Wow looking at this on my server NONE of the weather effects even seem to work anymore which is a tad bit disappointing, has anyone using these forums run this script on the latest nightly builds?....
Thinking this could be a complete rebuild from scratch deal here


RE: Strain. - Shaklaban - 08-17-2012 01:44 PM

Im using similar thing on @Environchange with maximum of 80 players, never had lag issue. But if you want a faster method you can store players layer on=@itemequip and on=@itemunequip in a tag, then you don't need to use for loop in every @environchangemethod.

You can get detailed information about your functions with enabling script profiler from sphere.ini. then when you write p# on console sphere writes all data about triggers and functions inti profiler_dump.txt.


RE: Strain. - Mordaunt - 08-17-2012 01:52 PM

Still need to run the check for the temperature though....

is weather broken or something? Been going through checking bits and pieces seems as though sector.rain and sector.snow don't do anything anymore, though it does cause @environchange to fire


RE: Strain. - Shaklaban - 08-17-2012 02:00 PM

hmm i never tried with weather, mine is basic thing only controls for terrain and if there is a snow if (<isneartype t_snow>) and player has not weared clothes player get cold like:
Code:
[function getcold]
if (<body> = c_woman)
    dorand 2
        sound 817
        sound 818
    enddo
else
    dorand 2
        sound 1091
        sound 1092
    enddo    
endif    
sayua 075,6,6,0 *brr*



RE: Strain. - Extreme - 08-17-2012 02:32 PM

I'm thinking in about something like this:
One handler that have a timer, 60 seconds, and send serv.allclients a function to check if where the player is with the right environ. The first time, the script looks what should be the environ in the moment and set it and set one tag in the region/sector i don't know, preventing it to get evaluated again for some time.

Example:

Code:
[ITEMDEF BLA BLA]
ON=@TIMER
SERV.ALLCLIENTS TIMERF <R10>,F_CHECK_ENVIRON
TIMER 60
RETURN 1

[FUNCTION F_CHECK_ENVIRON]
IF <REGION.TAG.CHECKED> && <SECTOR.TAG.CHECKED> // Can we set tag in sector?
RETURN 1
ENDIF

// It's not checked for some time then check it and set
// Now preventing it be rechecked in few time

REGION.TAG.CHECKED 1
SECTOR.TAG.CHECKED 1 // ?? =D
TIMERF <R30,45>,REGION.TAG.CHECKED 0
TIMERF <R30,45>,SECTOR.TAG.CHECKED 0 // ??
Assuming that lots of sector/regions will not update everytime unless players are there.
If 2+ players in the same sector/region, it will be checked only one time.

This is the best idea that I had.
Using the 'serv.rtime' would be very very nice too.
Right now we need get USE for the GameMinuteLength in sphere.ini =D


RE: Strain. - RanXerox - 08-18-2012 01:00 AM

FVAL returns a floating point result (it puts a decimal point right before the last digit)


RE: Strain. - Extreme - 08-18-2012 01:03 AM

A small fix and suggestion to your Environ System Mord:

Quote:[FUNCTION f_lightning_strike]
if (<isgm>) || (<flags> & statf_indoors) || (<flags> & statf_dead) || (<flags> & statf_freeze)
return 1
else
if (<r<ddef.lightning_strike>> == 1)
effect 1,1,1,1,1
sysmessage @,,1 You have been struck by lightning!
hits-=<eval <hits>/2>
if <flags> & statf_onhorse
dismount
anim 21
endif
if <hits> == 0
serv.log EnvironSystem: <name> killed by a lightning strike
endif

endif
endif
Falling from horse and anim 21 is nice hahahaha looks real!


RE: Strain. - Mordaunt - 08-18-2012 03:19 AM

@Extreme, that's not a bad idea lol

Even without my system on the older versions of the server you could change the weather in a sector with

sector.snow
sector.rain

and I beleive

sector.weather <x value>

Checking on it last night before I went to bed, regardless what I entered sector.weather always returned a value of 255.
I am assuming it is currently broken


RE: Strain. - Mordaunt - 08-18-2012 05:32 AM

*facepalm*

helps if i have weather turned on in sphere.ini


RE: Strain. - Extreme - 08-18-2012 09:43 AM

NoWeather = 0 or 1?
1 disables weather, 0 enables...
I set 0 and don't tested with set 1.