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


C++ UnitPointer类代码示例

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


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

示例1: getSelectedChar

bool ChatHandler::HandleCastSpellCommand(const char* args, WorldSession *m_session)
{
	UnitPointer caster = m_session->GetPlayer();
	UnitPointer target = getSelectedChar(m_session, false);
	if(!target)
		target = getSelectedCreature(m_session, false);
	if(!target)
	{
		RedSystemMessage(m_session, "Must select a char or creature.");
		return false;
	}

	uint32 spellid = atol(args);
	SpellEntry *spellentry = dbcSpell.LookupEntry(spellid);
	if(!spellentry)
	{
		RedSystemMessage(m_session, "Invalid spell id!");
		return false;
	}
	
	SpellPointer sp(new Spell(caster, spellentry, false, NULLAURA));
	if(!sp)
	{
		RedSystemMessage(m_session, "Spell failed creation!");
		sp->Destructor();
		sp = NULLSPELL;
		return false;
	}

	BlueSystemMessage(m_session, "Casting spell %d on target.", spellid);
	SpellCastTargets targets;
	targets.m_unitTarget = target->GetGUID();
	sp->prepare(&targets);
	return true;
}
开发者ID:CadeLaRen,项目名称:Xeon-MMORPG-Emulator,代码行数:35,代码来源:Level2.cpp

示例2: HandleListAIAgentCommand

bool ChatHandler::HandleListAIAgentCommand(const char* args, WorldSession *m_session)
{
	UnitPointer target = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(m_session->GetPlayer()->GetSelection()));
	if(!target)
	{
		RedSystemMessage(m_session, "You have to select a Creature!");
		return false;
	}

	std::stringstream sstext;
	sstext << "agentlist of creature: " << target->GetGUID() << '\n';

	std::stringstream ss;
	ss << "SELECT * FROM ai_agents where entry=" << target->GetUInt32Value(OBJECT_FIELD_ENTRY);
	QueryResult *result = WorldDatabase.Query( ss.str().c_str() );

	if( !result )
		return false;

	do
	{
		Field *fields = result->Fetch();
		sstext << "agent: "   << fields[1].GetUInt16()
			<< " | spellId: " << fields[5].GetUInt32()
			<< " | Event: "   << fields[2].GetUInt32()
			<< " | chance: "  << fields[3].GetUInt32()
			<< " | count: "   << fields[4].GetUInt32() << '\n';
	} while( result->NextRow() );

	delete result;

	SendMultilineMessage(m_session, sstext.str().c_str());

	return true;
}
开发者ID:CadeLaRen,项目名称:Xeon-MMORPG-Emulator,代码行数:35,代码来源:Level2.cpp

示例3: Execute

bool Execute(uint32 i, SpellPointer pSpell)
{
    //uint32 uSpellId = pSpell->m_spellInfo->Id;
    uint32 base_dmg = pSpell->damage;
    /*
    Attempt to finish off a wounded foe, causing 125 damage and converting each extra point
    of rage into 3 additional damage.  Only usable on enemies that have less than 20% health.
    */

    UnitPointer target = pSpell->GetUnitTarget();
    if(!target || !pSpell->u_caster) return true;

    // "Only usable on enemies that have less than 20% health."
    if(target->GetHealthPct() > 20)
    {
        // send failed
        pSpell->SendCastResult(SPELL_FAILED_BAD_TARGETS);
        return true;
    }

    // get the caster's rage points, and convert them
    // formula is 3 damage * spell rank * rage points
    uint32 add_damage = (3 * pSpell->m_spellInfo->RankNumber);
    add_damage *= pSpell->u_caster->GetUInt32Value(UNIT_FIELD_POWER2) / 10;   // rage is *10 always
    
    // send spell damage log
	//pSpell->u_caster->SpellNonMeleeDamageLog(target, 20647, base_dmg + add_damage, false);
	SpellEntry *sp_for_the_logs = dbcSpell.LookupEntry(20647);
	pSpell->u_caster->Strike( target, MELEE, sp_for_the_logs, base_dmg + add_damage, 0, 0, true, true );
	// zero rage
    pSpell->u_caster->SetUInt32Value(UNIT_FIELD_POWER2, 0);
    return true;
}
开发者ID:Vanj-crew,项目名称:HearthStone-Emu,代码行数:33,代码来源:WarriorSpells.cpp

示例4: HandleRangeCheckCommand

