What should I define uiDiff as ?
Here is the code I am using now, the wait function I found using google but I have heard that this will sleep the entire thread that updates units on the map. I should use a delayed execution instead but I have no idea how to do that.
This is my generic game object script that needs to be changed.
Code:
#include "ScriptPCH.h"
void wait(unsigned int mseconds) // This is the function I would like changed, this is no good.
{
clock_t goal = mseconds + clock();
while (goal > clock());
}
class generic_gobject : public GameObjectScript
{
public: generic_gobject(): GameObjectScript("generic_gobject") {}
bool OnGossipHello(Player* player, GameObject* gameobject)
{
uint32 nNowait = 0, sSpell1 = 54190, sSpell2 = 52096, mMap = 1, wWait1 = 80, wWait2 = 900;
float xCoord = 0.0f, yCoord = 0.0f, zCoord = 0, oOrient = 0.0f;
switch (gameobject->GetEntry()) //determine what game object was used
{
case 2: //Shattrath Portal to Dalaran gob entry
if (player->getLevel() <= 79)
{
//player is not level 80 do not port
player->GetSession()->SendNotification("You must reach level 80 to use this portal.");
return false;
}
else
{
nNowait = 1;
mMap = 571;
xCoord = 5820.606f;
yCoord = 544.037f;
zCoord = 652.932f;
oOrient = 1.858341f;
}
break;
case 3: //Shattrath Orb of Teleportation gob entry
mMap = 530;
xCoord = -1823.818f;
yCoord = 5350.067f;
zCoord = -11.428f;
oOrient = 5.154526f;
break;
case 4: //Dalaran Orb of Teleportation gob entry
mMap = 571;
xCoord = 5820.606f;
yCoord = 544.037f;
zCoord = 652.932f;
oOrient = 1.858341f;
break;
case 6: //Thunder Bluff Orb of Teleportation gob entry
xCoord = -1276.706f;
yCoord = 124.102f;
zCoord = 132.266f;
oOrient = 5.466212f;
break;
case 7: //Iron Forge Orb of Teleportation gob entry
mMap =0;
xCoord = -4937.491f;
yCoord = -935.506f;
zCoord = 504.144f;
oOrient = 5.411f;
break;
case 8: //Hyjal Teleporter (Hyjal Entrance) gob entry
if (player->getLevel() <= 79)
{
//player is not level 80 do not port
player->GetSession()->SendNotification("You must reach level 80 to use this portal.");
return false;
}
else if (player->HasAura(54643))
{
//player player has recently teleported do not port
player->GetSession()->SendNotification("You are unable to teleport right now.");
return false;
}
else
{
xCoord = 4612.435f;
yCoord = -3862.041f;
zCoord = 944.936f;
oOrient = 1.071263f;
sSpell2 = 54643; // add teleport buff to player
}
break;
case 9: //Island Orb of Teleportation gob entry
xCoord = 16200.689f;
yCoord = 16206.03f;
zCoord = 1.142f;
oOrient = 1.563672f;
break;
case 10: //Winterspring Teleporter (Hyjal Exit) gob entry
if (player->HasAura(54643))
{
//player player has recently teleported do not port
player->GetSession()->SendNotification("You are unable to teleport right now.");
return false;
}
else
{
xCoord = 4560.639f;
yCoord = -3935.394f;
zCoord = 943.289f;
oOrient = 4.200279f;
sSpell2 = 54643; // add teleport buff to player
}
break;
case 11: //Ratchet Orb of Teleportation gob entry
xCoord = -894.037f;
yCoord = -3773.568f;
zCoord = 12.479f;
oOrient = 2.432517f;
break;
case 12: //Booty Bay Orb of Teleportation gob entry
mMap = 0;
xCoord = -14446.071f;
yCoord = 513.053f;
zCoord = 27.333f;
oOrient = 4.620865f;
break;
case 14: //Wintergrasp Orb of Teleportation gob entry
mMap = 571;
xCoord = 5050.265f;
yCoord = 2845.859f;
zCoord = 394.149f;
oOrient = 6.242441f;
break;
case 17: //Argent Tournament Grounds Orb of Teleportation gob entry
mMap = 571;
xCoord = 8347.061f;
yCoord = 801.276f;
zCoord = 545.257f;
oOrient = 6.116282f;
break;
default:
break;
}
if (xCoord == 0) //no port location set, do nothing
{
return true;
}
else
{
if (nNowait == 1) // Player used portal in Shattrath keep the port blizzlike.
{
player->CastSpell(player, sSpell2, true);
}
else
{
player->CastSpell(player, sSpell1, true);
wait(wWait1);
player->CastSpell(player, sSpell2, true);
wait(wWait2);
}
player->TeleportTo(mMap, xCoord, yCoord, zCoord, oOrient);
return false;
}
}
};
void AddSC_generic_gobject()
{
new generic_gobject();
}
Basically what this does is allows me to use one script for various teleporter game objects. Eventually this code will grow bigger as I add more custom objects to my server but for now I would just like the wait function changed to pause the port the 'correct' way.