本文整理汇总了C++中Creature类的典型用法代码示例。如果您正苦于以下问题:C++ Creature类的具体用法?C++ Creature怎么用?C++ Creature使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Creature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoWaveSpawnForCreature
void DoWaveSpawnForCreature(Creature* creature)
{
switch (creature->GetEntry())
{
case ENTRY_BNAAR_C_CONSOLE:
if (rand()%2)
{
add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2933.68f, 4162.55f, 164.00f, 1.60f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
if (add) add->GetMotionMaster()->MovePoint(0, 2927.36f, 4212.97f, 164.00f);
}
else
{
add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2927.36f, 4212.97f, 164.00f, 4.94f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
if (add) add->GetMotionMaster()->MovePoint(0, 2933.68f, 4162.55f, 164.00f);
}
Wave_Timer = 30000;
break;
case ENTRY_CORUU_C_CONSOLE:
add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2445.21f, 2765.26f, 134.49f, 3.93f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
if (add) add->GetMotionMaster()->MovePoint(0, 2424.21f, 2740.15f, 133.81f);
add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2429.86f, 2731.85f, 134.53f, 1.31f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
if (add) add->GetMotionMaster()->MovePoint(0, 2435.37f, 2766.04f, 133.81f);
Wave_Timer = 20000;
break;
case ENTRY_DURO_C_CONSOLE:
add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2986.80f, 2205.36f, 165.37f, 3.74f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
if (add) add->GetMotionMaster()->MovePoint(0, 2985.15f, 2197.32f, 164.79f);
add = me->SummonCreature(ENTRY_SUNFURY_TECH, 2952.91f, 2191.20f, 165.32f, 0.22f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
if (add) add->GetMotionMaster()->MovePoint(0, 2060.01f, 2185.27f, 164.67f);
Wave_Timer = 15000;
break;
case ENTRY_ARA_C_CONSOLE:
if (rand()%2)
{
add = me->SummonCreature(ENTRY_ARA_TECH, 4035.11f, 4038.97f, 194.27f, 2.57f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
if (add) add->GetMotionMaster()->MovePoint(0, 4003.42f, 4040.19f, 193.49f);
add = me->SummonCreature(ENTRY_ARA_TECH, 4033.66f, 4036.79f, 194.28f, 2.57f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
if (add) add->GetMotionMaster()->MovePoint(0, 4003.42f, 4040.19f, 193.49f);
add = me->SummonCreature(ENTRY_ARA_TECH, 4037.13f, 4037.30f, 194.23f, 2.57f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
if (add) add->GetMotionMaster()->MovePoint(0, 4003.42f, 4040.19f, 193.49f);
}
else
{
add = me->SummonCreature(ENTRY_ARA_TECH, 3099.59f, 4049.30f, 194.22f, 0.05f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
if (add) add->GetMotionMaster()->MovePoint(0, 4028.01f, 4035.17f, 193.59f);
add = me->SummonCreature(ENTRY_ARA_TECH, 3999.72f, 4046.75f, 194.22f, 0.05f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
if (add) add->GetMotionMaster()->MovePoint(0, 4028.01f, 4035.17f, 193.59f);
add = me->SummonCreature(ENTRY_ARA_TECH, 3996.81f, 4048.26f, 194.22f, 0.05f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000);
if (add) add->GetMotionMaster()->MovePoint(0, 4028.01f, 4035.17f, 193.59f);
}
Wave_Timer = 15000;
break;
}
}
示例2: UpdateAI
void UpdateAI(const uint32 diff)
{
if (!me->isInCombat())
{
if (instance)
{
// Do not let the raid skip straight to Archimonde. Visible and hostile ONLY if Azagalor is finished.
if ((instance->GetData(DATA_AZGALOREVENT) < DONE) && (me->IsVisible() || (me->getFaction() != 35)))
{
me->SetVisible(false);
me->setFaction(35);
}
else if ((instance->GetData(DATA_AZGALOREVENT) >= DONE) && (!me->IsVisible() || (me->getFaction() == 35)))
{
me->setFaction(1720);
me->SetVisible(true);
}
}
if (DrainNordrassilTimer <= diff)
{
if (!IsChanneling)
{
Creature* temp = me->SummonCreature(CREATURE_CHANNEL_TARGET, NordrassilLoc, TEMPSUMMON_TIMED_DESPAWN, 1200000);
if (temp)
WorldTreeGUID = temp->GetGUID();
if (Unit* Nordrassil = Unit::GetUnit(*me, WorldTreeGUID))
{
Nordrassil->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
Nordrassil->SetDisplayId(11686);
DoCast(Nordrassil, SPELL_DRAIN_WORLD_TREE);
IsChanneling = true;
}
}
if (Unit* Nordrassil = Unit::GetUnit(*me, WorldTreeGUID))
{
Nordrassil->CastSpell(me, SPELL_DRAIN_WORLD_TREE_2, true);
DrainNordrassilTimer = 1000;
}
} else DrainNordrassilTimer -= diff;
}
if (!UpdateVictim())
return;
if (me->HealthBelowPct(10) && !BelowTenPercent && !Enraged)
BelowTenPercent = true;
if (!Enraged)
{
if (EnrageTimer <= diff)
{
if (HealthAbovePct(10))
{
me->GetMotionMaster()->Clear(false);
me->GetMotionMaster()->MoveIdle();
Enraged = true;
Talk(SAY_ENRAGE);
}
} else EnrageTimer -= diff;
if (CheckDistanceTimer <= diff)
{
// To simplify the check, we simply summon a Creature in the location and then check how far we are from the creature
Creature* Check = me->SummonCreature(CREATURE_CHANNEL_TARGET, NordrassilLoc, TEMPSUMMON_TIMED_DESPAWN, 2000);
if (Check)
{
Check->SetVisible(false);
if (me->IsWithinDistInMap(Check, 75))
{
me->GetMotionMaster()->Clear(false);
me->GetMotionMaster()->MoveIdle();
Enraged = true;
Talk(SAY_ENRAGE);
}
}
CheckDistanceTimer = 5000;
} else CheckDistanceTimer -= diff;
}
if (BelowTenPercent)
{
if (!HasProtected)
{
me->GetMotionMaster()->Clear(false);
me->GetMotionMaster()->MoveIdle();
//all members of raid must get this buff
DoCastVictim(SPELL_PROTECTION_OF_ELUNE, true);
HasProtected = true;
Enraged = true;
}
if (SummonWispTimer <= diff)
{
DoSpawnCreature(CREATURE_ANCIENT_WISP, float(rand()%40), float(rand()%40), 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
//.........这里部分代码省略.........
示例3: GetPlayer
//this void creates new auction and adds auction to some auctionhouse
void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_AUCTION_SELL_ITEM");
uint64 auctioneer, item;
uint64 bid, buyout;
uint32 etime, count;
uint32 unk = 1;
recv_data >> auctioneer; // uint64
recv_data >> unk; // 1
recv_data >> item; // uint64
recv_data >> count; // 3.2.2, number of items being auctioned
recv_data >> bid; // uint64, 4.0.6
recv_data >> buyout; // uint64, 4.0.6
recv_data >> etime; // uint32
Player* player = GetPlayer();
if (!item || !bid || !etime)
return; //check for cheaters
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
if (!creature)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleAuctionSellItem - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(auctioneer)));
return;
}
AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(creature->getFaction());
if (!auctionHouseEntry)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleAuctionSellItem - Unit (GUID: %u) has wrong faction.", uint32(GUID_LOPART(auctioneer)));
return;
}
// client send time in minutes, convert to common used sec time
etime *= MINUTE;
// client understand only 3 auction time
switch (etime)
{
case 1 * MIN_AUCTION_TIME:
case 2 * MIN_AUCTION_TIME:
case 4 * MIN_AUCTION_TIME:
break;
default:
return;
}
// remove fake death
if (GetPlayer()->HasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
Item* it = player->GetItemByGuid(item);
//do not allow to sell already auctioned items
if (sAuctionMgr->GetAItem(GUID_LOPART(item)))
{
sLog->outError("AuctionError, player %s is sending item id: %u, but item is already in another auction", player->GetName(), GUID_LOPART(item));
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
// prevent sending bag with items (cheat: can be placed in bag after adding equiped empty bag to auction)
if (!it)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_ITEM_NOT_FOUND);
return;
}
if (!it->CanBeTraded())
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
if (it->GetTemplate()->Flags & ITEM_PROTO_FLAG_CONJURED || it->GetUInt32Value(ITEM_FIELD_DURATION))
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
if (it->IsNotEmptyBag())
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
}
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
//we have to take deposit :
uint64 deposit = sAuctionMgr->GetAuctionDeposit(auctionHouseEntry, etime, it, count);
if (!player->HasEnoughMoney(deposit))
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_NOT_ENOUGH_MONEY);
return;
}
if (AccountMgr::IsGMAccount(GetSecurity()) && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE))
{
sLog->outCommand(GetAccountId(), "GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
//.........这里部分代码省略.........
示例4: UpdateAI
void UpdateAI(uint32 diff) override
{
//Check if we have a target
if (!UpdateVictim())
return;
uint32 currentPhase = instance->GetData(DATA_CTHUN_PHASE);
if (currentPhase == PHASE_EYE_GREEN_BEAM || currentPhase == PHASE_EYE_RED_BEAM)
{
// 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
EyeTentacleTimer = 45000;
} else EyeTentacleTimer -= diff;
}
switch (currentPhase)
{
case PHASE_EYE_GREEN_BEAM:
//BeamTimer
if (BeamTimer <= diff)
{
//SPELL_GREEN_BEAM
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
{
me->InterruptNonMeleeSpells(false);
DoCast(target, SPELL_GREEN_BEAM);
//Correctly update our target
me->SetTarget(target->GetGUID());
}
//Beam every 3 seconds
BeamTimer = 3000;
} else BeamTimer -= diff;
//ClawTentacleTimer
if (ClawTentacleTimer <= diff)
{
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
{
Creature* Spawned = NULL;
//Spawn claw tentacle on the random target
Spawned = me->SummonCreature(NPC_CLAW_TENTACLE, *target, TEMPSUMMON_CORPSE_DESPAWN, 500);
if (Spawned && Spawned->AI())
Spawned->AI()->AttackStart(target);
}
//One claw tentacle every 12.5 seconds
ClawTentacleTimer = 12500;
} else ClawTentacleTimer -= diff;
//PhaseTimer
if (PhaseTimer <= diff)
{
//Switch to Dark Beam
instance->SetData(DATA_CTHUN_PHASE, PHASE_EYE_RED_BEAM);
me->InterruptNonMeleeSpells(false);
me->SetReactState(REACT_PASSIVE);
//Remove any target
me->SetTarget(ObjectGuid::Empty);
//Select random target for dark beam to start on
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
{
//Face our target
DarkGlareAngle = me->GetAngle(target);
DarkGlareTickTimer = 1000;
DarkGlareTick = 0;
ClockWise = RAND(true, false);
}
//Add red coloration to C'thun
DoCast(me, SPELL_RED_COLORATION, true);
//Freeze animation
DoCast(me, SPELL_FREEZE_ANIM);
me->SetOrientation(DarkGlareAngle);
me->StopMoving();
//Darkbeam for 35 seconds
PhaseTimer = 35000;
} else PhaseTimer -= diff;
break;
//.........这里部分代码省略.........
示例5: UpdateFollowerAI
void UpdateFollowerAI(uint32 Diff)
{
if (!UpdateVictim())
{
//we are doing the post-event, or...
if (HasFollowState(STATE_FOLLOW_POSTEVENT))
{
if (PostEventTimer <= Diff)
{
PostEventTimer = 5000;
Creature* torta = Creature::GetCreature(*me, TortaGUID);
if (!torta || !torta->isAlive())
{
//something happened, so just complete
SetFollowComplete();
return;
}
switch (PhasePostEvent)
{
case 1:
Talk(SAY_TOOG_POST_1);
break;
case 2:
torta->AI()->Talk(SAY_TORT_POST_2);
break;
case 3:
Talk(SAY_TOOG_POST_3);
break;
case 4:
torta->AI()->Talk(SAY_TORT_POST_4);
break;
case 5:
Talk(SAY_TOOG_POST_5);
break;
case 6:
torta->AI()->Talk(SAY_TORT_POST_6);
me->GetMotionMaster()->MovePoint(POINT_ID_TO_WATER, ToWaterLoc);
break;
}
++PhasePostEvent;
}
else
PostEventTimer -= Diff;
}
//...we are doing regular speech check
else if (HasFollowState(STATE_FOLLOW_INPROGRESS))
{
if (CheckSpeechTimer <= Diff)
{
CheckSpeechTimer = 5000;
if (urand(0, 9) > 8)
Talk(SAY_TOOG_WORRIED);
}
else
CheckSpeechTimer -= Diff;
}
return;
}
DoMeleeAttackIfReady();
}
示例6: UpdateAI
void UpdateAI(const uint32 uiDiff)
{
if (uiPhase)
{
if (uiTimer <= uiDiff)
{
switch (uiPhase)
{
case 1:
DoScriptText(SAY_QUEST_ACCEPT_ATTACK, m_creature);
uiTimer = 3000;
uiPhase = 2;
break;
case 2:
if (pTyrion)
DoScriptText(SAY_TYRION_1, pTyrion);
uiTimer = 3000;
uiPhase = 3;
break;
case 3:
m_creature->UpdateEntry(NPC_PRIESTESS_TYRIONA, ALLIANCE);
uiTimer = 2000;
uiPhase = 4;
break;
case 4:
SetEscortPaused(false);
uiPhase = 0;
uiTimer = 0;
break;
case 5:
if (Creature* pGuard = m_creature->FindNearestCreature(NPC_STORMWIND_ROYAL, 10.0f, true))
DoScriptText(SAY_GUARD_1, pGuard);
uiTimer = 3000;
uiPhase = 6;
break;
case 6:
DoScriptText(SAY_SPYBOT_2, m_creature);
uiTimer = 3000;
uiPhase = 7;
break;
case 7:
SetEscortPaused(false);
uiTimer = 0;
uiPhase = 0;
break;
case 8:
if (pLescovar)
DoScriptText(SAY_LESCOVAR_1, pLescovar);
uiTimer = 3000;
uiPhase = 9;
break;
case 9:
DoScriptText(SAY_SPYBOT_4, m_creature);
uiTimer = 3000;
uiPhase = 10;
break;
case 10:
if (pLescovar && pLescovar->isAlive())
{
if (Player* pPlayer = GetPlayerForEscort())
CAST_AI(npc_lord_gregor_lescovarAI,pLescovar->AI())->Start(false, false, pPlayer->GetGUID());
CAST_AI(npc_lord_gregor_lescovarAI, pLescovar->AI())->SetMaxPlayerDistance(200.0f);
}
m_creature->DisappearAndDie();
uiTimer = 0;
uiPhase = 0;
break;
}
} else uiTimer -= uiDiff;
}
npc_escortAI::UpdateAI(uiDiff);
if (!UpdateVictim())
return;
DoMeleeAttackIfReady();
}
示例7: rand
void hyjalAI::SummonCreature(uint32 entry, float Base[4][3])
{
uint32 random = rand()%4;
float SpawnLoc[3];
for (uint8 i = 0; i < 3; ++i)
{
SpawnLoc[i] = Base[random][i];
}
Creature* creature = NULL;
switch (entry)
{
case 17906: //GARGOYLE
if (!FirstBossDead && (WaveCount == 1 || WaveCount == 3))
{//summon at tower
creature = me->SummonCreature(entry, SpawnPointSpecial[SPAWN_NEAR_TOWER][0]+irand(-20, 20), SpawnPointSpecial[SPAWN_NEAR_TOWER][1]+irand(-20, 20), SpawnPointSpecial[SPAWN_NEAR_TOWER][2]+irand(-10, 10), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
if (creature)
CAST_AI(hyjal_trashAI, creature->AI())->useFlyPath = true;
}
else
{//summon at gate
creature = me->SummonCreature(entry, SpawnPointSpecial[SPAWN_GARG_GATE][0]+irand(-10, 10), SpawnPointSpecial[SPAWN_GARG_GATE][1]+irand(-10, 10), SpawnPointSpecial[SPAWN_GARG_GATE][2]+irand(-10, 10), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
}
break;
case 17907: //FROST_WYRM,
if (FirstBossDead && WaveCount == 1) //summon at gate
creature = me->SummonCreature(entry, SpawnPointSpecial[SPAWN_WYRM_GATE][0], SpawnPointSpecial[SPAWN_WYRM_GATE][1], SpawnPointSpecial[SPAWN_WYRM_GATE][2], 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
else
{
creature = me->SummonCreature(entry, SpawnPointSpecial[SPAWN_NEAR_TOWER][0], SpawnPointSpecial[SPAWN_NEAR_TOWER][1], SpawnPointSpecial[SPAWN_NEAR_TOWER][2], 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
if (creature)
CAST_AI(hyjal_trashAI, creature->AI())->useFlyPath = true;
}
break;
case 17908: //GIANT_INFERNAL
++InfernalCount;
if (InfernalCount > 7)
InfernalCount = 0;
creature = me->SummonCreature(entry, InfernalPos[InfernalCount][0], InfernalPos[InfernalCount][1], InfernalPos[InfernalCount][2], 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
break;
default:
creature = me->SummonCreature(entry, SpawnLoc[0], SpawnLoc[1], SpawnLoc[2], 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
break;
}
if (creature)
{
// Increment Enemy Count to be used in World States and instance script
++EnemyCount;
creature->SetWalk(false);
creature->setActive(true);
switch (entry)
{
case NECROMANCER:
case ABOMINATION:
case GHOUL:
case BANSHEE:
case CRYPT_FIEND:
case GARGOYLE:
case FROST_WYRM:
case GIANT_INFERNAL:
case FEL_STALKER:
case RAGE_WINTERCHILL:
case ANETHERON:
case KAZROGAL:
case AZGALOR:
CAST_AI(hyjal_trashAI, creature->AI())->IsEvent = true;
break;
}
if (instance)
{
if (instance->GetData(DATA_RAIDDAMAGE) < MINRAIDDAMAGE)
creature->SetDisableReputationGain(true);//no repu for solo farming
}
// Check if Creature is a boss.
if (creature->isWorldBoss())
{
if (!FirstBossDead) BossGUID[0] = creature->GetGUID();
else BossGUID[1] = creature->GetGUID();
CheckTimer = 5000;
}
}
}
示例8: TC_LOG_DEBUG
//this void is called when player clicks on search button
void WorldSession::HandleAuctionListItems(WorldPacket& recvData)
{
TC_LOG_DEBUG("network", "WORLD: Received CMSG_AUCTION_LIST_ITEMS");
std::string searchedname;
uint8 levelmin, levelmax, usable;
uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality;
ObjectGuid guid;
recvData >> guid;
recvData >> listfrom; // start, used for page control listing by 50 elements
recvData >> searchedname;
recvData >> levelmin >> levelmax;
recvData >> auctionSlotID >> auctionMainCategory >> auctionSubCategory;
recvData >> quality >> usable;
recvData.read_skip<uint8>(); // unk
// this block looks like it uses some lame byte packing or similar...
uint8 unkCnt;
recvData >> unkCnt;
for (uint8 i = 0; i < unkCnt; i++)
{
recvData.read_skip<uint8>();
recvData.read_skip<uint8>();
}
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_AUCTIONEER);
if (!creature)
{
TC_LOG_DEBUG("network", "WORLD: HandleAuctionListItems - %s not found or you can't interact with him.", guid.ToString().c_str());
return;
}
// remove fake death
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
TC_LOG_DEBUG("auctionHouse", "Auctionhouse search (%s) list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u",
guid.ToString().c_str(), listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
WorldPacket data(SMSG_AUCTION_LIST_RESULT, (4+4+4));
uint32 count = 0;
uint32 totalcount = 0;
data << (uint32) 0;
// converting string that we try to find to lower case
std::wstring wsearchedname;
if (!Utf8toWStr(searchedname, wsearchedname))
return;
wstrToLower(wsearchedname);
auctionHouse->BuildListAuctionItems(data, _player,
wsearchedname, listfrom, levelmin, levelmax, usable,
auctionSlotID, auctionMainCategory, auctionSubCategory, quality,
count, totalcount);
data.put<uint32>(0, count);
data << (uint32) totalcount;
data << (uint32) 300; // unk 2.3.0 const?
SendPacket(&data);
}
示例9: UpdateAI
void UpdateAI(const uint32 diff)
{
//Return since we have no target
if (!UpdateVictim())
return;
switch(Phase)
{
case 0:
{
// *Heroic mode only:
if (IsHeroic())
{
if (PyroblastTimer <= diff)
{
me->InterruptSpell(CURRENT_CHANNELED_SPELL);
me->InterruptSpell(CURRENT_GENERIC_SPELL);
DoCast(me, SPELL_SHOCK_BARRIER, true);
DoCast(me->getVictim(), SPELL_PYROBLAST);
PyroblastTimer = 60000;
} else PyroblastTimer -= diff;
}
if (FireballTimer <= diff)
{
DoCast(me->getVictim(), SPELL_FIREBALL_NORMAL);
FireballTimer = urand(2000,6000);
} else FireballTimer -= diff;
if (PhoenixTimer <= diff)
{
Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM,1);
uint8 random = urand(1,2);
float x = KaelLocations[random][0];
float y = KaelLocations[random][1];
Creature* Phoenix = me->SummonCreature(CREATURE_PHOENIX, x, y, LOCATION_Z, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000);
if (Phoenix)
{
Phoenix->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE + UNIT_FLAG_NON_ATTACKABLE);
SetThreatList(Phoenix);
Phoenix->AI()->AttackStart(pTarget);
}
DoScriptText(SAY_PHOENIX, me);
PhoenixTimer = 60000;
} else PhoenixTimer -= diff;
if (FlameStrikeTimer <= diff)
{
if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
{
me->InterruptSpell(CURRENT_CHANNELED_SPELL);
me->InterruptSpell(CURRENT_GENERIC_SPELL);
DoCast(pTarget, SPELL_FLAMESTRIKE3, true);
DoScriptText(SAY_FLAMESTRIKE, me);
}
FlameStrikeTimer = urand(15000,25000);
} else FlameStrikeTimer -= diff;
// Below 50%
if (me->GetMaxHealth() * 0.5 > me->GetHealth())
{
me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true);
me->StopMoving();
me->GetMotionMaster()->Clear();
me->GetMotionMaster()->MoveIdle();
GravityLapseTimer = 0;
GravityLapsePhase = 0;
Phase = 1;
}
DoMeleeAttackIfReady();
}
break;
case 1:
{
if (GravityLapseTimer <= diff)
{
switch(GravityLapsePhase)
{
case 0:
if (FirstGravityLapse) // Different yells at 50%, and at every following Gravity Lapse
{
DoScriptText(SAY_GRAVITY_LAPSE, me);
FirstGravityLapse = false;
if (pInstance)
{
pInstance->HandleGameObject(pInstance->GetData64(DATA_KAEL_STATUE_LEFT), true);
pInstance->HandleGameObject(pInstance->GetData64(DATA_KAEL_STATUE_RIGHT), true);
}
}else
{
DoScriptText(SAY_RECAST_GRAVITY, me);
}
//.........这里部分代码省略.........
示例10: memset
//this void creates new auction and adds auction to some auctionhouse
void WorldSession::HandleAuctionSellItem(WorldPacket& recvData)
{
ObjectGuid auctioneer;
uint32 itemsCount, etime, bid, buyout;
recvData >> auctioneer;
recvData >> itemsCount;
ObjectGuid itemGUIDs[MAX_AUCTION_ITEMS]; // 160 slot = 4x 36 slot bag + backpack 16 slot
uint32 count[MAX_AUCTION_ITEMS];
memset(count, 0, sizeof(count));
if (itemsCount > MAX_AUCTION_ITEMS)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
recvData.rfinish();
return;
}
for (uint32 i = 0; i < itemsCount; ++i)
{
recvData >> itemGUIDs[i];
recvData >> count[i];
if (!itemGUIDs[i] || !count[i] || count[i] > 1000)
{
recvData.rfinish();
return;
}
}
recvData >> bid;
recvData >> buyout;
recvData >> etime;
if (!bid || !etime)
return;
if (bid > MAX_MONEY_AMOUNT || buyout > MAX_MONEY_AMOUNT)
{
TC_LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Player %s (GUID %u) attempted to sell item with higher price than max gold amount.", _player->GetName().c_str(), _player->GetGUIDLow());
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
return;
}
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
if (!creature)
{
TC_LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Unit (%s) not found or you can't interact with him.", auctioneer.ToString().c_str());
return;
}
AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(creature->getFaction());
if (!auctionHouseEntry)
{
TC_LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Unit (%s) has wrong faction.", auctioneer.ToString().c_str());
return;
}
etime *= MINUTE;
switch (etime)
{
case 1*MIN_AUCTION_TIME:
case 2*MIN_AUCTION_TIME:
case 4*MIN_AUCTION_TIME:
break;
default:
return;
}
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
Item* items[MAX_AUCTION_ITEMS];
uint32 finalCount = 0;
uint32 itemEntry = 0;
for (uint32 i = 0; i < itemsCount; ++i)
{
Item* item = _player->GetItemByGuid(itemGUIDs[i]);
if (!item)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_ITEM_NOT_FOUND);
return;
}
if (itemEntry == 0)
itemEntry = item->GetTemplate()->ItemId;
if (sAuctionMgr->GetAItem(item->GetGUIDLow()) || !item->CanBeTraded() || item->IsNotEmptyBag() ||
item->GetTemplate()->Flags & ITEM_PROTO_FLAG_CONJURED || item->GetUInt32Value(ITEM_FIELD_DURATION) ||
item->GetCount() < count[i] || itemEntry != item->GetTemplate()->ItemId)
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
return;
}
//.........这里部分代码省略.........
示例11: UpdateAI
void UpdateAI(uint32 uiDiff)
{
if (!UpdateVictim())
return;
if (me->GetPower(POWER_ENERGY) < 0)
me->SetPower(POWER_ENERGY, 0);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
if (me->GetPower(POWER_ENERGY) == 100)
{
me->RemoveFlag(UNIT_FIELD_FLAGS, 512);
me->RemoveAura(SPELL_SELF_ROOT);
me->RemoveAura(SPELL_BLESSING_RECHARGE);
blessing = false;
}
if (m_uiSunStrikeTimer <= uiDiff && blessing == false)
{
Unit* victim = SelectTarget(SELECT_TARGET_RANDOM, 0);
if(victim)
{
DoCast(victim, SPELL_SUN_STRIKE);
me->AddAura(SPELL_SUN_STRIKE_PERIODIC, victim);
}
m_uiSunStrikeTimer = urand(11000, 14000);
}
else
m_uiSunStrikeTimer -= uiDiff;
if (m_uiWindsTimer <= uiDiff && blessing == false)
{
if(Unit* victim = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me)))
DoCast(victim, SPELL_SOLAR_WINDS);
m_uiWindsTimer = urand(9000, 15000);
}
else
m_uiWindsTimer -= uiDiff;
if (m_uiLeapTimer <= uiDiff && blessing == false)
{
if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me)))
{
me->MonsterTextEmote(SAY_JUMP, NULL, true);
me->AddThreat(pTarget, 9000.0f);
DoCast(pTarget, SPELL_INFERNO_LEAP_MOB_SUMMON);
DoCast(pTarget, SPELL_INFERNO_LEAP_CAST_TIME);
leap_timer = 1500;
leap = true;
Creature* Summoned = me->FindNearestCreature(NPC_INFERNO_LEAP, 100, true);
if (Summoned)
{
Summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
Summoned->SetFloatValue(OBJECT_FIELD_SCALE_X, Summoned->GetFloatValue(OBJECT_FIELD_SCALE_X)*2.5f);
Summoned->setFaction(me->getFaction());
Summoned->SetLevel(me->getLevel());
}
m_uiLeapTimer = urand(18000, 22000);
}
}
else
m_uiLeapTimer -= uiDiff;
if (leap_timer <= uiDiff && leap == true)
{
DoCastVictim(SPELL_INFERNO_LEAP);
leap = false;
} else leap_timer -= uiDiff;
if (m_uiSunOrbTimer <= uiDiff && blessing == false)
{
if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, NonTankTargetSelector(me)))
DoCast(pTarget, SPELL_SUMMON_ORB);
m_uiSunOrbTimer = urand(24000, 31000);
}
else
m_uiSunOrbTimer -= uiDiff;
if (me->GetPower(POWER_ENERGY) == 0)
{
me->MonsterTextEmote(SAY_ANNOUNCE, NULL, true);
DoCast(me, SPELL_BLESSING_RECHARGE);
blessing = true;
me->SetFlag(UNIT_FIELD_FLAGS, 512);
me->AddAura(SPELL_SELF_ROOT, me);
Talk(SAY_BLESSING);
}
if(!me->HasAura(SPELL_BLESSING_RECHARGE))
DoMeleeAttackIfReady();
}
示例12: LOG_DETAIL
void WorldSession::HandleSpellClick(WorldPacket & recvPacket)
{
CHECK_INWORLD_RETURN
LOG_DETAIL("WORLD: got CMSG_SPELLCLICK packet, data length = %i", recvPacket.size());
if (_player->getDeathState() == CORPSE)
return;
uint64 target_guid; // this will store the guid of the object we are going to use it's spell. There must be a dbc that indicates what spells a unit has
recvPacket >> target_guid;
//we have only 1 example atm for entry : 28605
Unit* target_unit = _player->GetMapMgr()->GetUnit(target_guid);
if (!target_unit)
return;
if (!_player->isInRange(target_unit, MAX_INTERACTION_RANGE))
return;
if (target_unit->IsVehicle()){
if (target_unit->GetVehicleComponent() != NULL)
target_unit->GetVehicleComponent()->AddPassenger(_player);
return;
}
uint32 creature_id = target_unit->GetEntry();
uint32 cast_spell_id = 0;
if (!_player->HasAurasWithNameHash(SPELL_HASH_LIGHTWELL_RENEW) && target_unit->RemoveAura(59907))
{
SpellClickSpell *sp = SpellClickSpellStorage.LookupEntry(creature_id);
if (sp == NULL){
if (target_unit->IsCreature()){
Creature *c = TO< Creature* >(target_unit);
sChatHandler.BlueSystemMessage(this, "NPC Id %u ( %s ) has no spellclick spell associated with it.", c->GetProto()->Id, c->GetCreatureInfo()->Name);
LOG_ERROR("Spellclick packet received for creature %u but there is no spell associated with it.", creature_id);
return;
}
}
cast_spell_id = sp->SpellID;
target_unit->CastSpell(_player, cast_spell_id, true);
if (!target_unit->HasAura(59907))
TO_CREATURE(target_unit)->Despawn(0, 0); //IsCreature() check is not needed, refer to r2387 and r3230
return;
}
SpellClickSpell *sp = SpellClickSpellStorage.LookupEntry(creature_id);
if (sp == NULL){
if (target_unit->IsCreature()){
Creature *c = TO< Creature* >(target_unit);
sChatHandler.BlueSystemMessage(this, "NPC Id %u ( %s ) has no spellclick spell associated with it.", c->GetProto()->Id, c->GetCreatureInfo()->Name);
LOG_ERROR("Spellclick packet received for creature %u but there is no spell associated with it.", creature_id);
return;
}
}
cast_spell_id = sp->SpellID;
if (cast_spell_id == 0)
return;
SpellEntry* spellInfo = dbcSpell.LookupEntryForced(cast_spell_id);
if (spellInfo == NULL)
return;
Spell* spell = sSpellFactoryMgr.NewSpell(_player, spellInfo, false, NULL);
SpellCastTargets targets(target_guid);
spell->prepare(&targets);
}
示例13: getSelectedCreature
bool ChatHandler::HandleCreatePetCommand(const char* /*args*/)
{
Player* player = m_session->GetPlayer();
Creature* creatureTarget = getSelectedCreature();
if (!creatureTarget || creatureTarget->isPet() || creatureTarget->GetTypeId() == TYPEID_PLAYER)
{
PSendSysMessage(LANG_SELECT_CREATURE);
SetSentErrorMessage(true);
return false;
}
CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(creatureTarget->GetEntry());
// Creatures with family 0 crashes the server
if (cInfo->family == 0)
{
PSendSysMessage("This creature cannot be tamed. (family id: 0).");
SetSentErrorMessage(true);
return false;
}
if (player->GetPetGUID())
{
PSendSysMessage("You already have a pet");
SetSentErrorMessage(true);
return false;
}
// Everything looks OK, create new pet
Pet* pet = new Pet(player, HUNTER_PET);
if (!pet)
return false;
if (!pet->CreateBaseAtCreature(creatureTarget))
{
delete pet;
PSendSysMessage("Error 1");
return false;
}
creatureTarget->setDeathState(JUST_DIED);
creatureTarget->RemoveCorpse();
creatureTarget->SetHealth(0); // just for nice GM-mode view
pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID());
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction());
if (!pet->InitStatsForLevel(creatureTarget->getLevel()))
{
sLog->outError("InitStatsForLevel() in EffectTameCreature failed! Pet deleted.");
PSendSysMessage("Error 2");
delete pet;
return false;
}
// prepare visual effect for levelup
pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel()-1);
pet->GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true);
// this enables pet details window (Shift+P)
pet->InitPetCreateSpells();
pet->SetFullHealth();
pet->GetMap()->AddToMap(pet->ToCreature());
// visual effect for levelup
pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel());
player->SetMinion(pet, true);
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
player->PetSpellInitialize();
return true;
}
示例14: DoIntro
void DoIntro()
{
Creature* Madrigosa = Unit::GetCreature(*me, instance ? instance->GetData64(DATA_MADRIGOSA) : 0);
if (!Madrigosa)
return;
switch (IntroPhase)
{
case 0:
DoScriptText(YELL_MADR_ICE_BARRIER, Madrigosa);
IntroPhaseTimer = 7000;
++IntroPhase;
break;
case 1:
me->SetInFront(Madrigosa);
Madrigosa->SetInFront(me);
DoScriptText(YELL_MADR_INTRO, Madrigosa, me);
IntroPhaseTimer = 9000;
++IntroPhase;
break;
case 2:
DoScriptText(YELL_INTRO, me, Madrigosa);
IntroPhaseTimer = 13000;
++IntroPhase;
break;
case 3:
DoCast(me, SPELL_INTRO_FROST_BLAST);
Madrigosa->AddUnitMovementFlag(MOVEMENTFLAG_LEVITATING);
me->AttackStop();
Madrigosa->AttackStop();
IntroFrostBoltTimer = 3000;
IntroPhaseTimer = 28000;
++IntroPhase;
break;
case 4:
DoScriptText(YELL_INTRO_BREAK_ICE, me);
IntroPhaseTimer = 6000;
++IntroPhase;
break;
case 5:
Madrigosa->CastSpell(me, SPELL_INTRO_ENCAPSULATE_CHANELLING, false);
DoScriptText(YELL_MADR_TRAP, Madrigosa);
DoCast(me, SPELL_INTRO_ENCAPSULATE);
IntroPhaseTimer = 11000;
++IntroPhase;
break;
case 6:
DoScriptText(YELL_INTRO_CHARGE, me);
IntroPhaseTimer = 5000;
++IntroPhase;
break;
case 7:
me->Kill(Madrigosa);
DoScriptText(YELL_MADR_DEATH, Madrigosa);
me->SetFullHealth();
me->AttackStop();
IntroPhaseTimer = 4000;
++IntroPhase;
break;
case 8:
DoScriptText(YELL_INTRO_KILL_MADRIGOSA, me);
me->SetOrientation(0.14f);
me->StopMoving();
Madrigosa->setDeathState(CORPSE);
IntroPhaseTimer = 8000;
++IntroPhase;
break;
case 9:
DoScriptText(YELL_INTRO_TAUNT, me);
IntroPhaseTimer = 5000;
++IntroPhase;
break;
case 10:
EndIntro();
break;
}
}
示例15: pair
void hyjalAI::DoOverrun(uint32 faction, const uint32 diff)
{
npc_escortAI::UpdateAI(diff);
if (WaitForTeleport)
{
if (TeleportTimer <= diff)
{
CellCoord pair(Trinity::ComputeCellCoord(me->GetPositionX(), me->GetPositionY()));
Cell cell(pair);
cell.SetNoCreate();
std::list<Creature*> creatures;
Trinity::AllFriendlyCreaturesInGrid creature_check(me);
Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid> creature_searcher(me, creatures, creature_check);
TypeContainerVisitor
<Trinity::CreatureListSearcher<Trinity::AllFriendlyCreaturesInGrid>,
GridTypeMapContainer> creature_visitor(creature_searcher);
cell.Visit(pair, creature_visitor, *(me->GetMap()), *me, me->GetGridActivationRange());
if (!creatures.empty())
{
for (std::list<Creature*>::const_iterator itr = creatures.begin(); itr != creatures.end(); ++itr)
{
if ((*itr) && (*itr)->isAlive())
{
(*itr)->CastSpell(*itr, SPELL_TELEPORT_VISUAL, true);
(*itr)->setFaction(35);//make them friendly so mobs won't attack them
(*itr)->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
}
}
DoCast(me, SPELL_TELEPORT_VISUAL);
bRetreat = true;
RetreatTimer = 1000;
}
WaitForTeleport = false;
Teleported = true;
}TeleportTimer -= diff;
}
if (!Teleported)
return;
Overrun = false;//execute once
switch (faction)
{
case 0://alliance
for (uint8 i = 0; i < 92; ++i)//summon fires
me->SummonGameObject(FLAMEOBJECT, AllianceFirePos[i][0], AllianceFirePos[i][1], AllianceFirePos[i][2], AllianceFirePos[i][3], AllianceFirePos[i][4], AllianceFirePos[i][5], AllianceFirePos[i][6], AllianceFirePos[i][7], 0);
for (uint8 i = 0; i < 25; ++i)//summon 25 ghouls
{
uint8 r = rand()%4;
Creature* unit = me->SummonCreature(GHOUL, AllianceBase[r][0]+irand(-15, 15), AllianceBase[r][1]+irand(-15, 15), AllianceBase[r][2], 0, TEMPSUMMON_MANUAL_DESPAWN, 2*60*1000);
if (unit)
{
CAST_AI(hyjal_trashAI, unit->AI())->faction = Faction;
CAST_AI(hyjal_trashAI, unit->AI())->IsOverrun = true;
CAST_AI(hyjal_trashAI, unit->AI())->OverrunType = i;
unit->setActive(true);
}
}
for (uint8 i = 0; i < 3; ++i)//summon 3 abominations
{
uint8 r = rand()%4;
Creature* unit = me->SummonCreature(ABOMINATION, AllianceBase[r][0]+irand(-15, 15), AllianceBase[r][1]+irand(-15, 15), AllianceBase[r][2], 0, TEMPSUMMON_MANUAL_DESPAWN, 2*60*1000);
if (unit)
{
CAST_AI(hyjal_trashAI, unit->AI())->faction = Faction;
CAST_AI(hyjal_trashAI, unit->AI())->IsOverrun = true;
CAST_AI(hyjal_trashAI, unit->AI())->OverrunType = i;
unit->setActive(true);
}
}
for (uint8 i = 0; i < 5; ++i)//summon 5 gargoyles
{
Creature* unit = me->SummonCreature(GARGOYLE, AllianceOverrunGargPos[i][0], AllianceOverrunGargPos[i][1], AllianceOverrunGargPos[i][2], AllianceOverrunGargPos[i][3], TEMPSUMMON_MANUAL_DESPAWN, 2*60*1000);
if (unit)
{
unit->SetHomePosition(AllianceOverrunGargPos[i][0], AllianceOverrunGargPos[i][1], AllianceOverrunGargPos[i][2], AllianceOverrunGargPos[i][3]);
CAST_AI(hyjal_trashAI, unit->AI())->faction = Faction;
CAST_AI(hyjal_trashAI, unit->AI())->IsOverrun = true;
CAST_AI(hyjal_trashAI, unit->AI())->OverrunType = i;
unit->setActive(true);
}
}
break;
case 1://horde
for (uint8 i = 0; i < 65; ++i)//summon fires
me->SummonGameObject(FLAMEOBJECT, HordeFirePos[i][0], HordeFirePos[i][1], HordeFirePos[i][2], HordeFirePos[i][3], HordeFirePos[i][4], HordeFirePos[i][5], HordeFirePos[i][6], HordeFirePos[i][7], 0);
for (uint8 i = 0; i < 26; ++i)//summon infernals
{
Creature* unit = me->SummonCreature(GIANT_INFERNAL, InfernalSPWP[i][0], InfernalSPWP[i][1], InfernalSPWP[i][2], InfernalSPWP[i][3], TEMPSUMMON_MANUAL_DESPAWN, 2*60*1000);
if (unit)
{
unit->SetHomePosition(InfernalSPWP[i][0], InfernalSPWP[i][1], InfernalSPWP[i][2], InfernalSPWP[i][3]);
CAST_AI(hyjal_trashAI, unit->AI())->faction = Faction;
CAST_AI(hyjal_trashAI, unit->AI())->IsOverrun = true;
CAST_AI(hyjal_trashAI, unit->AI())->OverrunType = i;
unit->setActive(true);
//.........这里部分代码省略.........