mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-14 19:49:51 +00:00
120 lines
5.2 KiB
Text
120 lines
5.2 KiB
Text
Alain's code
|
|
|
|
/****************************************************************\
|
|
****************************************************************
|
|
Alain's Command section
|
|
****************************************************************
|
|
\****************************************************************/
|
|
|
|
// Command for add an entity on the GPMS
|
|
NLMISC_COMMAND(add_entity,"Add entity to GPMS","entity Id, sheet Id, entity PosX(meters), entity PosY, entity PosZ, entity Theta angle")
|
|
{
|
|
// check args, if there s not the right number of parameter, return bad
|
|
if(args.size() != 6) return false;
|
|
|
|
// get the values
|
|
uint32 Id = atoi(args[0].c_str());
|
|
uint32 SheetId = atoi(args[1].c_str());
|
|
sint32 PosX = atoi(args[2].c_str()) * 1000; //coordinates are in millimeters
|
|
uint32 PosY = atoi(args[3].c_str()) * 1000;
|
|
sint32 PosZ = atoi(args[4].c_str()) * 1000;
|
|
float Theta = (float) atof(args[5].c_str()); //direction of entity in radian (direct angle in radian, front of is on +Y (0 = Y direction), all conversion is now made on client)
|
|
|
|
//normaly creature type, but FE not ready for properties of creature type, this constructor set dynamicId and creatorId to serviceId
|
|
// At this time they are no namespace for enum of entity type, this be corrected when i'm change Sid/EntityId class and move it in game_share
|
|
Sid sid( /*Sid::*/npc, Id);
|
|
|
|
//make the message for add entity and send it
|
|
CMessage msgout("ADD_ENTITY");
|
|
msgout.serial( sid );
|
|
msgout.serial( PosX );
|
|
msgout.serial( PosY );
|
|
msgout.serial( PosZ );
|
|
msgout.serial( Theta );
|
|
NLMISC::TGameCycle tick = CTickEventHandler::getGameCycle();
|
|
//msgout.serial( tick ); //Chaine of time is not complete, must be made in shortly
|
|
msgout.serial( SheetId );
|
|
CUnifiedNetwork::getInstance()->send( "GPMS", msgout );
|
|
|
|
return true;
|
|
}
|
|
|
|
// Command for remove an entity on the GPMS
|
|
NLMISC_COMMAND(remove_entity,"Remove entity to GPMS","entity Id")
|
|
{
|
|
// check args, if there s not the right number of parameter, return bad
|
|
if(args.size() != 1) return false;
|
|
|
|
// get the values
|
|
uint32 Id = atoi(args[0].c_str());
|
|
|
|
//normaly creature type, but FE not ready for properties of creature type, this constructor set dynamicId and creatorId to serviceId
|
|
// At this time they are no namespace for enum of entity type, this be corrected when i'm change Sid/EntityId class and move it in game_share
|
|
Sid sid( /*Sid::*/npc, Id);
|
|
|
|
CMessage msgout("REMOVE_ENTITY");
|
|
msgout.serial( sid );
|
|
CUnifiedNetwork::getInstance()->send( "GPMS", msgout );
|
|
|
|
return true;
|
|
}
|
|
|
|
// Command for update position of an entity, remember pacs constraintes reduce the max move in one ticks at two cells (2*16 meters)
|
|
NLMISC_COMMAND(update_position,"Update position of an entity","entity Id, entity PosX(meters), entity PosY, entity PosZ, entity Theta angle")
|
|
{
|
|
// check args, if there s not the right number of parameter, return bad
|
|
if(args.size() != 5) return false;
|
|
|
|
// get the values
|
|
uint32 Id = atoi(args[0].c_str());
|
|
sint32 PosX = atoi(args[1].c_str()) * 1000; //coordinates are in millimeters
|
|
uint32 PosY = atoi(args[2].c_str()) * 1000;
|
|
sint32 PosZ = atoi(args[3].c_str()) * 1000;
|
|
float Theta = (float) atof(args[4].c_str()); //direction of entity in radian (direct angle in radian, front of is on +Y (0 = Y direction), all conversion is now made on client)
|
|
|
|
//normaly creature type, but FE not ready for properties of creature type, this constructor set dynamicId and creatorId to serviceId
|
|
// At this time they are no namespace for enum of entity type, this be corrected when i'm change Sid/EntityId class and move it in game_share
|
|
Sid sid( /*Sid::*/npc, Id);
|
|
|
|
CMessage msgout("UPDATE_ENTITY_POS");
|
|
msgout.serial( sid );
|
|
msgout.serial( PosX );
|
|
msgout.serial( PosY );
|
|
msgout.serial( PosZ );
|
|
msgout.serial( Theta );
|
|
NLMISC::TGameCycle tick = CTickEventHandler::getGameCycle();
|
|
msgout.serial( tick );
|
|
CUnifiedNetwork::getInstance()->send( "GPMS", msgout );
|
|
|
|
return true;
|
|
}
|
|
|
|
// Command for teleport an entity to new position, no limit of distance to move
|
|
NLMISC_COMMAND(teleportation,"Teleport entity to gived position","entity Id, entity PosX(meters), entity PosY, entity PosZ, entity Theta angle")
|
|
{
|
|
// check args, if there s not the right number of parameter, return bad
|
|
if(args.size() != 5) return false;
|
|
|
|
// get the values
|
|
uint32 Id = atoi(args[0].c_str());
|
|
sint32 PosX = atoi(args[1].c_str()) * 1000; //coordinates are in millimeters
|
|
uint32 PosY = atoi(args[2].c_str()) * 1000;
|
|
sint32 PosZ = atoi(args[3].c_str()) * 1000;
|
|
float Theta = (float) atof(args[4].c_str()); //direction of entity in radian (direct angle in radian, front of is on +Y (0 = Y direction), all conversion is now made on client)
|
|
|
|
//normaly creature type, but FE not ready for properties of creature type, this constructor set dynamicId and creatorId to serviceId
|
|
// At this time they are no namespace for enum of entity type, this be corrected when i'm change Sid/EntityId class and move it in game_share
|
|
Sid sid( /*Sid::*/npc, Id);
|
|
|
|
CMessage msgout("ENTITY_TELEPORTATION");
|
|
msgout.serial( sid );
|
|
msgout.serial( PosX );
|
|
msgout.serial( PosY );
|
|
msgout.serial( PosZ );
|
|
msgout.serial( Theta );
|
|
NLMISC::TGameCycle tick = CTickEventHandler::getGameCycle();
|
|
msgout.serial( tick );
|
|
CUnifiedNetwork::getInstance()->send( "GPMS", msgout );
|
|
|
|
return true;
|
|
}
|