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


C++ NPC::setTimeAICheck方法代码示例

本文整理汇总了C++中NPC::setTimeAICheck方法的典型用法代码示例。如果您正苦于以下问题:C++ NPC::setTimeAICheck方法的具体用法?C++ NPC::setTimeAICheck怎么用?C++ NPC::setTimeAICheck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NPC的用法示例。


在下文中一共展示了NPC::setTimeAICheck方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: runMap

void WorldServer::runMap(Map* curMap) {
	if (!curMap)
		return;
#else
void runMap(Map* curMap) {
	if (!curMap)
		return;
	ChronoTimer t;
	dword_t timePerFrame = (1000 / 60);
	do {
		long long timeDiff = timePerFrame - (t.getDuration());
		t.update();
		if (timeDiff > 0) {
			Sleep(timeDiff);
		}
		if (!curMap->hasActivePlayers()) {
			continue;
		}
#endif
	Player* curPlayer = nullptr;
	NPC* curNPC = nullptr;
	Map::Sector* newSector = nullptr;

	LinkedList<Entity*> entityToRemove;
	for(unsigned int i=0;i<curMap->getSectorCount();i++) {
		Map::Sector* curSector = curMap->getSector(i);
		LinkedList<Entity*>::Node* entityNode = curSector->getFirstEntity();
		bool updateNextNode = false;
		while(entityNode) {
			if(updateNextNode) {
				entityNode = entityNode->getNextNode();
				if(!entityNode)
					break;
			} 
			updateNextNode = true;
			Entity* curEntity = entityNode->getValue();
			if (!curEntity || !curEntity->isIngame() || curEntity->getEntityType() == Entity::TYPE_DROP) {
				continue;
			}
			byte_t result = curEntity->movementRoutine();
			if (result & Entity::Movement::INITIAL_ATTACK) {
				curEntity->getAttackAnimation();
			}
			if (result & Entity::Movement::TARGET_REACHED) {
				bool isProcFrameReached = curEntity->playAnimation();
			}
			if ((newSector = curEntity->checkForNewSector()) != nullptr) {
				entityNode = curEntity->setSector(newSector);
				curEntity->checkVisuality();
				if (entityNode) {//in case we have a valid succeeding node
					updateNextNode = false;
				}
			}
			switch (curEntity->getEntityType()) {
				case Entity::TYPE_PLAYER:
					curPlayer = dynamic_cast<Player*>(curEntity);
					curPlayer->checkRegeneration();
				break;
				case Entity::TYPE_NPC:
				case Entity::TYPE_MONSTER:
					curNPC = dynamic_cast<NPC*>(curEntity);
					if (result == Entity::Movement::IDLE) {
						//In case the NPC/Monster is idling
						//run AI with state "IDLE"
						if(curEntity->getTarget() == NULL) {
							AIService::run(curNPC, AIP::ON_IDLE);
						} else {
							AIService::run(curNPC, AIP::ON_ATTACK);
						}
					} else {
						//In case it's walking and has no target
						//i.e. walking around/away
						if (curEntity->getTarget() == NULL) {
							curNPC->setTimeAICheck();
						} else {
							AIService::run(curNPC, AIP::ON_ATTACK);
						}
					}
				break;
			}
		}
	}
	curMap->checkSpawns();
#ifdef __ROSE_MULTI_THREADED__
	} while (true);
#endif
	
}

bool WorldServer::loadSTBs() {

	std::cout << "Reading all STBs...\r";
#ifdef __ROSE_USE_VFS__	
	VFSData fileBuf;
	this->aiFile = new AISTB(this->vfs, "3DDATA\\STB\\FILE_AI.STB");
	this->npcFile = new NPCSTB(this->vfs, "3DDATA\\STB\\LIST_NPC.STB");
	this->skillFile = new SkillSTB(this->vfs, "3DDATA\\STB\\LIST_SKILL.STB");
	this->dropFile = new STBFile(this->vfs, "3DDATA\\STB\\ITEM_DROP.STB");
	this->zoneFile = new ZoneSTB(this->vfs, "3DDATA\\STB\\LIST_ZONE.STB");
	this->questFile = new STBFile(this->vfs, "3DDATA\\STB\\LIST_QUEST.STB", false);
//.........这里部分代码省略.........
开发者ID:DerBasti,项目名称:DreamROSE,代码行数:101,代码来源:WorldServer.cpp


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