void Door::TryBashLock(Actor *actor) { //Get the strength bonus against lock difficulty int bonus; if (core->HasFeature(GF_3ED_RULES)) { bonus = actor->GetAbilityBonus(IE_STR); } else { int str = actor->GetStat(IE_STR); int strEx = actor->GetStat(IE_STREXTRA); bonus = core->GetStrengthBonus(2, str, strEx); //BEND_BARS_LIFT_GATES } unsigned int roll = actor->LuckyRoll(1, 10, bonus, 0); actor->FaceTarget(this); if (core->HasFeature(GF_3ED_RULES)) { // ~Bash door check. Roll %d + %d Str mod > %d door DC.~ displaymsg->DisplayRollStringName(20460, DMC_LIGHTGREY, actor, roll, bonus, LockDifficulty); } if(roll < LockDifficulty || LockDifficulty == 100) { displaymsg->DisplayConstantStringName(STR_DOORBASH_FAIL, DMC_BG2XPGREEN, actor); return; } displaymsg->DisplayConstantStringName(STR_DOORBASH_DONE, DMC_LIGHTGREY, actor); SetDoorLocked(false, true); core->GetGameControl()->ResetTargetMode(); Flags|=DOOR_BROKEN; //This is ok, bashdoor also sends the unlocked trigger AddTrigger(TriggerEntry(trigger_unlocked, actor->GetGlobalID())); ImmediateEvent(); }
void Highlightable::TryDisarm(Actor *actor) { if (!Trapped || !TrapDetected) return; int skill = actor->GetStat(IE_TRAPS); int roll = 0; int bonus = 0; int trapDC = TrapRemovalDiff; if (core->HasFeature(GF_3ED_RULES)) { skill = actor->GetSkill(IE_TRAPS); roll = core->Roll(1, 20, 0); bonus = actor->GetAbilityBonus(IE_INT); trapDC = TrapRemovalDiff/7 + 10; // oddity from the original if (skill == 0) { // a trained skill trapDC = 100; } } else { roll = core->Roll(1, skill/2, 0); skill /= 2; } int check = skill + roll + bonus; if (check > trapDC) { AddTrigger(TriggerEntry(trigger_disarmed, actor->GetGlobalID())); //trap removed Trapped = 0; if (core->HasFeature(GF_3ED_RULES)) { // ~Successful Disarm Device - d20 roll %d + Disarm Device skill %d + INT mod %d >= Trap DC %d~ displaymsg->DisplayRollStringName(39266, DMC_LIGHTGREY, actor, roll, skill-bonus, bonus, trapDC); } displaymsg->DisplayConstantStringName(STR_DISARM_DONE, DMC_LIGHTGREY, actor); int xp = actor->CalculateExperience(XP_DISARM, actor->GetXPLevel(1)); Game *game = core->GetGame(); game->ShareXP(xp, SX_DIVIDE); core->GetGameControl()->ResetTargetMode(); core->PlaySound(DS_DISARMED); } else { if (core->HasFeature(GF_3ED_RULES)) { // ~Failed Disarm Device - d20 roll %d + Disarm Device skill %d + INT mod %d >= Trap DC %d~ displaymsg->DisplayRollStringName(39266, DMC_LIGHTGREY, actor, roll, skill-bonus, bonus, trapDC); } displaymsg->DisplayConstantStringName(STR_DISARM_FAIL, DMC_LIGHTGREY, actor); TriggerTrap(skill, actor->GetGlobalID()); } ImmediateEvent(); }
void Door::TryBashLock(Actor *actor) { //Get the strength bonus agains lock difficulty int str = actor->GetStat(IE_STR); int strEx = actor->GetStat(IE_STREXTRA); unsigned int bonus = core->GetStrengthBonus(2, str, strEx); //BEND_BARS_LIFT_GATES unsigned int roll = actor->LuckyRoll(1, 10, bonus, 0); if(roll < LockDifficulty || LockDifficulty == 100) { displaymsg->DisplayConstantStringName(STR_DOORBASH_FAIL, DMC_BG2XPGREEN, actor); return; } displaymsg->DisplayConstantStringName(STR_DOORBASH_DONE, DMC_LIGHTGREY, actor); SetDoorLocked(false, true); //Is this really useful ? AddTrigger(TriggerEntry(trigger_unlocked, actor->GetGlobalID())); ImmediateEvent(); }
void Highlightable::TryDisarm(Actor *actor) { if (!Trapped || !TrapDetected) return; int skill = actor->GetStat(IE_TRAPS); if (skill/2+core->Roll(1,skill/2,0)>TrapRemovalDiff) { AddTrigger(TriggerEntry(trigger_disarmed, actor->GetGlobalID())); //trap removed Trapped = 0; displaymsg->DisplayConstantStringName(STR_DISARM_DONE, DMC_LIGHTGREY, actor); int xp = actor->CalculateExperience(XP_DISARM, actor->GetXPLevel(1)); Game *game = core->GetGame(); game->ShareXP(xp, SX_DIVIDE); } else { displaymsg->DisplayConstantStringName(STR_DISARM_FAIL, DMC_LIGHTGREY, actor); TriggerTrap(skill, actor->GetGlobalID()); } ImmediateEvent(); }
void Door::TryPickLock(Actor *actor) { if (LockDifficulty == 100) { if (OpenStrRef != (ieDword)-1) { displaymsg->DisplayStringName(OpenStrRef, DMC_BG2XPGREEN, actor, IE_STR_SOUND|IE_STR_SPEECH); } else { displaymsg->DisplayConstantStringName(STR_DOOR_NOPICK, DMC_BG2XPGREEN, actor); } return; } int stat = actor->GetStat(IE_LOCKPICKING); if (core->HasFeature(GF_3ED_RULES)) { int skill = actor->GetSkill(IE_LOCKPICKING); if (skill == 0) { // a trained skill, make sure we fail stat = 0; } else { stat *= 7; // convert to percent (magic 7 is from RE) int dexmod = actor->GetAbilityBonus(IE_DEX); stat += dexmod; // the original didn't use it, so let's not multiply it displaymsg->DisplayRollStringName(39301, DMC_LIGHTGREY, actor, stat-dexmod, LockDifficulty, dexmod); } } if (stat < (signed)LockDifficulty) { displaymsg->DisplayConstantStringName(STR_LOCKPICK_FAILED, DMC_BG2XPGREEN, actor); AddTrigger(TriggerEntry(trigger_picklockfailed, actor->GetGlobalID())); core->PlaySound(DS_PICKFAIL); return; } SetDoorLocked( false, true); core->GetGameControl()->ResetTargetMode(); displaymsg->DisplayConstantStringName(STR_LOCKPICK_DONE, DMC_LIGHTGREY, actor); AddTrigger(TriggerEntry(trigger_unlocked, actor->GetGlobalID())); core->PlaySound(DS_PICKLOCK); ImmediateEvent(); int xp = actor->CalculateExperience(XP_LOCKPICK, actor->GetXPLevel(1)); Game *game = core->GetGame(); game->ShareXP(xp, SX_DIVIDE); }
void Door::TryPickLock(Actor *actor) { core->PlaySound(DS_PICKLOCK); if (LockDifficulty == 100) { if (OpenStrRef != (ieDword)-1) { displaymsg->DisplayStringName(OpenStrRef, DMC_BG2XPGREEN, actor, IE_STR_SOUND|IE_STR_SPEECH); } else { displaymsg->DisplayConstantStringName(STR_DOOR_NOPICK, DMC_BG2XPGREEN, actor); } return; } if (actor->GetStat(IE_LOCKPICKING)<LockDifficulty) { displaymsg->DisplayConstantStringName(STR_LOCKPICK_FAILED, DMC_BG2XPGREEN, actor); AddTrigger(TriggerEntry(trigger_picklockfailed, actor->GetGlobalID())); return; } SetDoorLocked( false, true); displaymsg->DisplayConstantStringName(STR_LOCKPICK_DONE, DMC_LIGHTGREY, actor); AddTrigger(TriggerEntry(trigger_unlocked, actor->GetGlobalID())); ImmediateEvent(); int xp = actor->CalculateExperience(XP_LOCKPICK, actor->GetXPLevel(1)); Game *game = core->GetGame(); game->ShareXP(xp, SX_DIVIDE); }