SphereCommunity

Full Version: Sailing around the world
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I would like to hear people's ideas on how to safely (and unnoticably) send a ship (with all its contents and crew) from one location to another... For example, before they reach the west edge of the map while sailing westward, transport them to the east side of the map (still sailing westward.)
my idea is using forchars and foritems and change the p of all items in ships region like:

PHP Code:
[function sendship//usage: sendship x,y,z
ref1=<uid>
foritems 8
    
if (<region.uid> = <ref1>) && (<ref1> != <uid>)
         
p=<eval <argv[0]> +(<p.x>-<ref1.p.x>)>,<eval <argv[1] + (<p.y>-<ref1.p.y>)>,<eval <argv[2]> + (<p.z>-<ref1.p.z>)>
         
update
    
endif
endfor

forchars 8
    
...
endfor
p=<args>
update 

maybe code was wrong about coordinates but i think it shows my idea.
Scrap all that and use SHIPGATE <location>
So the tricky part is not moving the ship, its contents, and its crew... the tricky part is detecting when the ship reaches the edge.

I tried to create a long narrow region on the west edge of the map, like so:

Code:
[AREADEF a_world_edge_west]
NAME=Western Ocean
GROUP=Ocean
P=5,5,0,0
RECT=0,0,10,4096,0
EVENTS=r_western_ocean_teleport

But it turns out that REGION triggers do not fire when a character is inside another region (the ship is a multi and therefore a region.)

I tried to override t_ship with some region triggers, but they do not fire either.

Unrelated, but still a bug... when you sail sideways, and hit the world edge with a boat, and then tell it to turn right or left you get some crazy errors... and if you logout or are at the edge when the world saves, parts of the boat are destroyed for being in invalid places.
What you may need to do is start a timerf when the ship starts moving that checks it's location using a function like this...

Code:
[FUNCTION f_ship_watch]

IF (<link.p.x> > 5100)
link.wrapx 20
ENDIF
IF (<link.p.x> < 20)
link.wrapx 5100
ENDIF
IF (<link.p.y> > 4070)
link.wrapy 8
ENDIF
IF (<link.p.y> < 8)
link.wrapy 4070
ENDIF
timerf 2,f_ship_watch

[function wrapx]
shipgate <ARGN>,<p.y>,<mapplane>,<z>

[function wrapy]
shipgate <p.x>,<ARGN>,<mapplane>,<z>

This is a modified extract of an old ship sript I have that would do what you are looking for. I'm sure there are some modifications that you will need to do, but It should help you get going Smile
(11-27-2012 11:38 AM)Ben Wrote: [ -> ]What you may need to do is start a timerf when the ship starts moving

What trigger is called when the ship starts/continues/stops moving?
run it on a voice command in the region....
Reference URL's