Go Back   RunUO - Ultima Online Emulation > RunUO > Script Support

Script Support Get support for modifying RunUO Scripts, or writing your own!

Reply
 
Thread Tools Display Modes
Old 09-03-2008, 03:23 PM   #1 (permalink)
Forum Novice
 
Join Date: Feb 2004
Posts: 108
Default Teleport player when fall

I want that player that falls in water are teleport to the nearest coast..I think it's a bit hard to do but i don't have any idea where start...
Zaihur is offline   Reply With Quote
Old 09-03-2008, 03:51 PM   #2 (permalink)
Forum Novice
 
Join Date: Apr 2006
Posts: 188
Default

I'm not sure how a player would fall in water, however you can check Strandedness.cs to see how it handles transporting a player to the neares shore when they log out in water.
__________________
http://www.crypticrealms.com
homergz is offline   Reply With Quote
Old 09-04-2008, 05:08 AM   #3 (permalink)
Forum Novice
 
Join Date: Feb 2004
Posts: 108
Default

Because i want create a boat wars so if an enemy boat sinks player dead and they are teleport on the nearest coast...
Zaihur is offline   Reply With Quote
Old 09-04-2008, 11:35 AM   #4 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Quote:
Originally Posted by Zaihur View Post
Because i want create a boat wars so if an enemy boat sinks player dead and they are teleport on the nearest coast...


Here's what I would suggest... I would create a new Item called CrashSitePlaceHolder and put them around the world in some valid crash site spots. Then, instead of using every single available coastal tile as a valid site for shipwrecks... once you have those spawned, whenever a ship sinks, you can run code that would check for the nearest shipwreck site (just example code to give you ideas... ):

notice below that you'll need to pass shipDestructionLocation (Point3D) as an arugment to this method...

Code:
public void CrashSiteLocation( Point3D shipDestructionLocation)
{
  local Point3D nearestCrashSite = null; // local variable 
  local int DistanceToSite = null;

  foreach ( Item CrashSitePlaceHolder in this.GetItemsInRange( 4000 ) )
  {

	if (nearestCrashSite == null)
             {
              if (CrashSitePlaceHolder != nulll) // always automatically assign the first site in range by default.
                  nearestCrashSite = CrashSitePlaceHolder.GetWorldLocation();
                  DistanceToSite = Math.Sqrt( Math.Pow( nearestCrashSite.Y - shipDestructionLocation.Y , 2 ) + Math.Pow( nearestCrashSite.X - shipDestructionLocation.X , 2 )); // distance from the boat sinking location to the fist crash site we assign.
              else
                  return // no valid crash sites -- no CrashSitePlaceHolder is spawned
              }

       if ( Math.Sqrt( Math.Pow( CrashSitePlaceHolder.GetWorldLocation().Y - shipDestructionLocation.Y , 2 ) + Math.Pow( CrashSitePlaceHolder.GetWorldLocation().X - shipDestructionLocation.X , 2 )) <= DistanceToSite) // here we compare all of the distances of the crash sites and find the nearest one, continually assigning nearer sites until we assign the closest site
       {
         nearestCrashSite = CrashSitePlaceHolder.GetWorldLocation();
        }
       else
       {} // we keep the previously assigned location if it is closer to the place where the ship sank

  }
  return nearestCrashSite;
}
Once you have the nearest site, kill all of the players on your recently-crashed boat and assign their locations to that location... ie...
Code:
m.Kill();
m.X = nearestCrashSite.X;
m.Y = nearestCrashSite.Y;
m.Z = nearestCrashSite.Z;
The reason I suggest this method is that I believe it would save you on cpu time -- instead of having to range check for every shore tile (thousands? of calculations), you could run only 20 comparison calculations, or however many crash sites you have.

Oh... and every time a player gets "on" a boat, you could append or edit the roster of players currently on the boat. When the boat "sinks", it would be easy to use that list or roster to find the eligible players to kill and transport.

/ideas

Last edited by Tassyon T; 09-04-2008 at 11:45 AM.
Tassyon T is offline   Reply With Quote
Old 09-06-2008, 02:08 PM   #5 (permalink)
Forum Novice
 
Join Date: Feb 2004
Posts: 108
Default

Uhm..It's a good method but how i can check and kill player if they are on water? I always have to check every water tile?
Zaihur is offline   Reply With Quote
Old 09-06-2008, 07:24 PM   #6 (permalink)
Forum Novice
 
Tassyon T's Avatar
 
Join Date: Sep 2007
Posts: 367
Default

Quote:
Originally Posted by Zaihur View Post
Uhm..It's a good method but how i can check and kill player if they are on water? I always have to check every water tile?
I would go look at the "plank" of a boat/ship in the scripts.

People use the plank to "board" a ship. So...

You could create an OnMoveOver() or OnDoubleClick() override for the plank that creates a serialized list of players that are currently "aboard" the ship -- adds new players to the list when they enter the ship, and subtracts them from the list when they leave. Then... whenever the ship "sinks" you could write something like...
Code:
foreach (Mobile m in ShipRoster[])
{
m.kill
}

Last edited by Tassyon T; 09-06-2008 at 07:28 PM.
Tassyon T is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5