lockpicking.src
Code: Select all
function PickLockedItem(who, tool, chest)
var lvl := CInt(GetObjProperty(chest,"lockable" ));
if (!lvl)
SendSysMessage(who,"That cannot be picked");
return;
endif
if (!chest.locked)
SendSysMessage(who,"That doesn't appear to be locked");
return;
endif
PlaySoundEffect(chest,SFX_LOCKPICK);
Sleepms(1500);
var diff := lvl + 10;
if ( SkillCheck(who, LOCKPICKING, diff) > 0 )
PlaySoundEffect(chest,SFX_UNLOCK);
chest.locked := 0;
else
SendSysMessage(who,"You fail to pick the lock.");
if (diff < 10)
diff := 0;
else
diff := diff -10;
endif
if ((RandomDiceRoll("1d99")+1) >= GetAttribute(who, LOCKPICKING))
PlaySoundEffect(chest,0xef);
SendSysMessage(who,"Your pick breaks!");
SubtractAmount(tool,1);
endif
return;
endif
endfunction
If we watch in the entire distro the property "Lockable" always was "1". I think that the correct code maybe
var lvl := CInt(GetObjProperty(chest,"LockPickDiff" ));
Besides this, I think that this implementation is not best. So i propose this way
Code: Select all
enum LOCK_TYPE
MAGIC_LOCK := 0x1,
KEY_LOCK := 0x2,
TREASURE_LOCK := 0x3
endenum
//For Carpentry & Tinkering
var lock := struct{ "type" := KEY_LOCK,
"level" := AP_GetSkill(who, TINKERING),
"lockid" := CreateLockID()};
SetObjProperty(theitem,"Lock", lock);
//For Magic Lock
var lock := struct{ "type" := MAGIC_LOCK,
"level" := AP_GetSkill(who, MAGERY)};
//For Treasures
var lock := struct{ "type" := TREASURE_LOCK,
"level" := ¿¿¿¿????};
SetObjProperty(theitem,"Lock", lock);
Code: Select all
function MakeKeyLock(theitem, craftskill )
var thekey := CreateItemInContainer(theitem, 0x100E, 1 );
thekey.SetLockId( CreateLockID() );
MakeLock(theitem, KEY_LOCK, level, thekey.GetLockId());
return thekey;
endfunction
function MakeMagicLock(theitem, mageryskill )
MakeLock(theitem, MAGIC_LOCK, level);
endfunction
function MakeTreasureLock(theitem, level)
MakeLock(theitem, TREASURE_LOCK, level);
endfunction
function MakeLock(theitem, type, level, lockid:=-1)
var lock := struct{ "type" := type,
"level" := level};
if( lockid >= 0)
lock.+lockid := lockid;
endif
SetObjProperty(theitem,"Lock", lock);
endfunction