本文整理汇总了C++中Unit类的典型用法代码示例。如果您正苦于以下问题:C++ Unit类的具体用法?C++ Unit怎么用?C++ Unit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Unit类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: flags
void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
{
uint32 spellId;
uint8 cast_count, unk_flags;
recvPacket >> cast_count;
recvPacket >> spellId;
recvPacket >> unk_flags; // flags (if 0x02 - some additional data are received)
// ignore for remote control state (for player case)
Unit* _mover = GetPlayer()->GetMover();
if (_mover != GetPlayer() && _mover->GetTypeId()==TYPEID_PLAYER)
{
recvPacket.rpos(recvPacket.wpos()); // prevent spam at ignore packet
return;
}
DEBUG_LOG("WORLD: got cast spell packet, spellId - %u, cast_count: %u, unk_flags %u, data length = %i",
spellId, cast_count, unk_flags, (uint32)recvPacket.size());
/* process anticheat check */
if (!GetPlayer()->GetAntiCheat()->DoAntiCheatCheck(CHECK_SPELL, spellId, CMSG_CAST_SPELL))
return;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId );
if(!spellInfo)
{
sLog.outError("WORLD: unknown spell id %u", spellId);
recvPacket.rpos(recvPacket.wpos()); // prevent spam at ignore packet
return;
}
// Players on vehicles may cast many simple spells (like knock) from self
Unit* mover = NULL;
if (spellInfo->HasAttribute(SPELL_ATTR_EX6_CASTABLE_ON_VEHICLE) && _mover->IsCharmerOrOwnerPlayerOrPlayerItself())
mover = _mover->GetCharmerOrOwnerPlayerOrPlayerItself();
else
mover = _mover;
// casting own spells on some vehicles
if (mover->IsVehicle() && mover->GetCharmerOrOwnerPlayerOrPlayerItself())
{
Player *plr = mover->GetCharmerOrOwnerPlayerOrPlayerItself();
if (mover->GetVehicleKit()->GetSeatInfo(plr) &&
((mover->GetVehicleKit()->GetSeatInfo(plr)->m_flags & SEAT_FLAG_CAN_ATTACK) ||
(mover->GetVehicleKit()->GetSeatInfo(plr)->m_flags & SEAT_FLAG_CAN_CAST) ))
mover = plr;
}
bool triggered = false;
SpellEntry const* triggeredBy = NULL;
Aura const* triggeredByAura = mover->GetTriggeredByClientAura(spellId);
if (triggeredByAura)
{
triggered = true;
triggeredBy = triggeredByAura->GetSpellProto();
cast_count = 0;
}
if (mover->GetTypeId()==TYPEID_PLAYER)
{
// not have spell in spellbook or spell passive and not casted by client
if (((((Player*)mover)->GetUInt16Value(PLAYER_FIELD_BYTES2, 0) == 0 &&
(!((Player*)mover)->HasActiveSpell(spellId) && !triggered))
|| IsPassiveSpell(spellInfo)) && spellId != 1843)
{
sLog.outError("WorldSession::HandleCastSpellOpcode: %s casts spell %u which he shouldn't have", mover->GetObjectGuid().GetString().c_str(), spellId);
//cheater? kick? ban?
recvPacket.rpos(recvPacket.wpos()); // prevent spam at ignore packet
return;
}
}
else
{
// not have spell in spellbook or spell passive and not casted by client
if ((!((Creature*)mover)->HasSpell(spellId) && !triggered)
|| IsPassiveSpell(spellInfo))
{
sLog.outError("WorldSession::HandleCastSpellOpcode: %s try casts spell %u which he shouldn't have", mover->GetObjectGuid().GetString().c_str(), spellId);
//cheater? kick? ban?
recvPacket.rpos(recvPacket.wpos()); // prevent spam at ignore packet
return;
}
}
// client provided targets
SpellCastTargets targets;
recvPacket >> targets.ReadForCaster(mover);
// some spell cast packet including more data (for projectiles?)
if (unk_flags & 0x02)
targets.ReadAdditionalData(recvPacket);
// auto-selection buff level base at target level (in spellInfo)
if (Unit* target = targets.getUnitTarget())
{
// if rank not found then function return NULL but in explicit cast case original spell can be casted and later failed with appropriate error message
//.........这里部分代码省略.........
开发者ID:Splash,项目名称:mangos,代码行数:101,代码来源:SpellHandler.cpp
示例2: pet
void WorldSession::HandlePetSetAction(WorldPacket & recv_data)
{
sLog->outDetail("HandlePetSetAction. CMSG_PET_SET_ACTION");
uint64 petguid;
uint8 count;
recv_data >> petguid;
Unit* pet = ObjectAccessor::GetUnit(*_player, petguid);
if (!pet || pet != _player->GetFirstControlled())
{
sLog->outError("HandlePetSetAction: Unknown pet (GUID: %u) or pet owner (GUID: %u)", GUID_LOPART(petguid), _player->GetGUIDLow());
return;
}
CharmInfo *charmInfo = pet->GetCharmInfo();
if (!charmInfo)
{
sLog->outError("WorldSession::HandlePetSetAction: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId());
return;
}
count = (recv_data.size() == 24) ? 2 : 1;
uint32 position[2];
uint32 data[2];
bool move_command = false;
for (uint8 i = 0; i < count; ++i)
{
recv_data >> position[i];
recv_data >> data[i];
uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]);
//ignore invalid position
if (position[i] >= MAX_UNIT_ACTION_BAR_INDEX)
return;
// in the normal case, command and reaction buttons can only be moved, not removed
// at moving count == 2, at removing count == 1
// ignore attempt to remove command|reaction buttons (not possible at normal case)
if (act_state == ACT_COMMAND || act_state == ACT_REACTION)
{
if (count == 1)
return;
move_command = true;
}
}
// check swap (at command->spell swap client remove spell first in another packet, so check only command move correctness)
if (move_command)
{
uint8 act_state_0 = UNIT_ACTION_BUTTON_TYPE(data[0]);
if (act_state_0 == ACT_COMMAND || act_state_0 == ACT_REACTION)
{
uint32 spell_id_0 = UNIT_ACTION_BUTTON_ACTION(data[0]);
UnitActionBarEntry const* actionEntry_1 = charmInfo->GetActionBarEntry(position[1]);
if (!actionEntry_1 || spell_id_0 != actionEntry_1->GetAction() ||
act_state_0 != actionEntry_1->GetType())
return;
}
uint8 act_state_1 = UNIT_ACTION_BUTTON_TYPE(data[1]);
if (act_state_1 == ACT_COMMAND || act_state_1 == ACT_REACTION)
{
uint32 spell_id_1 = UNIT_ACTION_BUTTON_ACTION(data[1]);
UnitActionBarEntry const* actionEntry_0 = charmInfo->GetActionBarEntry(position[0]);
if (!actionEntry_0 || spell_id_1 != actionEntry_0->GetAction() ||
act_state_1 != actionEntry_0->GetType())
return;
}
}
for (uint8 i = 0; i < count; ++i)
{
uint32 spell_id = UNIT_ACTION_BUTTON_ACTION(data[i]);
uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]);
sLog->outDetail("Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X", _player->GetName(), position[i], spell_id, uint32(act_state));
//if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add
if (!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id)))
{
//sign for autocast
if (act_state == ACT_ENABLED && spell_id)
{
if (pet->GetTypeId() == TYPEID_UNIT && pet->ToCreature()->isPet())
((Pet*)pet)->ToggleAutocast(spell_id, true);
else
charmInfo->ToggleCreatureAutocast(spell_id, true);
}
//sign for no/turn off autocast
else if (act_state == ACT_DISABLED && spell_id)
{
if (pet->GetTypeId() == TYPEID_UNIT && pet->ToCreature()->isPet())
((Pet*)pet)->ToggleAutocast(spell_id, false);
//.........这里部分代码省略.........
开发者ID:xerkoss,项目名称:Project-WoW,代码行数:101,代码来源:PetHandler.cpp
示例3: uint32
void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket)
{
sLog->outDetail("WORLD: CMSG_PET_CAST_SPELL");
uint64 guid;
uint8 castCount;
uint32 spellId;
uint8 castFlags;
recvPacket >> guid >> castCount >> spellId >> castFlags;
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_PET_CAST_SPELL, guid: " UI64FMTD ", castCount: %u, spellId %u, castFlags %u", guid, castCount, spellId, castFlags);
// This opcode is also sent from charmed and possessed units (players and creatures)
if (!_player->GetGuardianPet() && !_player->GetCharm())
return;
Unit* caster = ObjectAccessor::GetUnit(*_player, guid);
if (!caster || (caster != _player->GetGuardianPet() && caster != _player->GetCharm()))
{
sLog->outError("HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)), GetPlayer()->GetName());
return;
}
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo)
{
sLog->outError("WORLD: unknown PET spell id %i", spellId);
return;
}
if (spellInfo->StartRecoveryCategory > 0) // Check if spell is affected by GCD
if (caster->GetTypeId() == TYPEID_UNIT && caster->ToCreature()->GetGlobalCooldown() > 0)
{
caster->SendPetCastFail(spellId, SPELL_FAILED_NOT_READY);
return;
}
// do not cast not learned spells
if (!caster->HasSpell(spellId) || IsPassiveSpell(spellId))
return;
SpellCastTargets targets;
targets.read(recvPacket, caster);
HandleClientCastFlags(recvPacket, castFlags, targets);
caster->ClearUnitState(UNIT_STAT_FOLLOW);
Spell *spell = new Spell(caster, spellInfo, false);
spell->m_cast_count = castCount; // probably pending spell cast
spell->m_targets = targets;
// TODO: need to check victim?
SpellCastResult result;
if (caster->m_movedPlayer)
result = spell->CheckPetCast(caster->m_movedPlayer->GetSelectedUnit());
else
result = spell->CheckPetCast(NULL);
if (result == SPELL_CAST_OK)
{
if (caster->GetTypeId() == TYPEID_UNIT)
{
Creature* pet = caster->ToCreature();
pet->AddCreatureSpellCooldown(spellId);
if (pet->isPet())
{
Pet* p = (Pet*)pet;
// 10% chance to play special pet attack talk, else growl
// actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell
if (p->getPetType() == SUMMON_PET && (urand(0, 100) < 10))
pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL);
else
pet->SendPetAIReaction(guid);
}
}
spell->prepare(&(spell->m_targets));
}
else
{
caster->SendPetCastFail(spellId, result);
if (caster->GetTypeId() == TYPEID_PLAYER)
{
if (!caster->ToPlayer()->HasSpellCooldown(spellId))
GetPlayer()->SendClearCooldown(spellId, caster);
}
else
{
if (!caster->ToCreature()->HasSpellCooldown(spellId))
GetPlayer()->SendClearCooldown(spellId, caster);
}
spell->finish(false);
delete spell;
}
}
开发者ID:xerkoss,项目名称:Project-WoW,代码行数:97,代码来源:PetHandler.cpp
示例4: GetDocument
void CGame2View::OnDraw(CDC* pDC)
{
int result;
CRect ClientRect;
CRect MapSectionRect;
CGame2Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
GameMapObserver *GameMap = pDoc->GetMap();
Unit *theUnit;
int max_x = pDoc->GetMapWidth();
int max_y = pDoc->GetMapHeight();
int x,y;
// clear the memory DC
mInMemoryScreenDC.FillSolidRect(mMapRect,RGB(255,255,255));
// Draw box around map...
mInMemoryScreenDC.MoveTo(0 ,0 );
mInMemoryScreenDC.LineTo(mMapRect.right - 1 ,0 );
mInMemoryScreenDC.LineTo(mMapRect.right - 1 ,mMapRect.bottom - 1);
mInMemoryScreenDC.LineTo(0 ,mMapRect.bottom - 1);
mInMemoryScreenDC.LineTo(0 ,0 );
// Draw into it
for (x = 0; x < max_x; x++)
{
for(y = 0; y < max_y; y++)
{
if( (theUnit = GameMap->RequestLoc(x,y)))
{
theUnit->DrawUnit(&mInMemoryScreenDC);
}
}
}
if(mBoundingBoxIsUp)
{
DrawBoundingBox(mCurSelectRect);
}
mFlasher +=20;
if(mFlasher>200)
mFlasher = 0;
mInMemoryScreenDC.FillSolidRect( 60 + mFlasher,
10,
10,
10,
RGB(0,0,0));
GetClientRect(&ClientRect);
MapSectionRect = ClientRect;
// OnPrepareDC();
pDC->DPtoLP(&MapSectionRect);
// Blt it to screen
result = pDC->BitBlt(MapSectionRect.left,
MapSectionRect.top,
ClientRect.right,
ClientRect.bottom,
&mInMemoryScreenDC,
MapSectionRect.left,
MapSectionRect.top,
SRCCOPY);
}
开发者ID:amitahire,项目名称:development,代码行数:71,代码来源:game2view.cpp
示例5: pow
double SbmlReader::transformUnits( double mvalue,UnitDefinition * ud,string type, bool hasonlySubUnit ) {
double lvalue = mvalue;
if (type == "compartment") {
for ( unsigned int ut = 0; ut < ud->getNumUnits(); ut++ ) {
Unit * unit = ud->getUnit(ut);
double exponent = unit->getExponent();
double multiplier = unit->getMultiplier();
int scale = unit->getScale();
double offset = unit->getOffset();
lvalue *= pow( multiplier * pow(10.0,scale), exponent ) + offset;
// Need to check if spatial dimension is less than 3 then,
// then volume conversion e-3 to convert cubicmeter shd not be done.
if ( unit->isLitre() ) {
lvalue *= pow(1e-3,exponent);
return lvalue;
}
}
} else if(type == "substance") {
for ( unsigned int ut = 0; ut < ud->getNumUnits(); ut++ ) {
Unit * unit = ud->getUnit(ut);
//cout << " :) " << UnitKind_toString(unit->getKind());
if ( unit->isMole() ) {
double exponent = unit->getExponent();
double multiplier = unit->getMultiplier();
int scale = unit->getScale();
double offset = unit->getOffset();
lvalue *= pow( multiplier * pow(10.0,scale), exponent ) + offset;
if (hasonlySubUnit)
// if hasonlySubstanceUnit is true, then unit is subtance
// In Moose nInit = no. of molecules( unit is items)
// no. of molecules (items) = mole * Avogadro no.
// In SBML if initial Amount is set to mole then convert from mole to items (#)
lvalue *= pow( NA ,exponent);
else
// if hasonlySubstanceUnit is false,
//Then convert mole to milli Molar for moose as concentration units are in milliMolar
// Molar = mole/size
lvalue *= pow(1e+3,exponent);
return lvalue;
} else if(unit->isItem())
return lvalue;
else if(unit->isSecond())
return lvalue;
else {
cout << "check this units type " <<UnitKind_toString(unit->getKind());
return lvalue;
}
}
}
return lvalue;
}
开发者ID:csiki,项目名称:moose-csiki,代码行数:51,代码来源:SbmlReader.cpp
示例6: stop2
int Unit::think_stop_chase()
{
//-----------------------------------------------------//
//
// Stop the chase if the target is being far away from
// its original attacking location.
//
//-----------------------------------------------------//
if( !(action_mode==ACTION_ATTACK_UNIT && ai_original_target_x_loc>=0) )
return 0;
if( unit_array.is_deleted(action_para) )
{
stop2();
return 1;
}
Unit* targetUnit = unit_array[action_para];
if( !targetUnit->is_visible() )
{
stop2();
return 1;
}
//----------------------------------------//
int aiChaseDistance = 10 + nation_array[nation_recno]->pref_military_courage/20; // chase distance: 10 to 15
int curDistance = m.points_distance( targetUnit->next_x_loc(), targetUnit->next_y_loc(),
ai_original_target_x_loc, ai_original_target_y_loc );
if( curDistance <= aiChaseDistance )
return 0;
//--------- stop the unit ----------------//
stop2();
//--- if this unit leads a troop, stop the action of all troop members as well ---//
int leaderUnitRecno;
if( leader_unit_recno )
leaderUnitRecno = leader_unit_recno;
else
leaderUnitRecno = sprite_recno;
TeamInfo* teamInfo = unit_array[leaderUnitRecno]->team_info;
if( teamInfo )
{
for( int i=teamInfo->member_count-1 ; i>=0 ; i-- )
{
int unitRecno = teamInfo->member_unit_array[i];
if( unit_array.is_deleted(unitRecno) )
continue;
unit_array[unitRecno]->stop2();
}
}
return 1;
}
开发者ID:brianV,项目名称:7kaa,代码行数:66,代码来源:OUNITAI.cpp
示例7: mobilize_town_people
//---- Begin of function Town::independent_unit_join_nation ----//
//
// <int> raceId - race id. of the unit
// <int> toNationRecno - recno of the nation the unit should turn toward
//
int Town::independent_unit_join_nation(int raceId, int toNationRecno)
{
//----- mobilize a villager ----//
int unitRecno = mobilize_town_people(raceId, 1, 0); // 1-dec population after mobilizing the unit, 0-don't mobilize spies
if( !unitRecno )
return 0;
Unit* unitPtr = unit_array[unitRecno];
//----- set the skills of the unit -----//
int skillId, skillLevel, combatLevel;
switch( misc.random(3) )
{
case 0: // leaders
skillId = SKILL_LEADING;
if( misc.random(3)==0 )
skillLevel = misc.random(100);
else
skillLevel = misc.random(50);
combatLevel = skillLevel + misc.random(40) - 20;
combatLevel = MIN(combatLevel, 100);
combatLevel = MAX(combatLevel, 10);
break;
case 1: // peasants
skillId = 0;
skillLevel = 0;
combatLevel = 10 + misc.random(10);
break;
case 2: // skilled units
skillId = misc.random(MAX_TRAINABLE_SKILL)+1;
{
int loopCount=0; // no spying skill
while( skillId==SKILL_SPYING )
{
if( ++skillId > MAX_TRAINABLE_SKILL )
skillId = 1;
err_when( ++loopCount > 100 );
}
}
skillLevel = 10+misc.random(80);
combatLevel = 10+misc.random(30);
break;
}
//--------------------------------------//
unitPtr->skill.skill_id = skillId;
unitPtr->skill.skill_level = skillLevel;
unitPtr->set_combat_level( combatLevel );
//------ change nation now --------//
if( !unitPtr->betray(toNationRecno) )
return 0;
//---- the unit moves close to the newly joined nation ----//
unitPtr->ai_move_to_nearby_town();
//-------- set last_independent_unit_join_date --------//
nation_array[toNationRecno]->last_independent_unit_join_date = info.game_date;
return 1;
}
开发者ID:AMDmi3,项目名称:7kaa,代码行数:80,代码来源:OTOWNIND.cpp
示例8: UpdateAI
void UpdateAI(const uint32 uiDiff)
{
//Return since we have no target
if (!m_creature->SelectHostilTarget() || !m_creature->getVictim())
return;
//m_uiEarthquake_Timer
if (m_uiEarthquake_Timer < uiDiff)
{
if (!m_bEarthquake)
{
DoCast(m_creature->getVictim(), SPELL_EARTHQUAKE);
m_bEarthquake = true;
m_uiEarthquake_Timer = 5000;
}
else
{
DoScriptText(urand(0,1) ? SAY_SUMMON1 : SAY_SUMMON2, m_creature);
//north
m_creature->CastSpell(m_creature,SPELL_SUMMON_MURLOC_A6,true);
m_creature->CastSpell(m_creature,SPELL_SUMMON_MURLOC_A7,true);
m_creature->CastSpell(m_creature,SPELL_SUMMON_MURLOC_A8,true);
m_creature->CastSpell(m_creature,SPELL_SUMMON_MURLOC_A9,true);
m_creature->CastSpell(m_creature,SPELL_SUMMON_MURLOC_A10,true);
//south
m_creature->CastSpell(m_creature,SPELL_SUMMON_MURLOC_B6,true);
m_creature->CastSpell(m_creature,SPELL_SUMMON_MURLOC_B7,true);
m_creature->CastSpell(m_creature,SPELL_SUMMON_MURLOC_B8,true);
m_creature->CastSpell(m_creature,SPELL_SUMMON_MURLOC_B9,true);
m_creature->CastSpell(m_creature,SPELL_SUMMON_MURLOC_B10,true);
DoScriptText(EMOTE_EARTHQUAKE, m_creature);
m_bEarthquake = false;
m_uiEarthquake_Timer = 40000+rand()%5000;
}
}else m_uiEarthquake_Timer -= uiDiff;
//m_uiTidalWave_Timer
if (m_uiTidalWave_Timer < uiDiff)
{
DoCast(m_creature->getVictim(), SPELL_TIDAL_WAVE);
m_uiTidalWave_Timer = 20000;
}else m_uiTidalWave_Timer -= uiDiff;
if (!m_bPhase2)
{
//m_uiWateryGrave_Timer
if (m_uiWateryGrave_Timer < uiDiff)
{
//Teleport 4 players under the waterfalls
for(uint8 i = 0; i < 4; i++)
{
Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1);
if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER && !pTarget->HasAuraType(SPELL_AURA_MOD_STUN) && pTarget->IsWithinDistInMap(m_creature, 45.0f))
{
switch(i)
{
case 0: m_creature->CastSpell(pTarget,SPELL_WATERY_GRAVE_1,false); break;
case 1: m_creature->CastSpell(pTarget,SPELL_WATERY_GRAVE_2,false); break;
case 2: m_creature->CastSpell(pTarget,SPELL_WATERY_GRAVE_3,false); break;
case 3: m_creature->CastSpell(pTarget,SPELL_WATERY_GRAVE_4,false); break;
}
}
}
DoScriptText(urand(0,1) ? SAY_SUMMON_BUBL1 : SAY_SUMMON_BUBL2, m_creature);
DoScriptText(EMOTE_WATERY_GRAVE, m_creature);
m_uiWateryGrave_Timer = 30000;
}else m_uiWateryGrave_Timer -= uiDiff;
//Start Phase2
if ((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 25)
m_bPhase2 = true;
}
else
{
//m_uiWateryGlobules_Timer
if (m_uiWateryGlobules_Timer < uiDiff)
{
DoScriptText(EMOTE_WATERY_GLOBULES, m_creature);
m_creature->CastSpell(m_creature,SPELL_SUMMON_GLOBULE_1,true);
m_creature->CastSpell(m_creature,SPELL_SUMMON_GLOBULE_2,true);
m_creature->CastSpell(m_creature,SPELL_SUMMON_GLOBULE_3,true);
m_creature->CastSpell(m_creature,SPELL_SUMMON_GLOBULE_4,false);
m_uiWateryGlobules_Timer = 25000;
}else m_uiWateryGlobules_Timer -= uiDiff;
}
DoMeleeAttackIfReady();
}
开发者ID:,项目名称:,代码行数:97,代码来源:
示例9: UpdateAI
void UpdateAI(const uint32 diff)
{
//Check if we have a target
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
//No instance
if (!m_pInstance)
return;
switch (m_pInstance->GetData(TYPE_CTHUN_PHASE))
{
case 0:
{
//BeamTimer
if (BeamTimer < diff)
{
//SPELL_GREEN_BEAM
Unit* target = NULL;
target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0);
if (target)
{
m_creature->InterruptNonMeleeSpells(false);
DoCastSpellIfCan(target,SPELL_GREEN_BEAM);
//Correctly update our target
m_creature->SetUInt64Value(UNIT_FIELD_TARGET, target->GetGUID());
}
//Beam every 3 seconds
BeamTimer = 3000;
}else BeamTimer -= diff;
//ClawTentacleTimer
if (ClawTentacleTimer < diff)
{
Unit* target = NULL;
target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0);
if (target)
{
Creature* Spawned = NULL;
//Spawn claw tentacle on the random target
Spawned = (Creature*)m_creature->SummonCreature(MOB_CLAW_TENTACLE,target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(),0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,500);
if (Spawned)
Spawned->AI()->AttackStart(target);
}
//One claw tentacle every 12.5 seconds
ClawTentacleTimer = 12500;
}else ClawTentacleTimer -= diff;
//EyeTentacleTimer
if (EyeTentacleTimer < diff)
{
//Spawn the 8 Eye Tentacles in the corret spots
SpawnEyeTentacle(0, 20); //south
SpawnEyeTentacle(10, 10); //south west
SpawnEyeTentacle(20, 0); //west
SpawnEyeTentacle(10, -10); //north west
SpawnEyeTentacle(0, -20); //north
SpawnEyeTentacle(-10, -10); //north east
SpawnEyeTentacle(-20, 0); // east
SpawnEyeTentacle(-10, 10); // south east
//No point actually putting a timer here since
//These shouldn't trigger agian until after phase shifts
EyeTentacleTimer = 45000;
}else EyeTentacleTimer -= diff;
//PhaseTimer
if (PhaseTimer < diff)
{
//Switch to Dark Beam
m_pInstance->SetData(TYPE_CTHUN_PHASE, 1);
m_creature->InterruptNonMeleeSpells(false);
//Select random target for dark beam to start on
Unit* target = NULL;
target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0);
if (target)
{
//Correctly update our target
m_creature->SetUInt64Value(UNIT_FIELD_TARGET, target->GetGUID());
//Face our target
DarkGlareAngle = m_creature->GetAngle(target);
DarkGlareTickTimer = 1000;
DarkGlareTick = 0;
ClockWise = urand(0, 1);
}
//Add red coloration to C'thun
DoCastSpellIfCan(m_creature,SPELL_RED_COLORATION);
//Freeze animation
//.........这里部分代码省略.........
开发者ID:sd0,项目名称:scriptdevzero,代码行数:101,代码来源:boss_cthun.cpp
示例10: UpdateAI
void UpdateAI(const uint32 uiDiff)
{
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
// Mortal Wound
if (m_uiMortalWoundTimer < uiDiff)
{
DoCast(m_creature->getVictim(), SPELL_MORTALWOUND);
m_uiMortalWoundTimer = 10000;
}
else
m_uiMortalWoundTimer -= uiDiff;
//Decimate_Timer
if (m_uiDecimateTimer < uiDiff)
{
DoCast(m_creature->getVictim(),SPELL_DECIMATE); // need core support
// workaround below
std::list<HostileReference*> t_list = m_creature->getThreatManager().getThreatList();
if (t_list.size())
{
//begin + 1 , so we don't target the one with the highest threat
std::list<HostileReference*>::iterator itr = t_list.begin();
std::advance(itr, 1);
for(; itr!= t_list.end(); ++itr)
{
Unit *target = m_creature->GetMap()->GetUnit((*itr)->getUnitGuid());
if (target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER &&
(target->GetHealth() > target->GetMaxHealth() * 0.05))
target->SetHealth(target->GetMaxHealth() * 0.05);
}
}
// Move Zombies
if (!m_lZombieGUIDList.empty())
{
for(std::list<uint64>::iterator itr = m_lZombieGUIDList.begin(); itr != m_lZombieGUIDList.end(); ++itr)
if (Creature* pTemp = m_creature->GetMap()->GetCreature(*itr))
if (pTemp->isAlive())
{
((mob_zombie_chowsAI*)pTemp->AI())->bIsForceMove = true;
if (m_creature->GetHealth() > m_creature->GetMaxHealth() * 0.05) // remove when SPELL_DECIMATE is working
pTemp->SetHealth(pTemp->GetMaxHealth() * 0.02);
pTemp->AddThreat(m_creature, 1000000000.0f); // force move toward to Gluth
}
}
m_uiDecimateTimer = (m_bIsRegularMode ? 100000 : 120000);
}else m_uiDecimateTimer -= uiDiff;
// Enrage
if (m_uiEnrageTimer < uiDiff)
{
DoCast(m_creature, m_bIsRegularMode ? SPELL_ENRAGE : SPELL_ENRAGE_H);
m_uiEnrageTimer = 60000;
}
else m_uiEnrageTimer -= uiDiff;
if (RangeCheck_Timer < uiDiff)
{
if (!m_lZombieGUIDList.empty())
{
for(std::list<uint64>::iterator itr = m_lZombieGUIDList.begin(); itr != m_lZombieGUIDList.end(); ++itr)
if (Creature* pTemp = m_creature->GetMap()->GetCreature(*itr))
if (pTemp->isAlive() && m_creature->IsWithinDistInMap(pTemp, ATTACK_DISTANCE))
{
DoScriptText(EMOTE_ZOMBIE, m_creature);
m_creature->SetHealth(m_creature->GetHealth() + m_creature->GetMaxHealth() * 0.05);
pTemp->ForcedDespawn();
}
}
RangeCheck_Timer = 1000;
}else RangeCheck_Timer -= uiDiff;
//Summon_Timer
if (Summon_Timer < uiDiff)
{
for(uint8 i = 0; i < (m_bIsRegularMode ? 1 : 2); i++)
{
if (Creature* pZombie = m_creature->SummonCreature(NPC_ZOMBIE_CHOW,ADD_1X,ADD_1Y,ADD_1Z,0,TEMPSUMMON_TIMED_OR_DEAD_DESPAWN,80000))
{
if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
{
pZombie->AddThreat(pTarget);
m_lZombieGUIDList.push_back(pZombie->GetGUID());
}
}
}
Summon_Timer = 10000;
} else Summon_Timer -= uiDiff;
// Berserk
if (m_uiBerserkTimer < uiDiff)
{
DoCastSpellIfCan(m_creature, SPELL_BERSERK, CAST_TRIGGERED);
m_uiBerserkTimer = MINUTE*5*IN_MILLISECONDS;
}
else
m_uiBerserkTimer -= uiDiff;
//.........这里部分代码省略.........
开发者ID:vanadiel,项目名称:scriptdev2_stable,代码行数:101,代码来源:boss_gluth.cpp
示例11: UpdateAI
void UpdateAI(uint32 diff)
{
if (!UpdateVictim())
return;
//Invisible_Timer
if (Invisible_Timer <= diff)
{
me->InterruptSpell(CURRENT_GENERIC_SPELL);
SetEquipmentSlots(false, EQUIP_UNEQUIP, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE);
me->SetDisplayId(11686);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
Invisible = true;
Invisible_Timer = urand(15000, 30000);
} else Invisible_Timer -= diff;
if (Invisible)
{
if (Ambush_Timer <= diff)
{
Unit* target = NULL;
target = SelectTarget(SELECT_TARGET_RANDOM, 0);
if (target)
{
DoTeleportTo(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
DoCast(target, SPELL_AMBUSH);
}
Ambushed = true;
Ambush_Timer = 3000;
} else Ambush_Timer -= diff;
}
if (Ambushed)
{
if (Visible_Timer <= diff)
{
me->InterruptSpell(CURRENT_GENERIC_SPELL);
me->SetDisplayId(15268);
SetEquipmentSlots(false, EQUIP_ID_MAIN_HAND, EQUIP_NO_CHANGE, EQUIP_NO_CHANGE);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
Invisible = false;
Visible_Timer = 4000;
} else Visible_Timer -= diff;
}
//Resetting some aggro so he attacks other gamers
if (!Invisible)
{
if (Aggro_Timer <= diff)
{
Unit* target = NULL;
target = SelectTarget(SELECT_TARGET_RANDOM, 1);
if (DoGetThreat(me->getVictim()))
DoModifyThreatPercent(me->getVictim(), -50);
if (target)
AttackStart(target);
Aggro_Timer = urand(7000, 20000);
} else Aggro_Timer -= diff;
if (ThousandBlades_Timer <= diff)
{
DoCast(me->getVictim(), SPELL_THOUSANDBLADES);
ThousandBlades_Timer = urand(7000, 12000);
} else ThousandBlades_Timer -= diff;
}
DoMeleeAttackIfReady();
}
开发者ID:Arkania,项目名称:ArkCORE4,代码行数:78,代码来源:boss_renataki.cpp
示例12: TC_LOG_ERROR
uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject const* whisperTarget /*= nullptr*/, ChatMsg msgType /*= CHAT_MSG_ADDON*/, Language language /*= LANG_ADDON*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, uint32 sound /*= 0*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/, Player* srcPlr /*= nullptr*/)
{
if (!source)
return 0;
CreatureTextMap::const_iterator sList = mTextMap.find(source->GetEntry());
if (sList == mTextMap.end())
{
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Could not find Text for Creature %s (%s) in 'creature_text' table. Ignoring.", source->GetName().c_str(), source->GetGUID().ToString().c_str());
return 0;
}
CreatureTextHolder const& textHolder = sList->second;
CreatureTextHolder::const_iterator itr = textHolder.find(textGroup);
if (itr == textHolder.end())
{
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Could not find TextGroup %u for Creature %s (%s) in 'creature_text' table. Ignoring.", uint32(textGroup), source->GetName().c_str(), source->GetGUID().ToString().c_str());
return 0;
}
CreatureTextGroup const& textGroupContainer = itr->second; //has all texts in the group
CreatureTextRepeatIds repeatGroup = GetRepeatGroup(source, textGroup);//has all textIDs from the group that were already said
CreatureTextGroup tempGroup;//will use this to talk after sorting repeatGroup
for (CreatureTextGroup::const_iterator giter = textGroupContainer.begin(); giter != textGroupContainer.end(); ++giter)
if (std::find(repeatGroup.begin(), repeatGroup.end(), giter->id) == repeatGroup.end())
tempGroup.push_back(*giter);
if (tempGroup.empty())
{
source->ClearTextRepeatGroup(textGroup);
tempGroup = textGroupContainer;
}
auto iter = Trinity::Containers::SelectRandomWeightedContainerElement(tempGroup, [](CreatureTextEntry const& t) -> double
{
return t.probability;
});
ChatMsg finalType = (msgType == CHAT_MSG_ADDON) ? iter->type : msgType;
Language finalLang = (language == LANG_ADDON) ? iter->lang : language;
uint32 finalSound = sound ? sound : iter->sound;
if (range == TEXT_RANGE_NORMAL)
range = iter->TextRange;
if (finalSound)
SendSound(source, finalSound, finalType, whisperTarget, range, team, gmOnly);
Unit* finalSource = source;
if (srcPlr)
finalSource = srcPlr;
if (iter->emote)
SendEmote(finalSource, iter->emote);
if (srcPlr)
{
PlayerTextBuilder builder(source, finalSource, finalSource->getGender(), finalType, iter->group, iter->id, finalLang, whisperTarget);
SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
}
else
{
CreatureTextBuilder builder(finalSource, finalSource->getGender(), finalType, iter->group, iter->id, finalLang, whisperTarget);
SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly);
}
SetRepeatId(source, textGroup, iter->id);
return iter->duration;
}
开发者ID:DSlayerMan,项目名称:DraenorCore,代码行数:70,代码来源:CreatureTextMgr.cpp
示例13: LookupOpcodeName
void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
{
uint32 opcode = recv_data.GetOpcode();
sLog.outDebug("WORLD: Recvd %s (%u, 0x%X) opcode", LookupOpcodeName(opcode), opcode, opcode);
Unit *mover = _player->m_mover;
Player *plMover = mover->GetTypeId()==TYPEID_PLAYER ? (Player*)mover : NULL;
// ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck
if(plMover && plMover->IsBeingTeleported())
{
// movement anticheat
plMover->m_anti_JustTeleported = 1;
// end movement anticheat
return;
}
/* extract packet */
MovementInfo movementInfo;
ReadMovementInfo(recv_data, &movementInfo);
/*----------------*/
if(!(movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT) && _player->GetVehicleGUID())
{
if(mover->GetGUID() == _player->GetGUID())
{
return;
}
}
// we sent a movement packet with MOVEMENTFLAG_ONTRANSPORT and we are on vehicle
// this can be moving on vehicle or entering another transport (eg. boat)
if((movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT) && _player->GetVehicleGUID())
{
// we are controlling that vehicle
if(mover->GetGUID() == _player->GetVehicleGUID())
{
// we sent movement packet, related to movement ON vehicle,
// but not WITH vehicle, so mover = player
if(_player->GetVehicleGUID() == movementInfo.t_guid)
{
// this is required to avoid client crash, otherwise it will result
// in moving with vehicle on the same vehicle and that = crash
mover = _player;
plMover = _player;
}
}
if(_player->GetVehicleGUID() == movementInfo.t_guid)
{
_player->m_SeatData.OffsetX = movementInfo.t_x;
_player->m_SeatData.OffsetY = movementInfo.t_y;
_player->m_SeatData.OffsetZ = movementInfo.t_z;
_player->m_SeatData.Orientation = movementInfo.t_o;
}
}
if(recv_data.size() != recv_data.rpos())
{
sLog.outError("MovementHandler: player %s (guid %d, account %u) sent a packet (opcode %u) that is " SIZEFMTD " bytes larger than it should be. Kicked as cheater.", _player->GetName(), _player->GetGUIDLow(), _player->GetSession()->GetAccountId(), recv_data.GetOpcode(), recv_data.size() - recv_data.rpos());
KickPlayer();
return;
}
if (!MaNGOS::IsValidMapCoord(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o))
return;
/* handle special cases */
if (movementInfo.HasMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && !mover->GetVehicleGUID())
{
// transports size limited
// (also received at zeppelin leave by some reason with t_* as absolute in continent coordinates, can be safely skipped)
if( movementInfo.t_x > 60 || movementInfo.t_y > 60 || movementInfo.t_x < -60 || movementInfo.t_y < -60 )
return;
if( !MaNGOS::IsValidMapCoord(movementInfo.x+movementInfo.t_x, movementInfo.y + movementInfo.t_y,
movementInfo.z + movementInfo.t_z, movementInfo.o + movementInfo.t_o) )
return;
if (plMover && plMover->m_anti_TransportGUID == 0 && (movementInfo.t_guid !=0))
{
// if we boarded a transport, add us to it
if (plMover && !plMover->m_transport)
{
// elevators also cause the client to send MOVEMENTFLAG_ONTRANSPORT - just unmount if the guid can be found in the transport list
for (MapManager::TransportSet::const_iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter)
{
if ((*iter)->GetGUID() == movementInfo.t_guid)
{
plMover->m_transport = (*iter);
(*iter)->AddPassenger(plMover);
break;
}
}
}
//movement anticheat;
//Correct finding GO guid in DB (thanks to GriffonHeart)
GameObject *obj = HashMapHolder<GameObject>::Find(movementInfo.t_guid);
if(obj)
plMover->m_anti_TransportGUID = obj->GetDBTableGUIDLow();
else
plMover->m_anti_TransportGUID = GUID_LOPART(movementInfo.t_guid);
//.........这里部分代码省略.........
开发者ID:Trizzor,项目名称:uecore,代码行数:101,代码来源:MovementHandler.cpp
示例14: DEBUG_FILTER_LOG
void WorldSession::HandleGetMirrorimageData(WorldPacket& recv_data)
{
DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: CMSG_GET_MIRRORIMAGE_DATA");
ObjectGuid guid;
recv_data >> guid;
Creature* pCreature = _player->GetMap()->GetAnyTypeCreature(guid);
if (!pCreature)
return;
Unit::AuraList const& images = pCreature->GetAurasByType(SPELL_AURA_MIRROR_IMAGE);
if (images.empty())
return;
Unit* pCaster = images.front()->GetCaster();
WorldPacket data(SMSG_MIRRORIMAGE_DATA, 68);
data << guid;
data << (uint32)pCreature->GetDisplayId();
data << (uint8)pCreature->getRace();
data << (uint8)pCreature->getGender();
data << (uint8)pCreature->getClass();
if (pCaster && pCaster->GetTypeId() == TYPEID_PLAYER)
{
Player* pPlayer = (Player*)pCaster;
// skin, face, hair, haircolor
data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES, 0);
data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES, 1);
data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES, 2);
data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES, 3);
// facial hair
data << (uint8)pPlayer->GetByteValue(PLAYER_BYTES_2, 0);
// guild id
data << (uint32)pPlayer->GetGuildId();
if (pPlayer->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM))
data << (uint32)0;
else
data << (uint32)pPlayer->GetItemDisplayIdInSlot(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_HEAD
|
请发表评论