39 '''Find the first item in the specified direction'''
45 ob = map.ObjectAt(x+1, y-1)
47 ob = map.ObjectAt(x+1, y)
49 ob = map.ObjectAt(x+1, y+1)
51 ob = map.ObjectAt(x, y+1)
53 ob = map.ObjectAt(x-1, y+1)
55 ob = map.ObjectAt(x-1, y)
57 ob = map.ObjectAt(x-1, y-1)
59 ob = map.ObjectAt(x, y-1)
63 '''Give properties from either the archetype or the other archetype.'''
64 if lock == who.Archetype.Clone.Alive:
67 arch = who.OtherArchetype
68 who.MoveType = arch.Clone.MoveType
69 who.MoveBlock = arch.Clone.MoveBlock
70 who.MoveAllow = arch.Clone.MoveAllow
71 who.Alive = arch.Clone.Alive
72 who.Name = arch.Clone.Name
73 who.Face = arch.Clone.Face
76 '''Check if the lock was picked, and inform the player if this is the case.'''
77 if door.ReadKey(
'door_picked') ==
'1':
78 who.Write(
'You notice some suspicious traces on the lock.')
79 door.WriteKey(
'door_picked',
'')
82 '''Handle applying a locking key.'''
83 Crossfire.SetReturnValue(1)
85 key = Crossfire.WhoAmI()
86 who = Crossfire.WhoIsActivator()
91 if door.ReadKey(
'lockable') ==
'1':
96 who.Write(
'There is no lock here')
100 if door.Slaying != key.Slaying:
101 who.Write(
"You can't use this %s on this %s"%(key.Name, door.Name))
103 who.Write(
'You unlock the %s'%(door.Name))
108 if key.Slaying ==
'' or key.Slaying ==
None or key.Slaying == door.Slaying:
109 if key.Slaying ==
'' or key.Slaying ==
None:
110 key.Slaying = door.Slaying
111 key.Name = key.Name +
" (used)"
112 who.Write(
'You lock the %s'%(door.Name))
116 who.Write(
"You can't use this %s on this %s"%(key.Name, door.Name))
119 '''Get how many attempts to pick a lock a player did'''
120 s = door.ReadKey(
'attempts_' + who.Name)
126 '''Return the chance of successfully picking the lock for the player'''
127 if door.ReadKey(
'was_picked_' + who.Name) !=
'':
130 diff = level - door.Level - attempts
132 return max(25, min(90, 50 + diff * 5))
135 '''Return the experience for lockpicking the door'''
136 if door.ReadKey(
'was_picked_' + who.Name) !=
'':
140 return round((door.Exp * (100. - min(100., attempts * 20.))) / 100.)
143 '''Handle lockpicking a door.'''
144 Crossfire.SetReturnValue(1)
146 door = Crossfire.WhoAmI()
147 who = Crossfire.WhoIsActivator()
153 who.Write(
"This %s is unlocked."%(door.Name))
158 if random.randint(0, 100) < 100 - chance:
159 door.WriteKey(
'door_picked',
'1', 1)
162 if random.randint(0, 100) < chance:
163 who.Write(
'You successfully pick the lock.')
165 who.AddExp(
get_exp(door, who), Crossfire.WhoIsOther().Name)
166 door.WriteKey(
'was_picked_' + who.Name,
'1', 1)
168 who.Write(
'You fail to pick the lock.')
169 door.WriteKey(
'attempts_' + who.Name,
str(
get_attempts(door, who) + 1), 1)
171 event = Crossfire.WhatIsEvent()
172 if event.Subtype == Crossfire.EventType.APPLY:
174 elif event.Subtype == Crossfire.EventType.TRIGGER: