5 Crossfire.SetReturnValue( 1 )
7 whoami=Crossfire.WhoAmI()
8 who = Crossfire.WhoIsActivator()
12 help +=
'Usage: say <test name>\nAvailable tests:\n'
13 help +=
' - arch: archetypes-related tests\n'
14 help +=
' - maps: maps-related tests\n'
15 help +=
' - party: party-related tests\n'
16 help +=
' - region: party-related tests\n'
17 help +=
' - ref: some checks on objects references\n'
18 help +=
' - mark: marked item\n'
19 help +=
' - memory: storage-related tests\n'
20 help +=
' - time: time of day tests\n'
21 help +=
' - timer: timer activation test\n'
22 help +=
' - timer_kill: kill specified timer\n'
23 help +=
' - misc: other tests\n'
25 help +=
' - const: constants and such\n'
28 help +=
' - readkey\n'
29 help +=
' - writekey\n'
32 help +=
' - friendlylist\n'
34 help +=
' - directory\n'
37 help +=
' - attacktype\n'
38 help +=
' - players\n'
39 help +=
' - checkinv\n'
43 help +=
' - checkinventory\n'
45 help +=
' - move_to\n'
46 help +=
' - attr: object-attribute tests'
51 archs = Crossfire.GetArchetypes()
52 whoami.Say(
'%d archetypes'%len(archs))
53 which = random.randint(0,len(archs))
55 whoami.Say(
'random = %s'%arch.Name)
65 whoami.Say(
' head = %s, more = %s, clone = %s, next = %s'%(head, more, arch.Clone.Name, next))
68 whoami.Say(
'your archetype is %s'%arch.Name)
71 whoami.Say(
'Current map is %s'%who.Map.Name)
72 maps = Crossfire.GetMaps()
73 whoami.Say(
'%d maps loaded:'%len(maps))
76 list +=
'%s [%d] -> %d players\n'%(map.Name, map.Unique, map.Players)
79 whoami.Say(
'this map is %s, size %d, %d'%(whoami.Map.Name, whoami.Map.Width, whoami.Map.Height))
84 ready = Crossfire.ReadyMap(topic[1], flag)
86 whoami.Say(
'ok, loaded %d map %s'%(flag,ready.Name))
88 whoami.Say(
'can\'t load %d map %s'%(flag,topic[1]))
91 parties = Crossfire.GetParties()
92 whoami.Say(
'%d parties'%len(parties))
94 whoami.Say(
'%s (%s)'%(party.Name, party.Password))
95 players = party.GetPlayers()
96 for player
in players:
97 whoami.Say(
' %s'%player.Name)
99 who.Party = parties[1]
100 whoami.Say(
'changed your party!')
103 msg =
'Known regions, region for current map is signaled by ***\n'
104 cur = whoami.Map.Region
105 msg +=
'This map\'s region is %s (msg: %s)\n'%(cur.Name, cur.Message)
106 regions = Crossfire.GetRegions()
107 msg += (
'%d regions\n'%len(regions))
108 for region
in regions:
110 msg += (
'*** %s - %s\n'%(region.Name,region.Longname))
112 msg += (
'%s - %s\n'%(region.Name,region.Longname))
113 parent = cur.GetParent()
115 msg += (
'Parent is %s\n'%parent.Name)
117 msg += (
'Region without parent\n')
119 msg +=
"Jail: %s (%d,%d)"%(cur.JailPath, cur.JailX, cur.JailY)
124 who2 = Crossfire.WhoIsOther()
125 who3 = Crossfire.WhoAmI()
129 whoami.Say(
'let\'s hope no reference crash!')
134 whoami.Say(
' your marked item is: %s'%obj.Name)
137 whoami.Say(
' no marked item')
139 while (mark)
and (mark.Invisible):
141 who.MarkedItem = mark
142 whoami.Say(
'Changed marked item!')
145 whoami.Say(
'Value save test')
146 dict = Crossfire.GetPrivateDictionary()
149 whoami.Say(
' x was %d'%x)
159 whoami.Say(
'Resistance test')
161 whoami.Say(
' %d -> %d'%(r,who.GetResist(r)))
165 msg +=
' your type is %d\n'%who.Type
166 msg +=
' your race is %s\n'%who.Race
167 msg +=
' your level is %d\n'%who.Level
168 msg +=
' your nrof is %d\n'%who.Quantity
169 msg +=
' your weight is %d\n'%who.Weight
170 msg +=
' your name is %s\n'%who.Name
171 msg +=
' your archname is %s\n'%who.ArchName
172 msg +=
' your title is %s\n'%who.Title
173 msg +=
' your ip is %s\n'%who.IP
174 msg +=
' my name is %s\n'%whoami.Name
175 msg +=
' your permanent exp is %d\n' % who.PermExp()
179 cftime = Crossfire.GetTime()
180 whoami.Say(
'Year: %d'%cftime[0])
181 whoami.Say(
'Month: %d'%cftime[1])
182 whoami.Say(
'Day: %d'%cftime[2])
183 whoami.Say(
'Hour: %d'%cftime[3])
184 whoami.Say(
'Minute: %d'%cftime[4])
185 whoami.Say(
'Day of week: %d'%cftime[5])
186 whoami.Say(
'Week of year: %d'%cftime[6])
187 whoami.Say(
'Season: %d'%cftime[7])
190 id = whoami.CreateTimer(3,1)
192 whoami.Say(
'The countdown started with a 3 second delay, timerid = %d'%id)
194 whoami.Say(
'Timer failure: %d'%id)
197 if ( len(topic) < 2 ):
198 whoami.Say(
'Kill which timer?')
200 timer =
int(topic[1])
201 res = Crossfire.DestroyTimer(timer)
202 whoami.Say(
'Timer %d removed with code %d'%(timer,res))
205 inv = whoami.Inventory
207 whoami.Say(
"First inv = %s"%inv.Name)
208 whoami.Say(
"Inv.Env = %s"%inv.Env.Name)
210 whoami.Say(
"Empty inv??")
213 map = Crossfire.MapHasBeenLoaded(topic[1])
215 whoami.Say(
'map %s is loaded, size = %d, %d'%(map.Name, map.Width, map.Height))
217 whoami.Say(
'map %s is not loaded'%topic[1])
220 whoami.Say(
'You have:')
223 whoami.Say(
'%s (type = %d, subtype = %d)'%(inv.Name, inv.Type, inv.Subtype))
227 if ( len(topic) < 2 ):
228 whoami.Say(
"Your exp is %d, perm is %d, mult is %d"%(who.Exp, who.PermExp, who.ExpMul))
229 whoami.Say(
"Syntax is: exp <value> [option] [skill]")
231 value =
int(topic[1])
234 if ( len(topic) > 2 ):
236 if ( len(topic) > 3):
238 while ( i < len(topic) ):
239 skill = skill + topic[i] +
' '
241 skill = skill.rstrip()
242 who.AddExp(value, skill, arg)
243 whoami.Say(
"ok, added %d exp to %s"%(value,skill))
247 ret +=
"%s => %d\n"%(Crossfire.DirectionName[Crossfire.Direction.NORTH],Crossfire.Direction.NORTH)
248 ret +=
"Player type => %d\n"%Crossfire.Type.PLAYER
249 ret +=
"Move Fly High => %d\n"%Crossfire.Move.FLY_HIGH
250 ret +=
"MessageFlag NDI_BLUE => %d\n"%Crossfire.MessageFlag.NDI_BLUE
251 ret +=
"CostFlag F_NO_BARGAIN => %d\n"%Crossfire.CostFlag.NOBARGAIN
252 ret +=
"AttackMovement PETMOVE => %d\n"%Crossfire.AttackMovement.PETMOVE
258 Crossfire.Move.FLY_LOW,
259 Crossfire.Move.FLY_HIGH,
260 Crossfire.Move.FLYING,
262 Crossfire.Move.BOAT ]
266 s = s +
' ' + Crossfire.MoveName[t]
270 whoami.Say(
dump_move(
"movetype", who.MoveType))
273 whoami.Say(
"bed = %s at (%d, %d)"%(who.BedMap, who.BedX, who.BedY))
274 whoami.Say(
"changing to +1 -1")
275 who.BedX = who.BedX + 1
276 who.BedY = who.BedY - 1
277 whoami.Say(
"bed = %s at (%d, %d)"%(who.BedMap, who.BedX, who.BedY))
278 whoami.Say(
"resetting.")
279 who.BedX = who.BedX - 1
280 who.BedY = who.BedY + 1
284 whoami.Say(
'read what key?')
286 whoami.Say(
'key %s = %s'%(topic[1], who.ReadKey(topic[1])))
290 whoami.Say(
'syntax is writekey key add_update [value]')
296 whoami.Say(
'writekey returned %d'%who.WriteKey(topic[1], val,
int(topic[2])))
299 whoami.Say(
'Your speed is %f and your speed_left %f'%(who.Speed, who.SpeedLeft))
302 whoami.Say(
'Changed your speed, now %f and %f'%(who.Speed, who.SpeedLeft))
305 whoami.Say(
'Not implemented.')
308 friends = Crossfire.GetFriendlyList()
314 whoami.Say(
' - %s (%s)'%(ob.Name, n))
317 first = Crossfire.CreateObjectByName(
'gem')
319 whoami.Say(
'created gem: %s'%first.Name)
320 first.Teleport(whoami.Map, 2, 2)
321 second = Crossfire.CreateObjectByName(
'diamond')
323 whoami.Say(
'created diamond: %s'%second.Name)
324 second.Teleport(whoami.Map, 2, 2)
327 whoami.Say(
'map = %s'%Crossfire.MapDirectory())
328 whoami.Say(
'unique = %s'%Crossfire.UniqueDirectory())
329 whoami.Say(
'temp = %s'%Crossfire.TempDirectory())
330 whoami.Say(
'config = %s'%Crossfire.ConfigDirectory())
331 whoami.Say(
'local = %s'%Crossfire.LocalDirectory())
332 whoami.Say(
'player = %s'%Crossfire.PlayerDirectory())
333 whoami.Say(
'data = %s'%Crossfire.DataDirectory())
334 whoami.Say(
'scriptname = %s'%Crossfire.ScriptName())
337 whoami.Say(
'event title = %s' %Crossfire.WhatIsEvent().Title)
338 whoami.Say(
'event slaying = %s' %Crossfire.WhatIsEvent().Slaying)
339 whoami.Say(
'event msg = %s' %Crossfire.WhatIsEvent().Message)
342 whoami.Say(
'current light: %d'%whoami.Map.Light)
345 whoami.Map.ChangeLight(chg)
346 whoami.Say(
'new light: %d'%whoami.Map.Light)
349 att = [ Crossfire.AttackType.FIRE, Crossfire.AttackType.COLD, Crossfire.AttackType.ELECTRICITY ]
350 whoami.Say(
'Your attacktype are:')
352 if ( at & Crossfire.WhoIsActivator().AttackType == at):
353 whoami.Say(Crossfire.AttackTypeName[ at ])
356 players = Crossfire.GetPlayers()
357 whoami.Say(
'Players logged in:')
359 whoami.Say(
' - %s'%pl.Name)
366 find = who.CheckInventory(what)
368 whoami.Say(
'Found %s in your inventory.'%find.Name)
370 whoami.Say(
'Can\'t find %s in your inventory.'%what)
373 obj = whoami.Map.ObjectAt(4, 4)
375 whoami.Say(
'Face is %s'%obj.Face)
382 whoami.Say(
'Face changed to %s'%face)
384 whoami.Say(
'Invalid face %s'%face)
387 obj = whoami.Map.ObjectAt(4, 4).Above
389 whoami.Say(
'Animation is %s'%obj.Anim)
395 whoami.Say(
'Animation changed to %s'%anim)
397 whoami.Say(
'Invalid animation %s'%anim)
400 item = whoami.Map.CreateObject(
'food', 0, 0)
401 whoami.Say(
'Created item.')
402 item2 = whoami.Map.ObjectAt(0, 0)
406 whoami.Say(
'Not the same items!')
408 whoami.Say(
'Trying to access removed item, exception coming')
411 whoami.Say(
'No exception! Error!')
413 whoami.Say(
'Exception came, ok')
417 whoami.Say(
'use: checkinventory <item''s name>')
420 what =
' '.join(topic[1:])
421 item = who.CheckInventory(what)
423 whoami.Say(
'found item: ' + item.Name)
425 whoami.Say(
'did not find anything matching ' + what)
428 item = whoami.Map.CreateObject(
'food', 2, 1)
430 whoami.Say(
'no_save set, the food should not be saved')
433 if whoami.X == 2
and whoami.Y == 2:
434 whoami.WriteKey(
'dest_x',
'0', 1)
435 whoami.WriteKey(
'dest_y',
'4', 1)
437 whoami.WriteKey(
'dest_x',
'2', 1)
438 whoami.WriteKey(
'dest_y',
'2', 1)
442 whoami.Say(
'Usage: attr name [value], if value is omitted display the value')
446 val = getattr(whoami, topic[1])
448 whoami.Say(
'my %s is %s'%(topic[1],
str(val)))
452 setattr(whoami, topic[1], topic[2])
455 setattr(whoami, topic[1],
int(topic[2]))
458 setattr(whoami, topic[1], float(topic[2]))
460 whoami.Say(
"sorry, I don't know how to set this attribute...")
463 if whoami.ReadKey(
'dest_x') !=
'' or whoami.ReadKey(
'dest_y') !=
'':
466 topic = Crossfire.WhatIsMessage().
split()
469 if topic[0] ==
'arch':
471 elif topic[0] ==
'maps':
473 elif topic[0] ==
'party':
475 elif topic[0] ==
'region':
477 elif topic[0] ==
'mark':
479 elif topic[0] ==
'ref':
481 elif topic[0] ==
'memory':
483 elif topic[0] ==
'resist':
485 elif topic[0] ==
'basics':
487 elif topic[0] ==
'time':
489 elif topic[0] ==
'timer':
491 elif topic[0] ==
'timer_kill':
493 elif topic[0] ==
'misc':
495 elif topic[0] ==
'exp':
497 elif topic[0] ==
'const':
499 elif topic[0] ==
'move':
501 elif topic[0] ==
'inv':
503 elif topic[0] ==
'bed':
505 elif topic[0] ==
'readkey':
507 elif topic[0] ==
'writekey':
509 elif topic[0] ==
'speed':
511 elif topic[0] ==
'owner':
513 elif topic[0] ==
'friendlylist':
515 elif topic[0] ==
'create':
517 elif topic[0] ==
'directory':
519 elif topic[0] ==
'event':
521 elif topic[0] ==
'light':
523 elif topic[0] ==
'attacktype':
525 elif topic[0] ==
'players':
527 elif topic[0] ==
'checkinv':
529 elif topic[0] ==
'anim':
531 elif topic[0] ==
'face':
533 elif topic[0] ==
'hook':
535 elif topic[0] ==
'checkinventory':
537 elif topic[0] ==
'nosave':
539 elif topic[0] ==
'move_to':
541 elif topic[0] ==
'attr':
547 x = whoami.ReadKey(
'dest_x')
548 y = whoami.ReadKey(
'dest_y')
549 if x ==
'' or y ==
'':
553 result = whoami.MoveTo(x, y)
555 whoami.WriteKey(
'dest_x',
'', 1)
556 whoami.WriteKey(
'dest_y',
'', 1)
557 whoami.Say(
"I'm there")
559 whoami.Say(
'blocked...')
561 event = Crossfire.WhatIsEvent()
562 if event.Subtype == Crossfire.EventType.SAY:
563 topic = Crossfire.WhatIsMessage().
split()
565 elif event.Subtype == Crossfire.EventType.TIME: