-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(skymp5-server): add onEatItem, onDropItem gamemode events & impl…
…ement Potion.IsFood (#2085)
- Loading branch information
Showing
8 changed files
with
135 additions
and
42 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
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
28 changes: 28 additions & 0 deletions
28
skymp5-server/cpp/server_guest_lib/script_classes/PapyrusPotion.cpp
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,28 @@ | ||
#include "PapyrusPotion.h" | ||
#include "script_objects/EspmGameObject.h" | ||
|
||
VarValue PapyrusPotion::IsFood(VarValue self, | ||
const std::vector<VarValue>& arguments) | ||
{ | ||
const auto& item = GetRecordPtr(self); | ||
|
||
if (!item.rec) { | ||
return VarValue(false); | ||
} | ||
|
||
auto alch = espm::Convert<espm::ALCH>(item.rec); | ||
|
||
if (!alch) { | ||
return VarValue(false); | ||
} | ||
|
||
espm::CompressedFieldsCache cache; | ||
espm::ALCH::Data data = alch->GetData(cache); | ||
return VarValue(data.isFood); | ||
} | ||
|
||
void PapyrusPotion::Register( | ||
VirtualMachine& vm, std::shared_ptr<IPapyrusCompatibilityPolicy> policy) | ||
{ | ||
AddMethod(vm, "IsFood", &PapyrusPotion::IsFood); | ||
} |
16 changes: 16 additions & 0 deletions
16
skymp5-server/cpp/server_guest_lib/script_classes/PapyrusPotion.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
#include "IPapyrusClass.h" | ||
#include "SpSnippetFunctionGen.h" | ||
|
||
class PapyrusPotion final : public IPapyrusClass<PapyrusPotion> | ||
{ | ||
public: | ||
const char* GetName() override { return "potion"; } | ||
|
||
VarValue IsFood(VarValue self, const std::vector<VarValue>& arguments); | ||
|
||
void Register(VirtualMachine& vm, | ||
std::shared_ptr<IPapyrusCompatibilityPolicy> policy) override; | ||
|
||
std::shared_ptr<IPapyrusCompatibilityPolicy> compatibilityPolicy; | ||
}; |
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