2 Commity ace2e20281 ... 0f5ef8615b

Autor SHA1 Wiadomość Data
  Devn00b 0f5ef8615b Merge branch 'master' of https://git.eq2emu.com/devn00b/EQ2EMu 1 rok temu
  Devn00b f38b6fb788 Fix for issue #242. Added GetCanEvac/SetCanEvac lua function. Example code found in server/spells/scout/escape.lua 1 rok temu

+ 25 - 0
EQ2/source/WorldServer/LuaFunctions.cpp

@@ -11656,6 +11656,31 @@ int EQ2Emu_lua_GetCanGate(lua_State* state) {
 	return 0;
 }
 
+int EQ2Emu_lua_SetCanEvac(lua_State* state) {
+	if (!lua_interface)
+		return 0;
+	Spawn* player = lua_interface->GetSpawn(state);
+	ZoneServer* zone = player->GetZone();
+	bool canevac = lua_interface->GetInt32Value(state, 2);
+	lua_interface->ResetFunctionStack(state);
+	if (zone)
+		zone->SetCanEvac(canevac);
+	return 0;
+}
+
+int EQ2Emu_lua_GetCanEvac(lua_State* state) {
+	if (!lua_interface)
+		return 0;
+	Spawn* player = lua_interface->GetSpawn(state);
+	ZoneServer* zone = player->GetZone();
+	lua_interface->ResetFunctionStack(state);
+	if (zone) {
+		lua_interface->SetInt32Value(state, zone->GetCanEvac());
+		return 1;
+	}
+	return 0;
+}
+
 int EQ2Emu_lua_AddSpawnProximity(lua_State* state) {
 	if (!lua_interface)
 		return 0;

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

@@ -519,6 +519,9 @@ int EQ2Emu_lua_GetCanBind(lua_State* state);
 int EQ2Emu_lua_GetCanGate(lua_State* state);
 int EQ2Emu_lua_SetCanGate(lua_State* state);
 
+int EQ2Emu_lua_GetCanEvac(lua_State* state);
+int EQ2Emu_lua_SetCanEvac(lua_State* state);
+
 int EQ2Emu_lua_AddSpawnProximity(lua_State* state);
 
 int EQ2Emu_lua_CanSeeInvis(lua_State* state);

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

@@ -1392,6 +1392,9 @@ void LuaInterface::RegisterFunctions(lua_State* state) {
 	lua_register(state, "GetCanGate", EQ2Emu_lua_GetCanGate);
     lua_register(state, "SetCanGate", EQ2Emu_lua_SetCanGate);
 
+	lua_register(state, "SetCanEvac", EQ2Emu_lua_SetCanEvac);
+	lua_register(state, "GetCanEvac", EQ2Emu_lua_GetCanEvac);
+
 	lua_register(state, "AddSpawnProximity", EQ2Emu_lua_AddSpawnProximity);
 
 	lua_register(state, "CanSeeInvis", EQ2Emu_lua_CanSeeInvis);

+ 2 - 1
EQ2/source/WorldServer/WorldDatabase.cpp

@@ -2815,7 +2815,7 @@ void WorldDatabase::LoadZoneInfo(ZoneServer* zone){
 	Query query;
 	int32 ruleset_id;
 	char* escaped = getEscapeString(zone->GetZoneName());
-	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT id, file, description, underworld, safe_x, safe_y, safe_z, min_status, min_level, max_level, instance_type+0, shutdown_timer, zone_motd, default_reenter_time, default_reset_time, default_lockout_time, force_group_to_zone, safe_heading, xp_modifier, ruleset_id, expansion_id, weather_allowed, sky_file, can_bind, can_gate, city_zone FROM zones where name='%s'",escaped);
+	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT id, file, description, underworld, safe_x, safe_y, safe_z, min_status, min_level, max_level, instance_type+0, shutdown_timer, zone_motd, default_reenter_time, default_reset_time, default_lockout_time, force_group_to_zone, safe_heading, xp_modifier, ruleset_id, expansion_id, weather_allowed, sky_file, can_bind, can_gate, city_zone, can_evac FROM zones where name='%s'",escaped);
 	if(result && mysql_num_rows(result) > 0) {
 		MYSQL_ROW row;
 		row = mysql_fetch_row(result);
@@ -2864,6 +2864,7 @@ void WorldDatabase::LoadZoneInfo(ZoneServer* zone){
 		zone->SetCanBind(atoul(row[23]));
 		zone->SetCanGate(atoul(row[24]));
       	zone->SetCityZone(atoi(row[25]));
+		zone->SetCanEvac(atoul(row[26]));
 	}
 	safe_delete_array(escaped);
 }

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

@@ -619,6 +619,9 @@ public:
 	bool	GetCanGate() { return can_gate; }
 	void	SetCanGate(int32 val) { can_gate = val; }
 
+	bool	GetCanEvac() { return can_evac; }
+	void	SetCanEvac(int32 val) { can_evac = val; }
+
 	void	RemoveClientImmediately(Client* client);
 
 	void	ClearHate(Entity* entity);
@@ -956,6 +959,7 @@ private:
 	//devn00b:test
 	int		can_bind;
 	bool	can_gate;
+	bool	can_evac;
 
 	map<int16, PacketStruct*> versioned_pos_structs;
 	map<int16, PacketStruct*> versioned_info_structs;

+ 12 - 0
server/Spells/Scout/Escape.lua

@@ -8,6 +8,18 @@
 
 
 -- Teleports caster and caster's group within the zone
+
+function precast(Caster, Target)
+    if(GetCanEvac(Caster) == 1)
+    then
+        return true   
+    else
+        SendMessage(Caster, "You cannot use evacuate spells in this zone.", "red")
+        return false
+    end
+    return true
+end
+
 function cast(Caster, Target)
     Evac()
 end