#pragma once #include "Agent.h" #include "ScriptManager.h" #include "Main.h" //Scripted functions int GM_CDECL gm_GetAgent(gmThread *a_thread) { GM_CHECK_NUM_PARAMS(1); GM_CHECK_INT_PARAM(networkId, 0); //Try and get the agentID PLAYER_DATA *lir=AccessLocalData(networkId); if (lir!=NULL) { //Get the player Player* pPlayer=(Player*)lir->pPlayer; if (pPlayer!=NULL) { //Assemble the AgentID(AgentID, InstanceID) unsigned short agent_id=pPlayer->GetAgentId(); unsigned short instance_id=lir->instanceId; unsigned char comp_id[4]; memcpy(comp_id, &agent_id, 2); memcpy(comp_id+2, &instance_id, 2); unsigned long id=0; memcpy(&id, comp_id, 4); a_thread->PushInt(id); return GM_OK; } } GM_EXCEPTION_MSG("networkId does not lead to a player agent!"); return GM_EXCEPTION; } //Scripted Agent Action Packets int GM_CDECL gm_AgentMsg(gmThread *a_thread) { GM_CHECK_NUM_PARAMS(5); GM_CHECK_INT_PARAM(stat_id, 0); GM_CHECK_INT_PARAM(new_value, 1); GM_CHECK_INT_PARAM(excID, 2); GM_CHECK_INT_PARAM(expIn, 3); GM_CHECK_INT_PARAM(agent_id, 4); //Get the Instance and Agent GET_AGENT_POINTERS(agent_id); pAgent->AAAgentMsg(stat_id, new_value, excID, expIn, RELAY_TO_ALL); return GM_OK; } int GM_CDECL gm_GetAgentPosition(gmThread *a_thread) { GM_CHECK_NUM_PARAMS(1); GM_CHECK_INT_PARAM(agent_id, 0); GET_AGENT_POINTERS(agent_id); Vertex pos=pAgent->GetCurrentPos(); //Create a table to hold the position values gmTableObject* table=gpScriptMan->GetVM()->AllocTableObject(); gmVariable gv; gv.SetFloat(pos.x); table->Set(gpScriptMan->GetVM(), 0, gv); gv.SetFloat(pos.y); table->Set(gpScriptMan->GetVM(), 1, gv); gv.SetFloat(pos.z); table->Set(gpScriptMan->GetVM(), 2, gv); a_thread->PushTable(table); return GM_OK; } //Set the agent's vital status int GM_CDECL gm_UpdateVitalStatus(gmThread *a_thread) { GM_CHECK_NUM_PARAMS(3); GM_CHECK_INT_PARAM(statusID, 0); GM_CHECK_INT_PARAM(value, 1); GM_CHECK_INT_PARAM(agent_id, 2); GET_AGENT_POINTERS(agent_id); pAgent->UpdateVitalStatus(statusID, value); return GM_OK; }