void GameObject::EndFishing(Player* player, bool abort ) { Spell * spell = player->GetCurrentSpell(); if(spell) { if(abort) // abort becouse of a reason { //FIXME: here 'failed' should appear over progress bar spell->SendChannelUpdate(0); //spell->cancel(); spell->finish(); } else // spell ended { spell->SendChannelUpdate(0); spell->finish(); } } if(!abort) sEventMgr.AddEvent(this, &GameObject::ExpireAndDelete, EVENT_GAMEOBJECT_EXPIRE, 10000, 1,EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); else ExpireAndDelete(); }
void GameObject::EndFishing(Player* player, bool abort ) { Spell * spell = player->GetCurrentSpell(); if(spell) { if(abort) // abort becouse of a reason { //FIXME: here 'failed' should appear over progress bar spell->cancel(); } else // spell ended { if (!(GetUInt32Value(GAMEOBJECT_FLAGS) & 32)) // if there was no loot spell->SendCastResult(SPELL_FAILED_NO_FISH); spell->SendChannelUpdate(0); spell->finish(); /*if(this->IsInWorld()) RemoveFromWorld(); delete this;*/ ExpireAndDelete(); return; } } else // if this is called, and there is no spell so remove the gameobject { if(this->IsInWorld()) RemoveFromWorld(); delete this; } }
void GameObject::Despawn(uint32 time) { if(!IsInWorld()) return; loot.items.clear(); //This is for go get deleted while looting if(m_spawn) { SetUInt32Value(GAMEOBJECT_STATE, m_spawn->state); SetUInt32Value(GAMEOBJECT_FLAGS, m_spawn->flags); } CALL_GO_SCRIPT_EVENT(this, OnDespawn)(); if(time) { /* Get our originiating mapcell */ MapCell * pCell = m_mapCell; ASSERT(pCell); pCell->_respawnObjects.insert( ((Object*)this) ); sEventMgr.RemoveEvents(this); sEventMgr.AddEvent(m_mapMgr, &MapMgr::EventRespawnGameObject, this, pCell, EVENT_GAMEOBJECT_ITEM_SPAWN, time, 1, 0); Object::RemoveFromWorld(false); m_respawnCell=pCell; } else { Object::RemoveFromWorld(true); ExpireAndDelete(); } }
void GameObject::EndFishing(Player* player, bool abort ) { Spell* spell = player->GetCurrentSpell(); if(spell) { if(abort) // abort becouse of a reason { // FIXME: here 'failed' should appear over progress bar spell->SendChannelUpdate(0); // spell->cancel(); spell->finish(); } else // spell ended { spell->SendChannelUpdate(0); spell->finish(); } } if(!abort) TO_GAMEOBJECT(this)->ExpireAndDelete(20000); else ExpireAndDelete(); }
void GameObject::RemoveInRangeObject(Object* pObj) { Object::RemoveInRangeObject(pObj); if(m_summonedGo && m_summoner == pObj) { for(int i = 0; i < 4; i++) if (m_summoner->m_ObjectSlots[i] == GetGUIDLow()) m_summoner->m_ObjectSlots[i] = 0; m_summoner = 0; ExpireAndDelete(); } }
void GameObject::Update(uint32 p_time) { if(m_event_Instanceid != m_instanceId) { event_Relocate(); return; } if(!IsInWorld()) return; if(m_deleted) return; if(spell && (GetUInt32Value(GAMEOBJECT_STATE) == 1)) { if(checkrate > 1) { if(counter++%checkrate) return; } ObjectSet::iterator itr = GetInRangeSetBegin(); ObjectSet::iterator it2 = itr; ObjectSet::iterator iend = GetInRangeSetEnd(); Unit * pUnit; float dist; for(; it2 != iend;) { itr = it2; ++it2; dist = GetDistanceSq((*itr)); if( (*itr) != m_summoner && (*itr)->IsUnit() && dist <= range) { pUnit = static_cast<Unit*>(*itr); if(m_summonedGo) { if(!m_summoner) { ExpireAndDelete(); return; } if(!isAttackable(m_summoner,pUnit))continue; } Spell * sp=new Spell((Object*)this,spell,true,NULL); SpellCastTargets tgt((*itr)->GetGUID()); tgt.m_destX = GetPositionX(); tgt.m_destY = GetPositionY(); tgt.m_destZ = GetPositionZ(); sp->prepare(&tgt); if(m_summonedGo) { ExpireAndDelete(); return; } if(spell->EffectImplicitTargetA[0] == 16 || spell->EffectImplicitTargetB[0] == 16) return; // on area dont continue. } } } }
void GameObject::Update(uint32 p_time) { if(m_event_Instanceid != m_instanceId) { event_Relocate(); return; } if(!IsInWorld()) return; if(m_deleted) return; if(spell && (GetUInt32Value(GAMEOBJECT_STATE) == 1)) { if(checkrate > 1) { if(counter++%checkrate) return; } ObjectSet::iterator itr = GetInRangeSetBegin(); ObjectSet::iterator it2 = itr; ObjectSet::iterator iend = GetInRangeSetEnd(); Unit * pUnit; float dist; this->AquireInrangeLock(); //make sure to release lock before exit function ! for(; it2 != iend;) { itr = it2; ++it2; dist = GetDistanceSq((*itr)); if( (*itr) != m_summoner && (*itr)->IsUnit() && dist <= range) { pUnit = static_cast<Unit*>(*itr); if(m_summonedGo) { if(!m_summoner) { ExpireAndDelete(); return; } if(!isAttackable(m_summoner,pUnit))continue; } Spell * sp=SpellPool.PooledNew(); sp->Init((Object*)this,spell,true,NULL); SpellCastTargets tgt((*itr)->GetGUID()); tgt.m_destX = GetPositionX(); tgt.m_destY = GetPositionY(); tgt.m_destZ = GetPositionZ(); sp->prepare(&tgt); // proc on trap trigger if( pInfo->Type == GAMEOBJECT_TYPE_TRAP ) { if( m_summoner != NULL ) m_summoner->HandleProc( PROC_ON_TRAP_TRIGGER, pUnit, spell ); } if(m_summonedGo) { ExpireAndDelete(); this->ReleaseInrangeLock(); return; } if(spell->EffectImplicitTargetA[0] == 16 || spell->EffectImplicitTargetB[0] == 16) { this->ReleaseInrangeLock(); return; // on area dont continue. } } } this->ReleaseInrangeLock(); } }
void GameObject::Update(uint32 p_time) { if(m_event_Instanceid != m_instanceId) { event_Relocate(); return; } if(!IsInWorld()) return; if(m_deleted) return; if(spell && (GetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_STATE) == 1)) { if(checkrate > 1) { if(counter++%checkrate) return; } Object::InRangeSet::iterator itr,it2; Unit* pUnit; float dist; for( it2 = GetInRangeSetBegin(); it2 != GetInRangeSetEnd(); ++it2) { itr = it2; dist = GetDistanceSq((*itr)); if( (*itr) != m_summoner && (*itr)->IsUnit() && dist <= range) { pUnit = TO_UNIT(*itr); if(m_summonedGo) { if(!m_summoner) { ExpireAndDelete(); return; } if(!isAttackable(m_summoner,pUnit))continue; } Spell* sp= (new Spell(TO_OBJECT(this),spell,true,NULL)); SpellCastTargets tgt((*itr)->GetGUID()); tgt.m_destX = GetPositionX(); tgt.m_destY = GetPositionY(); tgt.m_destZ = GetPositionZ(); sp->prepare(&tgt); if(pInfo->Type == 6) { if(m_summoner != NULL) m_summoner->HandleProc(PROC_ON_TRAP_TRIGGER, pUnit, spell); } if(m_summonedGo) { ExpireAndDelete(); return; } if(spell->EffectImplicitTargetA[0] == 16 || spell->EffectImplicitTargetB[0] == 16) return; // on area dont continue. } } } }