It is currently Fri Dec 05, 2008 2:07 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Boats and world wrap
PostPosted: Tue Sep 19, 2006 3:14 pm 
Offline
Certified POL Expert
User avatar

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1223
Location: Southern Central USA
I have been having "fun" rescripting the boat.src and have encountered a strange thing. After a world wrap there is about a 2 minute delay before the boat continues on it's course. Now I have looked and just can't find out where this delay is introduced. There are no items in the hold and my Admin character is the only mobile on the boat. So I'm pretty sure the delay isn't from object moves.

This delay exists in the "virgin" POL 95 boat.src script as well as my modified one.

ANy help would be appreciated.

Thanks.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 19, 2006 3:48 pm 
Offline
Certified POL Expert
User avatar

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1223
Location: Southern Central USA
OK did a test and it seems that a speech event of any kind, whether recognized by the tillerman or not, stops the delay.

[Edit] Found the problem. It's in the stationary state handler. There's a ev := wait_for_event(120) line.

Now maybe someone could tell me if there would be a performance drop if I lowered that to maybe 30 instead of 120.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 19, 2006 4:52 pm 
Offline
POL Developer
User avatar

Joined: Sun Feb 12, 2006 9:50 pm
Posts: 843
Location: Bowling Green, KY
if it's in stationary from wrap, why not have the script set it back to moving state as appropriate, after wrap? :)

_________________
POL Developer - The Penguin Scripter


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 19, 2006 9:07 pm 
Offline
Certified POL Expert
User avatar

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1223
Location: Southern Central USA
That's what I want it to do but either I'm dense or I just keep missing it.

The odd thing is that it does go back to moving on it's own but apparently, for some reason, it starts in stationary after a wrap. I think it has to do with the fact that the boat is being recreated and we start with a new boat. Ther variable "state" is still set to STATE_MOVING after the new boat is created but some how it drops into stationary and times out then starts back moving again.

I'm going to go back and look at it again.

BTW Maud, I am sailing the stars!!!

*grins*

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 19, 2006 9:22 pm 
Offline
Certified POL Expert
User avatar

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1223
Location: Southern Central USA
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.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 3:59 am 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 430
Location: San Diego, California
Not a core bug.. I wrote one tonight in the 097 distro and there were no delay issues at all when wrapped (take a look at it, pretty different from whats been done)

http://svn.sourceforge.net/viewvc/pol-d ... iew=markup

_________________
-Austin


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 10:23 am 
Offline
Certified POL Expert
User avatar

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1223
Location: Southern Central USA
OK Austin, I'll take a gander.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl