SphereCommunity
FORITEMS doesn´t work right? - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: FORITEMS doesn´t work right? (/Thread-FORITEMS-doesn%C2%B4t-work-right)

Pages: 1 2


FORITEMS doesn´t work right? - admin phoenix - 07-06-2012 06:46 AM

For a resurrect script, I write a new script, so when you die you will be teleported to the next and nearest shrine.
this should work with foritems 6144
this doesn´t work as I wish because the players will not teleport to the nearest one.

I wrote a little script and checked it again. here is the script and the result... see the screenshot.
something is wrong there.

[FUNCTION test]
FORITEMS 6144
IF (<type> == t_gold)
local.x +=1
say <dlocal.x>
ENDIF
ENDFOR


RE: FORITEMS doesn´t work right? - Anarch Cassius - 07-06-2012 06:53 AM

Who ever said FORITEMS went in a certain order? Looks like it's scanning the potentially affected area left to right and top to bottom. Makes sense to me.

You need to manually find he closest shrine then teleport.

[FUNCTION nearest_shrine]
FORITEMS 6144
local.lowdistance=50000 //any shrine should be closer than this
IF (<type> == t_shrine)
IF (<src.distance <I>> < <local.lowdistance>) //if this is the closest one so far
local.lowdistance= <src.distance <I>>
obj = <I>
ENDIF
ENDIF
ENDFOR
SRC.P = <OBJ.P>
SRC.FIX
//and you should be at the closet shrine

That's totally untested but should get the idea


RE: FORITEMS doesn´t work right? - Extreme - 07-06-2012 07:25 AM

I think the best way, without use foritems is something like this:
Code:
[DEFNAMES SHRINES_P]
SHRINES 5
SHRINE_1 100,100
SHRINE_2 200,200
SHRINE_3 300,300
SHRINE_4 400,400
SHRINE_5 500,500

[FUNCTION GOTONEARESTSHRINE]
LOCAL.SHRINEDIST 10000
FOR 1 <DEF.SHRINES>
IF <SRC.DISTANCE <DEF.SHRINE_<dLOCAL._FOR>> < LOCAL.SHRINEDIST>
LOCAL.SHRINEDIST <SRC.DISTANCE <DEF.SHRINE_<dLOCAL._FOR>>
LOCAL.SHRINE <dLOCAL._FOR>
ENDIF
ENDFOR
SRC.GO <DEF.SHRINE_<dLOCAL.SHRINE>>
SRC.FIX
RETURN 1
I didn't test it, but I think its okay.


RE: FORITEMS doesn´t work right? - Anarch Cassius - 07-06-2012 07:29 AM

Extreme's wins. Smile

Much faster script if you have a reasonable number of shrines to define. Faster even if you don't really, but the defs might get tedious


RE: FORITEMS doesn´t work right? - Extreme - 07-06-2012 07:34 AM

(07-06-2012 07:29 AM)Anarch Cassius Wrote:  Extreme's wins. Smile

Much faster script if you have a reasonable number of shrines to define. Faster even if you don't really, but the defs might get tedious
Hehe, or can just use VARs Smile
(07-06-2012 06:46 AM)admin phoenix Wrote:  For a resurrect script, I write a new script, so when you die you will be teleported to the next and nearest shrine.
this should work with foritems 6144
this doesn´t work as I wish because the players will not teleport to the nearest one.

I wrote a little script and checked it again. here is the script and the result... see the screenshot.
something is wrong there.

[FUNCTION test]
FORITEMS 6144
IF (<type> == t_gold)
local.x +=1
say <dlocal.x>
ENDIF
ENDFOR
@OFF, this shard, Athoris is yours?
If yes, can I try play there?
I don't know German language, but I just want to know the server.
If you can make me an account I would be happy.
PS: this server looks awesome, I NEVER seen something like it, congrats.


RE: FORITEMS doesn´t work right? - darksun84 - 07-06-2012 10:18 AM

Offtopic :
I would like to try it too ! But I have the same german language problem Big Grin


RE: FORITEMS doesn´t work right? - Skul - 07-06-2012 04:40 PM

just off how I think this should work:
Code:
[function teletonearestshrine]
foritems 9999
if (<type>==t_shrine)
  local.s += 1
  local.shrine<dlocal.s>.p.x=<p.x>
  local.shrine<dlocal.s>.p.y=<p.y>
endif
endfor
for x 1 <dlocal.x>
if (strmatch(<local.p.x>,0)) && (strmatch(<local.p.y>,0))
  local.p.x=<local.shrine<dlocal.x>.p.x>
  local.p.y=<local.shrine<dlocal.x>.p.y>
endif
if (<local.shrine<dlocal.x>.p.x> < <local.p.x>) || (<local.shrine<dlocal.x>.p.y> < <local.p.y>)
  local.p.x=<local.shrine<dlocal.x>.p.x>
  local.p.y=<local.shrine<dlocal.x>.p.y>
endif
endfor
if (<local.p.x>) && (<local.p.y>)
go <local.p.x>,<local.p.y>,<serv.map(<local.p.x>,<local.p.y>,0,<map>).terrain.z>,<map>
endif
that's the function to seek for t_shrine across the whole map, teleports the player to the closest t_shrine, this next part is a @trigger to be placed on the player character
Code:
[event e_seek_shrine]
on=@death
teletonearestshrine



RE: FORITEMS doesn´t work right? - admin phoenix - 07-06-2012 09:14 PM

Thanks for helping me guys Smile
At first I will try Extreme code because it looks very nice but I will control the shrine via sql. Putting a new shrine in the world he coordinations will be writen in the sql.

@all
yes, it´s my shard and it is in german so it will be very hard for you to play ingame because all systems are in german too Smile
at the moment we have an on open beta.
if you want an account you have to register because we control all accounts and chars via sql.
for example you have to create a character via homepage ...
In 3 weeks we will finish the open-beta and if we don´t get enough german player maybe I will think for an international shard Smile

but then I also need international gamemasters and developers *g*


RE: FORITEMS doesn´t work right? - Shaklaban - 07-06-2012 09:38 PM

you can read shrines from sql then. i think foritems is not a good idea because its creating giant loops, if a players can use it frequently, even one player can frozen the whole shard with uo loop.


RE: FORITEMS doesn´t work right? - Extreme - 07-06-2012 10:24 PM

(07-06-2012 09:14 PM)admin phoenix Wrote:  Thanks for helping me guys Smile
At first I will try Extreme code because it looks very nice but I will control the shrine via sql. Putting a new shrine in the world he coordinations will be writen in the sql.

@all
yes, it´s my shard and it is in german so it will be very hard for you to play ingame because all systems are in german too Smile
at the moment we have an on open beta.
if you want an account you have to register because we control all accounts and chars via sql.
for example you have to create a character via homepage ...
In 3 weeks we will finish the open-beta and if we don´t get enough german player maybe I will think for an international shard Smile

but then I also need international gamemasters and developers *g*
I created the account, I think you must accept it, don't worry when you see what I wrote on the rp boxes Smile
Hope you will let us to try it =D