bool ChatHandler::HandleRangeCheckCommand( const char *args , WorldSession *m_session )
{
	WorldPacket data;
	uint64 guid = m_session->GetPlayer()->GetSelection();
	m_session->SystemMessage( "=== RANGE CHECK ===" );
	if (guid == 0)
	{
		m_session->SystemMessage("No selection imo.");
		return true;
	}

	UnitPointer unit = m_session->GetPlayer()->GetMapMgr()->GetUnit( guid );
	if(!unit)
	{
		m_session->SystemMessage("Invalid selection imo.");
		return true;
	}
	float DistSq = unit->GetDistanceSq( TO_OBJECT(m_session->GetPlayer()) );
	m_session->SystemMessage( "GetDistanceSq  :   %u" , FL2UINT( DistSq ) );
	LocationVector locvec( m_session->GetPlayer()->GetPositionX() , m_session->GetPlayer()->GetPositionY() , m_session->GetPlayer()->GetPositionZ() );
	float DistReal = unit->CalcDistance( locvec );
	m_session->SystemMessage( "CalcDistance   :   %u" , FL2UINT( DistReal ) );
	float Dist2DSq = unit->GetDistance2dSq( TO_OBJECT(m_session->GetPlayer()) );
	m_session->SystemMessage( "GetDistance2dSq:   %u" , FL2UINT( Dist2DSq ) );
	return true;
}
开发者ID:Vanj-crew,项目名称:HearthStone-Emu,代码行数:26,代码来源:Level0.cpp

示例5: SpellCast

    void SpellCast(float val)
    {
        if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget())
        {
			float comulativeperc = 0;
		    UnitPointer target = NULLUNIT;
			for(int i=0;i<nrspells;i++)
			{
				if(!spells[i].perctrigger) continue;
				
				if(m_spellcheck[i])
				{
					if (!spells[i].instant)
						_unit->GetAIInterface()->StopMovement(1);


					if (i == 3)
					{
						uint32 t = (uint32)time(NULL);
						if (t > spells[2].casttime && RandomUInt(2) == 1)
						{
							_unit->CastSpell(_unit, spells[2].info, spells[2].instant);

							spells[2].casttime = t + spells[2].cooldown;
						}
					}

					target = _unit->GetAIInterface()->GetNextTarget();
					switch(spells[i].targettype)
					{
						case TARGET_SELF:
						case TARGET_VARIOUS:
							_unit->CastSpell(_unit, spells[i].info, spells[i].instant); break;
						case TARGET_ATTACKING:
							_unit->CastSpell(target, spells[i].info, spells[i].instant); break;
						case TARGET_DESTINATION:
							_unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break;
						case TARGET_RANDOM_FRIEND:
						case TARGET_RANDOM_SINGLE:
						case TARGET_RANDOM_DESTINATION:
							CastSpellOnRandomTarget(i, spells[i].mindist2cast, spells[i].maxdist2cast, spells[i].minhp2cast, spells[i].maxhp2cast); break;
					}

					m_spellcheck[i] = false;
					return;
				}

				uint32 t = (uint32)time(NULL);
				if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger) && t > spells[i].casttime)
				{
					_unit->setAttackTimer(spells[i].attackstoptimer, false);
					spells[i].casttime = t + spells[i].cooldown;
					m_spellcheck[i] = true;
				}
				comulativeperc += spells[i].perctrigger;
			}
        }
    }
开发者ID:Vanj-crew,项目名称:HearthStone-Emu,代码行数:58,代码来源:Instance_ManaTombs.cpp

示例6: getSelectedCreature

bool ChatHandler::HandleMonsterCastCommand(const char * args, WorldSession * m_session)
{
	UnitPointer crt = getSelectedCreature(m_session, false);
	if(!crt)
	{
		RedSystemMessage(m_session, "Please select a creature before using this command.");
		return true;
	}
	uint32 spellId = (uint32)atoi(args);
	crt->CastSpell(m_session->GetPlayer()->GetGUID(),spellId,true);
	return true;
}
开发者ID:CadeLaRen,项目名称:Xeon-MMORPG-Emulator,代码行数:12,代码来源:Level2.cpp

示例7: GuardsOnWave

void GuardsOnWave(PlayerPointer pPlayer, UnitPointer pUnit)
{
	if ( pPlayer == NULLPLR || pUnit == NULLUNIT )
		return;

	// Check if we are friendly with our Guards (they will wave only when You are)
	if (((pUnit->GetEntry() == 68 || pUnit->GetEntry() == 1976) && pPlayer->GetStandingRank(72) >= FRIENDLY) || (pUnit->GetEntry() == 3296 && pPlayer->GetStandingRank(76) >= FRIENDLY))
	{
		uint32 EmoteChance = RandomUInt(100);
		if(EmoteChance < 33) // 1/3 chance to get Bow from Guard
			pUnit->Emote(EMOTE_ONESHOT_WAVE);
	}
}
开发者ID:Vanj-crew,项目名称:HearthStone-Emu,代码行数:13,代码来源:RandomScripts.cpp

