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


C++ Mob类代码示例

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


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

示例1: iterator

// solar: causes caster to hit every mob within dist range of center with
// spell_id.
// NPC spells will only affect other NPCs with compatible faction
void EntityList::AESpell(Mob *caster, Mob *center, uint16 spell_id, bool affect_caster, int16 resist_adjust)
{
    LinkedListIterator<Mob*> iterator(mob_list);
    Mob *curmob;

    float dist = caster->GetAOERange(spell_id);
    float dist2 = dist * dist;

    bool bad = IsDetrimentalSpell(spell_id);
    bool isnpc = caster->IsNPC();
    const int MAX_TARGETS_ALLOWED = 4;
    int iCounter = 0;

    for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
    {
        curmob = iterator.GetData();
        if(curmob == center)	//do not affect center
            continue;
        if(curmob == caster && !affect_caster)	//watch for caster too
            continue;
        if(center->DistNoRoot(*curmob) > dist2)	//make sure they are in range
            continue;
        if(isnpc && curmob->IsNPC()) {	//check npc->npc casting
            FACTION_VALUE f = curmob->GetReverseFactionCon(caster);
            if(bad) {
                //affect mobs that are on our hate list, or
                //which have bad faction with us
                if( ! (caster->CheckAggro(curmob) || f == FACTION_THREATENLY || f == FACTION_SCOWLS) )
                    continue;
            } else {
                //only affect mobs we would assist.
                if( ! (f <= FACTION_AMIABLE))
                    continue;
            }
        }
        //finally, make sure they are within range
        if(bad) {
            if(!caster->IsAttackAllowed(curmob, true))
                continue;
            if(!center->CheckLosFN(curmob))
                continue;
        }

        //if we get here... cast the spell.
        if(IsTargetableAESpell(spell_id) && bad)
        {
            if(iCounter < MAX_TARGETS_ALLOWED)
            {
                caster->SpellOnTarget(spell_id, curmob, false, true, resist_adjust);
            }
        }
        else
        {
            caster->SpellOnTarget(spell_id, curmob, false, true, resist_adjust);
        }

        if(!isnpc) //npcs are not target limited...
            iCounter++;
    }
}
开发者ID:regneq,项目名称:projecteqemu,代码行数:63,代码来源:effects.cpp

示例2: trySpawn

void Level::trySpawn(int count)
{
	for (int i = 0; i < count; i++)
	{
		Mob * mob;

		int minLevel = 1;
		int maxLevel = 1;
		if (depth < 0)
		{
			maxLevel = (-depth) + 1;
		}
		if (depth > 0)
		{
			minLevel = maxLevel = 4;
		}
		int lvl = random->nextInt(maxLevel - minLevel + 1) + minLevel;
		if (random->nextInt(2) == 0)
			mob = new Slime(lvl);
		else
			mob = new Zombie(lvl);

		if (!mob->findStartPos(this))
		{
			delete mob;
		}
		else
		{
			this->add(mob);
		}
	}
}
开发者ID:konchunas,项目名称:minicraft-psp,代码行数:32,代码来源:Level.cpp

示例3: unique_spawn

int16 QuestManager::unique_spawn(int npc_type, int grid, int unused, float x, float y, float z, float heading) {
	Mob *other = entity_list.GetMobByNpcTypeID(npc_type);
	if(other != NULL) {
		return(other->GetID());
	}


	NPCType* tmp = 0;
	if ((tmp = Database::Instance()->GetNPCType(npc_type)))
	{

		NPC* npc = new NPC(tmp, 0, x, y, z, heading);


		npc->AddLootTable();
		entity_list.AddNPC(npc,true);
		// Quag: Sleep in main thread? ICK!
		// Sleep(200);
		// Quag: check is irrelevent, it's impossible for npc to be 0 here
		// (we're in main thread, nothing else can possibly modify it)
//		if(npc != 0) {
			if(grid > 0)
			{
				// HarakiriFIXME npc->AssignWaypoints(grid);
			}
			npc->SendPosUpdate();
//		}
		return(npc->GetID());
	}
	return(0);
}
开发者ID:aceoyame,项目名称:OpenEQC,代码行数:31,代码来源:questmgr.cpp

示例4: Process

bool Trap::Process()
{
	if (chkarea_timer.Enabled() && chkarea_timer.Check() && !reset_timer.Enabled())
	{
		Mob* trigger = entity_list.GetTrapTrigger(this);
		if (trigger && !(trigger->IsClient() && trigger->CastToClient()->GetGM()))
		{
			Trigger(trigger);
		}
	}
	else if (reset_timer.Enabled() && reset_timer.Check())
	{
		Log.Out(Logs::General, Logs::Traps, "Reset timer disabled in Reset Check Process for trap %d.", trap_id);
		reset_timer.Disable();
		charid = 0;
	}

	if (respawn_timer.Enabled() && respawn_timer.Check())
	{
		detected = false;
		disarmed = false;
		chkarea_timer.Enable();
		respawn_timer.Disable();
	}


	return true;
}
开发者ID:jcon321,项目名称:Server,代码行数:28,代码来源:trap.cpp

示例5: GetLeader

void Group::ChangeLeader(Mob* newleader)
{
	// this changes the current group leader, notifies other members, and updates leadship AA

	// if the new leader is invalid, do nothing
	if (!newleader)
		return;

	Mob* oldleader = GetLeader();

	EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupJoin_Struct));
	GroupJoin_Struct* gu = (GroupJoin_Struct*) outapp->pBuffer;
	gu->action = groupActMakeLeader;

	strcpy(gu->membername, newleader->GetName());
	strcpy(gu->yourname, oldleader->GetName());
	SetLeader(newleader);
	database.SetGroupLeaderName(GetID(), newleader->GetName());
	for (uint32 i = 0; i < MAX_GROUP_MEMBERS; i++) {
		if (members[i] && members[i]->IsClient())
		{
			members[i]->CastToClient()->QueuePacket(outapp);
		}
	}
	safe_delete(outapp);
}
开发者ID:eqmactop,项目名称:Server,代码行数:26,代码来源:groups.cpp

示例6: UpdateLogic

void Game::UpdateLogic(float time) {
    // Updates all the game logic: one game turn has passed!

    // Clear the screen
    TCODConsole::root->setBackgroundFlag(TCOD_BKGND_SET);
    TCODConsole::root->setDefaultBackground(TCODColor::black);
    TCODConsole::root->setDefaultForeground(TCODColor::black);
    TCODConsole::root->clear();

    // Get all the mobs to update
    std::vector<Mob*> AllMobs = GameMap.GetAllMobs();

    for(int i = 0; i < AllMobs.size(); i++) {
        Mob* mob = AllMobs[i];

        /* If entity is a mob and set to skip update; then skip this mob! */
        if(Helper::Find(mob->groups, std::string("nologic")))
            continue;

        mob->tenergy += mob->get_property<int>("speed"); // add some energy

        while(mob->tenergy >= time) {
            mob->tenergy -= 100.0f; // 100.0f would be one second I guess
            mob->DoLogic(this);
        }
    }

    /* Clean out the delete buffer */
    if(DeleteBuff.size() >= 200) {
        delete(DeleteBuff[0]);
        DeleteBuff.erase( DeleteBuff.begin() );
    }
}
开发者ID:RedFox47,项目名称:Origin,代码行数:33,代码来源:Game.cpp

示例7: AEAttack

// Rampage and stuff for clients. Normal and Duration rampages
//NPCs handle it differently in Mob::Rampage
void EntityList::AEAttack(Mob *attacker, float dist, int Hand, int count, bool IsFromSpell) {
//Dook- Will need tweaking, currently no pets or players or horses
	Mob *curmob;

	float dist2 = dist * dist;

	int hit = 0;

	for (auto it = mob_list.begin(); it != mob_list.end(); ++it) {
		curmob = it->second;
		if (curmob->IsNPC()
				&& curmob != attacker //this is not needed unless NPCs can use this
				&&(attacker->IsAttackAllowed(curmob))
				&& curmob->GetRace() != 216 && curmob->GetRace() != 472 /* dont attack horses */
				&& (DistanceSquared(curmob->GetPosition(), attacker->GetPosition()) <= dist2)
		) {
			if (!attacker->IsClient() || attacker->GetClass() == MONK || attacker->GetClass() == RANGER)
				attacker->Attack(curmob, Hand, false, false, IsFromSpell);
			else
				attacker->CastToClient()->DoAttackRounds(curmob, Hand, IsFromSpell);
			hit++;
			if (count != 0 && hit >= count)
				return;
		}
	}
}
开发者ID:gpanula,项目名称:Server,代码行数:28,代码来源:effects.cpp

示例8: killBody

void Game::killBody()
{
	if(m_bodyToKill)
	{
		m_world.removeBody(m_bodyToKill);

		for(unsigned int i=0;i<m_mobs.size();i++)
		{
			if(m_mobs[i]->entity() == m_bodyToKill)
			{
				Mob* mobToDelete = m_mobs[i];
				for(unsigned int j=0;j<m_map.size();j++)
				{
					if(mobToDelete->drawable() == m_map[j])
					{
						m_map.erase(m_map.begin()+j);
						break;
					}
				}

				m_mobs.erase(m_mobs.begin()+i);
				delete mobToDelete;
				break;
			}
		}
		m_bodyToKill = 0;
	}
}
开发者ID:Canadadry,项目名称:TileGame,代码行数:28,代码来源:Game.cpp

示例9: getmob

	void MapMobs::sendmobhp(int32_t oid, int8_t percent, uint16_t playerlevel)
	{
		Mob* mob = getmob(oid);
		if (mob)
		{
			mob->sendhp(percent, playerlevel);
		}
	}
开发者ID:sonbk21,项目名称:JourneyClient,代码行数:8,代码来源:Mapmobs.cpp

示例10: mob_spawnMobN

int mob_spawnMobN(const char* name)
{
  int type = Mineserver::get()->mobs()->mobNametoType(std::string(name));
  Mob* m = Mineserver::get()->mobs()->createMob();
  m->type = type;
  m->spawnToAll();
  m->teleportToAll();
  return Mineserver::get()->mobs()->getAll().size()-1;
}
开发者ID:donno,项目名称:mineserver,代码行数:9,代码来源:plugin_api.cpp

示例11:

void	MobSpawner::spawnMob(RType::InGameEvent const& request)
{
    MobObject *mob = _mobs->create("Mob", 12);
    mob->init(_mobTypes->at(request.get<uint8_t>("mob_id")).get());
    _activeMobs.push_back(mob);
    Mob *m = mob->getComponent<Mob>();
    m->setX(request.get<uint32_t>("x"));
    m->setY(request.get<uint32_t>("y"));
}
开发者ID:ishigo974,项目名称:rtype,代码行数:9,代码来源:MobSpawner.cpp

示例12: ClearDraggedCorpses

void Client::ProcessMovePC(uint32 zoneID, uint32 instance_id, float x, float y, float z, float heading, uint8 ignorerestrictions, ZoneMode zm)
{
	// From what I have read, dragged corpses should stay with the player for Intra-zone summons etc, but we can implement that later.
	ClearDraggedCorpses();

	if(zoneID == 0)
		zoneID = zone->GetZoneID();

	if(zoneID == zone->GetZoneID() && instance_id == zone->GetInstanceID()) {
		// TODO: Determine if this condition is necessary.
		if(IsAIControlled()) {
			GMMove(x, y, z);
			return;
		}

		if(GetPetID() != 0) {
			//if they have a pet and they are staying in zone, move with them
			Mob *p = GetPet();
			if(p != nullptr){
				p->SetPetOrder(SPO_Follow);
				p->GMMove(x+15, y, z);	//so it dosent have to run across the map.
			}
		}
	}

	switch(zm) {
		case GateToBindPoint:
			ZonePC(zoneID, instance_id, x, y, z, heading, ignorerestrictions, zm);
			break;
		case EvacToSafeCoords:
		case ZoneToSafeCoords:
			ZonePC(zoneID, instance_id, x, y, z, heading, ignorerestrictions, zm);
			break;
		case GMSummon:
			Message(15, "You have been summoned by a GM!");
			ZonePC(zoneID, instance_id, x, y, z, heading, ignorerestrictions, zm);
			break;
		case ZoneToBindPoint:
			ZonePC(zoneID, instance_id, x, y, z, heading, ignorerestrictions, zm);
			break;
		case ZoneSolicited:
			ZonePC(zoneID, instance_id, x, y, z, heading, ignorerestrictions, zm);
			break;
		case SummonPC:
			Message(15, "You have been summoned!");
			ZonePC(zoneID, instance_id, x, y, z, heading, ignorerestrictions, zm);
			break;
		case Rewind:
			Message(15, "Rewinding to previous location.");
			ZonePC(zoneID, instance_id, x, y, z, heading, ignorerestrictions, zm);
			break;
		default:
			LogFile->write(EQEMuLog::Error, "Client::ProcessMovePC received a reguest to perform an unsupported client zone operation.");
			break;
	}
}
开发者ID:Corysia,项目名称:Server,代码行数:56,代码来源:zoning.cpp

示例13: attacknpc

void QuestManager::attacknpc(int npc_entity_id) {
	if(!owner->IsNPC())
		return;
	Mob *it = entity_list.GetMob(npc_entity_id);	
		owner->CastToNPC()->AddToHateList(it,1);	
		if(it)
			owner->Say("I am unable to attack %s.", it->GetName());
		else
			owner->Say("I am unable to locate NPC entity %i", npc_entity_id);	
}
开发者ID:aceoyame,项目名称:OpenEQC,代码行数:10,代码来源:questmgr.cpp

示例14: mob_setLook

bool mob_setLook(int uid, double rot, double pitch)
{
  Mob* m = Mineserver::get()->mobs()->getMobByID(uid);
  if (m != NULL)
  {
    m->look((int16_t)rot, (int16_t)pitch);
    return true;
  }
  return false;
}
开发者ID:ThuGie,项目名称:mineserver,代码行数:10,代码来源:plugin_api.cpp

示例15: FadePetCharmBuff

void Mob::FadePetCharmBuff()
{
	if ((this->GetPetType() == petCharmed))
	{
		Mob* formerpet = this->GetPet();

		if (formerpet) {
			formerpet->BuffFadeByEffect(SE_Charm);
		}
	}
}
开发者ID:jcon321,项目名称:Server,代码行数:11,代码来源:pets.cpp


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