本文整理汇总了C++中roll_chance_f函数的典型用法代码示例。如果您正苦于以下问题:C++ roll_chance_f函数的具体用法?C++ roll_chance_f怎么用?C++ roll_chance_f使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了roll_chance_f函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSkillValue
void Player::GenerateResearchProjects()
{
if (sResearchProjectSet.empty())
return;
uint16 skill_now = GetSkillValue(SKILL_ARCHAEOLOGY);
if (!skill_now)
return;
for (uint32 i = 0; i < MAX_RESEARCH_PROJECTS / 2; ++i)
SetUInt32Value(PLAYER_FIELD_RESEARCHING_1 + i, 0);
typedef std::map<uint32, ResearchProjectSet> ProjectsByBranch;
ProjectsByBranch tempProjects;
ProjectsByBranch tempRareProjects;
float rare_chance = GetRareArtifactChance(skill_now);
for (std::set<ResearchProjectEntry const*>::const_iterator itr = sResearchProjectSet.begin(); itr != sResearchProjectSet.end(); ++itr)
{
ResearchProjectEntry const* entry = (*itr);
if (entry->rare)
{
if (IsCompletedProject(entry->ID, true))
continue;
tempRareProjects[entry->branchId].insert(entry->ID);
}
else
tempProjects[entry->branchId].insert(entry->ID);
}
for (ProjectsByBranch::const_iterator itr = tempProjects.begin(); itr != tempProjects.end(); ++itr)
{
ResearchProjectSet::iterator itr2;
if (tempRareProjects[itr->first].size() > 0 && roll_chance_f(rare_chance))
{
itr2 = tempRareProjects[itr->first].begin();
std::advance(itr2, urand(0, tempRareProjects[itr->first].size() - 1));
}
else
{
itr2 = itr->second.begin();
std::advance(itr2, urand(0, itr->second.size() - 1));
}
ReplaceResearchProject(0, *itr2);
}
_archaeologyChanged = true;
}
示例2: ApplyClassDamageMultiplierSpell
void ApplyClassDamageMultiplierSpell(int32& damage, SpellNonMeleeDamage& /*damageinfo*/, SpellInfo const* spellInfo, WeaponAttackType /*attackType*/, bool& crit) const
{
uint32 spellId = spellInfo->Id;
//uint8 lvl = me->getLevel();
float fdamage = float(damage);
//1) apply additional crit chance. This additional chance roll will replace original (balance safe)
if (!crit)
{
float aftercrit = 0.f;
////Shatter: frozen targets crit
//if (lvl >= 11 && damageinfo.target && damageinfo.target->isFrozen())
// aftercrit *= 4.f;
if (aftercrit > 0.f)
crit = roll_chance_f(aftercrit);
}
//2) apply bonus damage mods
float pctbonus = 0.0f;
if (crit)
{
////!!!spell damage is not yet critical and will be multiplied by 1.5
////so we should put here bonus damage mult /1.5
////Spell Power: 50% additional crit damage bonus for All spells
//if (lvl >= 55)
// pctbonus += 0.333f;
}
//if (lvl >= 11 && spellId == FROSTBOLT && damageinfo.target && damageinfo.target->isFrozen())
// pctbonus *= 0.2f;
//Spellpower bonus damage (temp)
if (m_spellpower > 0)
{
if (spellId == SHADOW_BOLT)
fdamage += m_spellpower * 1.38f;
else if (spellId == IMMOLATE)
fdamage += m_spellpower * 0.75f; //guessed
else if (spellId == CONFLAGRATE)
fdamage += m_spellpower * 2.75f; //guessed
else if (spellId == CHAOS_BOLT)
fdamage += m_spellpower * 2.25f * 1.24f;
else if (spellId == RAIN_OF_FIRE || spellId == 42223)
fdamage += m_spellpower * 0.25f * 4.f;
else if (spellId == HAUNT)
fdamage += m_spellpower * 1.75f;
}
damage = int32(fdamage * (1.0f + pctbonus));
}
示例3: GetSkillDiscoverySpell
uint32 GetSkillDiscoverySpell(uint32 skillId, uint32 spellId, Player* player)
{
// check spell case
SkillDiscoveryMap::const_iterator tab = SkillDiscoveryStore.find(spellId);
if (tab != SkillDiscoveryStore.end())
{
for (SkillDiscoveryList::const_iterator item_iter = tab->second.begin(); item_iter != tab->second.end(); ++item_iter)
{
if (roll_chance_f(item_iter->chance * sWorld.getConfig(CONFIG_FLOAT_RATE_SKILL_DISCOVERY)) &&
!player->HasSpell(item_iter->spellId))
return item_iter->spellId;
}
return 0;
}
if (!skillId)
return 0;
// check skill line case
tab = SkillDiscoveryStore.find(-(int32)skillId);
if (tab != SkillDiscoveryStore.end())
{
for (SkillDiscoveryList::const_iterator item_iter = tab->second.begin(); item_iter != tab->second.end(); ++item_iter)
{
if (roll_chance_f(item_iter->chance * sWorld.getConfig(CONFIG_FLOAT_RATE_SKILL_DISCOVERY)) &&
!player->HasSpell(item_iter->spellId))
return item_iter->spellId;
}
return 0;
}
return 0;
}
示例4: OnCastItemCombatSpell
bool OnCastItemCombatSpell(Player* /*player*/, Unit* victim, SpellInfo const* /*spellInfo*/, Item* /*item*/) override
{
// spell proc chance gets severely reduced on victims > 60 (formula unknown)
if (victim->getLevel() > 60)
{
// gives ~0.1% proc chance at lvl 70
float const lvlPenaltyFactor = 9.93f;
float const failureChance = (victim->getLevel() - 60) * lvlPenaltyFactor;
// base ppm chance was already rolled, only roll success chance
return !roll_chance_f(failureChance);
}
return true;
}
示例5: RefreshAuctions
void BlackMarketMgr::RefreshAuctions()
{
SQLTransaction trans = CharacterDatabase.BeginTransaction();
// Delete completed auctions
for (BlackMarketEntryMap::iterator itr = _auctions.begin(); itr != _auctions.end();)
{
BlackMarketEntry* entry = itr->second;
if (!entry->IsCompleted())
{
++itr;
continue;
}
entry->DeleteFromDB(trans);
itr = _auctions.erase(itr);
delete entry;
}
CharacterDatabase.CommitTransaction(trans);
trans = CharacterDatabase.BeginTransaction();
std::list<BlackMarketTemplate const*> templates;
for (auto const& pair : _templates)
{
if (GetAuctionByID(pair.second->MarketID))
continue;
if (!roll_chance_f(pair.second->Chance))
continue;
templates.push_back(pair.second);
}
Trinity::Containers::RandomResizeList(templates, sWorld->getIntConfig(CONFIG_BLACKMARKET_MAXAUCTIONS));
for (BlackMarketTemplate const* templat : templates)
{
BlackMarketEntry* entry = new BlackMarketEntry();
entry->Initialize(templat->MarketID, templat->Duration);
entry->SaveToDB(trans);
AddAuction(entry);
}
CharacterDatabase.CommitTransaction(trans);
Update(true);
}
示例6: HandleOnHit
void HandleOnHit()
{
if (Unit* caster = GetCaster())
{
if (Unit* target = GetHitUnit())
{
if (caster->GetTypeId() == TYPEID_PLAYER && caster->HasAura(MASTERY_MONK_WINDWALKER))
{
float Mastery = caster->GetFloatValue(PLAYER_MASTERY) * 1.4f;
if (roll_chance_f(Mastery))
{
if (roll_chance_i(50))
caster->CastSpell(caster, MASTERY_SPELL_COMBO_BREAKER_1, true);
else
caster->CastSpell(caster, MASTERY_SPELL_COMBO_BREAKER_2, true);
}
}
}
}
}
示例7: Absorb
void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
// You have a chance equal to your Parry chance
if ((dmgInfo.GetDamageType() == SPELL_DIRECT_DAMAGE) && roll_chance_f(GetTarget()->GetUnitParryChance()))
absorbAmount = CalculatePctN(dmgInfo.GetDamage(), absorbPct);
}
示例8: GetPlayer
void WorldSession::DoLootRelease(ObjectGuid lguid)
{
Player* player = GetPlayer();
Loot* loot;
player->SetLootGuid(ObjectGuid());
player->SendLootRelease(lguid);
player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING);
if (!player->IsInWorld())
{ return; }
switch (lguid.GetHigh())
{
case HIGHGUID_GAMEOBJECT:
{
GameObject* go = GetPlayer()->GetMap()->GetGameObject(lguid);
// not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
if (!go || ((go->GetOwnerGuid() != _player->GetObjectGuid() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player, INTERACTION_DISTANCE)))
{ return; }
loot = &go->loot;
if (go->GetGoType() == GAMEOBJECT_TYPE_DOOR)
{
// locked doors are opened with spelleffect openlock, prevent remove its as looted
go->UseDoorOrButton();
}
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.getConfig(CONFIG_FLOAT_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.getConfig(CONFIG_FLOAT_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.0f * 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)
{
// The fishing hole used once more
go->AddUse(); // if the max usage is reached, will be despawned at next tick
if (go->GetUseCount() >= urand(go->GetGOInfo()->fishinghole.minSuccessOpens, go->GetGOInfo()->fishinghole.maxSuccessOpens))
{
go->SetLootState(GO_JUST_DEACTIVATED);
}
else
{ go->SetLootState(GO_READY); }
}
else // not chest (or vein/herb/etc)
{ go->SetLootState(GO_JUST_DEACTIVATED); }
loot->clear();
}
else
// not fully looted object
{
go->SetLootState(GO_ACTIVATED);
}
go->SetGoState(GO_STATE_READY);
//.........这里部分代码省略.........
示例9: GetPlayer
void WorldSession::DoLootRelease(uint64 lguid)
{
Player *player = GetPlayer();
Loot *loot;
player->SetLootGUID(0);
player->SendLootRelease(lguid);
player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING);
if (!player->IsInWorld())
return;
if (IS_GAMEOBJECT_GUID(lguid))
{
GameObject* go = GetPlayer()->GetMap()->GetGameObject(lguid);
// not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
if (!go || ((go->GetOwnerGUID() != _player->GetGUID() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player, INTERACTION_DISTANCE)))
return;
loot = &go->loot;
if (go->GetGoType() == GAMEOBJECT_TYPE_DOOR)
{
// locked doors are opened with spelleffect openlock, prevent remove its as looted
go->UseDoorOrButton();
}
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)
{ // 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))
{
go->SetLootState(GO_JUST_DEACTIVATED);
}
else
go->SetLootState(GO_READY);
}
else // not chest (or vein/herb/etc)
go->SetLootState(GO_JUST_DEACTIVATED);
loot->clear();
}
else
{
// not fully looted object
go->SetLootState(GO_ACTIVATED, player);
// if the round robin player release, reset it.
if (player->GetGUID() == loot->roundRobinPlayer)
{
if (Group* group = player->GetGroup())
{
if (group->GetLootMethod() != MASTER_LOOT)
//.........这里部分代码省略.........
示例10: DamageMade
void DamageMade(Unit* target, uint32 & damage, bool direct_damage)
{
if (direct_damage && roll_chance_f(25.0f))
me->CastSpell(target, SPELL_RIGHTEOUS_FIRE, true);
}
示例11: ApplyClassDamageMultiplierSpell
void ApplyClassDamageMultiplierSpell(int32& damage, SpellNonMeleeDamage& damageinfo, SpellInfo const* spellInfo, WeaponAttackType /*attackType*/, bool& crit) const
{
uint32 spellId = spellInfo->Id;
uint8 lvl = me->getLevel();
float fdamage = float(damage);
//1) apply additional crit chance. This additional chance roll will replace original (balance safe)
if (!crit)
{
float aftercrit = 0.f;
//World In Flames rank 3 (434 deprecated): 9% additional critical chance for
//Flamestrike, Pyroblast, Blast Wave, Dragon's Breath, Living Bomb, Blizzard and Arcane Explosion
if (spellId == FLAMESTRIKE ||
spellId == PYROBLAST ||
spellId == BLASTWAVE ||
spellId == DRAGONBREATH/* ||
spellId == ARCANEXPLOSION ||
spellId == LIVINGBOMB || //cannot be handled here
spellId == BLIZZARD*/) //cannot be handled here
aftercrit += 9.f;
//434 new
//Improved Fire Blast (part 1): 8% additional crit chance for Fire Blast
if (lvl >= 11 && spellId == FLAMESTRIKE)
aftercrit += 8.f;
//Shatter: frozen targets crit
if (lvl >= 11 && damageinfo.target && damageinfo.target->isFrozen())
aftercrit *= 4.f;
if (aftercrit > 0.f)
crit = roll_chance_f(aftercrit);
}
//2) apply bonus damage mods
float pctbonus = 0.0f;
if (crit)
{
////!!!spell damage is not yet critical and will be multiplied by 1.5
////so we should put here bonus damage mult /1.5
////Spell Power: 50% additional crit damage bonus for All spells
//if (lvl >= 55)
// pctbonus += 0.333f;
////Ice Shards: 50% additional crit damage bonus for Frost spells
//else if (lvl >= 15 && (SPELL_SCHOOL_MASK_FROST & spellInfo->GetSchoolMask()))
// pctbonus += 0.333f;
}
//Glyph of Cone of Cold: 25% bonus damage for Cone of Cold
if (spellId == CONEOFCOLD)
pctbonus += 0.25f;
//Fire Power (part 1): 3% bonus damage for Fire spells
if (lvl >= 9 && (SPELL_SCHOOL_MASK_FIRE & spellInfo->GetSchoolMask()))
pctbonus += 0.03f;
//434 new
//Critical Mass (part 1): 15% bonus damage for Pyroblast and Flame Orb
if (lvl >= 63 && (spellId == PYROBLAST/* || */))
pctbonus += 0.15f;
//Frost talent tree (part 2): 15% bonus damage for Frostbolt
if (lvl >= 10 && spellId == FROSTBOLT)
pctbonus += 0.15f;
if (lvl >= 11 && spellId == FROSTBOLT && damageinfo.target && damageinfo.target->isFrozen())
pctbonus *= 0.2f;
//Spellpower bonus damage (temp)
if (m_spellpower > 0)
{
if (spellId == ARCANEMISSILES_DAMAGE)
fdamage += m_spellpower * 0.222f;
else if (spellId == FIREBALL)
fdamage += m_spellpower * 1.555f;
else if (spellId == FIREBLAST)
fdamage += m_spellpower * 0.789f;
else if (spellId == FLAMESTRIKE)
fdamage += m_spellpower * 0.558f;
else if (spellId == PYROBLAST)
fdamage += m_spellpower * 1.988f;
else if (spellId == BLASTWAVE)
fdamage += m_spellpower * 1.256f; //guessed
else if (spellId == DRAGONBREATH)
fdamage += m_spellpower * 0.215f * 3.f;
else if (spellId == LIVING_BOMB_EXPLOSION)
fdamage += m_spellpower * 3.215f;
else if (spellId == FROSTBOLT)
fdamage += m_spellpower * 1.661f;
else if (spellId == FROSTNOVA)
fdamage += m_spellpower * 0.188f;
else if (spellId == CONEOFCOLD)
fdamage += m_spellpower * 0.318f;
else if (spellId == BLIZZARD_DAMAGE)
fdamage += m_spellpower * 0.367f;
}
damage = int32(fdamage * (1.0f + pctbonus));
}
示例12: KilledUnit
void KilledUnit(Unit* Victim)
{
if (roll_chance_f(30.0f))
DoPlaySoundToSet(m_creature, RAND(SOUND_SLAY1, SOUND_SLAY2));
}
示例13: GetPlayer
void WorldSession::DoLootRelease(uint64 lguid)
{
Player *player = GetPlayer();
Loot *loot;
player->SetLootGUID(0);
player->SendLootRelease(lguid);
player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING);
if (!player->IsInWorld())
return;
if (IS_GAMEOBJECT_GUID(lguid))
{
GameObject *go = GetPlayer()->GetMap()->GetGameObject(lguid);
// not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
if (!go || ((go->GetOwnerGUID() != _player->GetGUID() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE)))
return;
loot = &go->loot;
if (go->GetGoType() == GAMEOBJECT_TYPE_DOOR)
{
// locked doors are opened with spelleffect openlock, prevent remove its as looted
go->UseDoorOrButton();
}
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->requiredminingskill;
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(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)
{ // The fishing hole used once more
go->AddUse(); // if the max usage is reached, will be despawned in next tick
if (go->GetUseCount() >= irand(go->GetGOInfo()->fishinghole.minSuccessOpens,go->GetGOInfo()->fishinghole.maxSuccessOpens))
{
go->SetLootState(GO_JUST_DEACTIVATED);
}
else
go->SetLootState(GO_READY);
}
else // not chest (or vein/herb/etc)
go->SetLootState(GO_JUST_DEACTIVATED);
loot->clear();
}
else
// not fully looted object
go->SetLootState(GO_ACTIVATED);
}
else if (IS_CORPSE_GUID(lguid)) // ONLY remove insignia at BG
{
Corpse *corpse = ObjectAccessor::GetCorpse(*player, lguid);
if (!corpse || !corpse->IsWithinDistInMap(_player,INTERACTION_DISTANCE))
return;
loot = &corpse->loot;
//.........这里部分代码省略.........
示例14: KilledUnit
void KilledUnit(Unit* victim)
{
if (roll_chance_f(20.0f))
DoScriptText(RAND(SAY_SLAY_1, SAY_SLAY_2, SAY_SLAY_3, SAY_SLAY_4, SAY_SLAY_5, SAY_SLAY_6), me);
}
示例15: GetPlayer
void WorldSession::DoLootRelease(ObjectGuid lguid)
{
Player *player = GetPlayer();
Loot *loot;
player->SetLootGUID(ObjectGuid());
player->SendLootRelease(lguid);
player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING);
if(!player->IsInWorld())
return;
switch(lguid.GetHigh())
{
case HIGHGUID_GAMEOBJECT:
{
GameObject *go = GetPlayer()->GetMap()->GetGameObject(lguid);
// not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
if (!go || ((go->GetOwnerGUID() != _player->GetGUID() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE)))
return;
loot = &go->loot;
if (go->GetGoType() == GAMEOBJECT_TYPE_DOOR)
{
// locked doors are opened with spelleffect openlock, prevent remove its as looted
go->UseDoorOrButton();
}
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;
if (player->GetInstanceId())
{
Map *map = go->GetMap();
if (map->IsDungeon())
{
if (map->IsRaidOrHeroicDungeon())
{
((InstanceMap *)map)->PermBindAllPlayers(player);
}
else
{
// the reset time is set but not added to the scheduler
// until the players leave the instance
time_t resettime = go->GetRespawnTimeEx() + 2 * HOUR;
if(InstanceSave *save = player->GetMap()->GetInstanceSave())
if(save->GetResetTime() < resettime) save->SetResetTime(resettime);
}
}
}
// only vein pass this check
if(go_min != 0 && go_max > go_min)
{
float amount_rate = sWorld.getConfig(CONFIG_FLOAT_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.getConfig(CONFIG_FLOAT_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.0f*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)
{ // The fishing hole used once more
go->AddUse(); // if the max usage is reached, will be despawned at next tick
if (go->GetUseCount() >= urand(go->GetGOInfo()->fishinghole.minSuccessOpens,go->GetGOInfo()->fishinghole.maxSuccessOpens))
{
//.........这里部分代码省略.........