示例8: HandleKillCommand

bool ChatHandler::HandleKillCommand(const char *args, WorldSession *m_session)
{
	UnitPointer target = m_session->GetPlayer()->GetMapMgr()->GetUnit(m_session->GetPlayer()->GetSelection());
	if(target == 0)
	{
		RedSystemMessage(m_session, "A valid selection is required.");
		return true;
	}

	switch(target->GetTypeId())
	{
	case TYPEID_PLAYER:
		sGMLog.writefromsession(m_session, "used kill command on PLAYER %s", TO_PLAYER( target )->GetName() );
		break;

	case TYPEID_UNIT:
		sGMLog.writefromsession(m_session, "used kill command on CREATURE %s", TO_CREATURE( target )->GetCreatureName() ? TO_CREATURE( target )->GetCreatureName()->Name : "unknown");
		break;
	}
	

	// If we're killing a player, send a message indicating a gm killed them.
	if(target->IsPlayer())
	{
		PlayerPointer plr = TO_PLAYER(target);
		m_session->GetPlayer()->DealDamage(plr, plr->GetUInt32Value(UNIT_FIELD_HEALTH),0,0,0);
		//plr->SetUInt32Value(UNIT_FIELD_HEALTH, 0);
		plr->KillPlayer();
		BlueSystemMessageToPlr(plr, "%s killed you with a GM command.", m_session->GetPlayer()->GetName());
	}
	else
	{

		// Cast insta-kill.
		SpellEntry * se = dbcSpell.LookupEntry(5);
		if(se == 0) return false;

		SpellCastTargets targets(target->GetGUID());
		SpellPointer sp(new Spell(m_session->GetPlayer(), se, true, NULLAURA));
		sp->prepare(&targets);

/*		SpellEntry * se = dbcSpell.LookupEntry(20479);
		if(se == 0) return false;
		
		SpellCastTargets targets(target->GetGUID());
		SpellPointer sp(new Spell(target, se, true, NULLAURA));
		sp->prepare(&targets);*/
	}

	return true;
}
开发者ID:CadeLaRen,项目名称:Xeon-MMORPG-Emulator,代码行数:51,代码来源:Level2.cpp

示例9: SpellCast

void SpellCast(float val)
    {
if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget())
{
float comulativeperc = 0;
UnitPointer target = NULLUNIT;
for(int i=0;i<nrspells;i++)
{
if(!spells[i].perctrigger) continue;
                
if(m_spellcheck[i])
{
target = _unit->GetAIInterface()->GetNextTarget();
switch(spells[i].targettype)
{
case TARGET_SELF:

case TARGET_VARIOUS:
_unit->CastSpell(_unit, spells[i].info, spells[i].instant);
break;

case TARGET_ATTACKING:
_unit->CastSpell(target, spells[i].info, spells[i].instant);
break;

case TARGET_DESTINATION:
_unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant);
break;
}

if (spells[i].speech != "")
{
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str());
_unit->PlaySoundToSet(spells[i].soundid);
}

m_spellcheck[i] = false;
return;
}

if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger))
{
_unit->setAttackTimer(spells[i].attackstoptimer, false);
m_spellcheck[i] = true;
}

comulativeperc += spells[i].perctrigger;
}
}
}
开发者ID:Vanj-crew,项目名称:HearthStone-Emu,代码行数:50,代码来源:Instance_ScarletMonastery.cpp

示例10: DEBUG_LOG

