File: python

package info (click to toggle)
crossfire 1.75.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,168 kB
  • sloc: ansic: 83,169; sh: 4,659; perl: 1,736; lex: 1,443; makefile: 1,199; python: 43
file content (1420 lines) | stat: -rw-r--r-- 51,220 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
This documentation is not uptodate. Latest version is in the python.ps file,
or available online from http://wiki.metalforge.net/doku.php/cfpython



THE PYTHON PLUGIN, VERSION 2.0
===============================

What is the Python Plugin ?
---------------------------
It is a plugin part of the Crossfire server that allows map-makers to create
object behaviors using Python scripts instead of having to hardcode them in C.


Converting from CFPython 0.x and 1.0
------------------------------------
A lot of things have changed which hopefully make your Python coder's life a
little more comfortable.

1. The library name is now "Crossfire", instead of the previous "CFPython". No,
   that's not to annoy you without purpose. It will force you to think about
   reading your old Python code and make the necessary conversions.
2. Objects and Maps are now wrapped into Python objects. It means that instead
   of writing "CFPython.Teleport(object,map,x,y)", you'll now have to write
   "object.Teleport(map,x,y)". It is somewhat more logical and contributes to
   cleaner Python code.
3. The plugin event hook mechanism is now based on event objects contained in
   WhoAmI's inventory.

To make the transition as easy as possible, most functions of CFPython were
converted using the following rules:
- If the function was a getter/setter of an object or map attribute, it is now
  available as a Python object attribute.
  Examples: print CFPython.GetDamage(object) --> print object.Damage
            CFPython.SetDamage(object, value) --> object.Damage = value
- If the function was an action performed by an object/a map, or related to a
  specific object/map, it is now available as a Python object method.
  Examples: CFPython.Take(object, what) --> object.Take(what)
            CFPython.CheckMap(what, map, x, y) --> map.Check(what,x,y)

Only a few methods/attributes have changed names (this is the case for the seven
base attributes STR,DEX,CON,INT,WIS,POW,CHA for example).

Note that although it may seem that converting your old scripts to the new
format will be a huge job, it is rather straightforward in most cases. It only
took me an afternoon to convert and test all the scripts supplied with the
default map set, and I wasn't even their original author.


How do I hook a script to an object?
------------------------------------

There are special archetypes named event_xxx available. You need to put those in
the inventory of the objects to which you want to connect your script.

Some fields of the event_xxx archetypes have a special meaning:

- name: all parameters you want to pass to the scripts should go there;
- title: this is the plugin identifier. For the Python plugin, it is "Python"
         (without the quotes);
- slaying: the name of the script file to execute when the event is triggered.
        Note that this name is relative to the map base directory.

Example:

arch event_apply
name parms
title Python
slaying test.py
end

The event will be triggered when the container object is applied and will run
share/crossfire/maps/test.py, passing "parms" as a parameter string to the
script.

You of course need to write some Python code too... You do as usual, but
remember to add an "import Crossfire" to make all crossfire-specific functions
available in your script.


How do I hook a global event?
-----------------------------

Each global event is bound to a specific Python script file. Those files are
located in the python/events/ subdirectory of your crossfire map directory.
They have specific names, too: python_xxx.py, where xxx is the name of the
global event you want to intercept. For example, a script that should be run
each time a player logs in ("login" event) should be named python_login.py.


What functions are currently supported?
---------------------------------------

A complete list of those functions is given below.

Last count (2005-03-06) result: 217 functions (not including attack type/event
type wrapper functions). This of course does not include all the Python
functions, just the crossfire-specific ones.

In the following, I use the following type naming convention:
int   : An integer.
long  : A long.
float : A float.
object: A crossfire object. (In fact, it is a long).
map   : A crossfire map. (In fact, it is a long).
string: A character string.

1. Global Methods
+++++++++++++++++

Those are provided by the Crossfire library directly, so to call them, you have
to write something like: Crossfire.Method().

ConfigDirectory()    (1.x name: GetConfigurationDirectory())
  Return the name of the base directory containing Crossfire configuration
  files.
  Returns the directory name as a string.

DirectionN()
  Wrapper for the North direction.
  Return value: an integer representing the direction.

DirectionNE()
  Wrapper for the North-East direction.
  Return value: an integer representing the direction.

DirectionE()
  Wrapper for the East direction.
  Return value: an integer representing the direction.

DirectionSE()
  Wrapper for the South-East direction.
  Return value: an integer representing the direction.

DirectionS()
  Wrapper for the South direction.
  Return value: an integer representing the direction.

DirectionSW()
  Wrapper for the South-West direction.
  Return value: an integer representing the direction.

DirectionW()
  Wrapper for the West direction.
  Return value: an integer representing the direction.

DirectionNW()
  Wrapper for the North-West direction.
  Return value: an integer representing the direction.

2. Object-Specific Methods
++++++++++++++++++++++++++

Those are provided by the Python object wrapper.

ActivateRune(object activator)
  Trigger the rune. Note that both the rune and its activator must be in the
  same or in adjacent tiles of the same map.
  Does not return a value.

  Example:
    who = Crossfire.WhoIsActivator()
    rune = who.Map.CreateObject("rune_burning_hands", who.X, who.Y)
    rune.ActivateRune(who)

Apply(object what, int flags)
  Make the object apply an object 'what'. The applying object can be a
  player or a monster. The applied object need not be on the same tile as
  the applier. 'flags' specifies how to apply the object:
   - 0=toggle (apply/unapply) the object
   - 1=always apply the object
   - 2=always unapply the object
  Additionally, you can specify some modifier bits:
   - 16=do not merge an unapplied object with other objects
   - 32=unapply the item even if it is cursed
   - 64=print the object name but do not apply/unapply it

  Return value: integer denoting the result:
   - 0=player or monster can't apply an object of that type
   - 1=object has been applied, or there was an error applying the object
   - 2=objects of that type can't be applied if not in inventory

  Example:
    who = Crossfire.WhoIsActivator()

# create and apply a trigger object
    trigger = who.Map.CreateObject("trigger", who.X, who.Y)
    result = who.Apply(trigger, 0); # returns 1

# create and apply an amulet
    food = who.Map.CreateObject("amulet of sustenance", who.X, who.Y)
    result = who.Apply(food, 0); # returns 2

# create and apply/unapply a cursed shield
    shield = who.CreateObject("small shield")
    shield.Cursed = 1;
    result = who.Apply(shield, 1); # returns 1
    result = who.Apply(shield, 2); # returns 1 (it does not unapply the item)
    result = who.Apply(shield, 2|32); # returns 1

LearnSpell(object spell)   (1.x name: AcquireSpell)
  Learn the spell identified by a spell object.
  Does not return a value.

  Example:
    who = Crossfire.WhoIsActivator()
    spell = Crossfire.CreateObjectByName("spell_large_fireball")
    who.LearnSpell(spell)
    spell.Remove()

Say(message text)
  Say 'text'.
  Does not return a value.

3. Object-Specific Attributes
+++++++++++++++++++++++++++++

CanCastSpell
  Test if the object can cast spells.
  Return value: test result as an integer - 0 if and only if false.

CanPassThru
  Test if the object has the 'pass through' ability.
  Return value: test result as an integer - 0 if and only if false.

CanPickUp
  Test if the object can pick up stuff.
  Return value: test result as an integer - 0 if and only if false.

CanRoll
  Test if the object can roll.
  Return value: test result as an integer - 0 if and only if false.

CanSeeInDark
  Test if object has got infravision capabilities.
  Return value: test result as an integer - 0 if and only if false.

CanSeeInvisible
  Test if the object can see invisible things.
  Return value: test result as an integer - 0 if and only if false.

CanUseArmour
  Test if the object can wear armor.
  Return value: test result as an integer - 0 if and only if false.

CanUseBow
  Test if the object can use a bow.
  Return value: test result as an integer - 0 if and only if false.

CanUseHorn
  Test if the object can use a horn (and other musical instruments).
  Return value: test result as an integer - 0 if and only if false.

CanUseRing
  Test if the object can use rings.
  Return value: test result as an integer - 0 if and only if false.

CanUseRod
  Test if the object can use magical rods.
  Return value: test result as an integer - 0 if and only if false.

CanUseScroll
  Test if the object can read scrolls.
  Return value: test result as an integer - 0 if and only if false.

CanUseSkill
  Test if the object can use skills.
  Return value: test result as an integer - 0 if and only if false.

CanUseWand
  Test if the object can use a magical wand.
  Return value: test result as an integer - 0 if and only if false.

CanUseWeapon
  Test if the object can use a weapon.
  Return value: test result as an integer - 0 if and only if false.


4. Map-Specific Methods
+++++++++++++++++++++++

Those are provided by the Python map wrapper.

5. Map-Specific Attributes
++++++++++++++++++++++++++


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TODO: Finish converting the 1.x docs.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


A
AttackTypeXxx()
  Wrapper for attack type Xxx. Possible values for Xxx are: Acid Blind
  Cancellation Chaos Cold Confusion Counterspell Death Depletion Disease Drain
  Electricity Fear Fire Ghosthit Godpower HolyWord LifeStealing Magic Paralyze
  Physical Poison Slow TurnUndead Weaponmagic.
  Return value: an integer representing the attack type.

B
BlocksView(object obj)
  Check if 'obj' can block the line-of-sight.
  Return value: test result as in integer - 0 if and only if false.

C

CastAbility(object who, object caster, string spell, int direction, string
  options)
  Make the object 'caster' cast a 'spell'. 'who' is the owner of the casting
  object; 'who' and 'caster' may be the same item. The spell is identified by
  the spell name and cast into the given direction. 'options' can hold some
  options.
  Does not return a value.

  Note: to cast a spell by a spell object, use CastSpell().

  Example:
    who = CFPython.WhoIsActivator()
    caster = CFPython.CreateObjectInside("horn of Fire", who)
    CFPython.CastAbility(who, caster, "spell_firebolt", CFPython.DirectionE(), "")

  Example:
    who = CFPython.WhoIsActivator()
    CFPython.CastAbility(who, who, "spell_create_food", 0, "booze")

CastSpell(object who, object spell, int direction, string options)

  Make 'who' cast a spell, identified by a spell object, into one direction.
  'options' can hold some options.
  Does not return a value.

  Note: this function is similar to CastAbility() except that a spell object
  (instead of a spell name) is used and that 'caster' is set to 'who'.

  Note: the spell will be cast even if the 'who' has not sufficient spell
  points; in fact, 'who' may end with negative spell points.

  Example:
    # make the activator cast a large fireball (if he knows that spell)
    who = CFPython.WhoIsActivator()
    spell = CFPython.DoKnowSpell(who, "large fireball")
    if spell: CFPython.CastSpell(who, spell, CFPython.DirectionSE(), "")

CheckArchInventory(object who, string arch_name)
  Check if 'who' has an object with the archetype 'arch_name' in his inventory.
  Return value: the first matching object or 0 if the archetype was not found.

  Example:
    who = CFPython.WhoIsActivator()
    obj = CFPython.CheckArchInventory(who, 'key2')
    if obj: CFPython.Write(CFPython.GetName(obj), who)

CheckInventory(object who, string name)
  Check if 'who' has an object named 'name' in his inventory. It first checks
  for any item with a matching archetype name, then for an object with a name
  beginning with 'name'.
  Return value: the matching object or 0 if no object was found.

CheckInvisibleObjectInside(object who, string id)
  Check for the existence of an force object with a slaying field 'id' inside
  'who'.
  Return value: The force object found or 0.

CheckMap(string what, map map, (int x, int y))
  Check for an item with the archetype name 'what' in a map at a given
  position. The function works for tiled maps.
  Return value: The object found or 0.

CheckTrigger(object trigger, object what)
  Try to trigger an object 'trigger' by 'what'. The object 'what' may be
  destroyed. (For example if 'trigger' is an altar.)
  Does not return a value.

  Example:
    # create and trigger an altar
    altar = CFPython.CreateObject("altar_trigger", (0, 0))
    food = CFPython.CreateObject("food", (1, 0))
    CFPython.SetQuantity(food, 5)
    CFPython.CheckTrigger(altar, food)

CostFlagXxx()
  Wrapper for flags to use as the third parameter of GetObjectCost(). You must
  always choose one of FBuy, FSell, or FTrue. You may add any other flags as
  well. Possible Values for Xxx are:
   - FBuy: item value for a player buying the item
   - FSell: item value for a player selling the item
   - FTrue: true value of the item
   - FNoBargain: disable modifications due to bargaining skill
   - FIdentified: pretend the item as identified
   - FNotCursed: pretend the item as not cursed
  Return value: integer integer representing the flag.

CreateInvisibleObjectInside(object where, string name)
  Create a force object with a slaying field of 'name'. The object is placed in
  the inventory of 'where'.
  Return value: the created force object.

  Note: The statement "obj = CFPython.CreateInvisibleObjectInside(who, 'slay')"
  is basically the same as:
    obj = CFPython.CreateObjectInside('force', who)
    CFPython.SetSlaying(obj, 'slay')
    CFPython.SetSpeed(obj, 0)

CreateObject(string name, (int x, int y)[, string map])
  Create an object from the archetype 'name', or with the name 'name'. Insert
  it at position (x,y) in the map. If map is omitted, it defaults to
  GetMap(WhoAmI()).
  Return value: the created object. Note that the returned object may have
  nrof>1 if the new item has been merged with other objects.

  Note: Not all types of objects can be created; for example, objects of type
  PLAYER will crash the server.

  Note: Not all kinds of objects are created correctly; for example, currently
  a "horn of Fire" cannot be created: it creates a working horn but it is blue
  with message "Putting this shell to you ear, you hear a strange and haunting
  melody" and it is god-given.

  Note: This function does not work correctly if the object contains a
  "randomitems" field in the archetype.

CreateObjectInside(string name, object where)
  Create an object from the archetype 'name', or with the name 'name'. Insert
  it into the inventory of 'where'.
  Return value: the created object

  Note: see CreateObject()

  Examples:
    CFPython.CreateObjectInside("stylus", CFPython.WhoAmI()) # archetype name
    CFPython.CreateObjectInside("writing pen", CFPython.WhoAmI()) # object name
    CFPython.CreateObjectInside("levitation boots of mobility", CFPython.WhoAmI()) # artifact object

D
DecreaseObjectNr(object ob, int nrof)
  Remove the given number of items from ob. If nrof is equal or more
  than the items left in ob, ob is removed.
  Return value: the object ob if some items are still remaining or 0 if all
  objects are removed.

DoKnowSpell(object who, string spell)
  Check if 'who' knows the spell by the name of 'spell'.
  Returns the spell object if 'who' knows the spell or 0 if not.

  Example: see CastSpell()

Drop(object who, string name)
  Let 'who' drop the items named 'name'.
  Does not return a value.

E
EventXxx()
  Wrapper for event type Xxx. Possible values are: Apply Attack Close Death
  Drop Pickup Say Stop Throw Time Timer Trigger.
  Return value: an integer representing the event type.

F
FindPlayer(string name)
  Check for a player with the given name. Note: the comparison is
  case-sensitive and does not allow for partial matches.
  Return value: the player object or 0 if not found.

FixObject(object who)
  Update all abilities granted by applied objects in the inventory of the
  given object. This functions starts from base values (archetype or player
  object) and then adjusts them according to what the object has equipped.
  Does not return a value.

ForgetSpell(object who, string spell)
  Cause who to forget the spell named 'spell'.  who must be a player.
  Does not return a value.

  Example:
    who = CFPython.WhoIsActivator()
    CFPython.ForgetSpell(who, "large fireball")

G
GetAC(object who)
  Get the Armor Class coefficient associated with the given object.
  Returns the armor class coefficient as an integer.

GetArchType(object who)
  Get the archtype name of an object.
  Returns the archtype as a string.

GetAttackType(object who)
  Determine the attack type of an object.
  Returns the attack type as an integer.

GetCharisma(object who)
  Get the Charisma value of the given object.
  Returns the charisma value as an integer.

GetConstitution(object who)
  Get the Constitution value of the given object.
  Returns the constitution value as an integer.

GetDamage(object who)
  Get the amount of damage associated with the given object.
  Returns the damage value as an integer.

GetDataDirectory()
  Return the name of the base directory containing the Crossfire read only data
  files.
  Returns the directory name as a string.

GetDexterity(object who)
  Get the Dexterity value of the given object.
  Returns the dexterity value as an integer.

GetDirection(object who)
  Determine the direction an turnable object 'who' is currently moving. Use
  IsTurnable(who) to determine if an object is turnable.
  Returns the direction as an integer.

GetEventHandler(object who, int event)
  Get the event handler of 'who' for the event number 'event'. The parameter
  'event' should be a value returned by EventXxx().
  Returns the event handler name as a string or no object if the handler is not
  used.

GetEventOptions(object who, int event)
  Get the event options of 'who' for the event number 'event'. The parameter
  'event' should be a value returned by EventXxx().
  Returns the event options as a string or no object if the handler is not
  used.

GetEventPlugin(object who, int event)
  Get the event plugin name of 'who' for the event number 'event'. The
  parameter 'event' should be a value returned by EventXxx().
  Returns the event options as a string or no object if the handler is not
  used.

GetExperience(object who)
  Get the amount of experience associated with the object.
  Returns the event options as a long.

GetFacing(object who)
  Determine the direction an turnable object 'who' is currently facing. It
  is similar to GetDirection except it works for non-moving objects too. See
  GetDirection for details.
  Returns the direction as an integer.

GetFirstObjectOnSquare(map map, int x, int y)
  Get the first object at position (x,y) in the map 'map'. Use
  GetPreviousObject() to find the next item(s).
  Returns the object or 0 if the position is empty.

GetFood(object who)
  Get the food level of the given object.
  Returns the food level as an integer.

GetGod(object who)
  Get the name of the god associated with the given object. Usually, this will
  be the god 'who' is worshipping.
  Return value: the god name as a string or no object if 'who' has no god.

GetGrace(object obj)
  Get the grace amount of the given object.
  Returns the grace amount as an integer.

GetHP(object who)
  Get the amount of Hit Points associated with the given object.
  Returns the amount of hit points as an integer.

GetHumidity(int x, int y, map map)
  Get the humidity level of a given square of a map.
  Returns the humidity level as an integer.

  Remark: not implemented. Always returns zero.

GetIntelligence(object who)
  Get the Intelligence value of the given object.
  Returns the intelligence value as an integer.

GetInternalName(object who)
  Get the name of 'who' without any modifications.
  Returns the object name as a string.

GetInventory(object who)
  Get the first inventory object of 'who'. Use GetNextObject() to find the next
  inventory objects.
  Returns the object or 0 if the inventory is empty.

GetIP(object player)
  Get the ip address of 'player'. The given object should be a player object.
  Returns the ip address as a string or no value if the object is not a player
  object.

GetLastGrace(object who)
  Get the last_grace parameter value associated with the given object.
  Returns the last_grace value as an integer.

GetLastSP(object who)
  Get the last_sp parameter value associated with the given object.
  Returns the last_sp value as an integer.

GetLevel(object who)
  Get the level of a given object.
  Returns the level as an integer.

GetLocalDirectory()
  Return the name of the base directory containing the Crossfire read-write
  data files.
  Returns the directory name as a string.

GetMap(object who)
  Determine the map the object 'who' is currently in.
  Returns the map as a map or 0 if the items is not part of a map.

GetMapDirectory()
  Return the name of the base directory containing the Crossfire maps. You need
  to concatenate the result with the value returned by GetDataDirectory() to
  get an absolute path.
  Returns the directory as a string.

GetMapHeight(map map)
  Get the height (the number of tiles) of a map.
  Returns the height as an integer.

GetMapObject()
  This function should not be used anymore. It always throws an exception.

GetMapPath(map map)
  Get the path name of the map.
  Returns the path name as a string.

GetMapWidth(map map)
  Get the width (the number of tiles) of a map.
  Returns the width as an integer.

GetMaxHP(object who)
  Get the maximum amount of Hit Points the given object can get.
  Returns the amount of hit points as an integer.

GetMaxSP(object who)
  Get the maximum amount of mana the given object can get.
  Returns the maximum amount of mana as an integer.

GetMessage(object obj)
  Get the message contained in the specified object. The message is what
  appears inside msg...endmsg tags.
  Returns the message as a string.

GetName(object who)
  Get the 'clear name' of the given object.
  Returns the name as a string.

GetNextObject(object obj)
  Get the next object below 'obj'.
  Returns the next object or 0 if 'obj' is the last object.

GetObjectAt(map map, int x, int y)
  Get the first object at position (x,y) in the map.
  Returns the object or 0 if the position is empty.

GetObjectCost(object who, object obj, int type)
  Determine the cost of an object 'obj' if 'who' would buy or sell it. The
  parameter 'type' should be one or more values returned by CostFlagXxx().
  Returns the cost in silver coins as an integer.

GetObjectMoney(object who)
  Determine how much money 'who' is carrying, including what is in containers.
  Returns the amount in silver coins as an integer.

GetPlayerDirectory()
  Return the name of the base directory containing the Crossfire players files.
  You need to concatenate the result with the value returned by
  GetLocalDirectory() to get an absolute path.
  Returns the directory as a string.

GetPower(object who)
  Get the Power value of the given object.
  Returns the power value as an integer.

GetPressure(int x, int y, map map)
  Get the humidity level of a given square of a map.
  Returns the humidity level as an integer.

  Remark: not implemented. Always returns zero.

GetPreviousObject(object obj)
  Get the object before 'obj'.
  Returns the previous object or 0 if 'obj' is the first object.

GetQuantity(object obj)
  Return the number of items this object represents.
  Returns the number as a long.

GetReturnValue()
  Return the current exit status of the event script as an integer. See below
  for an overview of events that use the exit value.

GetSkillExperience(object who, string skill)
  Get the experience of skill 'skill' the object 'who' has. 'skill' should
  skill name.
  Returns the skill experience as a long or no value if 'who' does not know the
  skill.
  Example:
    who = CFPython.WhoIsActivator()
    exp = CFPython.GetSkillExperience(who, "alchemy")
    if exp != None:
        CFPython.Write("Alchemy experience %d"%(exp), who)
    else:
        CFPython.Write("Alchemy skill is unknown", who)

GetSlaying(object obj)
  Get the "slaying" field of an object.
  Returns the slaying value as a string.

GetSP(object who)
  Get the amount of mana possessed by the given object.
  Returns the amount of mana as an integer.

GetSpeed(object who)
  Get the speed of the given object.
  Returns the speed as a float.

GetStrength(object who)
  Get the Strength value of the given object.
  Returns the strength as an integer.

