Browse Source

fix status points and missing parry/block/avoidance fields in player::serialize add SetSpawnGroupID lua function

Fix #256 - status points function and SetInfoStructUInt can set them

Fix #273 - fields in player profile not updating

Fix #290 - add SetSpawnGroupID(Spawn, group_id) lua function
Image 3 years ago
parent
commit
1bff083459

+ 44 - 2
EQ2/source/WorldServer/LuaFunctions.cpp

@@ -383,7 +383,13 @@ int EQ2Emu_lua_SpawnSet(lua_State* state) {
 	string variable = lua_interface->GetStringValue(state, 2);
 	string value = lua_interface->GetStringValue(state, 3);
 	bool no_update = lua_interface->GetBooleanValue(state, 4); // send update is true by default in SetSpawnCommand, so allow user to specify 'true' to disable send update.
-	bool temporary_flag = lua_interface->GetBooleanValue(state, 5); // default false as originally designed, allow user to set temporary_flag true to not update DB
+	bool temporary_flag = true;
+	
+	int8 num_args = (int8)lua_interface->GetNumberOfArgs(state);
+
+	if(num_args >= 5)
+		temporary_flag = lua_interface->GetBooleanValue(state, 5); // this used to be false, but no one bothered to set it temporary, we don't need to update the DB
+	
 	int32 type = commands.GetSpawnSetType(variable);
 	if (type != 0xFFFFFFFF && value.length() > 0 && spawn)
 		commands.SetSpawnCommand(0, spawn, type, value.c_str(), !no_update, temporary_flag);
@@ -584,6 +590,22 @@ int EQ2Emu_lua_GetSpawnGroupID(lua_State* state) {
 	return 0;
 }
 
+int EQ2Emu_lua_SetSpawnGroupID(lua_State* state) {
+	if (!lua_interface)
+		return 0;
+	Spawn* spawn = lua_interface->GetSpawn(state);
+	int32 new_group_id = lua_interface->GetInt32Value(state, 2);
+	lua_interface->ResetFunctionStack(state);
+	if (spawn) {
+		spawn->SetSpawnGroupID(new_group_id);
+		lua_interface->SetBooleanValue(state, true);
+		return 1;
+	}
+
+	lua_interface->SetBooleanValue(state, false);
+	return 1;
+}
+
 int EQ2Emu_lua_GetSpawnLocationID(lua_State* state) {
 	Spawn* spawn = lua_interface->GetSpawn(state);
 	if (spawn) {
@@ -2002,7 +2024,6 @@ int EQ2Emu_lua_SetSpeed(lua_State* state) {
 	float value = lua_interface->GetFloatValue(state, 2);
 	lua_interface->ResetFunctionStack(state);
 	if (spawn) {
-				printf("Speed set lua: %f\n",value);
 		spawn->SetSpeed(value);
 		((Entity*)spawn)->SetSpeed(value);
 		if (spawn->IsPlayer()) {
@@ -12061,4 +12082,25 @@ int EQ2Emu_lua_PauseMovement(lua_State* state) {
 	}
 	lua_interface->ResetFunctionStack(state);
 	return 0;
+}
+
+int EQ2Emu_lua_GetArrowColor(lua_State* state) {
+	Player* player = (Player*)lua_interface->GetSpawn(state);
+	int8 level = lua_interface->GetInt8Value(state, 2);
+	lua_interface->ResetFunctionStack(state);
+	if (player && player->IsPlayer() && level > 0) {
+		lua_interface->SetInt32Value(state, player->GetArrowColor(level));
+		return 1;
+	}
+	return 0;
+}
+int EQ2Emu_lua_GetTSArrowColor(lua_State* state) {
+	Player* player = (Player*)lua_interface->GetSpawn(state);
+	int8 level = lua_interface->GetInt8Value(state, 2);
+	lua_interface->ResetFunctionStack(state);
+	if (player && player->IsPlayer() && level > 0) {
+		lua_interface->SetInt32Value(state, player->GetTSArrowColor(level));
+		return 1;
+	}
+	return 0;
 }

+ 4 - 0
EQ2/source/WorldServer/LuaFunctions.h

@@ -123,6 +123,7 @@ int EQ2Emu_lua_GetSpawnByGroupID(lua_State* state);
 int EQ2Emu_lua_GetSpawnByLocationID(lua_State* state);
 int EQ2Emu_lua_GetSpawnID(lua_State* state);
 int EQ2Emu_lua_GetSpawnGroupID(lua_State* state);
+int EQ2Emu_lua_SetSpawnGroupID(lua_State* state);
 int EQ2Emu_lua_GetSpawnLocationID(lua_State* state);
 int EQ2Emu_lua_GetSpawnLocationPlacementID(lua_State* state);
 int EQ2Emu_lua_GetFactionAmount(lua_State* state);
@@ -574,4 +575,7 @@ int EQ2Emu_lua_GetShardCreatedTimestamp(lua_State* state);
 int EQ2Emu_lua_DeleteDBShardID(lua_State* state);
 
 int EQ2Emu_lua_PauseMovement(lua_State* state);
+
+int EQ2Emu_lua_GetArrowColor(lua_State* state);
+int EQ2Emu_lua_GetTSArrowColor(lua_State* state);
 #endif

+ 4 - 0
EQ2/source/WorldServer/LuaInterface.cpp

@@ -792,6 +792,7 @@ void LuaInterface::RegisterFunctions(lua_State* state) {
 	lua_register(state, "GetZ", EQ2Emu_lua_GetZ);
 	lua_register(state, "GetSpawnID", EQ2Emu_lua_GetSpawnID);
 	lua_register(state, "GetSpawnGroupID", EQ2Emu_lua_GetSpawnGroupID);
+	lua_register(state, "SetSpawnGroupID", EQ2Emu_lua_SetSpawnGroupID);
 	lua_register(state, "GetSpawnLocationID", EQ2Emu_lua_GetSpawnLocationID);
 	lua_register(state, "GetSpawnLocationPlacementID", EQ2Emu_lua_GetSpawnLocationPlacementID);
 	lua_register(state, "CreateSpawnList", EQ2Emu_lua_CreateSpawnList);
@@ -1288,6 +1289,9 @@ void LuaInterface::RegisterFunctions(lua_State* state) {
 	lua_register(state, "DeleteDBShardID", EQ2Emu_lua_DeleteDBShardID);
 	
 	lua_register(state, "PauseMovement", EQ2Emu_lua_PauseMovement);
+	
+	lua_register(state, "GetArrowColor", EQ2Emu_lua_GetArrowColor);
+	lua_register(state, "GetTSArrowColor", EQ2Emu_lua_GetTSArrowColor);
 }
 
 void LuaInterface::LogError(const char* error, ...)  {

+ 20 - 3
EQ2/source/WorldServer/Player.cpp

@@ -387,6 +387,19 @@ PacketStruct* PlayerInfo::serialize2(int16 version){
 		packet->setDataByName("tradeskill_exp_blue", info_struct->get_tradeskill_exp_blue());
 		packet->setDataByName("flags", info_struct->get_flags());
 		packet->setDataByName("flags2", info_struct->get_flags2());
+
+		packet->setDataByName("avoidance_pct", (int16)info_struct->get_avoidance_display()*10.0f);//avoidance_pct 192 = 19.2% // confirmed DoV
+		packet->setDataByName("avoidance_base", (int16)info_struct->get_avoidance_base()*10.0f); // confirmed DoV
+		packet->setDataByName("avoidance", info_struct->get_cur_avoidance());
+		packet->setDataByName("base_avoidance_pct", info_struct->get_base_avoidance_pct());// confirmed DoV
+		float parry_pct = info_struct->get_parry(); // client works off of int16, but we use floats to track the actual x/100%
+		packet->setDataByName("parry",(int16)(parry_pct*10.0f));// confirmed DoV
+
+		float block_pct = info_struct->get_block()*10.0f;
+		
+		packet->setDataByName("block", (int16)block_pct);// confirmed DoV
+		packet->setDataByName("uncontested_block", info_struct->get_uncontested_block());// confirmed DoV
+
 		packet->setDataByName("str", info_struct->get_str());
 		packet->setDataByName("sta", info_struct->get_sta());
 		packet->setDataByName("agi", info_struct->get_agi());
@@ -948,7 +961,7 @@ EQ2Packet* PlayerInfo::serialize(int16 version, int16 modifyPos, int32 modifyVal
 		packet->setDataByName("pet_behavior", info_struct->get_pet_behavior());
 		packet->setDataByName("rain", info_struct->get_rain());
 		packet->setDataByName("rain2", info_struct->get_wind()); //-102.24);
-		packet->setDataByName("status_points", 999999);// info_struct->status_points);
+		packet->setDataByName("status_points", info_struct->get_status_points());
 		packet->setDataByName("guild_status", 888888);
 		//unknown_1096_44_MJ
 		if (house_zone_id > 0){
@@ -2170,6 +2183,10 @@ int32 Player::GetBankCoinsPlat(){
 	return GetInfoStruct()->get_bank_coin_plat();
 }
 
+int32 Player::GetStatusPoints(){
+	return GetInfoStruct()->get_status_points();
+}
+
 vector<QuickBarItem*>* Player::GetQuickbar(){
 	return &quickbar_items;
 }
@@ -3097,10 +3114,10 @@ void Player::AddMaintainedSpell(LuaSpell* luaspell){
 		effect->spell = luaspell;
 		luaspell->slot_pos = effect->slot_pos;
 		effect->spell_id = spell->GetSpellData()->id;
-		LogWrite(PLAYER__DEBUG, 5, "Player", "AddMaintainedSpell Spell ID: %u", spell->GetSpellData()->id);
+		LogWrite(PLAYER__DEBUG, 5, "Player", "AddMaintainedSpell Spell ID: %u, req concentration: %u", spell->GetSpellData()->id, spell->GetSpellData()->req_concentration);
 		effect->icon = spell->GetSpellData()->icon;
 		effect->icon_backdrop = spell->GetSpellData()->icon_backdrop;
-		effect->conc_used = spell->GetSpellData()->req_concentration / 256;
+		effect->conc_used = spell->GetSpellData()->req_concentration;
 		effect->total_time = spell->GetSpellDuration()/10;
 		effect->tier = spell->GetSpellData()->tier;
 		if (spell->GetSpellData()->duration_until_cancel)

+ 1 - 0
EQ2/source/WorldServer/Player.h

@@ -519,6 +519,7 @@ public:
 	int32	GetBankCoinsSilver();
 	int32	GetBankCoinsGold();
 	int32	GetBankCoinsPlat();
+	int32	GetStatusPoints();
 	float	GetXPVitality();
 	float	GetTSXPVitality();
 	bool	AdventureXPEnabled();

+ 5 - 5
server/WorldStructs.xml

@@ -2725,8 +2725,8 @@ to zero and treated like placeholders." />
 <Data ElementName="merc_unknown21cc" Type="int8" Size="4" />
 <Data ElementName="rain" Type="float" Size="1" />
 <Data ElementName="rain2" Type="float" Size="1" />
-<Data ElementName="unknownx527_1" Type="int32" Size="1" />
-<Data ElementName="unknownx527_2" Type="int32" Size="1" />
+<Data ElementName="status_points" Type="int32" Size="1" />
+<Data ElementName="guild_status" Type="int32" Size="1" />
 <Data ElementName="unknownx527" Type="int8" Size="1" />
 <Data ElementName="house_zone" Type="char" Size="48" />
 <Data ElementName="unknownx526_1" Type="int32" Size="1" />
@@ -2762,10 +2762,10 @@ to zero and treated like placeholders." />
 <Data ElementName="unknownx526_31" Type="int32" Size="1" />
 <Data ElementName="unknownx526_32" Type="int32" Size="1" />
 <Data ElementName="unknownx526_33" Type="int32" Size="1" />
-<Data ElementName="status_points" Type="int32" Size="1" />
-<Data ElementName="guild_status" Type="int32" Size="1" />
 <Data ElementName="unknownx526_34" Type="int32" Size="1" />
 <Data ElementName="unknownx526_35" Type="int32" Size="1" />
+<Data ElementName="unknownx526_36" Type="int32" Size="1" />
+<Data ElementName="unknownx526_37" Type="int32" Size="1" />
 <Data ElementName="unknown187" Type="int8" Size="3" />
 <Data ElementName="bind_zone" Type="char" Size="32" />
 <Data ElementName="unknown188" Type="int8" Size="52" />
@@ -18929,4 +18929,4 @@ to zero and treated like placeholders." />
 	<Data ElementName="item_id" Type="int32"/>
 </Data>
 </Struct>
-</EQ2Emulator>
+</EQ2Emulator>