AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
go_soulwell::go_soulwellAI Struct Reference
Inheritance diagram for go_soulwell::go_soulwellAI:
GameObjectAI

Public Member Functions

 go_soulwellAI (GameObject *go)
 
bool GossipHello (Player *player, bool reportUse) override
 
- Public Member Functions inherited from GameObjectAI
 GameObjectAI (GameObject *go)
 
virtual ~GameObjectAI ()
 
virtual void UpdateAI (uint32)
 
virtual void InitializeAI ()
 
virtual void Reset ()
 
virtual void DoAction (int32)
 
virtual void SetGUID (ObjectGuid, int32)
 
virtual ObjectGuid GetGUID (int32) const
 
virtual bool GossipHello (Player *, bool)
 
virtual bool GossipSelect (Player *, uint32, uint32)
 
virtual bool GossipSelectCode (Player *, uint32, uint32, char const *)
 
virtual bool QuestAccept (Player *, Quest const *)
 
virtual bool QuestReward (Player *, Quest const *, uint32)
 
virtual uint32 GetDialogStatus (Player *)
 
virtual void Destroyed (Player *, uint32)
 
virtual uint32 GetData (uint32) const
 
virtual void SetData (uint32, uint32)
 
virtual void OnGameEvent (bool, uint16)
 
virtual void OnStateChanged (uint32, Unit *)
 
virtual void EventInform (uint32)
 
virtual void SpellHit (Unit *, SpellInfo const *)
 
virtual bool CanBeSeen (Player const *)
 
virtual void JustSummoned (Creature *)
 
virtual void SummonedCreatureDespawn (Creature *)
 
virtual void SummonedCreatureDies (Creature *, Unit *)
 

Private Attributes

uint32 _stoneSpell
 
uint32 _stoneId
 

Additional Inherited Members

- Static Public Member Functions inherited from GameObjectAI
static int32 Permissible (GameObject const *go)
 
- Protected Attributes inherited from GameObjectAI
GameObject *const me
 

Detailed Description

Constructor & Destructor Documentation

◆ go_soulwellAI()

go_soulwell::go_soulwellAI::go_soulwellAI ( GameObject go)
inline
1451 : GameObjectAI(go)
1452 {
1453 _stoneSpell = 0;
1454 _stoneId = 0;
1455 switch (go->GetEntry())
1456 {
1457 case GO_SOUL_WELL_R1:
1459 if (Unit* owner = go->GetOwner())
1460 {
1461 if (owner->HasAura(SPELL_IMPROVED_HEALTH_STONE_R1))
1463 else if (owner->HasAura(SPELL_CREATE_MASTER_HEALTH_STONE_R2))
1465 }
1466 break;
1467 case GO_SOUL_WELL_R2:
1469 if (Unit* owner = go->GetOwner())
1470 {
1471 if (owner->HasAura(SPELL_IMPROVED_HEALTH_STONE_R1))
1473 else if (owner->HasAura(SPELL_CREATE_MASTER_HEALTH_STONE_R2))
1475 }
1476 break;
1477 }
1478 if (_stoneSpell == 0) // Should never happen
1479 return;
1480
1481 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(_stoneSpell);
1482 if (!spellInfo)
1483 return;
1484
1485 _stoneId = spellInfo->Effects[EFFECT_0].ItemType;
1486 }
#define sSpellMgr
Definition: SpellMgr.h:818
@ GO_SOUL_WELL_R1
Definition: go_scripts.cpp:1429
@ SPELL_CREATE_FEL_HEALTH_STONE_R1
Definition: go_scripts.cpp:1440
@ SPELL_CREATE_MASTER_HEALTH_STONE_R1
Definition: go_scripts.cpp:1436
@ SPELL_IMPROVED_HEALTH_STONE_R1
Definition: go_scripts.cpp:1432
@ SPELL_CREATE_FEL_HEALTH_STONE_R2
Definition: go_scripts.cpp:1441
@ SPELL_CREATE_MASTER_HEALTH_STONE_R2
Definition: go_scripts.cpp:1437
@ SPELL_CREATE_MASTER_HEALTH_STONE_R0
Definition: go_scripts.cpp:1435
@ GO_SOUL_WELL_R2
Definition: go_scripts.cpp:1430
@ SPELL_CREATE_FEL_HEALTH_STONE_R0
Definition: go_scripts.cpp:1439
@ EFFECT_0
Definition: SharedDefines.h:30
Definition: GameObjectAI.h:34
Unit * GetOwner() const
Definition: GameObject.cpp:1236
uint32 GetEntry() const
Definition: Object.h:109
Definition: Unit.h:1290
Definition: SpellInfo.h:314
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:391
uint32 _stoneSpell
Definition: go_scripts.cpp:1530
uint32 _stoneId
Definition: go_scripts.cpp:1531

References _stoneId, _stoneSpell, EFFECT_0, SpellInfo::Effects, Object::GetEntry(), GameObject::GetOwner(), GO_SOUL_WELL_R1, GO_SOUL_WELL_R2, SPELL_CREATE_FEL_HEALTH_STONE_R0, SPELL_CREATE_FEL_HEALTH_STONE_R1, SPELL_CREATE_FEL_HEALTH_STONE_R2, SPELL_CREATE_MASTER_HEALTH_STONE_R0, SPELL_CREATE_MASTER_HEALTH_STONE_R1, SPELL_CREATE_MASTER_HEALTH_STONE_R2, SPELL_IMPROVED_HEALTH_STONE_R1, and sSpellMgr.

Member Function Documentation

◆ GossipHello()

bool go_soulwell::go_soulwellAI::GossipHello ( Player player,
bool  reportUse 
)
inlineoverridevirtual

Due to the fact that this GameObject triggers CMSG_GAMEOBJECT_USE and CMSG_GAMEOBJECT_REPORT_USE, this GossipHello hook is called twice. The script's handling is fine as it won't remove two charges on the well. We have to find how to segregate REPORT_USE and USE.

Reimplemented from GameObjectAI.

1493 {
1494 if (reportUse)
1495 return false;
1496
1497 Unit* owner = me->GetOwner();
1498 if (_stoneSpell == 0 || _stoneId == 0)
1499 {
1500 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(_stoneSpell))
1501 Spell::SendCastResult(player, spell, 0, SPELL_FAILED_ERROR);
1502 return true;
1503 }
1504
1505 if (!owner || owner->GetTypeId() != TYPEID_PLAYER || !player->IsInSameRaidWith(owner->ToPlayer()))
1506 {
1507 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(_stoneSpell))
1509 return true;
1510 }
1511
1512 // Don't try to add a stone if we already have one.
1513 if (player->HasItemCount(_stoneId))
1514 {
1515 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(_stoneSpell))
1517 return true;
1518 }
1519
1520 player->CastSpell(player, _stoneSpell, false);
1521
1522 // Item has to actually be created to remove a charge on the well.
1523 if (player->HasItemCount(_stoneId))
1524 me->AddUse();
1525
1526 return true;
1527 }
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
@ SPELL_FAILED_ERROR
Definition: SharedDefines.h:953
@ SPELL_FAILED_TARGET_NOT_IN_RAID
Definition: SharedDefines.h:1060
@ SPELL_FAILED_TOO_MANY_OF_ITEM
Definition: SharedDefines.h:1050
GameObject *const me
Definition: GameObjectAI.h:36
void AddUse()
Definition: GameObject.h:241
Player * ToPlayer()
Definition: Object.h:195
TypeID GetTypeId() const
Definition: Object.h:121
bool IsInSameRaidWith(Player const *p) const
Definition: Player.h:1836
bool HasItemCount(uint32 item, uint32 count=1, bool inBankAlso=false) const
Definition: PlayerStorage.cpp:686
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1169
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 castCount, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE)
Definition: Spell.cpp:4631

References _stoneId, _stoneSpell, GameObject::AddUse(), Unit::CastSpell(), GameObject::GetOwner(), Object::GetTypeId(), Player::HasItemCount(), Player::IsInSameRaidWith(), GameObjectAI::me, Spell::SendCastResult(), SPELL_FAILED_ERROR, SPELL_FAILED_TARGET_NOT_IN_RAID, SPELL_FAILED_TOO_MANY_OF_ITEM, sSpellMgr, Object::ToPlayer(), and TYPEID_PLAYER.

Member Data Documentation

◆ _stoneId

uint32 go_soulwell::go_soulwellAI::_stoneId
private

Referenced by go_soulwellAI(), and GossipHello().

◆ _stoneSpell

uint32 go_soulwell::go_soulwellAI::_stoneSpell
private

Referenced by go_soulwellAI(), and GossipHello().