File: python

package info (click to toggle)
crossfire 1.1.0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 11,776 kB
  • ctags: 5,507
  • sloc: ansic: 55,776; sh: 2,694; lex: 1,778; perl: 1,710; makefile: 1,518
file content (294 lines) | stat: -rw-r--r-- 5,365 bytes parent folder | download
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
THE PYTHON PLUGIN
=================

How do I hook a script to an object ?
-------------------------------------
Use the event_xxx to specify the script to use. The base directory for the
scripts is the map directory.
The option field is unused for now.
The plugin field should be "Python" of course.
You of course need to write some Python code too... You do as usual, but
remember to add an "import CFPython" to make all crossfire-specific functions
available in your scripts.

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/ 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.
Note to Scriptfire users: CFPython implements all the old Scriptfire functions.
Although the syntax of Python is quite different from Guile, it should not be a
problem to port your old code.

Last count (10/09/2001) result: 181 functions (not counting the various spells
and skills wrappers). 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;
object: A crossfire object. (In fact, it is a long).
string: A character string.

A
AcquireSpell(object who, int spellid)
  Makes "who" learn the spell identified by its spellid.
  Wrappers for all crossfire spellids are available under CFPython.
  Does not return a value.

ActivateRune(object who, object what)
  Makes "who" trigger the rune "what".
  Does not return a value.

Apply(object who, object what, int flags)
  Makes object "who" do a manual apply on object "what" with the specified
  flags. Consult the crossfire source code for all available flags.
  Return value: integer.

B
BlocksView(object who)
  Checks if "who" can block the line-of-sight.
  Return value: integer.

C
CastAbility(object who, int spellid, int direction, string options)
  Makes "who" casts a spell, identified by its id, into one direction and with
  eventually some options (like "create food booze"). The spell is cast as an
  ability and thus does not use any mana point.
  Does not return a value.

CheckTrigger(object who, object what)
  Makes "who" test trigger "what".
  Does not return a value.

CastSpell(object who, int spellid, int direction, string options)
  Makes "who" casts a spell, identified by its id, into one direction and with
  eventually some options (like "create food booze").
  Does not return a value.

CheckInvisibleInside(object who, string id)
  Checks for the existence of an invisible object named "id" inside object
  "who".
  Return value: The object found, if any.

CreateInvisibleInside()
CreateObjectInside()
CheckMap()
CheckInventory()
CreateObject()
CanSeeInvisible()
CanRoll()
CanPassThru()
CanPickUp()
CanCastSpell()
CanUseScroll()
CanUseWand()
CanUseBow()
CanUseArmour()
CanUseWeapon()
CanUseRing()
CanUseSkill()
CanUseRod()
CanUseHorn()
CanSeeInDark()

D
Drop()
DirectionN()
DirectionNE()
DirectionE()
DirectionSE()
DirectionS()
DirectionSW()
DirectionW()
DirectionNW()
DoKnowSpell()

E
F
FindPlayer()
FixObject()
ForgetSpell()

G
GetSkillExperience()
GetMapPath()
GetMapObject()
GetMessage()
GetGod()
GetWeight()
GetMap()
GetNextObject()
GetPreviousObject()
GetFirstObjectOnSquare()
GetQuantity()
GetExperience()
GetSpeed()
GetFood()
GetGrace()
GetReturnValue()
GetDirection()
GetLastSP()
GetLastGrace()
GetAttackType()
GetDamage()
GetName()
GetEventOptions()
GetEventPlugin()
GetType()
GetEventHandler()
GetIP()
GetInventory()
GetInternalName()
GetAC()
GetCha()
GetCon()
GetDex()
GetHP()
GetInt()
GetPow()
GetSP()
GetStr()
GetWis()
GetMaxHP()
GetMaxSP()
GetXPos()
GetYPos()

H
HitBack()
HasXRays()
HasStealth()
HasBeenApplied()

I
IsOutOfMap()
IsCanBePicked()
InsertObjectInside()
IsInvisible()
IsAlive()
IsWiz()
IsApplied()
IsUnpaid()
IsFlying()
IsMonster()
IsFriendly()
IsGenerator()
IsThrown()
IsTurnable()
IsUsedUp()
IsIdentified()
IsSplitting()
IsUndead()
IsScared()
IsUnaggressive()
IsOfType()
IsRunningAway()
IsUnique()
IsFloor()
IsLifeSaver()
IsSleeping()
IsConfused()
IsCursed()
IsDamned()
IsKnownMagical()
IsKnownCursed()
IsBlind()

J
K
KillObject()

L
LoadObject()

M
MatchString()
Message()
MakeInvisible()

N
O
OnlyAttack()

P
PickUp()

Q
R
ReadyMap()
ReflectMissiles()
ReflectSpells()
RemoveObject()
RegisterCommand()

S
SetQuantity()
SetName()
SetMessage()
SetSkillExperience()
SetCursed()
SetUnaggressive()
SetGod()
SetWeight()
Say()
SetInvisible()
SetSpeed()
SetFood()
SetGrace()
SetReturnValue()
SetDirection()
SetLastSP()
SetLastGrace()
SetFace()
SetAttackType()
SetDamage()
SetBeenApplied()
SetIdentified()
SaveObject()
SetEventHandler()
SetEventPlugin()
SetEventOptions()
SetPosition()
SetNickname()
SetAC()
SetCha()
SetCon()
SetDex()
SetHP()
SetInt()
SetMaxHP()
SetMaxSP()
SetPow()
SetSP()
SetStr()
SetWis()
StandStill()

T
Take()
Teleport()

U
V
W
WhoAmI()
WhoIsActivator()
WhatIsMessage()
Write()
WhoIsOther()
WasWiz()

X
Y
Z

Chachkoff Y.

yann.chachkoff@mailandnews.com