-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4823 from LandSandBoat/tredecim_scythe
[core, Lua] Implement Tredecim Scythe
- Loading branch information
Showing
7 changed files
with
148 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
----------------------------------- | ||
-- ID: 18052 | ||
-- Tredecim Scythe | ||
----------------------------------- | ||
local itemObject = {} | ||
|
||
itemObject.onItemEquip = function(target, item) | ||
target:addListener('MELEE_SWING_HIT', 'TREDECIM_MELEE_SWING_HIT', function(playerArg, targetArg, attackArg) | ||
local mainWeapon = playerArg:getEquippedItem(xi.slot.MAIN) | ||
if mainWeapon and mainWeapon:getID() == xi.item.TREDECIM_SCYTHE then | ||
local exData = mainWeapon:getExData() | ||
local count = exData[0] | ||
|
||
if count % 13 == 12 then | ||
attackArg:setCritical(true) | ||
end | ||
|
||
exData[0] = (count + 1) % 13 | ||
|
||
mainWeapon:setExData(exData) | ||
end | ||
end) | ||
end | ||
|
||
itemObject.onItemUnequip = function(target, item) | ||
target:removeListener('TREDECIM_MELEE_SWING_HIT') | ||
end | ||
|
||
return itemObject |
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,61 @@ | ||
/* | ||
=========================================================================== | ||
Copyright (c) 2023 LandSandBoat Dev Teams | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see http://www.gnu.org/licenses/ | ||
=========================================================================== | ||
*/ | ||
|
||
#include "lua_attack.h" | ||
|
||
#include "attack.h" | ||
|
||
CLuaAttack::CLuaAttack(CAttack* attack) | ||
: m_PLuaAttack(attack) | ||
{ | ||
if (m_PLuaAttack == nullptr) | ||
{ | ||
ShowError("CLuaAttack created with nullptr instead of valid CAttack*!"); | ||
} | ||
} | ||
|
||
bool CLuaAttack::getCritical() const | ||
{ | ||
return m_PLuaAttack->IsCritical(); | ||
} | ||
|
||
void CLuaAttack::setCritical(bool critical) | ||
{ | ||
m_PLuaAttack->SetCritical(critical); | ||
} | ||
|
||
//==========================================================// | ||
|
||
void CLuaAttack::Register() | ||
{ | ||
SOL_USERTYPE("CAttack", CLuaAttack); | ||
SOL_REGISTER("getCritical", CLuaAttack::getCritical); | ||
SOL_REGISTER("setCritical", CLuaAttack::setCritical); | ||
}; | ||
|
||
std::ostream& operator<<(std::ostream& os, const CLuaAttack& attack) | ||
{ | ||
// TODO: Whats a sane log value for this? | ||
std::string id = attack.m_PLuaAttack ? "" : "nullptr"; | ||
return os << "CLuaAttack(" << id << ")"; | ||
} | ||
|
||
//==========================================================// |
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,52 @@ | ||
/* | ||
=========================================================================== | ||
Copyright (c) 2023 LandSandBoat Dev Teams | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see http://www.gnu.org/licenses/ | ||
=========================================================================== | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "common/cbasetypes.h" | ||
#include "luautils.h" | ||
|
||
class CAttack; | ||
|
||
class CLuaAttack | ||
{ | ||
CAttack* m_PLuaAttack; | ||
|
||
public: | ||
CLuaAttack(CAttack*); | ||
|
||
CAttack* GetAttack() const | ||
{ | ||
return m_PLuaAttack; | ||
} | ||
|
||
bool getCritical() const; | ||
void setCritical(bool critical); | ||
|
||
friend std::ostream& operator<<(std::ostream& out, const CLuaAttack& action); | ||
|
||
bool operator==(const CLuaAttack& other) const | ||
{ | ||
return this->m_PLuaAttack == other.m_PLuaAttack; | ||
} | ||
|
||
static void Register(); | ||
}; |
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