Crossfire Server, Trunk
magic_whistle.py
Go to the documentation of this file.
1 import Crossfire
2 import random
3 
5  """
6  Look for pets (monsters owned by the player) who are not marked as friendly.
7  Then try to re-pet them with a 1 in 10 change to fail.
8 
9  Some pets miss their Friendly flag only, others also miss the IsPet property.
10  Others also have the wrong value for attack_movement which should be PETMOVE for pets.
11  """
12 
13  PETMOVE = Crossfire.AttackMovement.PETMOVE
14  player = Crossfire.WhoIsActivator()
15  if player.Type != Crossfire.Type.PLAYER:
16  return
17  Crossfire.SetReturnValue( 1 )
18 
19  fizzle = True
20 
21  #Can't do this check by looking at the FriendlyList because we are looking for
22  #those pets who are *not* in that list. So check for the monsters in the same map
23  #as the player, owned by it, and yet not friendly.
24  #Is there a better way than checking all _items_ in the map?
25  for w in range(player.X-5, player.X+5):
26  if w<1 or w>range(player.Map.Width):
27  continue
28  for h in range(player.Y-5, player.Y+5):
29  if h<1 or h>range(player.Map.Height):
30  continue
31  obj = player.Map.ObjectAt(w,h)
32  while obj != None:
33  if obj.Monster and obj.Owner == player and not obj.Friendly: #angry pet
34  fizzle = False
35  if random.randint(0,9): #tame
36  obj.Friendly = True
37  if not obj.IsPet:
38  obj.IsPet = True
39  if obj.AttackMovement != PETMOVE:
40  obj.AttackMovement = PETMOVE
41  player.Write( 'Your %s looks at you tenderly, fearless at your enemies.' % obj.Name )
42  else: #fail
43  player.Write( 'Your %s is still angry with you.' % obj.Name )
44  obj = obj.Above
45  if fizzle:
46  player.Write('Fzzzzzzzz...')
47 
magic_whistle.tame_angry_pets
def tame_angry_pets()
Definition: magic_whistle.py:4