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'
47 help +=
' - cjson: Python cjson tests'
52 archs = Crossfire.GetArchetypes()
53 whoami.Say(
'%d archetypes'%len(archs))
54 which = random.randint(0,len(archs))
56 whoami.Say(
'random = %s'%arch.Name)
66 whoami.Say(
' head = %s, more = %s, clone = %s, next = %s'%(head, more, arch.Clone.Name, next))
69 whoami.Say(
'your archetype is %s'%arch.Name)
72 whoami.Say(
'Current map is %s'%who.Map.Name)
73 maps = Crossfire.GetMaps()
74 whoami.Say(
'%d maps loaded:'%len(maps))
77 list +=
'%s [%d] -> %d players\n'%(map.Name, map.Unique, map.Players)
80 whoami.Say(
'this map is %s, size %d, %d'%(whoami.Map.Name, whoami.Map.Width, whoami.Map.Height))
85 ready = Crossfire.ReadyMap(topic[1], flag)
87 whoami.Say(
'ok, loaded %d map %s'%(flag,ready.Name))
89 whoami.Say(
'can\'t load %d map %s'%(flag,topic[1]))
92 parties = Crossfire.GetParties()
93 whoami.Say(
'%d parties'%len(parties))
95 whoami.Say(
'%s (%s)'%(party.Name, party.Password))
96 players = party.GetPlayers()
97 for player
in players:
98 whoami.Say(
' %s'%player.Name)
100 who.Party = parties[1]
101 whoami.Say(
'changed your party!')
104 msg =
'Known regions, region for current map is signaled by ***\n'
105 cur = whoami.Map.Region
106 msg +=
'This map\'s region is %s (msg: %s)\n'%(cur.Name, cur.Message)
107 regions = Crossfire.GetRegions()
108 msg += (
'%d regions\n'%len(regions))
109 for region
in regions:
111 msg += (
'*** %s - %s\n'%(region.Name,region.Longname))
113 msg += (
'%s - %s\n'%(region.Name,region.Longname))
114 parent = cur.GetParent()
116 msg += (
'Parent is %s\n'%parent.Name)
118 msg += (
'Region without parent\n')
120 msg +=
"Jail: %s (%d,%d)"%(cur.JailPath, cur.JailX, cur.JailY)
125 who2 = Crossfire.WhoIsOther()
126 who3 = Crossfire.WhoAmI()
130 whoami.Say(
'let\'s hope no reference crash!')
135 whoami.Say(
' your marked item is: %s'%obj.Name)
138 whoami.Say(
' no marked item')
140 while (mark)
and (mark.Invisible):
142 who.MarkedItem = mark
143 whoami.Say(
'Changed marked item!')
146 whoami.Say(
'Value save test')
147 dict = Crossfire.GetPrivateDictionary()
150 whoami.Say(
' x was %d'%x)
160 whoami.Say(
'Resistance test')
162 whoami.Say(
' %d -> %d'%(r,who.GetResist(r)))
166 msg +=
' your type is %d\n'%who.Type
167 msg +=
' your race is %s\n'%who.Race
168 msg +=
' your level is %d\n'%who.Level
169 msg +=
' your nrof is %d\n'%who.Quantity
170 msg +=
' your weight is %d\n'%who.Weight
171 msg +=
' your name is %s\n'%who.Name
172 msg +=
' your archname is %s\n'%who.ArchName
173 msg +=
' your title is %s\n'%who.Title
174 msg +=
' your ip is %s\n'%who.IP
175 msg +=
' my name is %s\n'%whoami.Name
176 msg +=
' your permanent exp is %d\n' % who.PermExp()
180 cftime = Crossfire.GetTime()
181 whoami.Say(
'Year: %d'%cftime[0])
182 whoami.Say(
'Month: %d'%cftime[1])
183 whoami.Say(
'Day: %d'%cftime[2])
184 whoami.Say(
'Hour: %d'%cftime[3])
185 whoami.Say(
'Minute: %d'%cftime[4])
186 whoami.Say(
'Day of week: %d'%cftime[5])
187 whoami.Say(
'Week of year: %d'%cftime[6])
188 whoami.Say(
'Season: %d'%cftime[7])
191 id = whoami.CreateTimer(3,1)
193 whoami.Say(
'The countdown started with a 3 second delay, timerid = %d'%id)
195 whoami.Say(
'Timer failure: %d'%id)
198 if ( len(topic) < 2 ):
199 whoami.Say(
'Kill which timer?')
201 timer =
int(topic[1])
202 res = Crossfire.DestroyTimer(timer)
203 whoami.Say(
'Timer %d removed with code %d'%(timer,res))
206 inv = whoami.Inventory
208 whoami.Say(
"First inv = %s"%inv.Name)
209 whoami.Say(
"Inv.Env = %s"%inv.Env.Name)
211 whoami.Say(
"Empty inv??")
214 map = Crossfire.MapHasBeenLoaded(topic[1])
216 whoami.Say(
'map %s is loaded, size = %d, %d'%(map.Name, map.Width, map.Height))
218 whoami.Say(
'map %s is not loaded'%topic[1])
221 whoami.Say(
'You have:')
224 whoami.Say(
'%s (type = %d, subtype = %d)'%(inv.Name, inv.Type, inv.Subtype))
228 if ( len(topic) < 2 ):
229 whoami.Say(
"Your exp is %d, perm is %d, mult is %d"%(who.Exp, who.PermExp, who.ExpMul))
230 whoami.Say(
"Syntax is: exp <value> [option] [skill]")
232 value =
int(topic[1])
235 if ( len(topic) > 2 ):
237 if ( len(topic) > 3):
239 while ( i < len(topic) ):
240 skill = skill + topic[i] +
' '
242 skill = skill.rstrip()
243 who.AddExp(value, skill, arg)
244 whoami.Say(
"ok, added %d exp to %s"%(value,skill))
248 ret +=
"%s => %d\n"%(Crossfire.DirectionName[Crossfire.Direction.NORTH],Crossfire.Direction.NORTH)
249 ret +=
"Player type => %d\n"%Crossfire.Type.PLAYER
250 ret +=
"Move Fly High => %d\n"%Crossfire.Move.FLY_HIGH
251 ret +=
"MessageFlag NDI_BLUE => %d\n"%Crossfire.MessageFlag.NDI_BLUE
252 ret +=
"CostFlag F_NO_BARGAIN => %d\n"%Crossfire.CostFlag.NOBARGAIN
253 ret +=
"AttackMovement PETMOVE => %d\n"%Crossfire.AttackMovement.PETMOVE
259 Crossfire.Move.FLY_LOW,
260 Crossfire.Move.FLY_HIGH,
261 Crossfire.Move.FLYING,
263 Crossfire.Move.BOAT ]
267 s = s +
' ' + Crossfire.MoveName[t]
271 whoami.Say(
dump_move(
"movetype", who.MoveType))
274 whoami.Say(
"bed = %s at (%d, %d)"%(who.BedMap, who.BedX, who.BedY))
275 whoami.Say(
"changing to +1 -1")
276 who.BedX = who.BedX + 1
277 who.BedY = who.BedY - 1
278 whoami.Say(
"bed = %s at (%d, %d)"%(who.BedMap, who.BedX, who.BedY))
279 whoami.Say(
"resetting.")
280 who.BedX = who.BedX - 1
281 who.BedY = who.BedY + 1
285 whoami.Say(
'read what key?')
287 whoami.Say(
'key %s = %s'%(topic[1], who.ReadKey(topic[1])))
291 whoami.Say(
'syntax is writekey key add_update [value]')
297 whoami.Say(
'writekey returned %d'%who.WriteKey(topic[1], val,
int(topic[2])))
300 whoami.Say(
'Your speed is %f and your speed_left %f'%(who.Speed, who.SpeedLeft))
303 whoami.Say(
'Changed your speed, now %f and %f'%(who.Speed, who.SpeedLeft))
306 whoami.Say(
'Not implemented.')
309 friends = Crossfire.GetFriendlyList()
315 whoami.Say(
' - %s (%s)'%(ob.Name, n))
318 first = Crossfire.CreateObjectByName(
'gem')
320 whoami.Say(
'created gem: %s'%first.Name)
321 first.Teleport(whoami.Map, 2, 2)
322 second = Crossfire.CreateObjectByName(
'diamond')
324 whoami.Say(
'created diamond: %s'%second.Name)
325 second.Teleport(whoami.Map, 2, 2)
328 whoami.Say(
'map = %s'%Crossfire.MapDirectory())
329 whoami.Say(
'unique = %s'%Crossfire.UniqueDirectory())
330 whoami.Say(
'temp = %s'%Crossfire.TempDirectory())
331 whoami.Say(
'config = %s'%Crossfire.ConfigDirectory())
332 whoami.Say(
'local = %s'%Crossfire.LocalDirectory())
333 whoami.Say(
'player = %s'%Crossfire.PlayerDirectory())
334 whoami.Say(
'data = %s'%Crossfire.DataDirectory())
335 whoami.Say(
'scriptname = %s'%Crossfire.ScriptName())
338 whoami.Say(
'event title = %s' %Crossfire.WhatIsEvent().Title)
339 whoami.Say(
'event slaying = %s' %Crossfire.WhatIsEvent().Slaying)
340 whoami.Say(
'event msg = %s' %Crossfire.WhatIsEvent().Message)
343 whoami.Say(
'current light: %d'%whoami.Map.Light)
346 whoami.Map.ChangeLight(chg)
347 whoami.Say(
'new light: %d'%whoami.Map.Light)
350 att = [ Crossfire.AttackType.FIRE, Crossfire.AttackType.COLD, Crossfire.AttackType.ELECTRICITY ]
351 whoami.Say(
'Your attacktype are:')
353 if ( at & Crossfire.WhoIsActivator().AttackType == at):
354 whoami.Say(Crossfire.AttackTypeName[ at ])
357 players = Crossfire.GetPlayers()
358 whoami.Say(
'Players logged in:')
360 whoami.Say(
' - %s'%pl.Name)
367 find = who.CheckInventory(what)
369 whoami.Say(
'Found %s in your inventory.'%find.Name)
371 whoami.Say(
'Can\'t find %s in your inventory.'%what)
374 obj = whoami.Map.ObjectAt(4, 4)
376 whoami.Say(
'Face is %s'%obj.Face)
383 whoami.Say(
'Face changed to %s'%face)
385 whoami.Say(
'Invalid face %s'%face)
388 obj = whoami.Map.ObjectAt(4, 4).Above
390 whoami.Say(
'Animation is %s'%obj.Anim)
396 whoami.Say(
'Animation changed to %s'%anim)
398 whoami.Say(
'Invalid animation %s'%anim)
401 item = whoami.Map.CreateObject(
'food', 0, 0)
402 whoami.Say(
'Created item.')
403 item2 = whoami.Map.ObjectAt(0, 0)
407 whoami.Say(
'Not the same items!')
409 whoami.Say(
'Trying to access removed item, exception coming')
412 whoami.Say(
'No exception! Error!')
414 whoami.Say(
'Exception came, ok')
418 whoami.Say(
'use: checkinventory <item''s name>')
421 what =
' '.join(topic[1:])
422 item = who.CheckInventory(what)
424 whoami.Say(
'found item: ' + item.Name)
426 whoami.Say(
'did not find anything matching ' + what)
429 item = whoami.Map.CreateObject(
'food', 2, 1)
431 whoami.Say(
'no_save set, the food should not be saved')
434 if whoami.X == 2
and whoami.Y == 2:
435 whoami.WriteKey(
'dest_x',
'0', 1)
436 whoami.WriteKey(
'dest_y',
'4', 1)
438 whoami.WriteKey(
'dest_x',
'2', 1)
439 whoami.WriteKey(
'dest_y',
'2', 1)
443 whoami.Say(
'Usage: attr name [value], if value is omitted display the value')
447 val = getattr(whoami, topic[1])
449 whoami.Say(
'my %s is %s'%(topic[1],
str(val)))
453 setattr(whoami, topic[1], topic[2])
456 setattr(whoami, topic[1],
int(topic[2]))
459 setattr(whoami, topic[1], float(topic[2]))
461 whoami.Say(
"sorry, I don't know how to set this attribute...")
465 whoami.Say(
'Please add something so I can encode & decode it in JSON')
467 msg =
' '.join(Crossfire.WhatIsMessage().
split()[1:])
470 encoded = cjson.encode(json)
472 result = cjson.decode(encoded)[
'msg']
473 whoami.Say(
'You said after encode & decode: %s'%msg)
476 if whoami.ReadKey(
'dest_x') !=
'' or whoami.ReadKey(
'dest_y') !=
'':
479 topic = Crossfire.WhatIsMessage().
split()
482 if topic[0] ==
'arch':
484 elif topic[0] ==
'maps':
486 elif topic[0] ==
'party':
488 elif topic[0] ==
'region':
490 elif topic[0] ==
'mark':
492 elif topic[0] ==
'ref':
494 elif topic[0] ==
'memory':
496 elif topic[0] ==
'resist':
498 elif topic[0] ==
'basics':
500 elif topic[0] ==
'time':
502 elif topic[0] ==
'timer':
504 elif topic[0] ==
'timer_kill':
506 elif topic[0] ==
'misc':
508 elif topic[0] ==
'exp':
510 elif topic[0] ==
'const':
512 elif topic[0] ==
'move':
514 elif topic[0] ==
'inv':
516 elif topic[0] ==
'bed':
518 elif topic[0] ==
'readkey':
520 elif topic[0] ==
'writekey':
522 elif topic[0] ==
'speed':
524 elif topic[0] ==
'owner':
526 elif topic[0] ==
'friendlylist':
528 elif topic[0] ==
'create':
530 elif topic[0] ==
'directory':
532 elif topic[0] ==
'event':
534 elif topic[0] ==
'light':
536 elif topic[0] ==
'attacktype':
538 elif topic[0] ==
'players':
540 elif topic[0] ==
'checkinv':
542 elif topic[0] ==
'anim':
544 elif topic[0] ==
'face':
546 elif topic[0] ==
'hook':
548 elif topic[0] ==
'checkinventory':
550 elif topic[0] ==
'nosave':
552 elif topic[0] ==
'move_to':
554 elif topic[0] ==
'attr':
556 elif topic[0] ==
'cjson':
562 x = whoami.ReadKey(
'dest_x')
563 y = whoami.ReadKey(
'dest_y')
564 if x ==
'' or y ==
'':
568 result = whoami.MoveTo(x, y)
570 whoami.WriteKey(
'dest_x',
'', 1)
571 whoami.WriteKey(
'dest_y',
'', 1)
572 whoami.Say(
"I'm there")
574 whoami.Say(
'blocked...')
576 event = Crossfire.WhatIsEvent()
577 if event.Subtype == Crossfire.EventType.SAY:
578 topic = Crossfire.WhatIsMessage().
split()
580 elif event.Subtype == Crossfire.EventType.TIME: