当前位置: 首页>>代码示例>>C++>>正文


C++ Npc::checkEnd方法代码示例

本文整理汇总了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?
	}
}
开发者ID:JakeShirley,项目名称:Vana,代码行数:43,代码来源:InventoryHandler.cpp


注:本文中的Npc::checkEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。