OK Maud maybe you can see why it's happening.
Here is the main
while loop from boat.src in POL 95 Distro:
Code:
while(boat)
if(GetObjProperty(boat.hold, "#speed"))
state := STATE_MOVING;
ms_delay_between_moves := GetObjProperty(boat.hold, "#speed");
relative_direction := GetObjProperty(boat.hold, "#relativedir");
eraseobjproperty(boat.hold, "#speed");
eraseobjproperty(boat.hold, "#relativedir");
endif
decay := getobjproperty(boat.tillerman,"decay");
if((decay) and(!getobjproperty(tillerman,"nodecay")))
if(ReadGameClock() > decay)
PrintTextAbove(tillerman, "Arrrrrgh! She's going down, Captain! Abandon ship!");
sleep(4);
foreach item in EnumerateItemsInContainer( boat.hold )
DestroyItem(item);
endforeach
foreach mob in(boat.items)
DestroyItem(mob);
endforeach
foreach mob in(boat.mobiles)
MoveCharacterToLocation(mob, 1487, 1869, 0, MOVECHAR_FORCELOCATION );
SendSysMessage(mob, "Your ship, badly in need of maintenance, sinks beneath the waves!");
SendSysMessage(mob, "You awake on a distant shore...");
endforeach
if(boat.has_offline_mobiles)
foreach mob in(boat.offline_mobiles)
MoveCharacterToLocation(mob, 1487, 1869, 0, MOVECHAR_FORCELOCATION );
endforeach
endif
DestroyMulti(boat);
endif
endif
case(state)
STATE_MOVING: if(ReadGameClock() > nextsound)
PlayBoatSounds();
nextsound := ReadGameClock()+5;
endif
x := boat.x;
y := boat.y;
MoveBoatRelative(boat, relative_direction);
if(boat.x == 6 or boat.x == 5097 or boat.y == 6 or boat.y == 4089)
WorldWrap();
endif
if((x == boat.x) &&(y == boat.y))
ms_delay_between_moves := 1000;
state := STATE_DRIFTING;
PrintTextAbove(tillerman, "Aaargh! We've run ashore!");
//SmackEveryone();
endif
sleepms(ms_delay_between_moves);
if(ReadGameClock() > nextencounter)
DoEncounter();
nextencounter := ReadGameClock()+120;
endif
while(events_waiting())
process_event(wait_for_event(0));
endwhile
STATE_DRIFTING: if(ReadGameClock() > nextsound)
PlayBoatSounds();
nextsound := ReadGameClock()+5;
endif
if(driftcounter > 15)
MoveBoatRelative(boat, RandomInt(8));
driftcounter := 1;
else
driftcounter := driftcounter + 1;
endif
sleepms(1000);
while(events_waiting())
process_event(wait_for_event(0));
endwhile
STATE_STATIONARY: var ev := wait_for_event(120);
if(ev)
process_event(ev);
endif
/*NOTE NEW BOAT STATE*/
STATE_FOLLOWING_COURSE:
x := boat.x;
y := boat.y;
BoatFollowCourse(boat);
sleepms(ms_delay_between_moves);
while(events_waiting())
process_event(wait_for_event(0));
endwhile
/*END NEW BOAT STATE*/
endcase
if(ReadGameClock() > nextencounter)
checkres();
nextencounter := ReadGameClock()+120;
endif
endwhile
endprogram
Now here is Worldwrap function from same:
Code:
function WorldWrap()
var newx := boat.x;
var newy := boat.y;
if(boat.y <= 6)
newy := 4088;
elseif(boat.y >= 4089)
newy := 6;
endif
if(boat.x <= 6)
newx := 5096;
elseif(boat.x >= 5097)
newx := 6;
endif
var lockid := GetObjProperty(boat.hold, "lockid");
var owner := GetObjProperty(boat.hold, "owner");
var shiptype := boat.objtype;
var shipfacing, created;
case(tillerman.graphic)
0x3e4e: shipfacing := CRMULTI_FACING_NORTH;
0x3e55: shipfacing := CRMULTI_FACING_EAST;
0x3e4b: shipfacing := CRMULTI_FACING_SOUTH;
0x3e50: shipfacing := CRMULTI_FACING_WEST;
default: shipfacing := "Error!";
endcase
if(shipfacing == "Error!")
syslog( "[ERROR] [boat.src] Couldn't tell which way the ship was facing for the worldwrap!");
endif
created := CreateMultiAtLocation( newx, newy, -5, shiptype, shipfacing);
if(!created)
syslog( "[ERROR] [boat.src] New ship couldn't be created for worldwrap!");
return;
endif
var oldshiphold := boat.hold;
var newshiphold := created.hold;
foreach item in EnumerateItemsInContainer( oldshiphold )
if(item.container == oldshiphold)
MoveItemToContainer(item, newshiphold);
endif
endforeach
foreach item in EnumerateItemsInContainer( oldshiphold )
MoveItemToContainer(item, newshiphold);
endforeach
foreach mob in(boat.mobiles)
MoveCharacterToLocation(mob,(mob.x-boat.x)+created.x,(mob.y-boat.y)+created.y, -2, MOVECHAR_FORCELOCATION );
endforeach
if(boat.has_offline_mobiles)
foreach mob in(boat.offline_mobiles)
MoveCharacterToLocation(mob,(mob.x-boat.x)+created.x,(mob.y-boat.y)+created.y, -2, MOVECHAR_FORCELOCATION );
endforeach
endif
foreach mob in(boat.items)
MoveitemToLocation(mob,(mob.x-boat.x)+created.x,(mob.y-boat.y)+created.y, -2,0 );
endforeach
var newtillerman := created.tillerman;
newtillerman.name := tillerman.name;
SetObjProperty( created.starboardplank, "lockid", lockid);
SetObjProperty( created.portplank, "lockid", lockid);
SetObjProperty( created.ship.starboardplank, "owner", owner );
SetObjProperty( created.ship.portplank, "owner", owner );
SetObjProperty( created.ship.starboardplank, "tillermanid", newtillerman.serial );
SetObjProperty( created.ship.portplank, "tillermanid", newtillerman.serial );
SetObjProperty( created.hold, "lockid", lockid);
SetObjProperty( created.hold, "owner", owner);
SetObjProperty( created.tillerman, "owner", owner);
SetObjProperty( created.tillerman, "shipserial", created.serial);
SetObjProperty( created.tillerman, "lockid", lockid);
SetObjProperty( created.tillerman, "decay", decay);
if(boat.starboardplank.locked == 1)
created.starboardplank.locked := 1;
endif
if(boat.portplank.locked == 1)
created.portplank.locked := 1;
endif
if(boat.hold.locked == 1)
created.hold.locked := 1;
endif
SetObjProperty( created.hold, "#relativedir", relative_direction);
SetObjProperty( created.hold, "#speed", ms_delay_between_moves);
created.tillerman.usescript := ":boat:tillerman";
if(!DestroyMulti(boat))
DestroyItem(boat.tillerman);
syslog( "[ERROR] [boat.src] Old ship at " +(boat.x-1) +","+ boat.y +","+ boat.z + " couldn't be destroyed during worldwrap!");
endif
endfunction
I placed a Broadcast ("State = " + state) command at the end of the function and the state is reported as being 1 (STATE_MOVING) but for some reason, upon leaving Worldwrap, the script gets locked into the STATE_STATIONARY switch for the
case statement in the main loop. I know this is where it gets caught because I have changed the 120 in that statement to 15 and it only pauses for 15 seconds.