mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/GameObjects
* Removed long deprecated code for mining nodes (multiple uses, artifact of TBC) * Made fishing pools generate use count only on spawn (and respawn) instead of randomizing use count on every fishing attempt - prevents early despawning in some cases
This commit is contained in:
@@ -224,6 +224,10 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa
|
||||
|
||||
switch (goinfo->type)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_FISHINGHOLE:
|
||||
SetGoAnimProgress(animprogress);
|
||||
m_goValue.FishingHole.MaxOpens = urand(GetGOInfo()->fishinghole.minSuccessOpens, GetGOInfo()->fishinghole.maxSuccessOpens);
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING:
|
||||
m_goValue.Building.Health = goinfo->building.intactNumHits + goinfo->building.damagedNumHits;
|
||||
m_goValue.Building.MaxHealth = m_goValue.Building.Health;
|
||||
@@ -377,22 +381,27 @@ void GameObject::Update(uint32 diff)
|
||||
//we need to open doors if they are closed (add there another condition if this code breaks some usage, but it need to be here for battlegrounds)
|
||||
if (GetGoState() != GO_STATE_READY)
|
||||
ResetDoorOrButton();
|
||||
//flags in AB are type_button and we need to add them here so no break!
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_FISHINGHOLE:
|
||||
// Initialize a new max fish count on respawn
|
||||
m_goValue.FishingHole.MaxOpens = urand(GetGOInfo()->fishinghole.minSuccessOpens, GetGOInfo()->fishinghole.maxSuccessOpens);
|
||||
break;
|
||||
default:
|
||||
if (!m_spawnedByDefault) // despawn timer
|
||||
{
|
||||
// can be despawned or destroyed
|
||||
SetLootState(GO_JUST_DEACTIVATED);
|
||||
return;
|
||||
}
|
||||
// respawn timer
|
||||
uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
|
||||
if (poolid)
|
||||
sPoolMgr->UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
|
||||
else
|
||||
GetMap()->AddToMap(this);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!m_spawnedByDefault) // despawn timer
|
||||
{
|
||||
// can be despawned or destroyed
|
||||
SetLootState(GO_JUST_DEACTIVATED);
|
||||
return;
|
||||
}
|
||||
// respawn timer
|
||||
uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
|
||||
if (poolid)
|
||||
sPoolMgr->UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
|
||||
else
|
||||
GetMap()->AddToMap(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ struct GameObjectTemplate
|
||||
uint32 lootId; //1
|
||||
uint32 chestRestockTime; //2
|
||||
uint32 consumable; //3
|
||||
uint32 minSuccessOpens; //4
|
||||
uint32 maxSuccessOpens; //5
|
||||
uint32 minSuccessOpens; //4 Deprecated, pre 3.0 was used for mining nodes but since WotLK all mining nodes are usable once and grant all loot with a single use
|
||||
uint32 maxSuccessOpens; //5 Deprecated, pre 3.0 was used for mining nodes but since WotLK all mining nodes are usable once and grant all loot with a single use
|
||||
uint32 eventId; //6 lootedEvent
|
||||
uint32 linkedTrapId; //7
|
||||
uint32 questId; //8 not used currently but store quest required for GO activation for player
|
||||
@@ -529,6 +529,11 @@ class OPvPCapturePoint;
|
||||
|
||||
union GameObjectValue
|
||||
{
|
||||
//25 GAMEOBJECT_TYPE_FISHINGHOLE
|
||||
struct
|
||||
{
|
||||
uint32 MaxOpens;
|
||||
} FishingHole;
|
||||
//29 GAMEOBJECT_TYPE_CAPTURE_POINT
|
||||
struct
|
||||
{
|
||||
|
||||
@@ -277,61 +277,15 @@ void WorldSession::DoLootRelease(uint64 lguid)
|
||||
}
|
||||
else if (loot->isLooted() || go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE)
|
||||
{
|
||||
// GO is mineral vein? so it is not removed after its looted
|
||||
if (go->GetGoType() == GAMEOBJECT_TYPE_CHEST)
|
||||
{
|
||||
uint32 go_min = go->GetGOInfo()->chest.minSuccessOpens;
|
||||
uint32 go_max = go->GetGOInfo()->chest.maxSuccessOpens;
|
||||
|
||||
// only vein pass this check
|
||||
if (go_min != 0 && go_max > go_min)
|
||||
{
|
||||
float amount_rate = sWorld->getRate(RATE_MINING_AMOUNT);
|
||||
float min_amount = go_min*amount_rate;
|
||||
float max_amount = go_max*amount_rate;
|
||||
|
||||
go->AddUse();
|
||||
float uses = float(go->GetUseCount());
|
||||
|
||||
if (uses < max_amount)
|
||||
{
|
||||
if (uses >= min_amount)
|
||||
{
|
||||
float chance_rate = sWorld->getRate(RATE_MINING_NEXT);
|
||||
|
||||
int32 ReqValue = 175;
|
||||
LockEntry const* lockInfo = sLockStore.LookupEntry(go->GetGOInfo()->chest.lockId);
|
||||
if (lockInfo)
|
||||
ReqValue = lockInfo->Skill[0];
|
||||
float skill = float(player->GetSkillValue(SKILL_MINING))/(ReqValue+25);
|
||||
double chance = pow(0.8*chance_rate, 4*(1/double(max_amount))*double(uses));
|
||||
if (roll_chance_f((float)(100*chance+skill)))
|
||||
{
|
||||
go->SetLootState(GO_READY);
|
||||
}
|
||||
else // not have more uses
|
||||
go->SetLootState(GO_JUST_DEACTIVATED);
|
||||
}
|
||||
else // 100% chance until min uses
|
||||
go->SetLootState(GO_READY);
|
||||
}
|
||||
else // max uses already
|
||||
go->SetLootState(GO_JUST_DEACTIVATED);
|
||||
}
|
||||
else // not vein
|
||||
go->SetLootState(GO_JUST_DEACTIVATED);
|
||||
}
|
||||
else if (go->GetGoType() == GAMEOBJECT_TYPE_FISHINGHOLE)
|
||||
if (go->GetGoType() == GAMEOBJECT_TYPE_FISHINGHOLE)
|
||||
{ // The fishing hole used once more
|
||||
go->AddUse(); // if the max usage is reached, will be despawned in next tick
|
||||
if (go->GetUseCount() >= urand(go->GetGOInfo()->fishinghole.minSuccessOpens, go->GetGOInfo()->fishinghole.maxSuccessOpens))
|
||||
{
|
||||
if (go->GetUseCount() >= go->GetGOValue()->FishingHole.MaxOpens)
|
||||
go->SetLootState(GO_JUST_DEACTIVATED);
|
||||
}
|
||||
else
|
||||
go->SetLootState(GO_READY);
|
||||
}
|
||||
else // not chest (or vein/herb/etc)
|
||||
else
|
||||
go->SetLootState(GO_JUST_DEACTIVATED);
|
||||
|
||||
loot->clear();
|
||||
|
||||
@@ -3073,7 +3073,7 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
|
||||
// set target for proper facing
|
||||
if ((m_casttime || m_spellInfo->IsChanneled()) && !(_triggeredCastFlags & TRIGGERED_IGNORE_SET_FACING))
|
||||
if (m_caster->GetGUID() != m_targets.GetObjectTargetGUID() && m_caster->GetTypeId() == TYPEID_UNIT)
|
||||
m_caster->FocusTarget(this, m_targets.GetObjectTargetGUID());
|
||||
m_caster->FocusTarget(this, m_targets.GetObjectTargetGUID());
|
||||
|
||||
if (!(_triggeredCastFlags & TRIGGERED_IGNORE_GCD))
|
||||
TriggerGlobalCooldown();
|
||||
|
||||
@@ -497,8 +497,6 @@ void World::LoadConfigSettings(bool reload)
|
||||
rate_values[RATE_AUCTION_DEPOSIT] = ConfigMgr::GetFloatDefault("Rate.Auction.Deposit", 1.0f);
|
||||
rate_values[RATE_AUCTION_CUT] = ConfigMgr::GetFloatDefault("Rate.Auction.Cut", 1.0f);
|
||||
rate_values[RATE_HONOR] = ConfigMgr::GetFloatDefault("Rate.Honor", 1.0f);
|
||||
rate_values[RATE_MINING_AMOUNT] = ConfigMgr::GetFloatDefault("Rate.Mining.Amount", 1.0f);
|
||||
rate_values[RATE_MINING_NEXT] = ConfigMgr::GetFloatDefault("Rate.Mining.Next", 1.0f);
|
||||
rate_values[RATE_INSTANCE_RESET_TIME] = ConfigMgr::GetFloatDefault("Rate.InstanceResetTime", 1.0f);
|
||||
rate_values[RATE_TALENT] = ConfigMgr::GetFloatDefault("Rate.Talent", 1.0f);
|
||||
if (rate_values[RATE_TALENT] < 0.0f)
|
||||
|
||||
@@ -385,8 +385,6 @@ enum Rates
|
||||
RATE_AUCTION_DEPOSIT,
|
||||
RATE_AUCTION_CUT,
|
||||
RATE_HONOR,
|
||||
RATE_MINING_AMOUNT,
|
||||
RATE_MINING_NEXT,
|
||||
RATE_TALENT,
|
||||
RATE_CORPSE_DECAY_LOOTED,
|
||||
RATE_INSTANCE_RESET_TIME,
|
||||
|
||||
@@ -1882,20 +1882,6 @@ Rate.Auction.Cut = 1
|
||||
|
||||
Rate.Honor = 1
|
||||
|
||||
#
|
||||
# Rate.Mining.Amount
|
||||
# Description: Rate for minimum/maximum times a deposit can be used.
|
||||
# Default: 1
|
||||
|
||||
Rate.Mining.Amount = 1
|
||||
|
||||
#
|
||||
# Rate.Mining.Next
|
||||
# Description: Mining rates.
|
||||
# Default: Chance to to mine a deposit again.
|
||||
|
||||
Rate.Mining.Next = 1
|
||||
|
||||
#
|
||||
# Rate.Talent
|
||||
# Description: Talent point rate.
|
||||
|
||||
Reference in New Issue
Block a user