The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Distance @timer
Author Message
Rizz
Master
**

Posts: 396
Likes Given: 21
Likes Received: 14 in 9 posts
Joined: Oct 2012
Reputation: 0



Post: #1
Distance @timer
PHP Code:
ON=@TIMER



IF (<link.action>==Skill_Magery)
    
TIMERD=10
    LOCAL
.distance= <ref1.distance <ref2> >
    
serv.b distance<dLOCAL.distance>
    return 
1
ENDIF
return 


I can't say it's not working but... it gives me 1520+<distance>
Did i wrong something lol?

I tried this way:

PHP Code:
[FUNCTION f_magery_target_distance]
ref1=<argn1>
serv.b name <name> <ref1.name>
serv.b distance <ref1.distance>

ON=@timer
link
.f_magery_target_distance <ref1

The function works in game but doesn't work if i call from the @timer trigger
(This post was last modified: 04-26-2015 07:12 AM by Rizz.)
04-26-2015 06:29 AM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #2
RE: Distance @timer
REFx is not a global reference to an object, so you must define it again when using on @Timer

Code:
ON=@Timer
LINK.f_magery_target_distance <REF1>
this probably can get the LINK reference without problems but not the REF1 because there's no REF1 set (so it will be 0)

PS: you can't use triggers directly inside [functions] templates Tongue
04-26-2015 07:49 AM
Find all posts by this user Like Post Quote this message in a reply
Rizz
Master
**

Posts: 396
Likes Given: 21
Likes Received: 14 in 9 posts
Joined: Oct 2012
Reputation: 0



Post: #3
RE: Distance @timer
Refx are set under @timer, i just didn't copy here, i know they are not global lol

Infact the funcion works and gives me the two names but cannot resolve the coord.

The originale one is:

PHP Code:
on=@timer
ref1
=<tag0.target>
...
..
.
link.f_magery_target_distance <ref1
...
..


And as i told you, the serv.b names works correctly but not the distance.
(This post was last modified: 04-26-2015 08:15 AM by Rizz.)
04-26-2015 08:09 AM
Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #4
RE: Distance @timer
<argn> means ARG Numeric while <args> means ARG String (fast explanation), since UIDs are hexadecimal values and also have strings the argn value will not be read probably, use <args> instead, <argv0> or <argv[0]>.
04-27-2015 02:56 AM
Find all posts by this user Like Post Quote this message in a reply
Rizz
Master
**

Posts: 396
Likes Given: 21
Likes Received: 14 in 9 posts
Joined: Oct 2012
Reputation: 0



Post: #5
RE: Distance @timer
Still the same problem, i cannot get the distance:

Can't resolve <ref1.distance>

It works only if i type in game .f_magery_target_distance <uid>
(This post was last modified: 04-27-2015 03:45 AM by Rizz.)
04-27-2015 03:43 AM
Find all posts by this user Like Post Quote this message in a reply
Rizz
Master
**

Posts: 396
Likes Given: 21
Likes Received: 14 in 9 posts
Joined: Oct 2012
Reputation: 0



Post: #6
RE: Distance @timer
I decided to fix in this way:

Code:
[FUNCTION f_magery_target_distance]
ref1=<args>
// serv.b names <name> <ref1.name>
// serv.b distance <ref1.distance>
LOCAL.deltax=<eval <ref1.p.x>-<p.x>>
LOCAL.deltay=<eval <ref1.p.y>-<p.y>>
serv.b components <dLOCAL.deltax> <dLOCAL.deltay>
LOCAL.sum=(<LOCAL.deltax>*<LOCAL.deltax>) + (<LOCAL.deltay>*<LOCAL.deltay>)
LOCAL.hdistance=<eval SQRT(<LOCAL.sum>)>
serv.b handmade distance <dLOCAL.hdistance>


Normal distance and distance found in that way is almost the same but sometimes they have a difference of 1 tile.
Is a truncation problem?
How sphere calculates it?

Is just a difference between p.x and p.y and you take the biggest one?
(This post was last modified: 04-27-2015 06:04 AM by Rizz.)
04-27-2015 05:22 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 2 Guest(s)