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


C++ SpectatorVec类代码示例

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


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

示例1: getPosition

void Tile::onUpdateTile()
{
	const Position& cylinderMapPos = getPosition();

	SpectatorVec list;
	SpectatorVec::iterator it;
	g_game.getSpectators(Range(cylinderMapPos, true), list);

	//send to client
	Player* player = NULL;
	for(it = list.begin(); it != list.end(); ++it){
		if(player = (*it)->getPlayer()){
			player->sendUpdateTile(cylinderMapPos);
		}
	}

	g_game.isExecutingEvents = true;

	//event methods
	for(it = list.begin(); it != list.end(); ++it){
		(*it)->onUpdateTile(cylinderMapPos);
	}

	g_game.isExecutingEvents = false;
}
开发者ID:divinity76,项目名称:server,代码行数:25,代码来源:tile.cpp

示例2: updateTileFlags

void Tile::onRemoveTileItem(const SpectatorVec& list, std::vector<uint32_t>& oldStackPosVector, Item* item)
{
	if (item->hasProperty(MOVEABLE) || item->getContainer()) {
		Game::BrowseFieldMap::const_iterator it = g_game.browseFields.find(this);
		if (it != g_game.browseFields.end()) {
			it->second->__removeThing(item, item->getItemCount());
		}
	}

	updateTileFlags(item, true);

	const Position& cylinderMapPos = getPosition();
	const ItemType& iType = Item::items[item->getID()];

	SpectatorVec::const_iterator end = list.end();

	//send to client
	int32_t i = 0;

	for (SpectatorVec::const_iterator it = list.begin(); it != end; ++it) {
		if (Player* tmpPlayer = (*it)->getPlayer()) {
			tmpPlayer->sendRemoveTileItem(this, cylinderMapPos, oldStackPosVector[i], item);
			++i;
		}
	}

	//event methods
	for (SpectatorVec::const_iterator it = list.begin(); it != end; ++it) {
		(*it)->onRemoveTileItem(this, cylinderMapPos, iType, item);
	}
}
开发者ID:nclx,项目名称:forgottenserver,代码行数:31,代码来源:tile.cpp

示例3: internalGetString

int ActionScript::luaActionDoSendAnimatedText(lua_State *L)
{
	//doSendAnimatedText(position,text,color)
	int color = (int)internalGetNumber(L);
	const char * text = internalGetString(L);
	PositionEx pos;
	internalGetPositionEx(L,pos);

	ActionScript *action = getActionScript(L);

	Position realpos = internalGetRealPosition(action, action->_player,(Position&)pos);
	SpectatorVec list;
	SpectatorVec::iterator it;

	action->game->getSpectators(Range(realpos, true), list);

	for(it = list.begin(); it != list.end(); ++it) {
		Player *p = dynamic_cast<Player*>(*it);
		if(p)
			p->sendAnimatedText(realpos, color, text);
	}

	lua_pushnumber(L, 0);
	return 1;
}
开发者ID:divinity76,项目名称:YurOTS,代码行数:25,代码来源:actions.cpp

示例4: getPosition

void Tile::postRemoveNotification(Thing* thing, const Cylinder* newParent, int32_t index, bool isCompleteRemoval, cylinderlink_t link /*= LINK_OWNER*/)
{
	const Position& cylinderMapPos = getPosition();

	SpectatorVec list;
	g_game.getSpectators(list, cylinderMapPos, true, true);

	if (/*isCompleteRemoval &&*/ getThingCount() > 8) {
		onUpdateTile(list);
	}

	for (SpectatorVec::const_iterator it = list.begin(), end = list.end(); it != end; ++it) {
		(*it)->getPlayer()->postRemoveNotification(thing, newParent, index, isCompleteRemoval, LINK_NEAR);
	}

	//calling movement scripts
	Creature* creature = thing->getCreature();

	if (creature) {
		g_moveEvents->onCreatureMove(creature, this, false);
	} else {
		Item* item = thing->getItem();
		if (item) {
			g_moveEvents->onItemMove(item, this, false);
		}
	}
}
开发者ID:nclx,项目名称:forgottenserver,代码行数:27,代码来源:tile.cpp