void WorldSession::HandleAddDynamicTargetOpcode(WorldPacket & recvPacket)
{

	DEBUG_LOG( "WORLD"," got CMSG_PET_CAST_SPELL." );
	uint64 guid;
	uint8 counter;
	uint32 spellid;
	uint8 flags;
	UnitPointer caster;
	SpellCastTargets targets;
	SpellEntry *sp;
	SpellPointer pSpell;
	list<AI_Spell*>::iterator itr;

	recvPacket >> guid >> counter >> spellid >> flags;
	sp = dbcSpell.LookupEntry(spellid);

	// Summoned Elemental's Freeze
    if (spellid == 33395)
	{
		caster = _player->m_Summon;
		if( caster && TO_PET(caster)->GetAISpellForSpellId(spellid) == NULL )
			return;
	}
	else
	{
		caster = _player->m_CurrentCharm;
		if( caster != NULL )
		{
			for(itr = caster->GetAIInterface()->m_spells.begin(); itr != caster->GetAIInterface()->m_spells.end(); ++itr)
			{
				if( (*itr)->spell->Id == spellid )
					break;
			}

			if( itr == caster->GetAIInterface()->m_spells.end() )
				return;
		}
	}

	if( caster == NULL || guid != caster->GetGUID() )
		return;
	
	targets.read(recvPacket, _player->GetGUID());

	pSpell = SpellPointer(new Spell(caster, sp, false, NULLAURA));
	pSpell->prepare(&targets);
}
开发者ID:Vanj-crew,项目名称:HearthStone-Emu,代码行数:48,代码来源:SpellHandler.cpp

示例11: OnDied

	void OnDied(UnitPointer mKiller)
	{
		if(!mKiller)
			return;

		if (mKiller->IsPlayer()) 
		{
			QuestLogEntry *en = NULL;
			en = (TO_PLAYER(mKiller))->GetQuestLogForEntry(10703);
			if (en == NULL)
			{
				en = (TO_PLAYER(mKiller))->GetQuestLogForEntry(10702);
				if (en == NULL)
				{
					return;
				}
			}

			if(en->GetMobCount(0) < en->GetQuest()->required_mobcount[0])
			{
				uint32 newcount = en->GetMobCount(0) + 1;
				en->SetMobCount(0, newcount);
				en->SendUpdateAddKill(0);
				en->UpdatePlayerFields();
			}
		}
		return;
	}
开发者ID:Vanj-crew,项目名称:HearthStone-Emu,代码行数:28,代码来源:Shadowmoon.cpp

示例12: SpellFunc_CrystalSpikes

void SpellFunc_CrystalSpikes( SpellDesc* pThis, MoonScriptCreatureAI* pCreatureAI, UnitPointer pTarget, TargetType pType )
{
	if(pCreatureAI != NULL)
	{
		if( pTarget == NULL )
			return;

		for (int i = -2; i < 2; i++)
		{
			float x = pTarget->GetPositionX() + ( i * 3.0 );
			float y = pTarget->GetPositionY() + ( i * 3.0 );

			pCreatureAI->GetUnit()->GetMapMgr()->GetInterface()->SpawnCreature( CN_CRYSTAL_SPIKE, x, y, pTarget->GetPositionZ(), pTarget->GetOrientation(), true, true, NULL, NULL );
		};
		pCreatureAI->Emote( "Bleed!", Text_Yell, 13332 );
	};
};
开发者ID:Vanj-crew,项目名称:HearthStone-Emu,代码行数:17,代码来源:Instance_Nexus.cpp

示例13: OnCombatStart

	void OnCombatStart(UnitPointer mTarget) 
	{
		_unit->GetAIInterface()->m_canMove = false;
		_unit->GetAIInterface()->disable_melee = true;
		_unit->SetUInt64Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);

		UnitPointer antusul = NULLUNIT;
		antusul = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(1815.030029f, 686.817017f, 14.519000f, 8127);
		if(antusul)
		{
			if(antusul->isAlive())
			{
				antusul->GetAIInterface()->AttackReaction(mTarget, 0, 0);
				antusul->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Lunch has arrived, my beutiful childern. Tear them to pieces!");
			}
		}
	}
开发者ID:Vanj-crew,项目名称:HearthStone-Emu,代码行数:17,代码来源:Instance_ZulFarrak.cpp

示例14: HookOnPlayerKill

void ArathiBasin::HookOnPlayerKill(PlayerPointer plr, UnitPointer pVictim)
{
	if(pVictim->IsPlayer())
	{
		plr->m_bgScore.KillingBlows++;
		UpdatePvPData();
	}
}
开发者ID:CadeLaRen,项目名称:Xeon-MMORPG-Emulator,代码行数:8,代码来源:ArathiBasin.cpp

示例15: HookOnPlayerKill

void Arena::HookOnPlayerKill(PlayerPointer plr, UnitPointer pVictim)
{
	if( !pVictim->IsPlayer() )
		return;

	plr->m_bgScore.KillingBlows++;
	UpdatePlayerCounts();
}
开发者ID:CadeLaRen,项目名称:Xeon-MMORPG-Emulator,代码行数:8,代码来源:Arenas.cpp


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