Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SOMEWHERE IN FUNCTION: bool UseSkillOnLocker(Critter& cr, Item& locker, int skill)
- ...
- if(cr.Timeout[TO_SK_LOCKPICK] > 0)
- {
- cr.SayMsg(SAY_NETMSG, TEXTMSG_GAME, STR_SKILL_WEARINESS);
- return true;
- }
- if(locker.LockerId == 0 || FLAG(locker.LockerCondition, LOCKER_ISOPEN))
- {
- cr.SayMsg(SAY_NETMSG, TEXTMSG_GAME, STR_USE_NOTHING);
- return true;
- }
- int base = cr.Skill[SK_LOCKPICK] - locker.LockerComplexity;
- uint8 mode = 0;
- uint16 activePid = cr.GetSlotProto(SLOT_HAND1, mode).ProtoId;
- Item@ lockpicks = _CritGetItemHand(cr);
- // Replace starts here //
- if(valid(lockpicks) && lockpicks.Proto.Misc_ToolSkillNum == SK_LOCKPICK)
- {
- base += lockpicks.Proto.Misc_ToolSkillBonus;
- }
- // Todo: PID_ELECTRONIC_LOCKPICKS, PID_ELEC_LOCKPICK_MKII
- int timeout;
- int roll = Random(1, 100);
- // value of "base" is kept for timeout calculations
- int clampedBase = CLAMP(base, 0, 95);
- if(clampedBase >= roll)
- {
- int minTimeout = LOCKPICK_TIMEOUT(cr) / 4;
- int maxTimeout = LOCKPICK_TIMEOUT(cr) * 3 / 4;
- int factor = 50; // magic number, values around 50 are good in current setup, should be between an normal and an expanded lock pick set.
- // The formula below generates a fluid transition from min to max, depending on base (player skill, tools, lock complexity) and roll.
- timeout = CLAMP(minTimeout + ((maxTimeout - minTimeout) * (factor - base + roll) / factor), minTimeout, maxTimeout);
- if(locker.Proto.Container_Changeble && !LockerOpen(locker))
- Log("ERR: something wrong with this locker: " + locker.MapId + "," + locker.HexX + "," + locker.HexY + " pid " + locker.GetProtoId());
- locker.LockerId = 0;
- locker.LockerComplexity = 0;
- // TODO: OnOpen ??
- if(locker.GetType() == ITEM_TYPE_CONTAINER)
- cr.ShowContainer(null, locker, locker.Proto.GroundLevel ? TRANSFER_HEX_CONT_DOWN : TRANSFER_HEX_CONT_UP);
- cr.StatBase[ST_EXPERIENCE] += 50;
- LogExperience(cr, 50, SK_LOCKPICK, "Locker", locker.GetProtoId());
- AddScore(cr, SCORE_CRACKER, 1);
- }
- else
- {
- // Critical failure roll, if lock picks used, they will break.
- if (roll > 95)
- {
- if(valid(lockpicks) && lockpicks.Proto.Misc_ToolSkillNum == SK_LOCKPICK)
- {
- timeout = LOCKPICK_TIMEOUT(cr);
- cr.DeleteItem(lockpicks.GetProtoId(), 1);
- cr.Say(SAY_NETMSG, "Damn! You broke your lock picks!");
- }
- else
- {
- timeout = LOCKPICK_TIMEOUT(cr) * Random(2,5);
- cr.StatBase[ST_CURRENT_HP] -= Random(0, 5);
- cr.Say(SAY_NETMSG, "Ouch! You fingers hurt already!");
- }
- // failed critical "success", warn the player, that it will be very hard or impossible to open this lock.
- else if (roll <= 5)
- {
- timeout = LOCKPICK_TIMEOUT(cr);
- if (base <= 0)
- {
- cr.Say(SAY_NETMSG, "This lock seems impossible to pick!");
- }
- else
- {
- cr.Say(SAY_NETMSG, "Damn! You were so close!");
- }
- }
- // normal failure
- else
- {
- cr.SayMsg(SAY_NETMSG, TEXTMSG_GAME, STR_SKILL_LOCKPICK_FAIL);
- timeout = LOCKPICK_TIMEOUT(cr);
- }
- }
- _SetTimeout(cr, TO_SK_LOCKPICK, timeout);
- }
- // Replace ends here //
- else if(skill == SK_SCIENCE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement