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 Door::TryDetectSecret(int skill, ieDword actorID) { if (Type != ST_DOOR) return; if (Visible()) return; if (skill > (signed)DiscoveryDiff) { Flags |= DOOR_FOUND; core->PlaySound(DS_FOUNDSECRET); AddTrigger(TriggerEntry(trigger_detected, actorID)); } }
/* sends the hotkey trigger to all selected actors */ void Game::SetHotKey(unsigned long Key) { std::vector< Actor*>::const_iterator m; for ( m = selected.begin(); m != selected.end(); ++m) { Actor *actor = *m; if (actor->IsSelected()) { actor->AddTrigger(TriggerEntry(trigger_hotkey, (ieDword) Key)); } } }
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::SetDoorOpen(int Open, int playsound, ieDword ID) { if (playsound) { //the door cannot be blocked when opening, //but the actors will be pushed //BlockedOpen will mark actors to be pushed if (BlockedOpen(Open,0) && !Open) { //clear up the blocking actors area->JumpActors(false); return; } area->JumpActors(true); } if (Open) { if (Trapped) { AddTrigger(TriggerEntry(trigger_opened, ID)); } else { AddTrigger(TriggerEntry(trigger_harmlessopened, ID)); } // in PS:T, opening a door does not unlock it if (!core->HasFeature(GF_REVERSE_DOOR)) { SetDoorLocked(false,playsound); } } else { if (Trapped) { AddTrigger(TriggerEntry(trigger_closed, ID)); } else { AddTrigger(TriggerEntry(trigger_harmlessclosed, ID)); } } ToggleTiles(Open, playsound); //synchronising other data with the door state UpdateDoor(); area->ActivateWallgroups(open_wg_index, open_wg_count, Flags&DOOR_OPEN); area->ActivateWallgroups(closed_wg_index, closed_wg_count, !(Flags&DOOR_OPEN)); core->SetEventFlag(EF_TARGETMODE); }
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); }
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(); }
//trap that will fire now bool InfoPoint::TriggerTrap(int skill, ieDword ID) { if (Type!=ST_PROXIMITY) { return true; } if (Flags&TRAP_DEACTIVATED) { return false; } if (!Trapped) { // we have to set Entered somewhere, here seems best.. // FIXME: likely not best :) AddTrigger(TriggerEntry(trigger_harmlessentered, ID)); return true; } else if (Highlightable::TriggerTrap(skill, ID)) { return true; } return false; }
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(); }