本文整理汇总了C++中roll_chance_i函数的典型用法代码示例。如果您正苦于以下问题:C++ roll_chance_i函数的具体用法?C++ roll_chance_i怎么用?C++ roll_chance_i使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了roll_chance_i函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleImprovedFreeze
void HandleImprovedFreeze()
{
if (!_didHit)
return;
Unit* owner = GetCaster()->GetOwner();
if (!owner)
return;
if (AuraEffect* aurEff = owner->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_MAGE, ICON_MAGE_IMPROVED_FREEZE, EFFECT_0))
{
if (roll_chance_i(aurEff->GetAmount()))
owner->CastCustomSpell(SPELL_MAGE_FINGERS_OF_FROST, SPELLVALUE_AURA_STACK, 2, owner, true);
}
}
示例2: JustDied
void JustDied(Unit* killer) override
{
Player* player = killer->ToPlayer();
if (!player)
return;
if (roll_chance_i(20))
{
player->CastSpell(me, SPELL_SUMMON_FREED_MIST_WHISPER_SCOUT, true);
player->KilledMonsterCredit(NPC_MIST_WHISPER_SCOUT);
}
else
player->CastSpell(me, rivenWidowCocoonVictims[urand(0, 10)], true);
}
示例3: HandleImprovedFlamestrike
void HandleImprovedFlamestrike()
{
if (_targetCount >= 2)
if (AuraEffect* aurEff = GetCaster()->GetAuraEffect(SPELL_AURA_DUMMY, SPELLFAMILY_MAGE, ICON_MAGE_IMPROVED_FLAMESTRIKE, EFFECT_0))
if (roll_chance_i(aurEff->GetAmount()))
{
float x, y, z;
WorldLocation const* loc = GetExplTargetDest();
if (!loc)
return;
loc->GetPosition(x, y, z);
GetCaster()->CastSpell(x, y, z, SPELL_MAGE_FLAMESTRIKE, true);
}
}
示例4: Absorb
void Absorb(AuraEffect* aurEff, DamageInfo & dmgInfo, uint32 & absorbAmount)
{
Unit* target = GetTarget();
if (AuraEffect* talentAurEff = target->GetAuraEffectOfRankedSpell(SPELL_MAGE_FROST_WARDING_R1, EFFECT_0))
{
int32 chance = talentAurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue();
if (roll_chance_i(chance))
{
absorbAmount = dmgInfo.GetDamage();
int32 bp = absorbAmount;
target->CastCustomSpell(target, SPELL_MAGE_FROST_WARDING_TRIGGERED, &bp, NULL, NULL, true, NULL, aurEff);
}
}
}
示例5: HandleOnHit
void HandleOnHit()
{
// Fix Sword and Board
if (Player* _player = GetCaster()->ToPlayer())
{
if (Unit* target = GetHitUnit())
{
if (roll_chance_i(30))
{
_player->CastSpell(_player, WARRIOR_SPELL_SWORD_AND_BOARD, true);
_player->RemoveSpellCooldown(WARRIOR_SPELL_SHIELD_SLAM, true);
}
}
}
}
示例6: GossipHello_go_ulduar_teleporter
bool GossipHello_go_ulduar_teleporter(Player* pPlayer, GameObject* pGo)
{
instance_ulduar* pInstance = (instance_ulduar*)pGo->GetInstanceData();
if (!pInstance)
return true;
if (roll_chance_i(10))
DoOrSimulateScriptTextForMap(-1603430, 1000103, pGo->GetMap());
// Base camp
pPlayer->ADD_GOSSIP_ITEM_ID(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TELE_BASE_CAMP, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF);
// Formation grounds
if (pInstance->GetData(TYPE_LEVIATHAN) != NOT_STARTED || pPlayer->isGameMaster())
pPlayer->ADD_GOSSIP_ITEM_ID(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TELE_FORMATION_GROUNDS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
// Colossal Forge
if (pInstance->GetData(TYPE_LEVIATHAN) == DONE || pPlayer->isGameMaster())
pPlayer->ADD_GOSSIP_ITEM_ID(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TELE_COLOSSAL_FORGE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
// Scrapyard
if ((pInstance->GetData(TYPE_IGNIS) == DONE && pInstance->GetData(TYPE_RAZORSCALE) == DONE && pInstance->GetData(TYPE_XT002) != NOT_STARTED) || pPlayer->isGameMaster())
pPlayer->ADD_GOSSIP_ITEM_ID(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TELE_SCRAPYARD, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
// Antechamber
if (pInstance->GetData(TYPE_XT002) == DONE || pPlayer->isGameMaster())
pPlayer->ADD_GOSSIP_ITEM_ID(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TELE_ANTECHAMBER, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
// Shattered walkway
if (pInstance->GetData(TYPE_KOLOGARN) == DONE || pPlayer->isGameMaster())
pPlayer->ADD_GOSSIP_ITEM_ID(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TELE_WALKWAY, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
// Conservatory of life
if (pInstance->GetData(TYPE_AURIAYA) == DONE || pPlayer->isGameMaster())
pPlayer->ADD_GOSSIP_ITEM_ID(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TELE_CONSERVATORY, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6);
// Spark of imagination
if (pInstance->GetData(TYPE_MIMIRON) != NOT_STARTED || pPlayer->isGameMaster())
pPlayer->ADD_GOSSIP_ITEM_ID(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TELE_SPARK_IMAGINATION, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7);
// Prison of Yogg-Saron
if (pInstance->GetData(TYPE_VEZAX) == DONE || pPlayer->isGameMaster())
pPlayer->ADD_GOSSIP_ITEM_ID(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TELE_YOGG_SARON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8);
pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pGo->GetGOInfo()->GetGossipMenuId()), pGo->GetGUID());
return true;
}
示例7: UpdateAI
void UpdateAI(const uint32 uiDiff) override
{
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
return;
// Cleave
if (m_uiCleaveTimer <= uiDiff)
{
if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_SHADOW_CLEAVE) == CAST_OK)
m_uiCleaveTimer = urand(4000, 8000);
}
else
m_uiCleaveTimer -= uiDiff;
// Necrotic Strike
if (m_uiNecroticStrikeTimer <= uiDiff)
{
if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_NECROTIC_STRIKE) == CAST_OK)
m_uiNecroticStrikeTimer = urand(5000, 10000);
}
else
m_uiNecroticStrikeTimer -= uiDiff;
// random transformation
if (m_uiTransformationTimer <= uiDiff)
{
if (roll_chance_i(50))
{
if (DoCastSpellIfCan(m_creature, SPELL_DARK_TRANSFORMATION) == CAST_OK)
{
m_creature->SetSpeedRate(MOVE_RUN, 0.5f);
m_uiTransformationTimer = HOUR * IN_MILLISECONDS;
}
}
else
{
if (DoCastSpellIfCan(m_creature, SPELL_DARK_MARTYRDOM) == CAST_OK)
{
DoCastSpellIfCan(m_creature, SPELL_FANATICS_DETERMINATION, CAST_TRIGGERED);
m_uiTransformationTimer = HOUR * IN_MILLISECONDS;
}
}
}
else
m_uiTransformationTimer -= uiDiff;
DoMeleeAttackIfReady();
}
示例8: AttackedBy
void AttackedBy(Unit* pAttacker) override
{
if (!m_bIsFirstHit)
{
if (pAttacker->GetEntry() == NPC_MUTANUS)
DoScriptText(SAY_MUTANUS, m_creature, pAttacker);
// Check if already in ritual
else if (m_uiPoint >= 30)
DoScriptText(SAY_AGGRO_3, m_creature, pAttacker);
else
// Aggro 1 should be in 90% of the cases
DoScriptText(roll_chance_i(90) ? SAY_AGGRO_1 : SAY_AGGRO_2, m_creature, pAttacker);
m_bIsFirstHit = true;
}
}
示例9: UpdateAI
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
while (uint32 eventId = events.ExecuteEvent())
{
switch (eventId)
{
case EVENT_FROST_ATTACK:
DoCastVictim(SPELL_FROST_ATTACK, true);
events.ScheduleEvent(EVENT_FROST_ATTACK, urand(7000, 10000));
break;
case EVENT_ARCANE_BLAST:
DoCastVictim(SPELL_ARCANE_BLAST, true);
events.ScheduleEvent(EVENT_ARCANE_BLAST, 15000);
break;
case EVENT_DRAGONS_BREATH:
DoCastVictim(SPELL_DRAGONS_BREATH, true);
events.ScheduleEvent(EVENT_DRAGONS_BREATH, urand(12000, 22000));
if (roll_chance_i(50))
Talk(SAY_DRAGONS_BREATH);
break;
case EVENT_KNOCKBACK:
DoCastVictim(SPELL_KNOCKBACK, true);
events.ScheduleEvent(EVENT_KNOCKBACK, urand(15000, 25000));
break;
case EVENT_SOLARBURN:
DoCastVictim(SPELL_SOLARBURN, true);
events.ScheduleEvent(EVENT_SOLARBURN, 30000);
break;
default:
break;
}
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
}
DoMeleeAttackIfReady();
}
示例10: DoSummonMushrooms
void DoSummonMushrooms(bool bIsFirstSummon)
{
// This implementation may not be 100% accurate;
// On aggro boss summons about 20 mushrooms; On timer it summons about 5 mushrooms per turn
// There is a 33% chance that the mushroom will be healthy
// The summon position is based on the center of the area coords
float fX, fY, fZ;
uint32 uiMaxMushrooms = bIsFirstSummon ? 20 : 5;
for (uint8 i = 0; i < uiMaxMushrooms; ++i)
{
uint32 uiMushroomEntry = roll_chance_i(33) ? NPC_HEALTHY_MUSHROOM : NPC_POISONOUS_MUSHROOM;
m_creature->GetRandomPoint(aMushroomPos[0], aMushroomPos[1], aMushroomPos[2], 30.0f, fX, fY, fZ);
m_creature->SummonCreature(uiMushroomEntry, fX, fY, fZ, 0.0f, TEMPSUMMON_DEAD_DESPAWN, 0);
}
}
示例11: UpdateAI
void UpdateAI(uint32 diff)
{
if (!me->IsInCombat())
{
events2.Update(diff);
if (events2.ExecuteEvent() == EVENT_PHANTOM)
{
me->CastSpell(me, SPELL_SUMMON_PHANTOM, true);
events2.ScheduleEvent(EVENT_PHANTOM, urand(20000, 25000));
}
}
if (!UpdateVictim())
return;
events.Update(diff);
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
switch (events.ExecuteEvent())
{
case EVENT_GROUND_TREMOR:
if (roll_chance_i(50))
Talk(SAY_QUAKE);
me->CastSpell(me, me->GetDisplayId() != me->GetNativeDisplayId() ? SPELL_QUAKE : SPELL_GROUND_TREMOR, false);
events.ScheduleEvent(EVENT_GROUND_TREMOR, 10000);
break;
case EVENT_NUMBLING_SHOUT:
me->CastSpell(me, me->GetDisplayId() != me->GetNativeDisplayId() ? SPELL_NUMBING_ROAR : SPELL_NUMBING_SHOUT, false);
events.ScheduleEvent(EVENT_NUMBLING_SHOUT, 10000);
break;
case EVENT_DETERMINED_STAB:
me->CastSpell(me->GetVictim(), me->GetDisplayId() != me->GetNativeDisplayId() ? SPELL_DETERMINED_GORE : SPELL_DETERMINED_STAB, false);
events.ScheduleEvent(EVENT_DETERMINED_STAB, 8000);
break;
case EVENT_TRANSFORMATION:
Talk(EMOTE_TRANSFORM);
Talk(SAY_TRANSFORM);
me->CastSpell(me, SPELL_TRANSFORMATION, false);
me->CastSpell(me,SPELL_SUMMON_PHANTOM_TRANSFORM, true);
events.ScheduleEvent(EVENT_TRANSFORMATION, 10000);
break;
}
DoMeleeAttackIfReady();
}
示例12: HandleAfterHit
void HandleAfterHit()
{
Unit* target = GetHitUnit();
Unit* caster = GetCaster();
if (!caster || !target)
return;
// Remove Mind Spike debuff
target->RemoveAurasDueToSpell(87178, GetCaster()->GetGUID());
// Improved Mind blast - Mind Trauma cast
if (AuraEffect* improvedMindBlast = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, 95, EFFECT_1))
if (caster->GetShapeshiftForm() == FORM_SHADOW)
if (roll_chance_i(improvedMindBlast->GetAmount()))
caster->CastSpell(target, 48301, true);
}
示例13: Absorb
void Absorb(AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount)
{
Unit* target = GetTarget();
if (AuraEffect* talentAurEff = target->GetAuraEffectOfRankedSpell(SPELL_MAGE_FROST_WARDING_R1, EFFECT_0))
{
int32 chance = talentAurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue(); // SPELL_EFFECT_DUMMY with NO_TARGET
if (roll_chance_i(chance))
{
int32 bp = dmgInfo.GetDamage();
dmgInfo.AbsorbDamage(bp);
target->CastCustomSpell(target, SPELL_MAGE_FROST_WARDING_TRIGGERED, &bp, NULL, NULL, true, NULL, aurEff);
absorbAmount = 0;
PreventDefaultAction();
}
}
}
示例14: HandleCheckProc
bool HandleCheckProc(ProcEventInfo& eventInfo)
{
Unit const* const caster = GetCaster();
SpellInfo const* const triggerSpell = eventInfo.GetSpellInfo();
if (triggerSpell)
{
// Prevents proc by damage from the spell itself
if (triggerSpell->Id != GetId())
return true;
// Sanguinary Vein
if (AuraEffect const* const aurEff = caster->GetAuraEffectOfRankedSpell(SPELL_SANGUINARY_VEIN, EFFECT_1))
if (triggerSpell->GetAuraState() == AURA_STATE_BLEEDING && roll_chance_i(aurEff->GetAmount()))
return false;
}
return true;
}
示例15: ReceiveEmote
void ReceiveEmote(Player* player, uint32 emote)
{
if (following)
return;
if (player->HasAura(SPELL_WARTS))
return;
if ((player->GetQuestStatus(QUEST_1) == QUEST_STATUS_INCOMPLETE) ||
(player->GetQuestStatus(QUEST_2) == QUEST_STATUS_INCOMPLETE) ||
(player->GetQuestStatus(QUEST_3) == QUEST_STATUS_INCOMPLETE) ||
(player->GetQuestStatus(QUEST_4) == QUEST_STATUS_INCOMPLETE) ||
(player->GetQuestStatus(QUEST_5) == QUEST_STATUS_INCOMPLETE) ||
(player->GetQuestStatus(QUEST_6) == QUEST_STATUS_INCOMPLETE) ||
(player->GetQuestStatus(QUEST_7) == QUEST_STATUS_INCOMPLETE) ||
(player->GetQuestStatus(QUEST_8) == QUEST_STATUS_INCOMPLETE) ||
(player->GetQuestStatus(QUEST_9) == QUEST_STATUS_INCOMPLETE) ||
(player->GetQuestStatus(QUEST_10) == QUEST_STATUS_INCOMPLETE) ||
(player->GetQuestStatus(QUEST_11) == QUEST_STATUS_INCOMPLETE) ||
(player->GetQuestStatus(QUEST_12) == QUEST_STATUS_INCOMPLETE))
{
if (emote == TEXT_EMOTE_KISS && me->IsWithinDistInMap(player, 30.0f))
{
if (!player->HasAura(SPELL_WARTSBGONE_LIP_BALM))
player->AddAura(SPELL_WARTS, player);
else if (roll_chance_i(10))
{
if (Creature* maiden = player->SummonCreature(NPC_MAIDEN_OF_ASHWOOD_LAKE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 30000))
maiden->MonsterSay(SAY_FREED, LANG_UNIVERSAL, 0);
me->DisappearAndDie();
}
else
{
player->RemoveAura(SPELL_WARTSBGONE_LIP_BALM);
me->AddAura(SPELL_FROG_LOVE, me);
me->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
following = true;
}
}
}
}