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-nmm6 (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-nmm6 (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-nmm6 (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
some questions (foritems, block check)
Author Message
Art
Journeyman
*

Posts: 118
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Apr 2012
Reputation: 0



Post: #1
some questions (foritems, block check)
Hello.

Interesting to know, is there a way to use 'foritems' without actual object? For example, foritems function called by character or item, and search of items going from that object which called function. But is it possile to call function without object? I know coordinates where to start search, and seems i need to create item and call function, but can i do that foritems without creating item? Just somehow to specify coordinates where to start search, or maybe there is other function for such way?

And another question - is there function to check block point on map? For example, table, wall, tree - they are blocking, but floor not blocking, so instead of checking type of each static item on point, i want to check just is that point blocked for movement or not.
09-07-2015 09:24 PM
Find all posts by this user Like Post Quote this message in a reply
escribano
Journeyman
*

Posts: 170
Likes Given: 16
Likes Received: 32 in 23 posts
Joined: Nov 2012
Reputation: 2

Dragon Shard

Post: #2
RE: some questions (foritems, block check)
Art, i don't know if i really understood your question.. but, maybe this could be helpfull:

Question 1:
No, at least what i know that the only way to do that is creating an item and executing the FORanything in this item, the script for that is this:
Code:
[FUNCTION posempty]
serv.newitem i_gold
serv.new.p <args>
serv.new.attr 094
serv.new.update
return <qval <UID.<serv.new.uid>.f_posempty_check <args>> == 1?0:1>

[FUNCTION f_posempty_check]
local.tem 0
foritems 0
    if (<eval strlen(<baseid>)> > 1) && (<baseid> != i_gold)
        local.tem 1
    endif
endfor
remove
return <eval <local.tem>>
Note: this function should be called this way: if (<posempty 1000,1000,15,0>)

Question 2:
Yes, there is a way to check if the player can "see" the map point... this function also checks if the player is in distance z point, if there is walls blocking the line of sight...
Code:
If (<SRC.CANSEELOS 1000,1000,15,0>)

I don't know if this help.. but i've done an function to also check (using coordinates) if there is an item "near" of the point..
Code:
[FUNCTION isnearof]
serv.newitem i_gold
serv.new.p <argv[0]>,<argv[1]>,<argv[2]>,<argv[3]>
serv.new.attr 094
serv.new.update
return <UID.<serv.new.uid>.f_isnearof_check <argv[4]>,<argv[5]>>

[FUNCTION f_isnearof_check]
local.item <argv[0]>
local.closer 0

foritems <eval <argv[1]>>
    if (<baseid> == <local.item>)
        local.closer 1
    endif
endfor
remove
return <eval <local.closer>>
Note: this function should be called this way: if (<isnearof <src.p.x>,<src.p.y>,<src.p.z>,<src.p.m>,i_sword_viking,3>)
Where i_sword_viking you change to the item id you are looking for and the last parameter (3) is the distance you want to see if the item is near.

Hope it help!

UltimaPHP - OpenSource Ultima Online Server v0.1-pre-alpha under development, we need help!
(This post was last modified: 09-08-2015 03:21 AM by escribano.)
09-08-2015 03:17 AM
Find all posts by this user Like Post Quote this message in a reply
Art
Journeyman
*

Posts: 118
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Apr 2012
Reputation: 0



Post: #3
RE: some questions (foritems, block check)
Thanks for the answers. But i think question 2 is still actual. Canseelos could be useful tool but it is not that what i want. If i check for example point on wall or on tree, it still showing 1, because point not behind wall or tree, but right on wall and on tree, and that point is 'visible' for player. I want to check is there any static item which blocking movement. For example, tree and wall are blocking, can't walk there. Need to check it somehow.
09-09-2015 12:10 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: some questions (foritems, block check)
<canmove W> will check if you can move to the West.
09-09-2015 02:35 AM
Find all posts by this user Like Post Quote this message in a reply
Art
Journeyman
*

Posts: 118
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Apr 2012
Reputation: 0



Post: #5
RE: some questions (foritems, block check)
But what if i got coordinates of point where is static object like tree or wall? And actually character can stay far from that point. Player can not go to that point, but still need to check is there something blocking or not.
09-10-2015 03:28 PM
Find all posts by this user Like Post Quote this message in a reply
azmanomer
Journeyman
*

Posts: 139
Likes Given: 4
Likes Received: 18 in 16 posts
Joined: Nov 2013
Reputation: 1



Post: #6
RE: some questions (foritems, block check)
i think you can do something like this i assume that you want to check 9 step west. Also <uid> is player.

[function f_checkmove]
serv.newnpc c_llama
new.flags 02000
new.p <p>
ref1 <new>
local.check 0
local.count 0
for 0 <eval <p.x>-(<p.x>-9)>
if !<local.count>
if !<ref1.canmove W>
local.check <dlocal._for>
local.count ++
else
ref1.move -1
endif
endif
endfor
if <local.check>
serv.log player cant move at <eval <p.x>-<local.check>>,<p.y> point.
endif
ref1.remove
(This post was last modified: 09-10-2015 06:48 PM by azmanomer.)
09-10-2015 05:53 PM
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)