GetTempDirectory()
  Return the name of the base directory containing temporary Crossfire files
  (for example swapped-out maps).
  Returns the directory as a string.

GetTemperature(int x, int y, map map)
  Get the temperature of a given square of a map.
  Returns the temperature as an integer.

  Remark: not implemented. Always returns zero.

GetTitle(object who)
  Get the title of 'who'. The "title" is the artifact suffix of in item. For
  example, an "gauntlets of the Titans" has the title "of the Titans".
  Returns the title as a string or no value if the object has no title.

  Note: this function does not return the title the player has chosen for
  himself.

GetType(object who)
  Get the type of a given object, as a numerical identifier.
  Returns the type as an integer.

GetUniqueDirectory()
  Return the name of the base directory containing the Crossfire Unique items.
  You need to concatenate the result with the value returned by
  GetLocalDirectory() to get an absolute path.
  Returns the directory as a string.

GetValue(object who)
  Get the "value" field of an object.
  Returns the value as an integer.

GetWC(object who)
  Get the Weapon Class coefficient associated with the given object.
  Returns the weapon class coefficient as an integer.

GetWeight(object who)
  Determine the weight of the given object. The weight does not include the
  inventory.
  Returns the weight in grams as an integer.

GetWisdom(object who)
  Get the Wisdom value of the given object.
  Returns the wisdom value as an integer.

GetXPosition(object obj)
  Get the x-position of an object in its map.
  Returns the x-position as an integer.

GetYPosition()
  Get the y-position of an object in its map.
  Returns the y-position as an integer.

H
HasBeenApplied(object obj)
  Check whether the object has been applied before.
  Return value: test result as an integer - 0 if and only if false.

HasStealth(object obj)
  Check whether the object is stealthy.
  Return value: test result as an integer - 0 if and only if false.

HasXRays()
  Check whether the object uses or grants x-rays.
  Return value: test result as an integer - 0 if and only if false.

HitBack()
  Check whether the object has the hitback flag set.
  Return value: test result as an integer - 0 if and only if false.

I
InsertObjectInside(object obj, object environment)
  Insert the object 'obj' into 'environment'.
  Does not return a value.

  Example: see SetSlaying()

IsAlive(object who)
  Test if the given object is alive.
  Return value: test result as an integer - 0 if and only if false.

IsApplied(object who)
  Test if the given object is applied.
  Return value: test result as an integer - 0 if and only if false.

IsBlind(object who)
  Test if the given object causes blindness. For players, tests if he is blind.
  Return value: test result as an integer - 0 if and only if false.

IsCanBePicked(object who)
  Test if on object can be picked up.
  Return value: test result as an integer - 0 if and only if false.

IsConfused(object who)
  Test if the given object is confused.
  Return value: test result as an integer - 0 if and only if false.

IsCursed(object who)
  Test if the given object is cursed. Not that not all "damned" objects are
  cursed as well.
  Return value: test result as an integer - 0 if and only if false.

IsDamned(object who)
  Test if the given object is damned.
  Return value: test result as an integer - 0 if and only if false.

IsDungeonMaster(object who)
  Test if the given object is a DM.
  Return value: test result as an integer - 0 if and only if false.

IsFloor(object who)
  Test if the given object is a floor tile.
  Return value: test result as an integer - 0 if and only if false.

IsFlying(object who)
  Test if the given object is flying.
  Return value: test result as an integer - 0 if and only if false.

IsFriendly(object who)
  Test if the given object is in friendly mode.
  Return value: test result as an integer - 0 if and only if false.

IsGenerator(object who)
  Test if the given object is a generator.
  Return value: test result as an integer - 0 if and only if false.

IsIdentified(object who)
  Test if the given object is identified.
  Return value: test result as an integer - 0 if and only if false.

IsInvisible(object who)
  Test if the given object is invisible.
  Return value: test result as an integer - 0 if and only if false.

IsKnownCursed(object who)
  Test if the given object is known to be a cursed one.
  Return value: test result as an integer - 0 if and only if false.

IsKnownMagical(object who)
  Test if the given object is known to be a magical one.
  Return value: test result as an integer - 0 if and only if false.

IsLifesaver(object who)
  Test if the given object is a Lifesaver. For players, tests if he wears an
  object that is a Lifesaver.
  Return value: test result as an integer - 0 if and only if false.

IsMonster(object who)
  Test if the given object is a monster.
  Return value: test result as an integer - 0 if and only if false.

IsOfType(object obj, int type)
  Check if the object is of the given type.
  Return value: test result as an integer - 0 if and only if false.

  Note: There is no function to determine the type values by name.

  Example:
    if CFPython.IsOfType(CFPython.CreateObject("ring", (0, 0)), 70): # 70=RING
      # item is a ring

IsOutOfMap(object obj, int x, int y)
  Check if the object would be outside of the current map if moved to (x,y).
  This function works for tiled maps.
  Return value: test result as an integer - 0 if and only if false.

IsRunningAway(object who)
  Test if the given object is running away.
  Return value: test result as an integer - 0 if and only if false.

IsScared(object who)
  Test if the given object is scared.
  Return value: test result as an integer - 0 if and only if false.

IsSleeping(object who)
  Test if the given object is sleeping.
  Return value: test result as an integer - 0 if and only if false.

IsSplitting(object who)
  Test if the given object can split.
  Return value: test result as an integer - 0 if and only if false.

IsThrown(object who)
  Test if the given object is designed to be thrown.
  Return value: test result as an integer - 0 if and only if false.

IsTurnable(object who)
  Test if the given object can change its face with direction.
  Return value: test result as an integer - 0 if and only if false.

  Note: use SetDirection(who) to change the direction of turnable objects.

IsUnaggressive(object who)
  Test if the given object is in unaggressive mode.
  Return value: test result as an integer - 0 if and only if false.

