Hi all and happy new year !!! <img src="style_emoticons/<#EMO_DIR#>/par-ty.gif" style="vertical-align:middle" emoid="
" border="0" alt="par-ty.gif" />
Congratulations to all for the new stuffs in the build !
To CCC: i had a look to your new direct sail mod and i love it ! It makes the game more realistic !
I think it could be improved by using the real map coords and islands positions to test if you have reach the range of an other island on the world map!
So i have test a new code for your GetNeighbourIsland and Sea_ReloadDirect methods and it works for me !
First step : when DirectsailCheck() is called, convert your seaview position in real worldmap coords (as in stock game).
second step : check if you are in the range of another island on the worldmap (by using the radius of the islands)
third step : if you are in the range of another island, load it and convert your new worldmap position in seaview coords by using the new island as a reference (like in stock game when you enter in an island area)
Like that you will appear at the new island at the real position !!!
Could please have a look in this code and give your opinion about it and eventually test if it could work for your mod !
string GetNeighbourIsland(string Island, string dir)
// returns which neighbour island lies in the DIRection you leave an Island
// could also be done in Islands_init.c, but this way I can leave that file undisturbed
{
if(Island=="FalaiseDeFleur") Island = "FaleDeFler";
if(Island=="SaintMartin") Island = "Sent";
if(Island=="Turks") Island = "Terks";
ref Pchar = GetMaincharacter();
float psX = MakeFloat(pchar.Ship.Pos.x);
float psZ = MakeFloat(pchar.Ship.Pos.z);
float ix = MakeFloat(worldMap.islands.(Island).position.rx);
float iz = MakeFloat(worldMap.islands.(Island).position.rz);
//REAL CONVERTION OF YOUR SEAVIEW COORDS IN WORLD MAP COORDS
worldMap.playerShipX = (psX/WDM_MAP_TO_SEA_SCALE) + ix;
worldMap.playerShipZ = (psZ/WDM_MAP_TO_SEA_SCALE) + iz;
// AFTER THAT YOU CHECK IF YOU ARE IN THE RANGE OF ANOTHER ISLAND ON THE WORLDMAP
if(worldMap.playerShipX >= stf(worldMap.islands.FaleDeFler.position.x) - stf(worldMap.islands.FaleDeFler.radius) && worldMap.playerShipX <= stf(worldMap.islands.FaleDeFler.position.x) + stf(worldMap.islands.FaleDeFler.radius) && worldMap.playerShipZ >= stf(worldMap.islands.FaleDeFler.position.z) - stf(worldMap.islands.FaleDeFler.radius) && worldMap.playerShipZ <= stf(worldMap.islands.FaleDeFler.position.z) + stf(worldMap.islands.FaleDeFler.radius) && Island != "FaleDeFler")
{ return "FaleDeFler"; }
if(worldMap.playerShipX >= stf(worldMap.islands.Redmond.position.x) - stf(worldMap.islands.Redmond.radius) && worldMap.playerShipX <= stf(worldMap.islands.Redmond.position.x) + stf(worldMap.islands.Redmond.radius) && worldMap.playerShipZ >= stf(worldMap.islands.Redmond.position.z) - stf(worldMap.islands.Redmond.radius) && worldMap.playerShipZ <= stf(worldMap.islands.Redmond.position.z) + stf(worldMap.islands.Redmond.radius) && Island != "Redmond")
{ return "Redmond"; }
if(worldMap.playerShipX >= stf(worldMap.islands.Oxbay.position.x) - stf(worldMap.islands.Oxbay.radius) && worldMap.playerShipX <= stf(worldMap.islands.Oxbay.position.x) + stf(worldMap.islands.Oxbay.radius) && worldMap.playerShipZ >= stf(worldMap.islands.Oxbay.position.z) - stf(worldMap.islands.Oxbay.radius) && worldMap.playerShipZ <= stf(worldMap.islands.Oxbay.position.z) + stf(worldMap.islands.Oxbay.radius) && Island != "Oxbay")
{ return "Oxbay"; }
if(worldMap.playerShipX >= stf(worldMap.islands.Douwesen.position.x) - stf(worldMap.islands.Douwesen.radius) && worldMap.playerShipX <= stf(worldMap.islands.Douwesen.position.x) + stf(worldMap.islands.Douwesen.radius) && worldMap.playerShipZ >= stf(worldMap.islands.Douwesen.position.z) - stf(worldMap.islands.Douwesen.radius) && worldMap.playerShipZ <= stf(worldMap.islands.Douwesen.position.z) + stf(worldMap.islands.Douwesen.radius) && Island != "Douwesen")
{ return "Douwesen"; }
if(worldMap.playerShipX >= stf(worldMap.islands.Conceicao.position.x) - stf(worldMap.islands.Conceicao.radius) && worldMap.playerShipX <= stf(worldMap.islands.Conceicao.position.x) + stf(worldMap.islands.Conceicao.radius) && worldMap.playerShipZ >= stf(worldMap.islands.Conceicao.position.z) - stf(worldMap.islands.Conceicao.radius) && worldMap.playerShipZ <= stf(worldMap.islands.Conceicao.position.z) + stf(worldMap.islands.Conceicao.radius) && Island != "Conceicao")
{ return "Conceicao"; }
if(worldMap.playerShipX >= stf(worldMap.islands.IslaMuelle.position.x) - stf(worldMap.islands.IslaMuelle.radius) && worldMap.playerShipX <= stf(worldMap.islands.IslaMuelle.position.x) + stf(worldMap.islands.IslaMuelle.radius) && worldMap.playerShipZ >= stf(worldMap.islands.IslaMuelle.position.z) - stf(worldMap.islands.IslaMuelle.radius) && worldMap.playerShipZ <= stf(worldMap.islands.IslaMuelle.position.z) + stf(worldMap.islands.IslaMuelle.radius) && Island != "IslaMuelle")
{ return "IslaMuelle"; }
if(worldMap.playerShipX >= stf(worldMap.islands.QuebradasCostillas.position.x) - stf(worldMap.islands.QuebradasCostillas.radius) && worldMap.playerShipX <= stf(worldMap.islands.QuebradasCostillas.position.x) + stf(worldMap.islands.QuebradasCostillas.radius) && worldMap.playerShipZ >= stf(worldMap.islands.QuebradasCostillas.position.z) - stf(worldMap.islands.QuebradasCostillas.radius) && worldMap.playerShipZ <= stf(worldMap.islands.QuebradasCostillas.position.z) + stf(worldMap.islands.QuebradasCostillas.radius) && Island != "QuebradasCostillas")
{ return "QuebradasCostillas"; }
if(worldMap.playerShipX >= stf(worldMap.islands.KhaelRoa.position.x) - stf(worldMap.islands.KhaelRoa.radius) && worldMap.playerShipX <= stf(worldMap.islands.KhaelRoa.position.x) + stf(worldMap.islands.KhaelRoa.radius) && worldMap.playerShipZ >= stf(worldMap.islands.KhaelRoa.position.z) - stf(worldMap.islands.KhaelRoa.radius) && worldMap.playerShipZ <= stf(worldMap.islands.KhaelRoa.position.z) + stf(worldMap.islands.KhaelRoa.radius) && Island != "KhaelRoa")
{ return "KhaelRoa"; }
if(worldMap.playerShipX >= stf(worldMap.islands.Cayman.position.x) - stf(worldMap.islands.Cayman.radius) && worldMap.playerShipX <= stf(worldMap.islands.Cayman.position.x) + stf(worldMap.islands.Cayman.radius) && worldMap.playerShipZ >= stf(worldMap.islands.Cayman.position.z) - stf(worldMap.islands.Cayman.radius) && worldMap.playerShipZ <= stf(worldMap.islands.Cayman.position.z) + stf(worldMap.islands.Cayman.radius) && Island != "Cayman")
{ return "Cayman"; }
if(worldMap.playerShipX >= stf(worldMap.islands.Cuba.position.x) - stf(worldMap.islands.Cuba.radius) && worldMap.playerShipX <= stf(worldMap.islands.Cuba.position.x) + stf(worldMap.islands.Cuba.radius) && worldMap.playerShipZ >= stf(worldMap.islands.Cuba.position.z) - stf(worldMap.islands.Cuba.radius) && worldMap.playerShipZ <= stf(worldMap.islands.Cuba.position.z) + stf(worldMap.islands.Cuba.radius) && Island != "Cuba")
{ return "Cuba"; }
if(worldMap.playerShipX >= stf(worldMap.islands.Hispaniola.position.x) - stf(worldMap.islands.Hispaniola.radius) && worldMap.playerShipX <= stf(worldMap.islands.Hispaniola.position.x) + stf(worldMap.islands.Hispaniola.radius) && worldMap.playerShipZ >= stf(worldMap.islands.Hispaniola.position.z) - stf(worldMap.islands.Hispaniola.radius) && worldMap.playerShipZ <= stf(worldMap.islands.Hispaniola.position.z) + stf(worldMap.islands.Hispaniola.radius) && Island != "Hispaniola")
{ return "Hispaniola"; }
if(worldMap.playerShipX >= stf(worldMap.islands.Guadeloupe.position.x) - stf(worldMap.islands.Guadeloupe.radius) && worldMap.playerShipX <= stf(worldMap.islands.Guadeloupe.position.x) + stf(worldMap.islands.Guadeloupe.radius) && worldMap.playerShipZ >= stf(worldMap.islands.Guadeloupe.position.z) - stf(worldMap.islands.Guadeloupe.radius) && worldMap.playerShipZ <= stf(worldMap.islands.Guadeloupe.position.z) + stf(worldMap.islands.Guadeloupe.radius) && Island != "Guadeloupe")
{ return "Guadeloupe"; }
if(worldMap.playerShipX >= stf(worldMap.islands.sent.position.x) - stf(worldMap.islands.sent.radius) && worldMap.playerShipX <= stf(worldMap.islands.sent.position.x) + stf(worldMap.islands.sent.radius) && worldMap.playerShipZ >= stf(worldMap.islands.sent.position.z) - stf(worldMap.islands.sent.radius) && worldMap.playerShipZ <= stf(worldMap.islands.sent.position.z) + stf(worldMap.islands.sent.radius) && Island != "sent")
{ return "Sent"; }
if(worldMap.playerShipX >= stf(worldMap.islands.Antigua.position.x) - stf(worldMap.islands.Antigua.radius) && worldMap.playerShipX <= stf(worldMap.islands.Antigua.position.x) + stf(worldMap.islands.Antigua.radius) && worldMap.playerShipZ >= stf(worldMap.islands.Antigua.position.z) - stf(worldMap.islands.Antigua.radius) && worldMap.playerShipZ <= stf(worldMap.islands.Antigua.position.z) + stf(worldMap.islands.Antigua.radius) && Island != "Antigua")
{ return "Antigua"; }
if(worldMap.playerShipX >= stf(worldMap.islands.Terks.position.x) - stf(worldMap.islands.Terks.radius) && worldMap.playerShipX <= stf(worldMap.islands.Terks.position.x) + stf(worldMap.islands.Terks.radius) && worldMap.playerShipZ >= stf(worldMap.islands.Terks.position.z) - stf(worldMap.islands.Terks.radius) && worldMap.playerShipZ <= stf(worldMap.islands.Terks.position.z) + stf(worldMap.islands.Terks.radius) && Island != "Terks")
{ return "Terks"; }
trace("GetNeighbourIsland for" + Island + " direction "+dir+" went wrong")
return ""; // default
}
void Sea_ReloadDirect() // called by Sea_ReloadStartDirect(), structure like original Sea_Reload
{
DelEventHandler("Sea_ReloadDirect", "Sea_ReloadDirect");
ref rPlayer = GetMainCharacter();
object Login;
Login.PlayerGroup.ay = stf(rPlayer.Ship.Ang.y);
Login.PlayerGroup.x = MakeFloat(rPlayer.ship.pos.x);
Login.PlayerGroup.y = 0.0;
Login.PlayerGroup.z = MakeFloat(rPlayer.ship.pos.z);
Login.Island = Characters[0].location;
// ccc oct06 directsail
if(CheckAttribute(rPlayer,"directsail.toisland"))
// if Directsail() calls islandchange island and playerposition are changed
{
Login.Island = rPlayer.directsail.toisland;
string toislandname = rPlayer.directsail.toisland;
// SECTION TO APPEAR IN THE NEW REAL POSITION AT THE NEW ISLAND
float psX = MakeFloat(worldMap.playerShipX);
float psZ = MakeFloat(worldMap.playerShipZ);
float ix = MakeFloat(worldMap.islands.(toislandname).position.rx);
float iz = MakeFloat(worldMap.islands.(toislandname).position.rz);
Login.playerGroup.x = (psX - ix)*WDM_MAP_TO_SEA_SCALE;
Login.playerGroup.z = (psZ - iz)*WDM_MAP_TO_SEA_SCALE;
Login.PlayerGroup.ay = stf(rPlayer.Ship.Ang.y); // your old heading
}
Trace("Sea_reloadDirect at "+ Login.Island );
SeaLoginDirect(&Login);
}
Of course, you have to outcomment or del this section of code in the DirectIslandCheck() method :
//if(dir=="")return false;
and
//worldMap.playerShipX = stf(worldMap.islands.(toislandname).position.x)+(stf(pchar.directsail.tox)/30); //divisor needs adjusting for final version
//worldMap.playerShipZ = stf(worldMap.islands.(toislandname).position.z)+(stf(pchar.directsail.toz)/30); // increase to get closer to the island
and i think some others sections of code are no more needed too !
Cheers <img src="style_emoticons/<#EMO_DIR#>/keith.gif" style="vertical-align:middle" emoid="
" border="0" alt="keith.gif" />