示例5: updateTileFlags

void Tile::onRemoveTileItem(const SpectatorVec& list, std::vector<uint32_t>& oldStackPosVector, Item* item)
{
	updateTileFlags(item, true);
	const Position& cylinderMapPos = getPosition();
	const ItemType& iType = Item::items[item->getID()];
	SpectatorVec::const_iterator it;
	//send to client
	Player* tmpPlayer = NULL;
	uint32_t i = 0;

	for (it = list.begin(); it != list.end(); ++it)
	{
		if ((tmpPlayer = (*it)->getPlayer()))
		{
			tmpPlayer->sendRemoveTileItem(this, cylinderMapPos, oldStackPosVector[i], item);
			++i;
		}
	}

	//event methods
	for (it = list.begin(); it != list.end(); ++it)
	{
		(*it)->onRemoveTileItem(this, cylinderMapPos, iType, item);
	}
}
开发者ID:edubart,项目名称:otserv,代码行数:25,代码来源:tile.cpp

示例6: findPlayer

bool Spawn::findPlayer(const Position& pos)
{
	SpectatorVec list;
	g_game.getSpectators(list, pos, false, true);

	for (SpectatorVec::const_iterator it = list.begin(), end = list.end(); it != end; ++it) {
		if (!(*it)->getPlayer()->hasFlag(PlayerFlag_IgnoredByMonsters)) {
			return true;
		}
	}

	return false;
}
开发者ID:nclx,项目名称:forgottenserver,代码行数:13,代码来源:spawn.cpp

示例7: OTSYS_TIME

void Spawn::idle(int t)
{
	SpawnedMap::iterator it;
	for(it = spawnedmap.begin(); it != spawnedmap.end();) {
		if (it->second->isRemoved == true /*it->second->health <= 0*/) {
			if(it->first != 0) {
				spawnmap[it->first].lastspawn = OTSYS_TIME();
			}
			it->second->releaseThing();
			//delete it->second;
			spawnedmap.erase(it++);
		}
		else if(!isInSpawnRange(it->second->pos) && it->first != 0) {
			spawnedmap.insert(spawned_pair(0, it->second));
			spawnedmap.erase(it++);
		}
		else
			++it;
	}
	
	for(SpawnMap::iterator sit = spawnmap.begin(); sit != spawnmap.end(); ++sit) {

		if(spawnedmap.count(sit->first) == 0) {
			if((OTSYS_TIME() - sit->second.lastspawn) >= sit->second.spawntime) {

				SpectatorVec list;
				SpectatorVec::iterator it;

				game->getSpectators(Range(sit->second.pos, true), list);

				bool playerFound = false;
				for(it = list.begin(); it != list.end(); ++it) {
					Player *player = dynamic_cast<Player*>(*it);

					if(player && player->access < g_config.ACCESS_PROTECT) {
						playerFound = true;
						break;
					}
				}
				
				if(playerFound) {
					sit->second.lastspawn = OTSYS_TIME();
					continue;
				}

				respawn(sit->first, sit->second.pos, sit->second.name, sit->second.dir);
			}
		}
	}
}
开发者ID:divinity76,项目名称:YurOTS,代码行数:50,代码来源:spawn.cpp

示例8: findPlayer

bool Spawn::findPlayer(const Position& pos)
{
	SpectatorVec list;
	g_game.getSpectators(list, pos);

	Player* tmpPlayer = NULL;
	for(SpectatorVec::iterator it = list.begin(); it != list.end(); ++it)
	{
		if((tmpPlayer = (*it)->getPlayer()) && !tmpPlayer->hasFlag(PlayerFlag_IgnoredByMonsters))
			return true;
	}

	return false;
}
开发者ID:Fir3element,项目名称:035,代码行数:14,代码来源:spawn.cpp

示例9: setFollowCreature

