mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Remove Weather functions and type, add Map:SetWeather
Weather hook changes
This commit is contained in:
@@ -2051,76 +2051,6 @@ namespace LuaGlobalFunctions
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the [Weather] for a zone.
|
|
||||||
*
|
|
||||||
* @param uint32 zoneId : zone Id to check for [Weather]
|
|
||||||
* @return [Weather] weather
|
|
||||||
*/
|
|
||||||
int FindWeather(Eluna* /*E*/, lua_State* L)
|
|
||||||
{
|
|
||||||
uint32 zoneId = Eluna::CHECKVAL<uint32>(L, 1);
|
|
||||||
#ifndef TRINITY
|
|
||||||
Weather* weather = eWorld->FindWeather(zoneId);
|
|
||||||
#else
|
|
||||||
Weather* weather = WeatherMgr::FindWeather(zoneId);
|
|
||||||
#endif
|
|
||||||
Eluna::Push(L, weather);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds weather to a zone and returns the new [Weather] object.
|
|
||||||
*
|
|
||||||
* @param uint32 zoneId : zone Id to add [Weather]
|
|
||||||
* @return [Weather] weather
|
|
||||||
*/
|
|
||||||
int AddWeather(Eluna* /*E*/, lua_State* L)
|
|
||||||
{
|
|
||||||
uint32 zoneId = Eluna::CHECKVAL<uint32>(L, 1);
|
|
||||||
#ifndef TRINITY
|
|
||||||
Weather* weather = eWorld->AddWeather(zoneId);
|
|
||||||
#else
|
|
||||||
Weather* weather = WeatherMgr::AddWeather(zoneId);
|
|
||||||
#endif
|
|
||||||
Eluna::Push(L, weather);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes [Weather] from a zone.
|
|
||||||
*
|
|
||||||
* @param uint32 zoneId : zone Id to remove [Weather]
|
|
||||||
*/
|
|
||||||
int RemoveWeather(Eluna* /*E*/, lua_State* L)
|
|
||||||
{
|
|
||||||
uint32 zoneId = Eluna::CHECKVAL<uint32>(L, 1);
|
|
||||||
#ifndef TRINITY
|
|
||||||
eWorld->RemoveWeather(zoneId);
|
|
||||||
#else
|
|
||||||
WeatherMgr::RemoveWeather(zoneId);
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a clear weather packet to a [Player].
|
|
||||||
*
|
|
||||||
* Does not affect other [Player]s in the same zone, or affect the zone.
|
|
||||||
*
|
|
||||||
* @param [Player] player : [Player] to send the normal weather to
|
|
||||||
*/
|
|
||||||
int SendFineWeatherToPlayer(Eluna* /*E*/, lua_State* L)
|
|
||||||
{
|
|
||||||
Player* player = Eluna::CHECKOBJ<Player>(L, 1);
|
|
||||||
#ifndef TRINITY
|
|
||||||
Weather::SendFineWeatherUpdateToPlayer(player);
|
|
||||||
#else
|
|
||||||
WeatherMgr::SendFineWeatherUpdateToPlayer(player);
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns `true` if the bag and slot is a valid inventory position, otherwise `false`.
|
* Returns `true` if the bag and slot is a valid inventory position, otherwise `false`.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -273,13 +273,13 @@ bool Eluna::OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* pTrigger)
|
|||||||
return CallAllFunctionsBool(ServerEventBindings, TRIGGER_EVENT_ON_TRIGGER);
|
return CallAllFunctionsBool(ServerEventBindings, TRIGGER_EVENT_ON_TRIGGER);
|
||||||
}
|
}
|
||||||
// weather
|
// weather
|
||||||
void Eluna::OnChange(Weather* weather, WeatherState state, float grade)
|
void Eluna::OnChange(Weather* weather, uint32 zone, WeatherState state, float grade)
|
||||||
{
|
{
|
||||||
if (!ServerEventBindings->HasEvents(WEATHER_EVENT_ON_CHANGE))
|
if (!ServerEventBindings->HasEvents(WEATHER_EVENT_ON_CHANGE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LOCK_ELUNA;
|
LOCK_ELUNA;
|
||||||
Push(weather->GetZone());
|
Push(zone);
|
||||||
Push(state);
|
Push(state);
|
||||||
Push(grade);
|
Push(grade);
|
||||||
CallAllFunctions(ServerEventBindings, WEATHER_EVENT_ON_CHANGE);
|
CallAllFunctions(ServerEventBindings, WEATHER_EVENT_ON_CHANGE);
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace HookMgr
|
|||||||
TRIGGER_EVENT_ON_TRIGGER = 24, // (event, player, triggerId) - Can return true
|
TRIGGER_EVENT_ON_TRIGGER = 24, // (event, player, triggerId) - Can return true
|
||||||
|
|
||||||
// Weather
|
// Weather
|
||||||
WEATHER_EVENT_ON_CHANGE = 25, // (event, weather, state, grade)
|
WEATHER_EVENT_ON_CHANGE = 25, // (event, zoneId, state, grade)
|
||||||
|
|
||||||
// Auction house
|
// Auction house
|
||||||
AUCTION_EVENT_ON_ADD = 26, // (event, AHObject)
|
AUCTION_EVENT_ON_ADD = 26, // (event, AHObject)
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ public:
|
|||||||
bool OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* pTrigger);
|
bool OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* pTrigger);
|
||||||
|
|
||||||
/* Weather */
|
/* Weather */
|
||||||
void OnChange(Weather* weather, WeatherState state, float grade);
|
void OnChange(Weather* weather, uint32 zone, WeatherState state, float grade);
|
||||||
|
|
||||||
/* Auction House */
|
/* Auction House */
|
||||||
void OnAdd(AuctionHouseObject* auctionHouse);
|
void OnAdd(AuctionHouseObject* auctionHouse);
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ extern "C"
|
|||||||
#include "QuestMethods.h"
|
#include "QuestMethods.h"
|
||||||
#include "MapMethods.h"
|
#include "MapMethods.h"
|
||||||
#include "CorpseMethods.h"
|
#include "CorpseMethods.h"
|
||||||
#include "WeatherMethods.h"
|
|
||||||
#include "VehicleMethods.h"
|
#include "VehicleMethods.h"
|
||||||
#include "BattleGroundMethods.h"
|
#include "BattleGroundMethods.h"
|
||||||
|
|
||||||
@@ -137,10 +136,6 @@ ElunaGlobal::ElunaRegister GlobalMethods[] =
|
|||||||
{ "RemoveCorpse", &LuaGlobalFunctions::RemoveCorpse },
|
{ "RemoveCorpse", &LuaGlobalFunctions::RemoveCorpse },
|
||||||
{ "ConvertCorpseForPlayer", &LuaGlobalFunctions::ConvertCorpseForPlayer },
|
{ "ConvertCorpseForPlayer", &LuaGlobalFunctions::ConvertCorpseForPlayer },
|
||||||
{ "RemoveOldCorpses", &LuaGlobalFunctions::RemoveOldCorpses },
|
{ "RemoveOldCorpses", &LuaGlobalFunctions::RemoveOldCorpses },
|
||||||
{ "FindWeather", &LuaGlobalFunctions::FindWeather },
|
|
||||||
{ "AddWeather", &LuaGlobalFunctions::AddWeather },
|
|
||||||
{ "RemoveWeather", &LuaGlobalFunctions::RemoveWeather },
|
|
||||||
{ "SendFineWeatherToPlayer", &LuaGlobalFunctions::SendFineWeatherToPlayer },
|
|
||||||
{ "CreateInt64", &LuaGlobalFunctions::CreateLongLong },
|
{ "CreateInt64", &LuaGlobalFunctions::CreateLongLong },
|
||||||
{ "CreateUint64", &LuaGlobalFunctions::CreateULongLong },
|
{ "CreateUint64", &LuaGlobalFunctions::CreateULongLong },
|
||||||
|
|
||||||
@@ -1190,6 +1185,9 @@ ElunaRegister<Map> MapMethods[] =
|
|||||||
{ "GetHeight", &LuaMap::GetHeight }, // :GetHeight(x, y[, phasemask]) - Returns ground Z coordinate. UNDOCUMENTED
|
{ "GetHeight", &LuaMap::GetHeight }, // :GetHeight(x, y[, phasemask]) - Returns ground Z coordinate. UNDOCUMENTED
|
||||||
{ "GetWorldObject", &LuaMap::GetWorldObject }, // :GetWorldObject(guid) - Returns a worldobject (player, creature, gameobject..) from the map by it's guid
|
{ "GetWorldObject", &LuaMap::GetWorldObject }, // :GetWorldObject(guid) - Returns a worldobject (player, creature, gameobject..) from the map by it's guid
|
||||||
|
|
||||||
|
// Setters
|
||||||
|
{ "SetWeather", &LuaMap::SetWeather },
|
||||||
|
|
||||||
// Booleans
|
// Booleans
|
||||||
#ifndef CLASSIC
|
#ifndef CLASSIC
|
||||||
{ "IsArena", &LuaMap::IsArena }, // :IsArena() - Returns the true if the map is an arena, else false UNDOCUMENTED
|
{ "IsArena", &LuaMap::IsArena }, // :IsArena() - Returns the true if the map is an arena, else false UNDOCUMENTED
|
||||||
@@ -1217,24 +1215,6 @@ ElunaRegister<Corpse> CorpseMethods[] =
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
ElunaRegister<Weather> WeatherMethods[] =
|
|
||||||
{
|
|
||||||
// Getters
|
|
||||||
{ "GetZoneId", &LuaWeather::GetZoneId },
|
|
||||||
|
|
||||||
// Setters
|
|
||||||
{ "SetWeather", &LuaWeather::SetWeather },
|
|
||||||
|
|
||||||
// Boolean
|
|
||||||
{ "Regenerate", &LuaWeather::Regenerate },
|
|
||||||
{ "UpdateWeather", &LuaWeather::UpdateWeather },
|
|
||||||
|
|
||||||
// Other
|
|
||||||
{ "SendWeatherUpdateToPlayer", &LuaWeather::SendWeatherUpdateToPlayer },
|
|
||||||
|
|
||||||
{ NULL, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
ElunaRegister<AuctionHouseObject> AuctionMethods[] =
|
ElunaRegister<AuctionHouseObject> AuctionMethods[] =
|
||||||
{
|
{
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
@@ -1397,9 +1377,6 @@ void RegisterFunctions(Eluna* E)
|
|||||||
ElunaTemplate<Map>::Register(E, "Map");
|
ElunaTemplate<Map>::Register(E, "Map");
|
||||||
ElunaTemplate<Map>::SetMethods(E, MapMethods);
|
ElunaTemplate<Map>::SetMethods(E, MapMethods);
|
||||||
|
|
||||||
ElunaTemplate<Weather>::Register(E, "Weather");
|
|
||||||
ElunaTemplate<Weather>::SetMethods(E, WeatherMethods);
|
|
||||||
|
|
||||||
ElunaTemplate<AuctionHouseObject>::Register(E, "AuctionHouseObject");
|
ElunaTemplate<AuctionHouseObject>::Register(E, "AuctionHouseObject");
|
||||||
ElunaTemplate<AuctionHouseObject>::SetMethods(E, AuctionMethods);
|
ElunaTemplate<AuctionHouseObject>::SetMethods(E, AuctionMethods);
|
||||||
|
|
||||||
|
|||||||
42
MapMethods.h
42
MapMethods.h
@@ -235,5 +235,47 @@ namespace LuaMap
|
|||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the [Weather] type based on [WeatherType] and grade supplied.
|
||||||
|
*
|
||||||
|
* enum WeatherType
|
||||||
|
* {
|
||||||
|
* WEATHER_TYPE_FINE = 0,
|
||||||
|
* WEATHER_TYPE_RAIN = 1,
|
||||||
|
* WEATHER_TYPE_SNOW = 2,
|
||||||
|
* WEATHER_TYPE_STORM = 3,
|
||||||
|
* WEATHER_TYPE_THUNDERS = 86,
|
||||||
|
* WEATHER_TYPE_BLACKRAIN = 90
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* @param uint32 zone : id of the zone to set the weather for
|
||||||
|
* @param [WeatherType] type : the [WeatherType], see above available weather types
|
||||||
|
* @param float grade : the intensity/grade of the [Weather], ranges from 0 to 1
|
||||||
|
*/
|
||||||
|
int SetWeather(Eluna* /*E*/, lua_State* L, Map* map)
|
||||||
|
{
|
||||||
|
uint32 zoneId = Eluna::CHECKVAL<uint32>(L, 2);
|
||||||
|
uint32 weatherType = Eluna::CHECKVAL<uint32>(L, 3);
|
||||||
|
float grade = Eluna::CHECKVAL<float>(L, 4);
|
||||||
|
|
||||||
|
#if (defined(CMANGOS) && defined(WOTLK))
|
||||||
|
if (Weather::IsValidWeatherType(weatherType))
|
||||||
|
map->SetWeather(zoneId, (WeatherType)weatherType, grade, false);
|
||||||
|
#else
|
||||||
|
#ifdef TRINITY
|
||||||
|
Weather* weather = WeatherMgr::FindWeather(zoneId);
|
||||||
|
if (!weather)
|
||||||
|
weather = WeatherMgr::AddWeather(zoneId);
|
||||||
|
#else
|
||||||
|
Weather* weather = eWorld->FindWeather(zoneId);
|
||||||
|
if (!weather)
|
||||||
|
weather = eWorld->AddWeather(zoneId);
|
||||||
|
#endif
|
||||||
|
if (weather)
|
||||||
|
weather->SetWeather((WeatherType)weatherType, grade);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2010 - 2015 Eluna Lua Engine <http://emudevs.com/>
|
|
||||||
* This program is free software licensed under GPL version 3
|
|
||||||
* Please see the included DOCS/LICENSE.md for more information
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WEATHERMETHODS_H
|
|
||||||
#define WEATHERMETHODS_H
|
|
||||||
|
|
||||||
namespace LuaWeather
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Returns the zone id of the [Weather]
|
|
||||||
*
|
|
||||||
* @return uint32 zoneId
|
|
||||||
*/
|
|
||||||
int GetZoneId(Eluna* /*E*/, lua_State* L, Weather* weather)
|
|
||||||
{
|
|
||||||
Eluna::Push(L, weather->GetZone());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the [Weather] type based on [WeatherType] and grade supplied.
|
|
||||||
*
|
|
||||||
* <pre>
|
|
||||||
* enum WeatherType
|
|
||||||
* {
|
|
||||||
* WEATHER_TYPE_FINE = 0,
|
|
||||||
* WEATHER_TYPE_RAIN = 1,
|
|
||||||
* WEATHER_TYPE_SNOW = 2,
|
|
||||||
* WEATHER_TYPE_STORM = 3,
|
|
||||||
* WEATHER_TYPE_THUNDERS = 86,
|
|
||||||
* WEATHER_TYPE_BLACKRAIN = 90
|
|
||||||
* };
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @param WeatherType type : the [WeatherType], see above available weather types
|
|
||||||
* @param float grade : the intensity/grade of the [Weather], ranges from 0 to 1
|
|
||||||
*/
|
|
||||||
int SetWeather(Eluna* /*E*/, lua_State* L, Weather* weather)
|
|
||||||
{
|
|
||||||
uint32 weatherType = Eluna::CHECKVAL<uint32>(L, 2);
|
|
||||||
float grade = Eluna::CHECKVAL<float>(L, 3);
|
|
||||||
|
|
||||||
weather->SetWeather((WeatherType)weatherType, grade);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a [Weather] update to the [Player] supplied.
|
|
||||||
*
|
|
||||||
* @param [Player] player
|
|
||||||
*/
|
|
||||||
int SendWeatherUpdateToPlayer(Eluna* /*E*/, lua_State* L, Weather* weather)
|
|
||||||
{
|
|
||||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
|
||||||
|
|
||||||
weather->SendWeatherUpdateToPlayer(player);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Regenerates the [Weather], causing it to change based on the below statistics.
|
|
||||||
*
|
|
||||||
* * 30% chance of no change
|
|
||||||
* * 30% chance of [Weather] getting better (if not fine) or changing [Weather] type
|
|
||||||
* * 30% chance of [Weather] getting worse (if not fine)
|
|
||||||
* * 10% chance of radical change (if not fine)
|
|
||||||
*
|
|
||||||
* @return bool changed : returns 'true' if [Weather] changed
|
|
||||||
*/
|
|
||||||
int Regenerate(Eluna* /*E*/, lua_State* L, Weather* weather)
|
|
||||||
{
|
|
||||||
Eluna::Push(L, weather->ReGenerate());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a [Weather] update to the all [Player] in the zone.
|
|
||||||
*
|
|
||||||
* @param bool changed : returns 'true' if weather changed for any [Player] in the zone, 'false' if no [Player] is within the zone
|
|
||||||
*/
|
|
||||||
int UpdateWeather(Eluna* /*E*/, lua_State* L, Weather* weather)
|
|
||||||
{
|
|
||||||
Eluna::Push(L, weather->UpdateWeather());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user