-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: GameWingsAurasEffects connection server (#1)
* init with bug * fix compilation * fix missin packet * update lua
- Loading branch information
Showing
38 changed files
with
2,648 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<auras> | ||
<aura id="8" name="3 aura" speed="20" /> | ||
</auras> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<effects> | ||
<effect id="7" name="1 effect" speed="20" /> | ||
</effects> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<shaders> | ||
<shader id="1" name="Outfit - Rainbow" premium="no" /> | ||
<shader id="2" name="Outfit - Ghost" premium="no" /> | ||
<shader id="3" name="Outfit - Jelly" premium="no" /> | ||
<shader id="4" name="Outfit - Fragmented" premium="no" /> | ||
<shader id="5" name="Outfit - Outline" premium="no" /> | ||
|
||
</shaders> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<wings> | ||
<wing id="2" name="1 wings" speed="20" /> | ||
<wing id="11" name="11 wings" speed="20" /> | ||
</wings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
local mehah = { | ||
talkactions = { | ||
attacheffect = "!attacheffect", | ||
detachEffect = "!detacheffect", | ||
playerSetShader = "!playerSetShader", | ||
itemSetShader = "!itemSetShader", | ||
mapShader = "!mapShader" | ||
}, | ||
} | ||
|
||
local events = {} | ||
|
||
local function processCommand(player, words, param, type, action) | ||
if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then | ||
player:sendCancelMessage("No tienes acceso a este comando.") | ||
return false | ||
end | ||
|
||
local params, arg | ||
if param:find("\"") then | ||
params = { param:match("\"(.+)\",*(.*)") } | ||
arg = params[1] | ||
print(params) | ||
print(arg) | ||
pdump(params) | ||
else | ||
params = param:split(", ") | ||
arg = params[1] | ||
print("2",params) | ||
print("2",arg) | ||
end | ||
|
||
if not arg then | ||
player:sendCancelMessage("Parámetro inválido. Por favor proporciona un argumento válido.") | ||
return false | ||
end | ||
|
||
local creature | ||
if params[2] and params[2] ~= "" then | ||
creature = Player(params[2]) | ||
if not creature then | ||
player:sendCancelMessage("El nombre del jugador proporcionado no es válido.") | ||
return false | ||
end | ||
else | ||
creature = player | ||
end | ||
|
||
action(creature, arg) | ||
return false | ||
end | ||
|
||
local attachEffect = TalkAction(mehah.talkactions.attacheffect) | ||
function attachEffect.onSay(player, words, param, type) | ||
return processCommand(player, words, param, type, function(creature, effect) | ||
creature:attachEffectById(tonumber(effect), false) | ||
end) | ||
end | ||
table.insert(events, attachEffect) | ||
|
||
local detachEffect = TalkAction(mehah.talkactions.detachEffect) | ||
function detachEffect.onSay(player, words, param, type) | ||
return processCommand(player, words, param, type, function(creature, effect) | ||
creature:detachEffectById(tonumber(effect)) | ||
end) | ||
end | ||
table.insert(events, detachEffect) | ||
|
||
local setShader = TalkAction(mehah.talkactions.playerSetShader) | ||
function setShader.onSay(player, words, param, type) | ||
return processCommand(player, words, param, type, function(creature, shader) | ||
creature:setShader(shader) | ||
end) | ||
end | ||
table.insert(events, setShader) | ||
|
||
local mapShader = TalkAction(mehah.talkactions.mapShader) | ||
function mapShader.onSay(player, words, param, type) | ||
return processCommand(player, words, param, type, function(creature, shader) | ||
if creature:getMapShader() ~= shader then | ||
creature:setMapShader(shader, true) | ||
end | ||
end) | ||
end | ||
table.insert(events, mapShader) | ||
|
||
for _, event in ipairs(events) do | ||
event:accountType(ACCOUNT_TYPE_GOD) | ||
event:access(true) | ||
event:separator(" ") | ||
event:register() | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2023 The Forgotten Server Authors. All rights reserved. | ||
// Use of this source code is governed by the GPL-2.0 License that can be found in the LICENSE file. | ||
|
||
#include "otpch.h" | ||
|
||
#include "auras.h" | ||
|
||
#include "pugicast.h" | ||
#include "tools.h" | ||
|
||
bool Auras::reload() | ||
{ | ||
auras.clear(); | ||
return loadFromXml(); | ||
} | ||
|
||
bool Auras::loadFromXml() | ||
{ | ||
pugi::xml_document doc; | ||
pugi::xml_parse_result result = doc.load_file("data/XML/auras.xml"); | ||
if (!result) { | ||
printXMLError("Error - Auras::loadFromXml", "data/XML/auras.xml", result); | ||
return false; | ||
} | ||
|
||
for (auto auraNode : doc.child("auras").children()) { | ||
uint16_t nodeId = pugi::cast<uint16_t>(auraNode.attribute("id").value()); | ||
if (nodeId == 0 || nodeId > std::numeric_limits<uint16_t>::max()) { | ||
std::cout << "[Notice - Auras::loadFromXml] Aura id "" << nodeId << "" is not within 1 and 65535 range" | ||
<< std::endl; | ||
continue; | ||
} | ||
|
||
if (getAuraByID(nodeId)) { | ||
std::cout << "[Notice - Auras::loadFromXml] Duplicate aura with id: " << nodeId << std::endl; | ||
continue; | ||
} | ||
|
||
auras.emplace_back( | ||
static_cast<uint16_t>(nodeId), | ||
auraNode.attribute("name").as_string(), pugi::cast<int32_t>(auraNode.attribute("speed").value()), | ||
auraNode.attribute("premium").as_bool()); | ||
} | ||
auras.shrink_to_fit(); | ||
return true; | ||
} | ||
|
||
Aura* Auras::getAuraByID(uint16_t id) | ||
{ | ||
auto it = std::find_if(auras.begin(), auras.end(), [id](const Aura& aura) { return aura.id == id; }); | ||
|
||
return it != auras.end() ? &*it : nullptr; | ||
} | ||
|
||
Aura* Auras::getAuraByName(std::string_view name) | ||
{ | ||
for (auto& it : auras) { | ||
if (strcasecmp(name.data(), it.name.c_str()) == 0) { | ||
return ⁢ | ||
} | ||
} | ||
|
||
return nullptr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2023 The Forgotten Server Authors. All rights reserved. | ||
// Use of this source code is governed by the GPL-2.0 License that can be found in the LICENSE file. | ||
|
||
#ifndef FS_AURAS_H | ||
#define FS_AURAS_H | ||
|
||
struct Aura | ||
{ | ||
Aura(uint16_t id, std::string_view name, int32_t speed, bool premium) : | ||
name{name}, speed{speed}, id{id}, premium{premium} | ||
{} | ||
|
||
std::string name; | ||
int32_t speed; | ||
|
||
uint16_t id; | ||
bool premium; | ||
}; | ||
|
||
class Auras | ||
{ | ||
public: | ||
bool reload(); | ||
bool loadFromXml(); | ||
Aura* getAuraByID(uint16_t id); | ||
Aura* getAuraByName(std::string_view name); | ||
|
||
|
||
const std::vector<Aura>& getAuras() const { return auras; } | ||
|
||
private: | ||
std::vector<Aura> auras; | ||
}; | ||
|
||
#endif // FS_AURAS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
77f80d5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protocolgame.cpp
protocolgame.h