bool Monster::convinceCreature(Creature* creature)
{
	Player* player = creature->getPlayer();
	if(player && !player->hasFlag(PlayerFlag_CanConvinceAll) && !mType->isConvinceable)
		return false;

	Creature* oldMaster = NULL;
	if(isSummon())
		oldMaster = master;

	if(oldMaster)
	{
		if(oldMaster->getPlayer() || oldMaster == creature)
			return false;

		oldMaster->removeSummon(this);
	}

	setFollowCreature(NULL);
	setAttackedCreature(NULL);
	destroySummons();

	creature->addSummon(this);
	updateTargetList();
	updateIdleStatus();

	//Notify surrounding about the change
	SpectatorVec list;
	g_game.getSpectators(list, getPosition(), false, true);
	g_game.getSpectators(list, creature->getPosition(), true, true);

	isMasterInRange = true;
	for(SpectatorVec::iterator it = list.begin(); it != list.end(); ++it)
		(*it)->onCreatureConvinced(creature, this);

	if(spawn)
	{
		spawn->removeMonster(this);
		spawn = NULL;
		masterRadius = -1;
	}

	if(raid)
	{
		raid->unRef();
		raid = NULL;
	}

	return true;
}
开发者ID:alexisjojo,项目名称:darkkonia,代码行数:50,代码来源:monster.cpp

示例10: __getIndexOfThing

void Tile::moveCreature(Creature* creature, Cylinder* toCylinder, bool teleport /* = false*/)
{
	int32_t oldStackPos = __getIndexOfThing(creature);

	//remove the creature
	__removeThing(creature, 0);

	//add the creature
	toCylinder->__addThing(creature);

	Position fromPos = getPosition();
	Position toPos = toCylinder->getPosition();

	if(!teleport){
		if(fromPos.y > toPos.y)
			creature->setDirection(NORTH);
		else if(fromPos.y < toPos.y)
			creature->setDirection(SOUTH);
		if(fromPos.x < toPos.x)
			creature->setDirection(EAST);
		else if(fromPos.x > toPos.x)
			creature->setDirection(WEST);
	}

	SpectatorVec list;
	SpectatorVec::iterator it;
	g_game.getSpectators(Range(fromPos, true), list);
	g_game.getSpectators(Range(toPos, true), list);

	//send to client
	Player* player = NULL;
	for(it = list.begin(); it != list.end(); ++it) {
		if(player = (*it)->getPlayer()){
			player->sendCreatureMove(creature, fromPos, oldStackPos, teleport);
		}
	}

	g_game.isExecutingEvents = true;

	//event method
	for(it = list.begin(); it != list.end(); ++it) {
		(*it)->onCreatureMove(creature, fromPos, oldStackPos, teleport);
	}

	g_game.isExecutingEvents = false;

	toCylinder->postAddNotification(creature);
	postRemoveNotification(creature);
}
开发者ID:divinity76,项目名称:server,代码行数:49,代码来源:tile.cpp

示例11: getPosition

void Container::onAddContainerItem(Item* item)
{
	const Position& cylinderMapPos = getPosition();

	SpectatorVec list;
	g_game.getSpectators(list, cylinderMapPos, false, true, 2, 2, 2, 2);

	SpectatorVec::const_iterator end = list.end();

	//send to client
	for(SpectatorVec::const_iterator it = list.begin(); it != end; ++it)
		(*it)->getPlayer()->sendAddContainerItem(this, item);

	//event methods
	for(SpectatorVec::const_iterator it = list.begin(); it != end; ++it)
		(*it)->getPlayer()->onAddContainerItem(this, item);
}
开发者ID:CkyLua,项目名称:tfs,代码行数:17,代码来源:container.cpp

示例12: message

