本文整理汇总了C++中Npc::checkEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ Npc::checkEnd方法的具体用法?C++ Npc::checkEnd怎么用?C++ Npc::checkEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Npc
的用法示例。
在下文中一共展示了Npc::checkEnd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleScriptItem
void InventoryHandler::handleScriptItem(Player *player, PacketReader &packet) {
if (player->getNpc() != nullptr || player->getShop() != 0 || player->getTradeId() != 0) {
// Player is busy :O! Hack
InventoryPacket::blankUpdate(player); // We don't want stuck players, do we?
return;
}
if (!player->updateTickCount(packet.get<int32_t>())) {
// Tickcount was the same or less than 100 of the difference.
return;
}
int16_t slot = packet.get<int16_t>();
int32_t itemid = packet.get<int32_t>();
Item *item = player->getInventory()->getItem(Inventories::UseInventory, slot);
if (item == nullptr || item->getId() != itemid) {
// Hacking or hacking failure
InventoryPacket::blankUpdate(player); // We don't want stuck players, do we?
return;
}
string scriptName = ScriptDataProvider::Instance()->getItemScript(itemid);
if (scriptName == "") {
// Hacking or no script for item found.
InventoryPacket::blankUpdate(player); // We don't want stuck players, do we?
return;
}
int32_t npcid = ItemDataProvider::Instance()->getItemNpc(itemid);
// Lets run the NPC!
Npc *npc = new Npc(npcid, player, scriptName);
if (!npc->checkEnd()) {
// NPC is running/script found!
// Delete the item used.
Inventory::takeItem(player, itemid, 1);
npc->run();
}
else {
// NPC didn't ran/no script found O.o! Lets unstuck the player.
InventoryPacket::blankUpdate(player); // We don't want stuck players, do we?
}
}