Address Issue #142
Fix #142 LUA Functions: SendTransporters(NPC,Spawn,TransportID) SetTemporaryTransportID(TransportID) GetTemporaryTransportID()
This commit is contained in:
parent
0519ae0683
commit
fcd92434da
8 changed files with 99 additions and 3 deletions
|
@ -9438,6 +9438,9 @@ int EQ2Emu_lua_RemovePrimaryEntityCommand(lua_State* state)
|
|||
|
||||
|
||||
int EQ2Emu_lua_SendUpdateDefaultCommand(lua_State* state) {
|
||||
if (!lua_interface)
|
||||
return 0;
|
||||
|
||||
Spawn* spawn = lua_interface->GetSpawn(state);
|
||||
float distance = lua_interface->GetFloatValue(state, 2);
|
||||
string command = lua_interface->GetStringValue(state, 3);
|
||||
|
@ -9447,4 +9450,72 @@ int EQ2Emu_lua_SendUpdateDefaultCommand(lua_State* state) {
|
|||
spawn->GetZone()->SendUpdateDefaultCommand(spawn, command.c_str(), distance, player);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EQ2Emu_lua_SendTransporters(lua_State* state) {
|
||||
if (!lua_interface)
|
||||
return 0;
|
||||
|
||||
Spawn* spawn = lua_interface->GetSpawn(state);
|
||||
Spawn* player = lua_interface->GetSpawn(state, 2);
|
||||
int32 transport_id = lua_interface->GetInt32Value(state, 3);
|
||||
|
||||
if (spawn && player && transport_id && player->IsPlayer()) {
|
||||
Client* client = 0;
|
||||
if (player && player->IsPlayer())
|
||||
client = player->GetZone()->GetClientBySpawn(player);
|
||||
|
||||
if (!client)
|
||||
return 0;
|
||||
|
||||
vector<TransportDestination*> destinations;
|
||||
player->GetZone()->GetTransporters(&destinations, client, transport_id);
|
||||
|
||||
if (destinations.size())
|
||||
{
|
||||
client->SetTemporaryTransportID(transport_id);
|
||||
client->ProcessTeleport(spawn, &destinations, transport_id);
|
||||
}
|
||||
else
|
||||
client->Message(CHANNEL_COLOR_RED, "There are no transporters available (ID: %u)", transport_id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EQ2Emu_lua_SetTemporaryTransportID(lua_State* state) {
|
||||
if (!lua_interface)
|
||||
return 0;
|
||||
|
||||
Spawn* player = lua_interface->GetSpawn(state);
|
||||
int32 transport_id = lua_interface->GetInt32Value(state, 2);
|
||||
|
||||
if (player && player->IsPlayer()) {
|
||||
Client* client = 0;
|
||||
if (player && player->IsPlayer())
|
||||
client = player->GetZone()->GetClientBySpawn(player);
|
||||
|
||||
if (!client)
|
||||
return 0;
|
||||
|
||||
client->SetTemporaryTransportID(transport_id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EQ2Emu_lua_GetTemporaryTransportID(lua_State* state) {
|
||||
if (!lua_interface)
|
||||
return 0;
|
||||
Spawn* player = lua_interface->GetSpawn(state);
|
||||
if (player && player->IsPlayer()) {
|
||||
Client* client = 0;
|
||||
if (player && player->IsPlayer())
|
||||
client = player->GetZone()->GetClientBySpawn(player);
|
||||
|
||||
if (!client)
|
||||
return 0;
|
||||
|
||||
lua_interface->SetInt32Value(state, client->GetTemporaryTransportID());
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -429,4 +429,9 @@ int EQ2Emu_lua_SetSeeHide(lua_State* state);
|
|||
int EQ2Emu_lua_SetAccessToEntityCommand(lua_State* state);
|
||||
int EQ2Emu_lua_RemovePrimaryEntityCommand(lua_State* state);
|
||||
int EQ2Emu_lua_SendUpdateDefaultCommand(lua_State* state);
|
||||
|
||||
|
||||
int EQ2Emu_lua_SendTransporters(lua_State* state);
|
||||
int EQ2Emu_lua_SetTemporaryTransportID(lua_State* state);
|
||||
int EQ2Emu_lua_GetTemporaryTransportID(lua_State* state);
|
||||
#endif
|
|
@ -1032,6 +1032,10 @@ void LuaInterface::RegisterFunctions(lua_State* state) {
|
|||
lua_register(state, "SetAccessToEntityCommand", EQ2Emu_lua_SetAccessToEntityCommand);
|
||||
lua_register(state, "RemovePrimaryEntityCommand", EQ2Emu_lua_RemovePrimaryEntityCommand);
|
||||
lua_register(state, "SendUpdateDefaultCommand", EQ2Emu_lua_SendUpdateDefaultCommand);
|
||||
|
||||
lua_register(state, "SendTransporters", EQ2Emu_lua_SendTransporters);
|
||||
lua_register(state, "SetTemporaryTransportID", EQ2Emu_lua_SetTemporaryTransportID);
|
||||
lua_register(state, "GetTemporaryTransportID", EQ2Emu_lua_GetTemporaryTransportID);
|
||||
}
|
||||
|
||||
void LuaInterface::LogError(const char* error, ...) {
|
||||
|
|
|
@ -48,8 +48,11 @@ void Object::HandleUse(Client* client, string command){
|
|||
vector<TransportDestination*> destinations;
|
||||
if(GetTransporterID() > 0)
|
||||
GetZone()->GetTransporters(&destinations, client, GetTransporterID());
|
||||
if(destinations.size())
|
||||
if (destinations.size())
|
||||
{
|
||||
client->SetTemporaryTransportID(0);
|
||||
client->ProcessTeleport(this, &destinations, GetTransporterID());
|
||||
}
|
||||
else if (client && command.length() > 0 && appearance.show_command_icon == 1 && MeetsSpawnAccessRequirements(client->GetPlayer())){
|
||||
EntityCommand* entity_command = FindEntityCommand(command);
|
||||
if (entity_command)
|
||||
|
|
|
@ -239,6 +239,7 @@ void Sign::HandleUse(Client* client, string command)
|
|||
|
||||
if( destinations.size() )
|
||||
{
|
||||
client->SetTemporaryTransportID(0);
|
||||
client->ProcessTeleport(this, &destinations, GetTransporterID());
|
||||
}
|
||||
else if( sign_type == SIGN_TYPE_ZONE && GetSignZoneID() > 0 )
|
||||
|
|
|
@ -350,7 +350,10 @@ void Widget::HandleUse(Client* client, string command, int8 overrideWidgetType){
|
|||
}
|
||||
|
||||
if (client && GetTransporterID() > 0)
|
||||
{
|
||||
client->SetTemporaryTransportID(0);
|
||||
GetZone()->GetTransporters(&destinations, client, GetTransporterID());
|
||||
}
|
||||
if (destinations.size())
|
||||
client->ProcessTeleport(this, &destinations, GetTransporterID());
|
||||
else if (overrideWidgetType == WIDGET_TYPE_DOOR || overrideWidgetType == WIDGET_TYPE_LIFT){
|
||||
|
|
|
@ -194,6 +194,7 @@ Client::Client(EQStream* ieqs) : pos_update(125), quest_pos_timer(2000), lua_deb
|
|||
tempPlacementSpawn = nullptr;
|
||||
placement_unique_item_id = 0;
|
||||
SetHasOwnerOrEditAccess(false);
|
||||
temporary_transport_id = 0;
|
||||
}
|
||||
|
||||
Client::~Client() {
|
||||
|
@ -7162,8 +7163,8 @@ void Client::ProcessTeleportLocation(EQApplicationPacket* app) {
|
|||
int32 cost = packet->getType_int32_ByName("cost");
|
||||
vector<TransportDestination*> destinations;
|
||||
TransportDestination* destination = 0;
|
||||
if (spawn && spawn == transport_spawn && spawn->GetTransporterID() > 0)
|
||||
GetCurrentZone()->GetTransporters(&destinations, this, spawn->GetTransporterID());
|
||||
if (this->GetTemporaryTransportID() || (spawn && spawn == transport_spawn && spawn->GetTransporterID()))
|
||||
GetCurrentZone()->GetTransporters(&destinations, this, this->GetTemporaryTransportID() ? this->GetTemporaryTransportID() : spawn->GetTransporterID());
|
||||
vector<TransportDestination*>::iterator itr;
|
||||
for (itr = destinations.begin(); itr != destinations.end(); itr++) {
|
||||
if ((*itr)->unique_id == unique_id && (*itr)->display_name == zone_name && (*itr)->cost == cost) {
|
||||
|
@ -7171,6 +7172,9 @@ void Client::ProcessTeleportLocation(EQApplicationPacket* app) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetTemporaryTransportID(0);
|
||||
|
||||
if (!destination)
|
||||
SimpleMessage(CHANNEL_COLOR_RED, "Error processing transport.");
|
||||
else {
|
||||
|
|
|
@ -422,6 +422,9 @@ public:
|
|||
bool PopulateHouseSpawnFinalize();
|
||||
|
||||
void SendMoveObjectMode(Spawn* spawn, uint8 placementMode, float unknown2_3=0.0f);
|
||||
|
||||
void SetTemporaryTransportID(int32 id) { temporary_transport_id = id; }
|
||||
int32 GetTemporaryTransportID() { return temporary_transport_id; }
|
||||
private:
|
||||
void SavePlayerImages();
|
||||
void SkillChanged(Skill* skill, int16 previous_value, int16 new_value);
|
||||
|
@ -521,6 +524,8 @@ private:
|
|||
Spawn* tempPlacementSpawn;
|
||||
int32 placement_unique_item_id;
|
||||
bool hasOwnerOrEditAccess;
|
||||
|
||||
int32 temporary_transport_id;
|
||||
};
|
||||
|
||||
class ClientList {
|
||||
|
|
Loading…
Reference in a new issue