SphereCommunity

Full Version: some questions (foritems, block check)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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!
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.
<canmove W> will check if you can move to the West.
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.
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
Reference URL's