bool ConditionRegeneration::executeCondition(Creature* creature, int32_t interval)
{
	internalHealthTicks += interval;
	internalManaTicks += interval;

	if (creature->getZone() != ZONE_PROTECTION) {
		if (internalHealthTicks >= healthTicks) {
			internalHealthTicks = 0;

			int32_t realHealthGain = creature->getHealth();
			creature->changeHealth(healthGain);
			realHealthGain = creature->getHealth() - realHealthGain;

			if (isBuff && realHealthGain > 0) {
				Player* player = creature->getPlayer();
				if (player) {
					std::string healString = std::to_string(realHealthGain) + (realHealthGain != 1 ? " hitpoints." : " hitpoint.");

					TextMessage message(MESSAGE_HEALED, "You were healed for " + healString);
					message.position = player->getPosition();
					message.primary.value = realHealthGain;
					message.primary.color = TEXTCOLOR_MAYABLUE;
					player->sendTextMessage(message);

					SpectatorVec list;
					g_game.map.getSpectators(list, player->getPosition(), false, true);
					list.erase(player);
					if (!list.empty()) {
						message.type = MESSAGE_HEALED_OTHERS;
						message.text = player->getName() + " was healed for " + healString;
						for (Creature* spectator : list) {
							spectator->getPlayer()->sendTextMessage(message);
						}
					}
				}
			}
		}

		if (internalManaTicks >= manaTicks) {
			internalManaTicks = 0;
			creature->changeMana(manaGain);
		}
	}

	return ConditionGeneric::executeCondition(creature, interval);
}
开发者ID:Blaggo,项目名称:forgottenserver,代码行数:46,代码来源:condition.cpp

示例13: getActionScript

int ActionScript::luaActionDoPlayerAddHealth(lua_State *L)
{
	//doPlayerAddHealth(uid,health)
	int addhealth = (int)internalGetNumber(L);
	unsigned int cid = (unsigned int)internalGetNumber(L);

	ActionScript *action = getActionScript(L);

	const KnownThing* tmp = action->GetPlayerByUID(cid);
	if(tmp){
		Player *player = (Player*)(tmp->thing);
		int tmp = player->health + addhealth;
		if(tmp <= 0){
			player->health = 1;
		}
		else if(tmp > player->healthmax){
			player->health = player->healthmax;
		}
		else{
			player->health = tmp;
		}
		player->sendStats();

		SpectatorVec list;
		SpectatorVec::iterator it;

		action->game->getSpectators(Range(player->pos,true), list);
		for(it = list.begin(); it != list.end(); ++it) {
			Player* p = dynamic_cast<Player*>(*it);
			if(p)
				p->sendCreatureHealth(player);
		}
	}
	else{
		lua_pushnumber(L, -1);
		std::cout << "luaDoPlayerAddHealth: player not found" << std::endl;
		return 1;
	}

	lua_pushnumber(L, 0);
	return 1;
}
开发者ID:divinity76,项目名称:YurOTS,代码行数:42,代码来源:actions.cpp

示例14: getMaster

void Creature::onGainExperience(uint64_t gainExp, Creature* target)
{
	if (gainExp != 0 && getMaster()) {
		gainExp = gainExp / 2;
		getMaster()->onGainExperience(gainExp, target);

		const Position& targetPos = getPosition();

		std::ostringstream ssExp;
		ssExp << ucfirst(getNameDescription()) << " gained " << gainExp << " experience points.";
		std::string strExp = ssExp.str();

		SpectatorVec list;
		g_game.getSpectators(list, targetPos, false, true);

		for (SpectatorVec::const_iterator it = list.begin(), end = list.end(); it != end; ++it) {
			(*it)->getPlayer()->sendExperienceMessage(MSG_EXPERIENCE_OTHERS, strExp, targetPos, gainExp, TEXTCOLOR_WHITE_EXP);
		}
	}
}
开发者ID:fabianobn,项目名称:forgottenserver,代码行数:20,代码来源:creature.cpp

示例15: getPosition

void Container::onRemoveContainerItem(uint32_t index, Item* item)
{
    const Position& cylinderMapPos = getPosition();
    SpectatorVec list;

    SpectatorVec::iterator it;
    g_game.getSpectators(list, cylinderMapPos, false, false, 2, 2, 2, 2);

    //send change to client
    Player* player = NULL;
    for(it = list.begin(); it != list.end(); ++it)
    {
        if((player = (*it)->getPlayer()))
            player->sendRemoveContainerItem(this, index, item);
    }

    //event methods
    for(it = list.begin(); it != list.end(); ++it)
    {
        if((player = (*it)->getPlayer()))
            player->onRemoveContainerItem(this, index, item);
    }
}
开发者ID:Klailex,项目名称:otxserver,代码行数:23,代码来源:container.cpp


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