IsUndead(object who)
  Test if the given object is an undead.
  Return value: test result as an integer - 0 if and only if false.

IsUnique(object who)
  Test if the given object is unique.
  Return value: test result as an integer - 0 if and only if false.

IsUnpaid(object who)
  Test if the given object is paid.
  Return value: test result as an integer - 0 if and only if false.

IsUsedUp(object who)
  Test if the given object has the flag "FLAG_IS_USED_UP" set.
  Return value: test result as an integer - 0 if and only if false.

  Example:
    who = CFPython.WhoIsActivator()
    obj = CFPython.CreateObject("burning item", (0, 0))
    CFPython.Write("IsUsedUp(%s)=%d"%(CFPython.GetName(obj), CFPython.IsUsedUp(obj)), who)


J
K
KillObject(object who, object what, int type)
  Kill the object 'what' in an combat-like fashion. 'who' is the object killing
  'what'. 'type' is the attack type; it should be one or more values returned
  by AttackTypeXxx().
  Does not return a value.

  Note: the death event of 'what' will be called.

L
LoadObject(string str)
  Construct an object from its string representation. Use SaveObject() to
  convert an object into its string representation.
  Returns the created object or 0 if the object could no be created.

M
MakeInvisible(object obj)
  Test if the given object makes the wielder invisible. For players, tests if
  he is invisible.
  Return value: test result as an integer - 0 if and only if false.

MatchString(string str, string regex)
  Try to match the string 'str' to a regular expression 'regex'.
  Return value: test result as an integer - 0 if and only if false.

Message(string text, object who[, int color])
  Write the message 'text' to the map of 'who'. 'color' determines the color
  and flags to use. (Consult the crossfire source code for all available flags
  NDI_*.) If 'color' if omitted, NDI_BLUE|NDI_UNIQUE is used.
  Does not return a value.

  Note: to write a message to just one player, use Write().

N
O
OnlyAttack(object who)
  Test if the given object evaporates if it has no enemy.
  Return value: test result as an integer - 0 if and only if false.

P
PayAmount(object buyer, int silver)
  Remove a given amount of silver coins from the buyer object. It uses money
  from the inventory or from pouches in the inventory of 'buyer'.
  Returns an integer, 1 for success or 0 for failure.

PayForItem(object buyer, object what)
  Make 'buyer' to buy the object 'what'. Removes the necessary money from the
  inventory or from pouches in the inventory. It grants bargaining experience
  for a successful completion.
  Returns an integer, 1 for success or 0 for failure.

PickUp(object who, object what)
  Make 'who' pick up the object 'what'.
  Does not return a value.

Q
R
ReadyMap(string mapname)
  Return the map with the name 'mapname'. The functions loads (or swaps in) the
  map if necessary.
  Returns the map or 0 if the map could not be loaded.

  Example:
    # teleport activator to another map
    map = CFPython.ReadyMap("/scorn/misc/beginners")
    CFPython.Teleport(CFPython.WhoIsActivator(), map, 10, 10)

ReflectMissiles(object obj)
  Test if the given object reflects missiles. For players, tests if he reflects
  missiles.
  Return value: test result as an integer - 0 if and only if false.

ReflectSpells(object obj)
  Test if the given object reflects spells. For players, tests if he reflects
  spells.
  Return value: test result as an integer - 0 if and only if false.

RegisterCommand(string command, string script, float speed)
  Define a new command that players can call. 'script' is the Python script to
  execute if a player issues 'command'. 'speed' determines how long the command
  will paralyze the player.

  When the script is run, WhoAmI() will return the player that issued the
  command. WhatIsMessage() returns the command parameters (if any).
  Throws an exception if the command is already registered or if 'speed' is
  negative.
  If the script fails, it should call SetReturnValue(0).

  Note: It is possible to overwrite internal commands.

RemoveObject(object obj)
  Remove an object from its environment (and frees it).
  Does not return a value.

  Note: do not use the object 'obj' afterwards.

  Note: if the removed object is a container, the objects inside are not freed,
  they are dropped to the ground.

S


SendCustomCommand(object player, string cmd)
  Send 'cmd' to the crossfire client of 'player'. Consult the crossfire
  protocol specification for valid commands. 'player' must be a player object.
  Does not return a value.

  Example:
    CFPython.SendCustomCommand(CFPython.WhoIsActivator(), "drawinfo 1 text")

SetAC(object obj, int value)
  Set the Armor Class coefficient if the given object to 'value'.
  Does not return a value.
  Throws an exception if the value is less than -120 or higher than 120.

SetAttackType(object obj, int type)
  Sets the attack type of an object. The type can be one or more return values
  of AttackTypeXxx().
  Does not return a value.

  Example:
    # create a sword with fire and cold attack type
    sword = CFPython.CreateObject("sword", (1, 3))
    CFPython.SetAttackType(sword, CFPython.AttackTypeFire()|CFPython.AttackTypeCold())
    CFPython.SetIdentified(sword, 1)

SetBeenApplied(object obj, int flag)
  Mark the object as been applied before (flag != 0) or has never been applied
  (flag = 0).
  Does not return a value.

SetCharisma(object obj, int value)
  Set the Charisma value of the given object.
  Does not return a value.
  Throws an exception if the value is less than -30 or higher than 30.

SetConstitution(object obj, int value)
  Set the Constitution value of the given object.
  Does not return a value.
  Throws an exception if the value is less than -30 or higher than 30.

SetCursed(object obj, int flag)
  Make the object cursed (flag != 0) or removes a curse (flag = 0).
  Does not return a value.

  Note: does not remove the damned flag - use SetDamned() to change the damned
  status.

SetDamage(object obj, int value)
  Set the amount of damage associated with the given object.
  Does not return a value.
  Throws an exception if the value is negative or higher than 120.

SetDamned(object obj, int flag)
  Make the object damned (flag != 0) or removes a damnation (flag = 0).
  Does not return a value.

  Note: does not affect the cursed flag - use SetCursed() to change the cursed
  status.

SetDexterity(object obj, int value)
  Set the Dexterity value of the given object.
  Does not return a value.
  Throws an exception if the value is less than -30 or higher than 30.

SetDirection(object who, int dir)
  Set the direction 'who' is currently moving.
  Does not return a value.

SetFace(object obj, string anim)
  Set the face of an object 'obj' to 'anim'. 'anim' is an animation name.
  Does not return a value.

  Example:
    # make a pair of speed boots look like Idaten boots
    obj = CFPython.CreateObject("speedboots", (1, 3))
    CFPython.SetFace(obj, "idaten")

SetFood(object who, int food)
  Set the food level of the given object.
  Does not return a value.
  Throws an exception if the value is negative or higher than 999.

SetGod(object who, string god)
  Make 'who' to become a follower of 'god'.
  Does not return a value.
  Throws an exception if 'god' is invalid.

  Note: Does nothing if 'who' does not know the skill 'praying'.

SetGrace(object obj, int value)
  Set the grace amount of the given object.
  Does not return a value.
  Throws an exception if the value is less than -32000 or higher than 32000.

SetHP(object obj, int value)
  Set the amount of Hit Points associated with the given object.
  Does not return a value.
  Throws an exception if the value is negative or higher than 32000.

SetIdentified(object obj, int flag)
  Mark the object as identified (flag != 0) or not identified (flag = 0).
  Does not return a value.

SetIntelligence(object who, int value)
  Set the Intelligence value of the given object.
  Does not return a value.
  Throws an exception if the value is less than -30 or higher than 30.

SetInvisible(object obj, int flag)
  Set (flag != 0) or clears (flag = 0) the invisible flag of the object.
  Does not return a value.

SetLastGrace(object who, int value)
  Set the last_grace parameter value associated with the given object.
  Does not return a value.
  Throws an exception if the value is negative or higher than 32000.

SetLastSP(object who, int value)
  Set the last_sp parameter value associated with the given object.
  Does not return a value.
  Throws an exception if the value is negative or higher than 32000.

SetMaxHP(object who, int value)
  Set the maximum amount of Hit Points the given object can get.
  Does not return a value.
  Throws an exception if the value is negative or higher than 32000.

SetMaxSP(object who, int value)
  Set the maximum amount of mana the given object can get.
  Does not return a value.
  Throws an exception if the value is negative or higher than 32000.

SetMessage(object obj, string msg)
  Set the message contained in the specified object. The message is what
  appears inside msg...endmsg tags.
  Does not return a value.

SetName(object name, string name[, string name_pl])
  Set the 'clear name' of the given object. If 'name_pl' (name to use for
  multiple objects) is not given, 'name' is used.
  Does not return a value.

  Example:
    # create a scroll with a custom name
    key = CFPython.CreateObject("scroll", (0, 0))
    CFPython.SetName(key, "warning scroll", "warning scrolls")
    CFPython.SetMessage(key, "<unreadable text>")

SetNickname(object obj, string name)
  Set the title of a player or an object.
  Does not return a value.

SetPosition(object obj, (int x, int y))
  Move an object to another spot on the same map. The object must not be part
  of an inventory. Places the item in a nearby spot if the destination spot is
  blocked. The object will no be moved if no free spot can be found.
  Does not return a value.

SetPower(object obj, int value)
  Set the Power value of the given object.
  Does not return a value.
  Throws an exception if the value is less than -30 or higher than 30.

SetQuantity(object obj, int nrof)
  Set the number of items this object represents.
  Does not return a value.
  Throws an exception if the value is negative.

  Note: the object should not be in a player's inventory because the client
  view will not be updated.

  Note: "nrof=0" does not mean "destroy the item".

SetReturnValue(int value)
  Set the current exit status of the event script. See below for an overview of
  events that use the exit value.
  Does not return a value.

SetSkillExperience(object who, string skill, long exp)
  Set the experience of skill 'skill' the object 'who' has. 'skill' should be a
  skill name.
  Does not return a value.
  Throws an exception if 'who' does not know the 'skill'.
  Throws an exception if the value is negative.

  Note: If the new experience value is less than the current value, 'who'
  looses the difference from his total experience.

SetSlaying(object obj, string value)
  Set the "slaying" field of an object.
  Does not return a value.

  Example:
    # create a key and set its lock-code
    key = CFPython.CreateObject("key2", (0, 0))
    CFPython.SetName(key, "treasure key")
    CFPython.SetSlaying(key, "treasure-code")
    CFPython.InsertObjectInside(key, CFPython.WhoIsActivator())

SetSP(object obj, int value)
  Set the amount of mana possessed by the given object.
  Does not return a value.
  Throws an exception if the value is negative or higher than 32000.

SetSpeed(object obj, float value)
  Set the speed value of the given object.
  Does not return a value.
  Throws an exception if the speed value is less than -9.99 or higher than
  9.99.

SetStrength(object obj, int value)
  Set the Strength value of the given object.
  Does not return a value.
  Throws an exception if the value is less than -30 or higher than 30.

SetTitle(object obj, string title)
  Set the title of the given object.
  Note: to set the title of a player, use SetNickname() instead.
  Does not return a value.

SetUnaggressive(object obj, int flag)
  Make the given object unaggressive (flag != 0) or aggressive (flag = 0).
  Does not return a value.

SetValue(object obj, int silver)
  Set the "value" field of an object in silver coins.
  Does not return a value.
  Throws an exception if the value is negative.

SetVariable(object obj, string value)
  Change an object according to an argument string. It is equivalent of the DM
  patch command.
  Does not return a value.

SetWC(object obj. int value)
  Set the Weapon Class coefficient associated with the given object.
  Does not return a value.
  Throws an exception if the value is less than -120 or higher than 120.

SetWeight(object obj, long weight)
  Set the weight (in grams) of the given object.
  Does not return a value.
  Throws an exception if the value is negative or higher than 1000000000.

SetWisdom(object obj, int value)
  Set the Wisdom value of the given object.
  Does not return a value.
  Throws an exception if the value is less than -30 or higher than 30.

StandStill(object obj)
  Test if the given object has the flag "FLAG_STAND_STILL" set.
  Return value: test result as an integer - 0 if and only if false.

T
Take(object who, string what)
  Make 'who' to pick up 'what'. The syntax of 'what' is the same as what is
  allowed for the client command 'get'.
  Does not return a value.

Teleport(object who, map map, int x, int y)
  Move the given object to (x,y) in map 'map'. The object to be moved may be
  part of a map or in some object's inventory. If the destination position is
  blocked, the object is placed in a nearby space.
  Does not return a value.

  Note: if the destination coordinates are outside of the map or if no free
  space could be found, this function does not move the object.

  Note: the object to be moved should not be part of a player's inventory.

U
V
W
WasDungeonMaster(object who)
  Test if the given object is or has been a DM.
  Return value: test result as an integer - 0 if and only if false.

WhatIsMessage()
  Return the message related to the current event as a string or no object if
  no message is applicable.

  Note: see below for an overview of events with messages.

WhoAmI()
  Return the object related to the current event or 0 if not applicable.

  Note: the related object is frequently (but not always) the object containing
  the script. See below for an overview of events with related objects.

WhoIsActivator()
  Return the object that caused the script to run or 0 if not applicable.
  Note: See below for an overview of events with activator objects.

WhoIsOther()
  Return an auxiliary object for the current event or 0 if not applicable.

  Note: See below for an overview of events with auxiliary objects.

Write(string text, object who[, int color])
  Write the message 'text' to the player 'who'. 'color' determines the color
  and flags to use. (Consult the crossfire source code for all available flags
  NDI_*.) If 'color' if omitted, NDI_BLUE|NDI_UNIQUE is used.
  Does not return a value.

  Note: to write a message to all players in a map, use Message().

X
Y
Z


What parameters are available to a script?
------------------------------------------

The following table contains all events that can be tied to objects.

event Activator WhoAmI Other Message parm1 parm2 parm3 result comment
----- --------- ------ ----- ------- ----- ----- ----- ------ --------------
apply   op     ALTAR     -      -    0     0     0     yes    'op' prays at 'altar'
apply   op     BOOK      -      -    0     0     0     no     'op' reads 'book'
apply   op     ITEM      -      -    aflag 0     0     yes    'op' applies 'item'
attack  hitter hitter    OP     -    0     dam   wc    no     'hitter' hits 'op'
attack  hitter ITEM      op     -    0     dam   wc    no     'hitter' hits 'op' with 'item'
close   op     CONTAINER -      -    0     0     0     yes    'op' closes 'container'
death   -      PLAYER    -      -    0     0     0     yes    'player' dies
death   hitter OP        -      -    atype 0     0     yes    'hitter' kills 'op'
drop    op     ITEM      -      -    nrof  0     0     yes    'op' drops 'item'
pickup                                                        (not implemented)
say     op     ITEM      npc    msg  0     0     0     always 'op' tells 'msg' to 'item' in 'npc''s inventory
say     op     NPC       -      msg  0     0     0     always 'op' tells 'msg' to 'npc'
stop    -      OP        -      -    0     0     0     no     thrown object 'op' is stopped
throw   op     ITEM      -      -    0     0     0     no     'op' throws 'item'
time    -      OP        -      -    0     0     0     no     'op' takes a turn
timer   OP     -         -      -    0     0     0     no     timer of 'op' has expired
trigger OP     item      -      msg  0     0     0     always 'op' writes 'msg' into 'item'
trigger TELEPORTER op    -      -    0     0     0     yes    'teleporter' moves 'op'
trigger TRAP  originator victim -    0     0     0     yes    'originator' causes 'victim' to trigger 'trap'

Notes:
- the object that contains the event script is written in capitals.
- result column: indicates how the result value set by SetReturnValue() is
  used: no=result value is not used; yes=non-zero result value prevents the
  normal action; always=prevents the normal action regardless of result value.
- apply event: aflag: Consult the crossfire source code for all available flags
  AP_*.
- death event: atype=attacktype
- trigger event: originator is unset if the trap (pedestal/button) someone left
  it.
- parm1..3 are not currently available to the script.
- attack event: 'item' can be a weapon or a missile.


The following table contains all global events.

event Activator WhoAmI Other Message  comment
----- --------- ------ ----- -------- --------------
born     op     -      -     -        new player 'op' was created
clock    -      -      -     -        called each tick
crash                                 (not implemented)
gdeath                                player 'op' dies (not implemented)
gkill                                 'hitter' kills 'op' (not implemented)
kick     op     -      -     name     player 'op' named 'name' is kicked out of the game
login    op     op     -     ip       player 'op' logged in from IP address 'ip'
logout   op     op     -     ip       player 'op' logged out from IP address 'ip'
mapenter op     -      -     -        player 'op' has entered a new map
mapleave op     -      -     -        player 'op' is leaving a map
mapreset -      -      -     mappath  map 'mappath' is resetting
muzzle   op     -      -     name     player 'op' named 'name' is muzzled
remove   op     -      -     -        player 'op' quits the game
shout    op     -      -     message  player 'op' shouts 'message'
tell                                  (not implemented)

Notes:
- kick event: param is either the player name or None if all players are
  kicked.
- login event: this event is also called when a new player was created.