MCPcopy Create free account
hub / github.com/EasyRPG/Player / IsItemUsable

Method IsItemUsable

src/game_actor.cpp:199–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199bool Game_Actor::IsItemUsable(int item_id) const {
200 const lcf::rpg::Item* item = lcf::ReaderUtil::GetElement(lcf::Data::items, item_id);
201 if (!item) {
202 Output::Warning("IsItemUsable: Invalid item ID {}", item_id);
203 return false;
204 }
205
206 int query_idx = GetId() - 1;
207 auto* query_set = &item->actor_set;
208 if (Player::IsRPG2k3() && lcf::Data::system.equipment_setting == lcf::rpg::System::EquipmentSetting_class) {
209 auto* cls = GetClass();
210
211 // Class index. If there's no class, in the "class_set" it's equal to 0. The first class is 1, not 0
212 query_idx = cls ? cls->ID : 0;
213 query_set = &item->class_set;
214 }
215
216 // If the actor or class ID is out of range this is an optimization in the ldb file
217 // (all actors or classes missing can equip the item)
218 if (query_set->size() <= (unsigned)(query_idx)) {
219 return true;
220 }
221 return (*query_set)[query_idx];
222}
223
224bool Game_Actor::IsSkillLearned(int skill_id) const {
225 return std::find(data.skills.begin(), data.skills.end(), skill_id) != data.skills.end();

Callers 2

vExecuteMethod · 0.45
CheckEnableMethod · 0.45

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected