bool ChatHandler::HandleRangeCheckCommand(const char* /*args*/, WorldSession* m_session) { uint64 guid = m_session->GetPlayer()->GetSelection(); if (!guid) { m_session->SystemMessage("No selection."); return false; } Unit* unit = m_session->GetPlayer()->GetMapMgr()->GetUnit(guid); if (!unit) { m_session->SystemMessage("Invalid selection."); return false; } float DistSq = unit->GetDistanceSq(m_session->GetPlayer()); m_session->SystemMessage("GetDistanceSq : %u", float2int32(DistSq)); LocationVector locvec(m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ()); float DistReal = unit->CalcDistance(locvec); m_session->SystemMessage("CalcDistance : %u", float2int32(DistReal)); float Dist2DSq = unit->GetDistance2dSq(m_session->GetPlayer()); m_session->SystemMessage("GetDistance2dSq: %u", float2int32(Dist2DSq)); return true; }
bool ChatHandler::HandleRangeCheckCommand(const char *args, WorldSession *m_session) { WorldPacket data; uint64 guid = m_session->GetPlayer()->GetSelection(); m_session->SystemMessage("=== RANGE CHECK ==="); if (guid == 0) { m_session->SystemMessage("No selection."); return true; } Unit *unit = m_session->GetPlayer()->GetMapMgr()->GetUnit(guid); if (!unit) { m_session->SystemMessage("Invalid selection."); return true; } float DistSq = unit->GetDistanceSq(static_cast<Object*>(m_session->GetPlayer())); m_session->SystemMessage("GetDistanceSq : %u", float2int32(DistSq)); LocationVector locvec(m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ()); float DistReal = unit->CalcDistance(locvec); m_session->SystemMessage("CalcDistance : %u", float2int32(DistReal)); float Dist2DSq = unit->GetDistance2dSq(static_cast<Object*>(m_session->GetPlayer())); m_session->SystemMessage("GetDistance2dSq: %u", float2int32(Dist2DSq)); return true; }
int32 HonorHandler::CalculateHonorPointsForKill( uint32 playerLevel, uint32 victimLevel ) { uint32 k_level = playerLevel; uint32 v_level = victimLevel; uint32 k_grey = 0; if( k_level > 5 && k_level < 40 ) { k_grey = k_level - 5 - float2int32( floor( ((float)k_level) / 10.0f ) ); } else { k_grey = k_level - 1 - float2int32( floor( ((float)k_level) / 5.0f ) ); } if(v_level <= k_grey) return 0; // Correct formula unknown. This one is correct for lvl 70 killing lvl 70 and scales down for lower levels // uint32 diff_level = v_level - k_level; // Should somehow affect the result float honor_points = 20.9f; honor_points *= ((float)k_level) / PLAYER_LEVEL_CAP; honor_points *= World::getSingleton().getRate( RATE_HONOR ); if(honor_points < 1.0f) // Make sure we get at least 1 point on low levels return 1; return float2int32( honor_points ); }
int32 HonorHandler::CalculateHonorPointsForKill( Player *pPlayer, Unit* pVictim ) { // this sucks.. ;p if( pVictim == NULL ) { int32 pts = rand() % 100 + 100; return pts; } // Suicide lol if( pVictim == pPlayer ) return 0; if( pVictim->GetTypeId() != TYPEID_PLAYER ) return 0; //use Player::m_honorless, applied with Aura::SpellAuraNoPVPCredit // How dishonorable, you fiend! //if( pVictim->HasActiveAura( PLAYER_HONORLESS_TARGET_SPELL ) ) // return 0; if ( pVictim->GetTypeId() == TYPEID_PLAYER && static_cast< Player* >(pVictim)->m_honorless ) return 0; uint32 k_level = pPlayer->GetUInt32Value( UNIT_FIELD_LEVEL ); uint32 v_level = pVictim->GetUInt32Value( UNIT_FIELD_LEVEL ); int k_honor = pPlayer->m_honorPoints; int v_honor = static_cast< Player* >( pVictim )->m_honorPoints; uint32 k_grey = 0; if( k_level > 5 && k_level < 40 ) { k_grey = k_level - 5 - float2int32( floor( ((float)k_level) / 10.0f ) ); } else { k_grey = k_level - 1 - float2int32( floor( ((float)k_level) / 5.0f ) ); } if( k_honor == 0 ) k_honor = 1; float diff_level = ((float)v_level - k_grey) / ((float)k_level - k_grey); if( diff_level > 2 ) diff_level = 2.0f; if( diff_level < 0 ) diff_level = 0.0f; float diff_honor = ((float)v_honor) / ((float)k_honor); if( diff_honor > 3 ) diff_honor = 3.0f; if( diff_honor < 0 ) diff_honor = 0.0f; float honor_points = diff_level * ( 150.0f + diff_honor * 60 ); honor_points *= ((float)k_level) / PLAYER_LEVEL_CAP; honor_points *= World::getSingleton().getRate( RATE_HONOR ); return float2int32( honor_points ); }
bool ChatHandler::HandleGODelete(const char *args, WorldSession *m_session) { GameObject *GObj = m_session->GetPlayer()->GetSelectedGo(); if( !GObj ) { RedSystemMessage(m_session, "No selected GameObject..."); return true; } if(GObj->m_spawn != 0 && GObj->m_spawn->entry == GObj->GetEntry()) { uint32 cellx=float2int32(((_maxX-GObj->m_spawn->x)/_cellSize)); uint32 celly=float2int32(((_maxY-GObj->m_spawn->y)/_cellSize)); if(cellx < _sizeX && celly < _sizeY) { //m_session->GetPlayer()->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cellx,celly)->GOSpawns.erase(GObj->m_spawn); CellSpawns * c = GObj->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cellx, celly); for(GOSpawnList::iterator itr = c->GOSpawns.begin(); itr != c->GOSpawns.end(); ++itr) if((*itr) == GObj->m_spawn) { c->GOSpawns.erase(itr); break; } GObj->DeleteFromDB(); delete GObj->m_spawn; } } GObj->Despawn(0); sGMLog.writefromsession( m_session, "deleted gameobject %s, entry %u", GameObjectNameStorage.LookupEntry(GObj->GetEntry())->Name, GObj->GetEntry() ); delete GObj; m_session->GetPlayer()->m_GM_SelectedGO = 0; /* std::stringstream sstext; GameObject *GObj = m_session->GetPlayer()->m_GM_SelectedGO; if( !GObj ) { RedSystemMessage(m_session, "No selected GameObject..."); return true; } GObj->GetMapMgr()->GetBaseMap()->GetTemplate()->RemoveIndex<GameObject>(GObj); // remove index GObj->Despawn(3600000); GObj->DeleteFromDB(); sObjHolder.Delete<GameObject>(GObj); m_session->GetPlayer()->m_GM_SelectedGO = NULL; GreenSystemMessage(m_session, "GameObject successfully deleted from world and database !"); */ return true; }
bool ChatHandler::HandleDeleteCommand(const char* args, WorldSession *m_session) { uint64 guid = m_session->GetPlayer()->GetSelection(); if (guid == 0) { SystemMessage(m_session, "No selection."); return true; } Creature *unit = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid)); if(!unit) { SystemMessage(m_session, "You should select a creature."); return true; } if ( unit->IsPet() ) { SystemMessage(m_session, "You can't delete a pet." ); return true; } sGMLog.writefromsession(m_session, "used npc delete, sqlid %u, creature %s, pos %f %f %f", unit->GetSQL_id(), unit->GetCreatureInfo() ? unit->GetCreatureInfo()->Name : "wtfbbqhax", unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()); if( unit->m_spawn == NULL ) return false; BlueSystemMessage(m_session, "Deleted creature ID %u", unit->spawnid); if(unit->IsInWorld()) { if(unit->m_spawn) { uint32 cellx=float2int32(((_maxX-unit->m_spawn->x)/_cellSize)); uint32 celly=float2int32(((_maxY-unit->m_spawn->y)/_cellSize)); if(cellx <= _sizeX && celly <= _sizeY) { CellSpawns * c = unit->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cellx, celly); for(CreatureSpawnList::iterator itr = c->CreatureSpawns.begin(); itr != c->CreatureSpawns.end(); ++itr) if((*itr) == unit->m_spawn) { c->CreatureSpawns.erase(itr); break; } delete unit->m_spawn; } } unit->RemoveFromWorld(false,true); } unit->DeleteFromDB(); delete unit; return true; }
int32 HonorHandler::CalculateHonorPointsFormula(uint32 AttackerLevel,uint32 VictimLevel) { float zd = 6.0f; float j = AttackerLevel <= VictimLevel ? 1.0f + float((VictimLevel - AttackerLevel) / zd): 1.0f - float((AttackerLevel - VictimLevel) / zd); j = j < 0 ? 0 : j > 2? 2 : j; return float2int32(AttackerLevel * 0.33f * j * World::getSingleton().getRate( RATE_HONOR )); }
ProcCondHandlerRes ProcHandler::LightningOverload(ProcCondSharedDataStruct *shareddata) { if(shareddata->CastingSpell == NULL) return PROCCOND_BREAK_EXECUTION; //trigger on lightning and chain lightning. Spell should be identical , well maybe next time :P if(shareddata->CastingSpell->NameHash == SPELL_HASH_LIGHTNING_BOLT || shareddata->CastingSpell->NameHash == SPELL_HASH_CHAIN_LIGHTNING) { shareddata->owner->CastSpell(shareddata->owner, 39805, true); shareddata->spellId = shareddata->CastingSpell->Id; shareddata->origId = 39805; //we have to increase time to aura remove AURAPOINTER aur = shareddata->owner->FindAura(39805); if(aur) { int32 time = float2int32(sSpellMgr.GetSpellTimeToHit(shareddata->owner, shareddata->victim, shareddata->CastingSpell)) + 500; sEventMgr.ModifyEventTimeLeft(aur.get(), EVENT_AURA_REMOVE, time); } return PROCCOND_CONTINUE_EXECUTION; } return PROCCOND_BREAK_EXECUTION; }
bool DeathStrike(uint32 i, Spell* pSpell) { if(pSpell->p_caster == NULL || pSpell->GetUnitTarget() == NULL) return true; Unit* Target = pSpell->GetUnitTarget(); int count = 0; if(Target->HasAura(BLOOD_PLAGUE)) count++; if(Target->HasAura(FROST_FEVER)) count++; if(Target->HasAurasWithNameHash(SPELL_HASH_EBON_PLAGUE)) count++; if(Target->HasAurasWithNameHash(SPELL_HASH_CRYPT_FEVER)) count++; count = min(count, 3); //limited to 15% incase spell uniques are wrong for ebon plague and crypt fever if(count) { float pct = pSpell->p_caster->GetMaxHealth() * 0.05f; uint32 val = float2int32(pct * count); Aura* aur = pSpell->p_caster->FindAuraByNameHash(SPELL_HASH_IMPROVED_DEATH_STRIKE); if(aur != NULL) val += val * (aur->GetSpellProto()->EffectBasePoints[2] + 1) / 100; if(val > 0) pSpell->u_caster->Heal(pSpell->u_caster, pSpell->GetProto()->Id, val); } return true; }
void Player::Reputation_OnKilledUnit(Unit* pUnit, bool InnerLoop) { // add rep for on kill if ( pUnit->GetTypeId() != TYPEID_UNIT || pUnit->IsPet() || !pUnit->m_factionDBC ) return; Group * m_Group = GetGroup(); // Why would this be accessed if the group didn't exist? if ( !InnerLoop && m_Group != NULL ) { /* loop the rep for group members */ m_Group->getLock().Acquire(); GroupMembersSet::iterator it; for ( uint32 i = 0; i < m_Group->GetSubGroupCount(); i++ ) { for ( it = m_Group->GetSubGroup(i)->GetGroupMembersBegin(); it != m_Group->GetSubGroup(i)->GetGroupMembersEnd(); ++it ) { if ( (*it)->m_loggedInPlayer && (*it)->m_loggedInPlayer->isInRange( this, 100.0f ) ) (*it)->m_loggedInPlayer->Reputation_OnKilledUnit( pUnit, true ); } } m_Group->getLock().Release(); return; } uint32 team = GetTeam(); ReputationModifier * modifier = objmgr.GetReputationModifier( pUnit->GetEntry(), pUnit->m_factionDBC->ID ); if( modifier != 0 ) { // Apply this data. for( vector<ReputationMod>::iterator itr = modifier->mods.begin(); itr != modifier->mods.end(); itr++ ) { if ( !(*itr).faction[team] ) continue; /* rep limit? */ if ( !IS_INSTANCE( GetMapId() ) || ( IS_INSTANCE( GetMapId() ) && iInstanceType != MODE_5PLAYER_HEROIC) ) { if ( (*itr).replimit ) { if ( GetStanding( (*itr).faction[team] ) >= (int32)(*itr).replimit ) continue; } } ModStanding( itr->faction[team], float2int32( itr->value * sWorld.getRate( RATE_KILLREPUTATION ) ) ); } } else { if ( IS_INSTANCE( GetMapId() ) && objmgr.HandleInstanceReputationModifiers( this, pUnit ) ) return; if ( pUnit->m_factionDBC->RepListId < 0 ) return; int32 change = int32( -5.0f * sWorld.getRate( RATE_KILLREPUTATION ) ); ModStanding( pUnit->m_factionDBC->ID, change ); } }
bool AIInterface::CanCastFuckingSpell(Unit* Target, AI_Spell* toCast, uint32 currentTime) { if(toCast->cooldown) { if((toCast->lastcast+toCast->cooldown) > currentTime) return false; } if(toCast->minHPPercentReq) if(Target->GetHealthPct() > toCast->minHPPercentReq) return false; if(toCast->ProcLimit) { if(toCast->ProcResetDelay) { if(toCast->ProcResetTimer <= currentTime) { toCast->procCounter = 0; toCast->ProcResetTimer = currentTime+toCast->ProcResetDelay; } } if(toCast->procCounter >= toCast->ProcLimit) return false; } float dist = fabs(m_Unit->CalcDistance(Target)); if(dist < toCast->mindist2cast) return false; if(toCast->maxdist2cast) if(dist > toCast->maxdist2cast) return false; if(toCast->info->powerType == POWER_TYPE_MANA) { int32 currentPower = m_Unit->GetPower(POWER_TYPE_MANA); int32 cost; if( toCast->info->ManaCostPercentage)//Percentage spells cost % of !!!BASE!!! mana cost = (m_Unit->GetUInt32Value(UNIT_FIELD_BASE_MANA)*toCast->info->ManaCostPercentage)/100; else cost = toCast->info->manaCost; cost += m_Unit->PowerCostMod[toCast->info->School];//this is not percent! cost += float2int32(cost*m_Unit->GetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+toCast->info->School)); //apply modifiers if( toCast->info->SpellGroupType ) { SM_FIValue(m_Unit->SM[SMT_COST][0], &cost, toCast->info->SpellGroupType); SM_PIValue(m_Unit->SM[SMT_COST][1], &cost, toCast->info->SpellGroupType); } if(cost > currentPower) return false; } return true; }
uint32 SpellProc::CalcProcChance(Unit* victim, SpellEntry* CastingSpell) { // Check if proc chance is based on combo points if(mTarget->IsPlayer() && mOrigSpell && mOrigSpell->AttributesEx & ATTRIBUTESEX_REQ_COMBO_POINTS1 && mOrigSpell->AttributesExD & FLAGS5_PROCCHANCE_COMBOBASED) return float2int32(TO_PLAYER(mTarget)->m_comboPoints * mOrigSpell->EffectPointsPerComboPoint[0]); else return mProcChance; }
uint32 SpellProc::CalcProcChance(Unit* victim, SpellEntry* CastingSpell) { // Check if proc chance is based on combo points if (mTarget->IsPlayer() && mOrigSpell && mOrigSpell->AttributesEx & ATTRIBUTESEX_REQ_COMBO_POINTS1 && mOrigSpell->AttributesExD & SP_ATTR_EX_D_PROCCHANCE_COMBOBASED) return float2int32(static_cast<Player*>(mTarget)->m_comboPoints * mOrigSpell->eff[0].EffectPointsPerComboPoint); else return mProcChance; }
void EyeOfTheStorm::HookGenerateLoot(Player* plr, Corpse* pCorpse) { // add some money float gold = ((float(plr->getLevel()) / 2.5f)+1) * 100.0f; // fix this later gold *= sWorld.getRate(RATE_MONEY); // set it pCorpse->m_loot.gold = float2int32(gold); }
void IsleOfConquest::HookGenerateLoot(Player* plr, Object* pCorpse) { if(pCorpse->IsCorpse()) { // add some money float gold = ((float(plr->getLevel()) / 2.5f)+1) * 100.0f; // fix this later gold *= sWorld.getRate(RATE_MONEY); TO< Corpse* >(pCorpse)->loot.gold = float2int32(gold); } }
bool ChatHandler::HandleGODelete(const char *args, WorldSession *m_session) { GameObject *GObj = m_session->GetPlayer()->m_GM_SelectedGO; if( !GObj ) { RedSystemMessage(m_session, "No selected GameObject..."); return true; } if(GObj->m_spawn != 0) { uint32 cellx=float2int32(((_maxX-GObj->m_spawn->x)/_cellSize)); uint32 celly=float2int32(((_maxY-GObj->m_spawn->y)/_cellSize)); m_session->GetPlayer()->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cellx,celly)->GOSpawns.erase(GObj->m_spawn); delete GObj->m_spawn; } GObj->DeleteFromDB(); GObj->Despawn(0); delete GObj; m_session->GetPlayer()->m_GM_SelectedGO = 0; /* std::stringstream sstext; GameObject *GObj = m_session->GetPlayer()->m_GM_SelectedGO; if( !GObj ) { RedSystemMessage(m_session, "No selected GameObject..."); return true; } GObj->GetMapMgr()->GetBaseMap()->GetTemplate()->RemoveIndex<GameObject>(GObj); // remove index GObj->Despawn(3600000); GObj->DeleteFromDB(); sObjHolder.Delete<GameObject>(GObj); m_session->GetPlayer()->m_GM_SelectedGO = NULL; GreenSystemMessage(m_session, "GameObject successfully deleted from world and database !"); */ return true; }
bool ChatHandler::HandleGODelete(const char *args, WorldSession *m_session) { GameObject* GObj = m_session->GetPlayer()->m_GM_SelectedGO; if( !GObj ) { RedSystemMessage(m_session, "No selected GameObject..."); return true; } if(GObj->m_spawn != 0 && GObj->m_spawn->entry == GObj->GetEntry()) { uint32 cellx=float2int32(((_maxX-GObj->m_spawn->x)/_cellSize)); uint32 celly=float2int32(((_maxY-GObj->m_spawn->y)/_cellSize)); GObj->DeleteFromDB(); if(cellx < _sizeX && celly < _sizeY) { CellSpawns * c = GObj->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cellx, celly); GOSpawnList::iterator itr,itr2; for(itr = c->GOSpawns.begin(); itr != c->GOSpawns.end();) { itr2 = itr; itr++; if((*itr2) == GObj->m_spawn) { c->GOSpawns.erase(itr2); break; } } delete GObj->m_spawn; GObj->m_spawn = NULL; } } GObj->Despawn(0); GObj->Destructor(); GObj = NULL; m_session->GetPlayer()->m_GM_SelectedGO = NULL; return true; }
uint32 GetBuyPriceForItem( ItemPrototype* proto, uint32 count, Player* plr, Creature* vendor ) { int32 cost = proto->BuyPrice; if( plr != NULL && vendor != NULL ) { Standing plrstanding = plr->GetStandingRank( vendor->m_faction->Faction ); cost = float2int32( ceilf( float( proto->BuyPrice ) * pricemod[plrstanding] ) ); } return cost * count; }
bool ChatHandler::HandleDeleteCommand(const char* args, WorldSession *m_session) { uint64 guid = m_session->GetPlayer()->GetSelection(); if (guid == 0) { SystemMessage(m_session, "No selection."); return true; } Creature *unit = m_session->GetPlayer()->GetMapMgr()->GetCreature(guid); if(!unit) { SystemMessage(m_session, "You should select a creature."); return true; } sGMLog.writefromsession(m_session, "used npc delete, sqlid %u, creature %s, pos %f %f %f", unit->GetSQL_id(), unit->GetCreatureName()->Name, unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()); if(unit->m_spawn == 0) return false; BlueSystemMessage(m_session, "Deleted creature ID %u", unit->spawnid); if(unit->IsInWorld()) { if(unit->m_spawn) { uint32 cellx=float2int32(((_maxX-unit->m_spawn->x)/_cellSize)); uint32 celly=float2int32(((_maxY-unit->m_spawn->y)/_cellSize)); unit->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cellx, celly)->CreatureSpawns.erase(unit->m_spawn); } unit->RemoveFromWorld(false); } unit->DeleteFromDB(); delete unit; return true; }
void GameObject::UseFishingNode(Player* player) { sEventMgr.RemoveEvents( this ); if( GetUInt32Value( GAMEOBJECT_FLAGS ) != 32 ) // Clicking on the bobber before something is hooked { player->GetSession()->OutPacket( SMSG_FISH_NOT_HOOKED ); EndFishing( player, true ); return; } FishingZoneEntry *entry = NULL; uint32 zone = player->GetAreaID(); if(zone != 0) { entry = FishingZoneStorage.LookupEntry( zone ); if( entry == NULL ) // No fishing information found for area, log an error { OUT_DEBUG( "ERROR: Fishing area information for area %d not found!", zone ); } } if(zone == 0 || entry == NULL) { zone = player->GetZoneId(); entry = FishingZoneStorage.LookupEntry( zone ); if( entry == NULL ) // No fishing information found for area, log an error { OUT_DEBUG( "ERROR: Fishing zone information for zone %d not found!", zone ); EndFishing( player, true ); return; } } uint32 maxskill = entry->MaxSkill; uint32 minskill = entry->MinSkill; if( player->_GetSkillLineCurrent( SKILL_FISHING, false ) < maxskill ) player->_AdvanceSkillLine( SKILL_FISHING, float2int32( 1.0f * sWorld.getRate( RATE_SKILLRATE ) ) ); // Open loot on success, otherwise FISH_ESCAPED. if( Rand(((player->_GetSkillLineCurrent( SKILL_FISHING, true ) - minskill) * 100) / maxskill) ) { lootmgr.FillFishingLoot( &m_loot, zone ); player->SendLoot( GetGUID(), LOOT_FISHING ); EndFishing( player, false ); } else // Failed { player->GetSession()->OutPacket( SMSG_FISH_ESCAPED ); EndFishing( player, true ); } }
bool ExplosiveShot(uint32 i, Aura* a, bool apply) { if(!apply) return true; Unit* m_target = a->GetTarget(); a->SetNegative(); int32 dmg = a->GetModAmount(i); dmg += float2int32(m_target->GetRangedAttackPower() * 0.16f); a->EventPeriodicDamage(dmg); return true; }
int32 HonorHandler::CalculateHonorPointsForKill(uint32 playerLevel, uint32 victimLevel) { uint32 k_level = playerLevel; uint32 v_level = victimLevel; uint32 k_grey = 0; if(k_level > 5 && k_level < 40) { k_grey = k_level - 5 - float2int32(std::floor(((float)k_level) / 10.0f)); } else { k_grey = k_level - 1 - float2int32(std::floor(((float)k_level) / 5.0f)); } if(v_level <= k_grey) return 0; float honor_points = -0.53177f + 0.59357f * exp((k_level + 23.54042f) / 26.07859f); honor_points *= World::getSingleton().getRate(RATE_HONOR); return float2int32(honor_points); }
void QuestMgr::BuildQuestComplete(Player*plr, Quest* qst) { uint32 xp ; if(plr->getLevel() >= plr->GetUInt32Value(PLAYER_FIELD_MAX_LEVEL)) { plr->ModUInt32Value(PLAYER_FIELD_COINAGE, qst->reward_xp_as_money); xp = 0; }else { xp = float2int32(GenerateQuestXP(plr,qst) * sWorld.getRate(RATE_QUESTXP)); plr->GiveXP(xp, 0, false); } WorldPacket data( SMSG_QUESTGIVER_QUEST_COMPLETE,72 ); data << qst->id; data << uint32(3); //if(qst->reward_xp > 0) // data << uint32(qst->reward_xp); //else // data << uint32(GenerateQuestXP(NULL,qst)); //xp data << xp; data << uint32(qst->reward_money); data << uint32(qst->count_reward_item); //Reward item count ItemPrototype *ip; for(uint32 i = 0; i < 4; ++i) { data << qst->reward_item[i]; data << qst->reward_itemcount[i]; if(qst->reward_item[i]) { ip = ItemPrototypeStorage.LookupEntry(qst->reward_item[i]); data << ((ip != NULL) ? ip->DisplayInfoID : uint32(0)); } else { data << (uint32)0; } } plr->GetSession()->SendPacket(&data); }
void AuctionMgr::LoadAuctionHouses() { Log.Notice("AuctionMgr", "Loading Auction Houses..."); QueryResult * res = CharacterDatabase.Query("SELECT MAX(auctionId) FROM auctions"); if(res) { maxId = res->Fetch()[0].GetUInt32(); delete res; } res = WorldDatabase.Query("SELECT DISTINCT `group` FROM auctionhouse"); AuctionHouse * ah; map<uint32, AuctionHouse*> tempmap; if(res) { uint32 period = (res->GetRowCount() / 20) + 1; uint32 c = 0; do { ah = new AuctionHouse(res->Fetch()[0].GetUInt32()); ah->LoadAuctions(); auctionHouses.push_back(ah); tempmap.insert( make_pair( res->Fetch()[0].GetUInt32(), ah ) ); if( !((++c) % period) ) Log.Notice("AuctionHouse", "Done %u/%u, %u%% complete.", c, res->GetRowCount(), float2int32( (float(c) / float(res->GetRowCount()))*100.0f )); }while(res->NextRow()); delete res; } res = WorldDatabase.Query("SELECT creature_entry, `group` FROM auctionhouse"); if(res) { do { auctionHouseEntryMap.insert( make_pair( res->Fetch()[0].GetUInt32(), tempmap[res->Fetch()[1].GetUInt32()] ) ); } while(res->NextRow()); delete res; } }
int32 HonorHandler::CalculateHonorPointsForKill( PlayerPointer pPlayer, UnitPointer pVictim ) { // this sucks.. ;p if( pVictim == NULL ) return 0; // Suicide lol if( pVictim == pPlayer ) return 0; if( pVictim->GetTypeId() != TYPEID_PLAYER ) return 0; // How dishonorable, you fiend! if( pVictim->HasActiveAura( PLAYER_HONORLESS_TARGET_SPELL ) ) return 0; uint32 k_level = pPlayer->GetUInt32Value( UNIT_FIELD_LEVEL ); uint32 v_level = pVictim->GetUInt32Value( UNIT_FIELD_LEVEL ); // formula guessed int32 honor_points = 6; if(k_level != v_level) { int32 diff = v_level - k_level; honor_points += diff; if(honor_points <= 0) return 0; if(honor_points >= 8) honor_points = 8; } honor_points = float2int32(float(honor_points) * World::getSingleton().getRate( RATE_HONOR )); //honor_points *= World::getSingleton().getRate( RATE_HONOR ); return honor_points; }
void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) { bool moved = true; if(!_player->IsInWorld() || _player->m_uint32Values[UNIT_FIELD_CHARMEDBY] || _player->GetPlayerStatus() == TRANSFER_PENDING || _player->GetTaxiState()) return; // spell cancel on movement, for now only fishing is added Object * t_go = _player->m_SummonedObject; if (t_go) { if (t_go->GetEntry() == GO_FISHING_BOBBER) ((GameObject*)t_go)->EndFishing(GetPlayer(),true); } /************************************************************************/ /* Clear standing state to stand. */ /************************************************************************/ if( recv_data.GetOpcode() == MSG_MOVE_START_FORWARD ) _player->SetStandState( STANDSTATE_STAND ); /************************************************************************/ /* Make sure the packet is the correct size range. */ /************************************************************************/ if(recv_data.size() > 80) { Disconnect(); return; } /************************************************************************/ /* Read Movement Data Packet */ /************************************************************************/ movement_info.init(recv_data); /************************************************************************/ /* Update player movement state */ /************************************************************************/ switch( recv_data.GetOpcode() ) { case MSG_MOVE_START_FORWARD: case MSG_MOVE_START_BACKWARD: _player->moving = true; break; case MSG_MOVE_START_STRAFE_LEFT: case MSG_MOVE_START_STRAFE_RIGHT: _player->strafing = true; break; case MSG_MOVE_JUMP: _player->jumping = true; break; case MSG_MOVE_STOP: _player->moving = false; break; case MSG_MOVE_STOP_STRAFE: _player->strafing = false; break; case MSG_MOVE_FALL_LAND: _player->jumping = false; break; default: moved = false; break; } if( moved ) { if( !_player->moving && !_player->strafing && !_player->jumping ) _player->m_isMoving = false; else _player->m_isMoving = true; } /************************************************************************/ /* Anti-Fly Hack Checks */ /************************************************************************/ if( sWorld.antihack_flight && ( recv_data.GetOpcode() == CMSG_MOVE_FLY_START_AND_END || recv_data.GetOpcode() == CMSG_FLY_PITCH_DOWN_AFTER_UP ) && !( movement_info.flags & MOVEFLAG_SWIMMING || movement_info.flags & MOVEFLAG_FALLING || movement_info.flags & MOVEFLAG_FALLING_FAR || movement_info.flags & MOVEFLAG_FREE_FALLING ) && _player->flying_aura == 0 ) { if( sWorld.no_antihack_on_gm && _player->GetSession()->HasGMPermissions() ) { // Do nothing. } else { _player->BroadcastMessage( "Flyhack detected. In case the server is wrong then make a report how to reproduce this case. You will be logged out in 5 seconds." ); sEventMgr.AddEvent( _player, &Player::_Kick, EVENT_PLAYER_KICK, 5000, 1, 0 ); } } //update the detector if( sWorld.antihack_speed && !_player->GetTaxiState() && _player->m_TransporterGUID == 0 && !_player->GetSession()->GetPermissionCount()) { // simplified: just take the fastest speed. less chance of fuckups too float speed = ( _player->flying_aura ) ? _player->m_flySpeed : ( _player->m_swimSpeed >_player-> m_runSpeed ) ? _player->m_swimSpeed : _player->m_runSpeed; _player->SDetector->AddSample( movement_info.x, movement_info.y, getMSTime(), speed ); if( _player->SDetector->IsCheatDetected() ) _player->SDetector->ReportCheater( _player ); } /************************************************************************/ /* Remove Emote State */ /************************************************************************/ if(_player->m_uint32Values[UNIT_NPC_EMOTESTATE]) _player->SetUInt32Value(UNIT_NPC_EMOTESTATE,0); /************************************************************************/ /* Make sure the co-ordinates are valid. */ /************************************************************************/ if( !((movement_info.y >= _minY) && (movement_info.y <= _maxY)) || !((movement_info.x >= _minX) && (movement_info.x <= _maxX)) ) { Disconnect(); return; } /************************************************************************/ /* Dump movement flags - Wheee! */ /************************************************************************/ #if 0 printf("=========================================================\n"); printf("Full movement flags: 0x%.8X\n", movement_info.flags); uint32 z, b; for(z = 1, b = 1; b < 32;) { if(movement_info.flags & z) printf(" Bit %u (0x%.8X or %u) is set!\n", b, z, z); z <<= 1; b+=1; } printf("=========================================================\n"); #endif /************************************************************************/ /* Orientation dumping */ /************************************************************************/ #if 0 printf("Packet: 0x%03X (%s)\n", recv_data.GetOpcode(), LookupName( recv_data.GetOpcode(), g_worldOpcodeNames ) ); printf("Orientation: %.10f\n", movement_info.orientation); #endif /************************************************************************/ /* Calculate the timestamp of the packet we have to send out */ /************************************************************************/ size_t pos = (size_t)m_MoverWoWGuid.GetNewGuidLen() + 1; uint32 mstime = mTimeStamp(); int32 move_time; if(m_clientTimeDelay == 0) m_clientTimeDelay = mstime - movement_info.time; /************************************************************************/ /* Copy into the output buffer. */ /************************************************************************/ if(_player->m_inRangePlayers.size()) { move_time = (movement_info.time - (mstime - m_clientTimeDelay)) + MOVEMENT_PACKET_TIME_DELAY + mstime; memcpy(&movement_packet[pos], recv_data.contents(), recv_data.size()); movement_packet[pos+5]=0; /************************************************************************/ /* Distribute to all inrange players. */ /************************************************************************/ for(set<Player*>::iterator itr = _player->m_inRangePlayers.begin(); itr != _player->m_inRangePlayers.end(); ++itr) { #ifdef USING_BIG_ENDIAN *(uint32*)&movement_packet[pos+5] = swap32(move_time + (*itr)->GetSession()->m_moveDelayTime); #else *(uint32*)&movement_packet[pos+5] = uint32(move_time + (*itr)->GetSession()->m_moveDelayTime); #endif #if defined(ENABLE_COMPRESSED_MOVEMENT) && defined(ENABLE_COMPRESSED_MOVEMENT_FOR_PLAYERS) if( _player->GetPositionNC().Distance2DSq((*itr)->GetPosition()) >= World::m_movementCompressThreshold ) (*itr)->AppendMovementData( recv_data.GetOpcode(), uint16(recv_data.size() + pos), movement_packet ); else (*itr)->GetSession()->OutPacket(recv_data.GetOpcode(), uint16(recv_data.size() + pos), movement_packet); #else (*itr)->GetSession()->OutPacket(recv_data.GetOpcode(), uint16(recv_data.size() + pos), movement_packet); #endif } } /************************************************************************/ /* Falling damage checks */ /************************************************************************/ if( _player->blinked ) { _player->blinked = false; _player->m_fallDisabledUntil = UNIXTIME + 5; _player->SpeedCheatDelay( 2000 ); //some say they managed to trigger system with knockback. Maybe they moved in air ? } else { if( recv_data.GetOpcode() == MSG_MOVE_FALL_LAND ) { // player has finished falling //if _player->z_axisposition contains no data then set to current position if( !_player->z_axisposition ) _player->z_axisposition = movement_info.z; // calculate distance fallen uint32 falldistance = float2int32( _player->z_axisposition - movement_info.z ); /*if player is a rogue or druid(in cat form), then apply -17 modifier to fall distance. these checks need improving, low level rogue/druid should not receive this benefit*/ if( ( _player->getClass() == ROGUE ) || ( _player->GetShapeShift() == FORM_CAT ) ) { if( falldistance > 17 ) falldistance -=17; else falldistance = 1; } //checks that player has fallen more than 12 units, otherwise no damage will be dealt //falltime check is also needed here, otherwise sudden changes in Z axis position, such as using !recall, may result in death if( _player->isAlive() && !_player->GodModeCheat && falldistance > 12 && ( UNIXTIME >= _player->m_fallDisabledUntil ) && movement_info.FallTime > 1000 ) { // 1.7% damage for each unit fallen on Z axis over 13 uint32 health_loss = float2int32( float( _player->GetUInt32Value( UNIT_FIELD_MAXHEALTH ) * ( ( falldistance ) * 0.017 ) ) ); if( health_loss >= _player->GetUInt32Value( UNIT_FIELD_HEALTH ) ) health_loss = _player->GetUInt32Value( UNIT_FIELD_HEALTH ); _player->SendEnvironmentalDamageLog( _player->GetGUID(), DAMAGE_FALL, health_loss ); _player->DealDamage( _player, health_loss, 0, 0, 0 ); //_player->RemoveStealth(); // cebernic : why again? lost stealth by AURA_INTERRUPT_ON_ANY_DAMAGE_TAKEN already. } _player->z_axisposition = 0.0f; } else //whilst player is not falling, continuosly update Z axis position. //once player lands this will be used to determine how far he fell. if( !( movement_info.flags & MOVEFLAG_FALLING ) ) _player->z_axisposition = movement_info.z; } /************************************************************************/ /* Transporter Setup */ /************************************************************************/ if(!_player->m_lockTransportVariables) { if(_player->m_TransporterGUID && !movement_info.transGuid) { /* we left the transporter we were on */ if(_player->m_CurrentTransporter) { _player->m_CurrentTransporter->RemovePlayer(_player); _player->m_CurrentTransporter = NULL; } _player->m_TransporterGUID = 0; _player->SpeedCheatReset(); } else if(movement_info.transGuid) { if(!_player->m_TransporterGUID) { /* just walked into a transport */ if(_player->IsMounted()) _player->RemoveAura(_player->m_MountSpellId); _player->m_CurrentTransporter = objmgr.GetTransporter(GUID_LOPART(movement_info.transGuid)); if(_player->m_CurrentTransporter) _player->m_CurrentTransporter->AddPlayer(_player); /* set variables */ _player->m_TransporterGUID = movement_info.transGuid; _player->m_TransporterTime = movement_info.transTime; _player->m_TransporterX = movement_info.transX; _player->m_TransporterY = movement_info.transY; _player->m_TransporterZ = movement_info.transZ; } else { /* no changes */ _player->m_TransporterTime = movement_info.transTime; _player->m_TransporterX = movement_info.transX; _player->m_TransporterY = movement_info.transY; _player->m_TransporterZ = movement_info.transZ; } } /*float x = movement_info.x - movement_info.transX; float y = movement_info.y - movement_info.transY; float z = movement_info.z - movement_info.transZ; Transporter* trans = _player->m_CurrentTransporter; if(trans) sChatHandler.SystemMessageToPlr(_player, "Client t pos: %f %f\nServer t pos: %f %f Diff: %f %f", x,y, trans->GetPositionX(), trans->GetPositionY(), trans->CalcDistance(x,y,z), trans->CalcDistance(movement_info.x, movement_info.y, movement_info.z));*/ } /************************************************************************/ /* Anti-Speed Hack Checks */ /************************************************************************/ /************************************************************************/ /* Breathing System */ /************************************************************************/ _HandleBreathing(movement_info, _player, this); /************************************************************************/ /* Remove Spells */ /************************************************************************/ _player->RemoveAurasByInterruptFlag(AURA_INTERRUPT_ON_MOVEMENT); /************************************************************************/ /* Update our position in the server. */ /************************************************************************/ if( _player->m_CurrentCharm && _player->GetMapMgr() ) { Unit *cc = _player->GetMapMgr()->GetUnit( _player->m_CurrentCharm ); if( cc ) cc->SetPosition(movement_info.x, movement_info.y, movement_info.z, movement_info.orientation); } else { if(!_player->m_CurrentTransporter) { if( !_player->SetPosition(movement_info.x, movement_info.y, movement_info.z, movement_info.orientation) ) { _player->SetUInt32Value(UNIT_FIELD_HEALTH, 0); _player->KillPlayer(); } } else { _player->SetPosition(movement_info.x, movement_info.y, movement_info.z, movement_info.orientation + movement_info.transO, false); } } }
void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data ) { if(!_player->IsInWorld() || _player->m_uint32Values[UNIT_FIELD_CHARMEDBY] || _player->GetPlayerStatus() == TRANSFER_PENDING || _player->GetTaxiState()) return; // spell cancel on movement, for now only fishing is added Object * t_go = _player->m_SummonedObject; uint32 mstime_s; if (t_go) { if (t_go->GetEntry() == GO_FISHING_BOBBER) ((GameObject*)t_go)->EndFishing(GetPlayer(),true); } /************************************************************************/ /* Make sure the packet is the correct size range. */ /************************************************************************/ if(recv_data.size() > 80) { Disconnect(); return; } /************************************************************************/ /* Read Movement Data Packet */ /************************************************************************/ movement_info.init(recv_data); /************************************************************************/ /* Update player movement state */ /************************************************************************/ if( recv_data.GetOpcode() == MSG_MOVE_STOP || recv_data.GetOpcode() == MSG_MOVE_STOP_STRAFE || recv_data.GetOpcode() == MSG_MOVE_STOP_TURN || recv_data.GetOpcode() == MSG_MOVE_FALL_LAND || ( recv_data.GetOpcode() == MSG_MOVE_SET_FACING && !(movement_info.flags & MOVEFLAG_MOVING_MASK) ) ) { if( _player->m_isMoving ) { #ifdef _DEBUG // printf("MOVING: FALSE (Packet %s)\n", LookupName( recv_data.GetOpcode(), g_worldOpcodeNames ) ); #endif mstime_s = getMSTime(); _player->_SpeedhackCheck(mstime_s); _player->m_isMoving = false; _player->_startMoveTime = 0; } } else { if( !_player->m_isMoving ) { #ifdef _DEBUG // printf("MOVING: TRUE (Packet %s)\n", LookupName( recv_data.GetOpcode(), g_worldOpcodeNames ) ); #endif mstime_s = getMSTime(); _player->m_isMoving = true; _player->_startMoveTime = mstime_s; _player->_lastHeartbeatPosition = _player->GetPosition(); } } /************************************************************************/ /* Remove Emote State */ /************************************************************************/ if(_player->m_uint32Values[UNIT_NPC_EMOTESTATE]) _player->SetUInt32Value(UNIT_NPC_EMOTESTATE,0); /************************************************************************/ /* Make sure the co-ordinates are valid. */ /************************************************************************/ if( !((movement_info.y >= _minY) && (movement_info.y <= _maxY)) || !((movement_info.x >= _minX) && (movement_info.x <= _maxX)) ) { Disconnect(); return; } /************************************************************************/ /* Dump movement flags - Wheee! */ /************************************************************************/ #if 0 printf("=========================================================\n"); printf("Full movement flags: 0x%.8X\n", movement_info.flags); uint32 z, b; for(z = 1, b = 1; b < 32;) { if(movement_info.flags & z) printf(" Bit %u (0x%.8X or %u) is set!\n", b, z, z); z <<= 1; b+=1; } printf("=========================================================\n"); #endif /************************************************************************/ /* Orientation dumping */ /************************************************************************/ #if 0 printf("Packet: 0x%03X (%s)\n", recv_data.GetOpcode(), LookupName( recv_data.GetOpcode(), g_worldOpcodeNames ) ); printf("Orientation: %.10f\n", movement_info.orientation); #endif /************************************************************************/ /* Anti-Hack Checks */ /************************************************************************/ if( !(HasGMPermissions() && sWorld.no_antihack_on_gm) && !_player->m_uint32Values[UNIT_FIELD_CHARM] && !_player->_heartbeatDisable) { /************************************************************************/ /* Anti-Teleport */ /************************************************************************/ if(sWorld.antihack_teleport && _player->m_position.Distance2DSq(movement_info.x, movement_info.y) > 5625.0f && _player->m_runSpeed < 50.0f && !_player->m_TransporterGUID) { sCheatLog.writefromsession(this, "Used teleport hack {3}, speed was %f", _player->m_runSpeed); Disconnect(); return; } } /************************************************************************/ /* Calculate the timestamp of the packet we have to send out */ /************************************************************************/ size_t pos = (size_t)m_MoverWoWGuid.GetNewGuidLen() + 1; uint32 mstime = mTimeStamp(); int32 move_time; if(m_clientTimeDelay == 0) m_clientTimeDelay = mstime - movement_info.time; /************************************************************************/ /* Copy into the output buffer. */ /************************************************************************/ if(_player->m_inRangePlayers.size()) { move_time = (movement_info.time - (mstime - m_clientTimeDelay)) + MOVEMENT_PACKET_TIME_DELAY + mstime; memcpy(&movement_packet[pos], recv_data.contents(), recv_data.size()); movement_packet[pos+5]=0; /************************************************************************/ /* Distribute to all inrange players. */ /************************************************************************/ for(set<Player*>::iterator itr = _player->m_inRangePlayers.begin(); itr != _player->m_inRangePlayers.end(); ++itr) { #ifdef USING_BIG_ENDIAN *(uint32*)&movement_packet[pos+5] = swap32(move_time + (*itr)->GetSession()->m_moveDelayTime); #else *(uint32*)&movement_packet[pos+5] = uint32(move_time + (*itr)->GetSession()->m_moveDelayTime); #endif #if defined(ENABLE_COMPRESSED_MOVEMENT) && defined(ENABLE_COMPRESSED_MOVEMENT_FOR_PLAYERS) if( _player->GetPositionNC().Distance2DSq((*itr)->GetPosition()) >= World::m_movementCompressThreshold ) (*itr)->AppendMovementData( recv_data.GetOpcode(), uint16(recv_data.size() + pos), movement_packet ); else (*itr)->GetSession()->OutPacket(recv_data.GetOpcode(), uint16(recv_data.size() + pos), movement_packet); #else (*itr)->GetSession()->OutPacket(recv_data.GetOpcode(), uint16(recv_data.size() + pos), movement_packet); #endif } } /************************************************************************/ /* Falling damage checks */ /************************************************************************/ if( _player->blinked ) { _player->blinked = false; _player->m_fallDisabledUntil = UNIXTIME + 5; _player->DelaySpeedHack( 5000 ); } else { if( recv_data.GetOpcode() == MSG_MOVE_FALL_LAND ) { // player has finished falling //if _player->z_axisposition contains no data then set to current position if( !_player->z_axisposition ) _player->z_axisposition = movement_info.z; // calculate distance fallen uint32 falldistance = float2int32( _player->z_axisposition - movement_info.z ); /*if player is a rogue or druid(in cat form), then apply -17 modifier to fall distance. these checks need improving, low level rogue/druid should not receive this benefit*/ if( ( _player->getClass() == ROGUE ) || ( _player->GetShapeShift() == FORM_CAT ) ) { if( falldistance > 17 ) falldistance -=17; else falldistance = 1; } //checks that player has fallen more than 12 units, otherwise no damage will be dealt //falltime check is also needed here, otherwise sudden changes in Z axis position, such as using !recall, may result in death if( _player->isAlive() && !_player->GodModeCheat && falldistance > 12 && ( UNIXTIME >= _player->m_fallDisabledUntil ) && movement_info.FallTime > 1000 ) { // 1.7% damage for each unit fallen on Z axis over 13 uint32 health_loss = float2int32( float( _player->GetUInt32Value( UNIT_FIELD_MAXHEALTH ) * ( ( falldistance - 12 ) * 0.017 ) ) ); if( health_loss >= _player->GetUInt32Value( UNIT_FIELD_HEALTH ) ) health_loss = _player->GetUInt32Value( UNIT_FIELD_HEALTH ); _player->SendEnvironmentalDamageLog( _player->GetGUID(), DAMAGE_FALL, health_loss ); _player->DealDamage( _player, health_loss, 0, 0, 0 ); _player->RemoveStealth(); // Fall Damage will cause stealthed units to lose stealth. } _player->z_axisposition = 0.0f; } else //whilst player is not falling, continuosly update Z axis position. //once player lands this will be used to determine how far he fell. if( !( movement_info.flags & MOVEFLAG_FALLING ) ) _player->z_axisposition = movement_info.z; } /************************************************************************/ /* Transporter Setup */ /************************************************************************/ if(!_player->m_lockTransportVariables) { if(_player->m_TransporterGUID && !movement_info.transGuid) { /* we left the transporter we were on */ if(_player->m_CurrentTransporter) { _player->m_CurrentTransporter->RemovePlayer(_player); _player->m_CurrentTransporter = NULL; } _player->m_TransporterGUID = 0; _player->ResetHeartbeatCoords(); } else if(movement_info.transGuid) { if(!_player->m_TransporterGUID) { /* just walked into a transport */ if(_player->IsMounted()) _player->RemoveAura(_player->m_MountSpellId); _player->m_CurrentTransporter = objmgr.GetTransporter(GUID_LOPART(movement_info.transGuid)); if(_player->m_CurrentTransporter) _player->m_CurrentTransporter->AddPlayer(_player); /* set variables */ _player->m_TransporterGUID = movement_info.transGuid; _player->m_TransporterUnk = movement_info.transUnk; _player->m_TransporterX = movement_info.transX; _player->m_TransporterY = movement_info.transY; _player->m_TransporterZ = movement_info.transZ; } else { /* no changes */ _player->m_TransporterUnk = movement_info.transUnk; _player->m_TransporterX = movement_info.transX; _player->m_TransporterY = movement_info.transY; _player->m_TransporterZ = movement_info.transZ; } } /*float x = movement_info.x - movement_info.transX; float y = movement_info.y - movement_info.transY; float z = movement_info.z - movement_info.transZ; Transporter* trans = _player->m_CurrentTransporter; if(trans) sChatHandler.SystemMessageToPlr(_player, "Client t pos: %f %f\nServer t pos: %f %f Diff: %f %f", x,y, trans->GetPositionX(), trans->GetPositionY(), trans->CalcDistance(x,y,z), trans->CalcDistance(movement_info.x, movement_info.y, movement_info.z));*/ } /************************************************************************/ /* Anti-Speed Hack Checks */ /************************************************************************/ /************************************************************************/ /* Breathing System */ /************************************************************************/ _HandleBreathing(movement_info, _player, this); /************************************************************************/ /* Remove Spells */ /************************************************************************/ _player->RemoveAurasByInterruptFlag(AURA_INTERRUPT_ON_MOVEMENT); /************************************************************************/ /* Update our position in the server. */ /************************************************************************/ if( _player->m_CurrentCharm ) _player->m_CurrentCharm->SetPosition(movement_info.x, movement_info.y, movement_info.z, movement_info.orientation); else { if(!_player->m_CurrentTransporter) { if( !_player->SetPosition(movement_info.x, movement_info.y, movement_info.z, movement_info.orientation) ) { _player->SetUInt32Value(UNIT_FIELD_HEALTH, 0); _player->KillPlayer(); } } else { _player->SetPosition(movement_info.x, movement_info.y, movement_info.z, movement_info.orientation + movement_info.transO, false); } } }
void CalculateEffect(uint32 EffectIndex, Unit * target, int32* value) { if( _spell->u_caster != NULL ) *value += float2int32(_spell->u_caster->GetAP()*0.06f); }
void AuctionHouse::RemoveAuction(Auction * auct) { Log.Debug("AuctionHouse", "%u: Removing auction %u, reason %u.", dbc->id, auct->Id, auct->DeletedReason); char subject[100]; char body[200]; switch(auct->DeletedReason) { case AUCTION_REMOVE_EXPIRED: { // ItemEntry:0:3 snprintf(subject, 100, "%u:0:3", (unsigned int)auct->pItem->GetEntry()); // Auction expired, resend item, no money to owner. sMailSystem.SendAutomatedMessage(AUCTION, dbc->id, auct->Owner, subject, "", 0, 0, auct->pItem->GetGUID(), MAIL_STATIONERY_AUCTION); }break; case AUCTION_REMOVE_WON: { // ItemEntry:0:1 snprintf(subject, 100, "%u:0:1", (unsigned int)auct->pItem->GetEntry()); // <owner player guid>:bid:buyout snprintf(body, 200, "%X:%u:%u", (unsigned int)auct->Owner, (unsigned int)auct->HighestBid, (unsigned int)auct->BuyoutPrice); // Auction won by highest bidder. He gets the item. sMailSystem.SendAutomatedMessage(AUCTION, dbc->id, auct->HighestBidder, subject, body, 0, 0, auct->pItem->GetGUID(), MAIL_STATIONERY_AUCTION); // Send a mail to the owner with his cut of the price. uint32 auction_cut = float2int32(float(cut_percent * float(auct->HighestBid))); int32 amount = auct->HighestBid - auction_cut + auct->DepositAmount; if(amount < 0) amount = 0; Player *seller = objmgr.GetPlayer( auct->Owner ); if( seller ) { seller->Event_Achiement_Received( ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS,ACHIEVEMENT_UNUSED_FIELD_VALUE,ACHIEVEMENT_UNUSED_FIELD_VALUE,amount,ACHIEVEMENT_EVENT_ACTION_ADD); seller->Event_Achiement_Received( ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION,ACHIEVEMENT_UNUSED_FIELD_VALUE,ACHIEVEMENT_UNUSED_FIELD_VALUE,1,ACHIEVEMENT_EVENT_ACTION_ADD); seller->Event_Achiement_Received( ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED,ACHIEVEMENT_UNUSED_FIELD_VALUE,ACHIEVEMENT_UNUSED_FIELD_VALUE,amount,ACHIEVEMENT_EVENT_ACTION_SET_MAX); } Player *buyer = objmgr.GetPlayer( auct->HighestBidder ); if( buyer ) { seller->Event_Achiement_Received( ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID,ACHIEVEMENT_UNUSED_FIELD_VALUE,ACHIEVEMENT_UNUSED_FIELD_VALUE,amount,ACHIEVEMENT_EVENT_ACTION_SET_MAX); seller->Event_Achiement_Received( ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS,ACHIEVEMENT_UNUSED_FIELD_VALUE,ACHIEVEMENT_UNUSED_FIELD_VALUE,1,ACHIEVEMENT_EVENT_ACTION_ADD); } // ItemEntry:0:2 snprintf(subject, 100, "%u:0:2", (unsigned int)auct->pItem->GetEntry()); // <hex player guid>:bid:0:deposit:cut if(auct->HighestBid == auct->BuyoutPrice) // Buyout snprintf(body, 200, "%X:%u:%u:%u:%u", (unsigned int)auct->HighestBidder, (unsigned int)auct->HighestBid, (unsigned int)auct->BuyoutPrice, (unsigned int)auct->DepositAmount, (unsigned int)auction_cut); else snprintf(body, 200, "%X:%u:0:%u:%u", (unsigned int)auct->HighestBidder, (unsigned int)auct->HighestBid, (unsigned int)auct->DepositAmount, (unsigned int)auction_cut); // send message away. sMailSystem.SendAutomatedMessage(AUCTION, dbc->id, auct->Owner, subject, body, amount, 0, 0, MAIL_STATIONERY_AUCTION); // If it's not a buyout (otherwise the players has been already notified) if(auct->HighestBid < auct->BuyoutPrice || auct->BuyoutPrice == 0) { this->SendAuctionBuyOutNotificationPacket(auct); } }break; case AUCTION_REMOVE_CANCELLED: { snprintf(subject, 100, "%u:0:5", (unsigned int)auct->pItem->GetEntry()); uint32 cut = uint32(float(cut_percent * auct->HighestBid)); Player * plr = objmgr.GetPlayer(auct->Owner); if(cut && plr && plr->GetGold() >= cut) plr->ModGold(-((int32)cut)); sMailSystem.SendAutomatedMessage(AUCTION, GetID(), auct->Owner, subject, "", 0, 0, auct->pItem->GetGUID(), MAIL_STATIONERY_AUCTION); // return bidders money if(auct->HighestBidder) { sMailSystem.SendAutomatedMessage(AUCTION, GetID(), auct->HighestBidder, subject, "", auct->HighestBid, 0, 0, MAIL_STATIONERY_AUCTION); } }break; } // Remove the auction from the hashmap. auctionLock.AcquireWriteLock(); auctions.erase(auct->Id); auctionLock.ReleaseWriteLock(); // Destroy the item from memory (it still remains in the db) auct->pItem->DeleteMe(); auct->pItem = NULL; // Finally destroy the auction instance. auct->DeleteFromDB(); delete auct; auct = NULL; }
uint32 CalculateDamage( Unit* pAttacker, Unit* pVictim, uint32 weapon_damage_type, uint32 *spellgroup, SpellEntry* ability ) // spellid is used only for 2-3 spells, that have AP bonus { //TODO: Some awesome formula to determine how much damage to deal //consider this is melee damage // weapon_damage_type: 0 = melee, 1 = offhand(dualwield), 2 = ranged // Attack Power increases your base damage-per-second (DPS) by 1 for every 14 attack power. // (c) wowwiki //type of this UNIT_FIELD_ATTACK_POWER_MODS is unknown, not even uint32 disabled for now. uint32 offset; Item *it = NULL; if(ability && ability->NameHash == SPELL_HASH_FLAMETONGUE_WEAPON) return 0; if(pAttacker->disarmed && pAttacker->IsPlayer()) { offset=UNIT_FIELD_MINDAMAGE; it = static_cast< Player* >(pAttacker)->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_MAINHAND); } else if( weapon_damage_type == MELEE ) offset = UNIT_FIELD_MINDAMAGE; else if( weapon_damage_type == OFFHAND ) offset = UNIT_FIELD_MINOFFHANDDAMAGE; else // weapon_damage_type == RANGED offset = UNIT_FIELD_MINRANGEDDAMAGE; float min_damage = pAttacker->GetFloatValue(offset); float max_damage = pAttacker->GetFloatValue(offset+1); if(it) { min_damage -= it->GetProto()->Damage[0].Min; max_damage -= it->GetProto()->Damage[0].Max; } float ap = 0; float bonus; float wspeed; if(offset == UNIT_FIELD_MINRANGEDDAMAGE) { //starting from base attack power then we apply mods on it //ap += pAttacker->GetRAP(); ap += pVictim->RAPvModifier; if(!pVictim->IsPlayer()) { uint32 creatType = TO_CREATURE(pVictim)->GetCreatureInfo()->Type; ap += (float)pAttacker->CreatureRangedAttackPowerMod[creatType]; if(pAttacker->IsPlayer()) { min_damage = (min_damage + static_cast< Player* >(pAttacker)->IncreaseDamageByType[creatType]) * (1 + static_cast< Player* >(pAttacker)->IncreaseDamageByTypePCT[creatType]); max_damage = (max_damage + static_cast< Player* >(pAttacker)->IncreaseDamageByType[creatType]) * (1 + static_cast< Player* >(pAttacker)->IncreaseDamageByTypePCT[creatType]); } } if(pAttacker->IsPlayer()) { if(!pAttacker->disarmed) { it = static_cast< Player* >(pAttacker)->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_RANGED); if(it) wspeed = (float)it->GetProto()->Delay; else wspeed = 2000; } else wspeed = (float)pAttacker->GetBaseAttackTime(RANGED); } else { wspeed = (float)pAttacker->GetBaseAttackTime(MELEE); } //ranged weapon normalization. if(pAttacker->IsPlayer() && ability) { if(ability->Effect[0] == SPELL_EFFECT_DUMMYMELEE || ability->Effect[1] == SPELL_EFFECT_DUMMYMELEE || ability->Effect[2] == SPELL_EFFECT_DUMMYMELEE) { wspeed = 2800; } } //Weapon speed constant in feral forms if(pAttacker->IsPlayer()) { if(static_cast< Player* >(pAttacker)->IsInFeralForm()) { uint8 ss = static_cast< Player* >(pAttacker)->GetShapeShift(); if(ss == FORM_CAT) wspeed = 1000.0; else if(ss == FORM_DIREBEAR || ss == FORM_BEAR) wspeed = 2500.0; } } bonus = (wspeed-pAttacker->GetBaseAttackTime(RANGED))/14000.0f*ap; min_damage += bonus; max_damage += bonus; } else { //MinD = AP(28AS-(WS/7))-MaxD //starting from base attack power then we apply mods on it //ap += pAttacker->GetAP(); ap += pVictim->APvModifier; if(!pVictim->IsPlayer()) { uint32 creatType = TO_CREATURE(pVictim)->GetCreatureInfo()->Type; ap += (float)pAttacker->CreatureAttackPowerMod[creatType]; if(pAttacker->IsPlayer()) { min_damage = (min_damage + static_cast< Player* >(pAttacker)->IncreaseDamageByType[creatType]) * (1 + static_cast< Player* >(pAttacker)->IncreaseDamageByTypePCT[creatType]); max_damage = (max_damage + static_cast< Player* >(pAttacker)->IncreaseDamageByType[creatType]) * (1 + static_cast< Player* >(pAttacker)->IncreaseDamageByTypePCT[creatType]); } } if(pAttacker->IsPlayer()) { if(!pAttacker->disarmed) { it = static_cast< Player* >(pAttacker)->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_MAINHAND); if(it) wspeed = (float)it->GetProto()->Delay; else wspeed = 2000; } else wspeed = (float)pAttacker->GetBaseAttackTime(MELEE); } else { wspeed = (float)pAttacker->GetBaseAttackTime(MELEE); } //Normalized weapon damage checks. if(pAttacker->IsPlayer() && ability) { if(ability->Effect[0] == SPELL_EFFECT_DUMMYMELEE || ability->Effect[1] == SPELL_EFFECT_DUMMYMELEE || ability->Effect[2] == SPELL_EFFECT_DUMMYMELEE) { it = static_cast< Player* >(pAttacker)->GetItemInterface()->GetInventoryItem(EQUIPMENT_SLOT_MAINHAND); if(it) { if(it->GetProto()->Class == 2) //weapon { if(it->GetProto()->InventoryType == INVTYPE_2HWEAPON) wspeed = 3300; else if(it->GetProto()->SubClass == 15) wspeed = 1700; else wspeed = 2400; } } } } //Weapon speed constant in feral forms if(pAttacker->IsPlayer()) { if(static_cast< Player* >(pAttacker)->IsInFeralForm()) { uint8 ss = static_cast< Player* >(pAttacker)->GetShapeShift(); if(ss == FORM_CAT) wspeed = 1000.0; else if(ss == FORM_DIREBEAR || ss == FORM_BEAR) wspeed = 2500.0; } } if (offset == UNIT_FIELD_MINDAMAGE) bonus = (wspeed-pAttacker->GetBaseAttackTime(MELEE))/14000.0f*ap; else bonus = (wspeed-pAttacker->GetBaseAttackTime(OFFHAND))/14000.0f*ap; min_damage += bonus; max_damage += bonus; } float diff = fabs(max_damage - min_damage); float result = min_damage; if(diff >= 1) result += RandomFloat(diff); if(result >= 0) { if( pAttacker->IsPlayer() && TO_PLAYER(pAttacker)->m_outStealthDamageBonusTimer ) { if( (uint32)UNIXTIME >= TO_PLAYER(pAttacker)->m_outStealthDamageBonusTimer ) TO_PLAYER(pAttacker)->m_outStealthDamageBonusTimer = 0; else result *= ((TO_PLAYER(pAttacker)->m_outStealthDamageBonusPct) / 100.0f) + 1.0f; } return float2int32(result); } return 0; }