Added script driven kart teleports
This commit is contained in:
parent
2f57a14c87
commit
d908489ca7
@ -2,4 +2,5 @@ void onTrigger()
|
||||
{
|
||||
displayMessage("Bananas! Bananas! Everywhere!");
|
||||
squashKart(0,35.0); //id of kart,time to squash
|
||||
teleportKart(0, 5, 5 ,5); //id of kart, x,y,z
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ class World : public WorldStatus
|
||||
{
|
||||
public:
|
||||
typedef std::vector<AbstractKart*> KartList;
|
||||
|
||||
private:
|
||||
/** A pointer to the global world object for a race. */
|
||||
static World *m_world;
|
||||
@ -166,7 +167,6 @@ protected:
|
||||
virtual void update(float dt);
|
||||
virtual void createRaceGUI();
|
||||
void updateTrack(float dt);
|
||||
void moveKartTo(AbstractKart* kart, const btTransform &t);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Used for AI karts that are still racing when all player kart finished.
|
||||
* Generally it should estimate the arrival time for those karts, but as
|
||||
@ -217,6 +217,8 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
void moveKartAfterRescue(AbstractKart* kart);
|
||||
// ------------------------------------------------------------------------
|
||||
void moveKartTo(AbstractKart* kart, const btTransform &t);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Called when it is needed to know whether this kind of race involves
|
||||
* counting laps. */
|
||||
virtual bool raceHasLaps() = 0;
|
||||
|
@ -35,11 +35,28 @@ namespace Scripting{
|
||||
AbstractKart* kart = World::getWorld()->getKart(id);
|
||||
kart->setSquash(time, 0.5); //0.5 * max speed is new max for squashed duration
|
||||
}
|
||||
|
||||
void teleportKart(asIScriptGeneric *gen)
|
||||
{
|
||||
int id = (int)gen->GetArgDWord(0);
|
||||
|
||||
float x = gen->GetArgFloat(1);
|
||||
float y = gen->GetArgFloat(2);
|
||||
float z = gen->GetArgFloat(3);
|
||||
|
||||
AbstractKart* kart = World::getWorld()->getKart(id);
|
||||
kart->setXYZ(btVector3(x, y, z));
|
||||
unsigned int index = World::getWorld()->getRescuePositionIndex(kart);
|
||||
btTransform s = World::getWorld()->getRescueTransform(index);
|
||||
const btVector3 &xyz = s.getOrigin();
|
||||
float angle = atan2(0, 0);
|
||||
s.setRotation(btQuaternion(btVector3(0.0f, 1.0f, 0.0f), angle));
|
||||
World::getWorld()->moveKartTo(kart, s);
|
||||
}
|
||||
void registerScriptFunctions(asIScriptEngine *engine)
|
||||
{
|
||||
int r;
|
||||
r = engine->RegisterGlobalFunction("void squashKart(int id, float time)", asFUNCTION(squashKart), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void teleportKart(int id, float x, float y,float z)", asFUNCTION(teleportKart), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user