void GameObject::InitAI() { if(!pInfo) return; // this fixes those fuckers in booty bay if(pInfo->SpellFocus == 0 && pInfo->sound1 == 0 && pInfo->sound2 == 0 && pInfo->sound3 != 0 && pInfo->sound5 != 3 && pInfo->sound9 == 1) return; if(pInfo->DisplayID == 1027)//Shaman Shrine { if(pInfo->ID != 177964 && pInfo->ID != 153556) { //Deactivate //SetUInt32Value(GAMEOBJECT_DYN_FLAGS, 0); } } uint32 spellid = 0; if(pInfo->Type==GAMEOBJECT_TYPE_TRAP) { spellid = pInfo->sound3; } else if(pInfo->Type == GAMEOBJECT_TYPE_SPELL_FOCUS) { // get spellid from attached gameobject - by sound2 field if( pInfo->sound2 == 0 ) return; if( GameObjectNameStorage.LookupEntry( pInfo->sound2 ) == NULL ) return; spellid = GameObjectNameStorage.LookupEntry( pInfo->sound2 )->sound3; } else if(pInfo->Type == GAMEOBJECT_TYPE_RITUAL) { m_ritualmembers = new uint32[pInfo->SpellFocus]; memset(m_ritualmembers,0,sizeof(uint32)*pInfo->SpellFocus); } else if(pInfo->Type == GAMEOBJECT_TYPE_CHEST) { Lock *pLock = dbcLock.LookupEntry(GetInfo()->SpellFocus); if(pLock) { for(uint32 i=0; i < 5; i++) { if(pLock->locktype[i]) { if(pLock->locktype[i] == 2) //locktype; { //herbalism and mining; if(pLock->lockmisc[i] == LOCKTYPE_MINING || pLock->lockmisc[i] == LOCKTYPE_HERBALISM) { CalcMineRemaining(true); } } } } } } else if ( pInfo->Type == GAMEOBJECT_TYPE_FISHINGHOLE ) { CalcFishRemaining( true ); } myScript = sScriptMgr.CreateAIScriptClassForGameObject(GetEntry(), this); // hackfix for bad spell in BWL if(!spellid || spellid == 22247) return; SpellEntry *sp= dbcSpell.LookupEntry(spellid); if(!sp) { spell = NULL; return; } else { spell = sp; } //ok got valid spell that will be casted on target when it comes close enough //get the range for that float r = 0; for(uint32 i=0;i<3;i++) { if(sp->Effect[i]) { float t = GetRadius(dbcSpellRadius.LookupEntry(sp->EffectRadiusIndex[i])); if(t > r) r = t; } } if(r < 0.1)//no range r = GetMaxRange(dbcSpellRange.LookupEntry(sp->rangeIndex)); range = r*r;//square to make code faster checkrate = 20;//once in 2 seconds }
void GameObject::InitAI() { if(pInfo == NULL) return; // this fixes those fuckers in booty bay if(pInfo->SpellFocus == 0 && pInfo->sound1 == 0 && pInfo->sound2 == 0 && pInfo->sound3 != 0 && pInfo->sound5 != 3 && pInfo->sound9 == 1) return; uint32 spellid = 0; switch(pInfo->Type) { case GAMEOBJECT_TYPE_TRAP: { spellid = pInfo->sound3; }break; case GAMEOBJECT_TYPE_SPELL_FOCUS://redirect to properties of another go { uint32 new_entry = pInfo->sound2; if(new_entry) { pInfo = GameObjectNameStorage.LookupEntry( new_entry ); if(pInfo == NULL) { Log.Warning("GameObject","Redirected gameobject %u doesn't seem to exists in database, skipping",new_entry); return; } if(pInfo->sound3) spellid = pInfo->sound3; } }break; case GAMEOBJECT_TYPE_RITUAL: { m_ritualmembers = new uint32[pInfo->SpellFocus]; memset(m_ritualmembers,0,sizeof(uint32)*pInfo->SpellFocus); }break; case GAMEOBJECT_TYPE_CHEST: { Lock *pLock = dbcLock.LookupEntry(GetInfo()->SpellFocus); if(pLock) { for(uint32 i = 0; i < 5; i++) { if(pLock->locktype[i]) { if(pLock->locktype[i] == 2) //locktype; { //herbalism and mining; if(pLock->lockmisc[i] == LOCKTYPE_MINING || pLock->lockmisc[i] == LOCKTYPE_HERBALISM) { CalcMineRemaining(true); } } } } } else if(pInfo->Type == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING) { Health = pInfo->SpellFocus + pInfo->sound5; } } } //Null out gossip_script here, will be set with sScriptMgr.register_go_gossip_script (if any). pInfo->gossip_script = NULL; myScript = sScriptMgr.CreateAIScriptClassForGameObject(GetEntry(), this); // hackfix for bad spell in BWL if(!spellid || spellid == 22247) return; SpellEntry *sp= dbcSpell.LookupEntry(spellid); if(!sp) { spell = NULL; return; } else { spell = sp; } //ok got valid spell that will be casted on target when it comes close enough //get the range for that float r = 0; for(uint32 i = 0; i < 3; i++) { if(sp->Effect[i]) { float t = GetDBCCastTime(dbcSpellRadius.LookupEntry(sp->EffectRadiusIndex[i])); if(t > r) r = t; } } if(r < 0.1)//no range r = GetMaxRange(dbcSpellRange.LookupEntry(sp->rangeIndex)); range = r*r;//square to make code faster checkrate = 20;//once in 2 seconds }