Crossfire Server  1.75.0
cfpython_object.cpp
Go to the documentation of this file.
1 /*****************************************************************************/
2 /* CFPython - A Python module for Crossfire RPG. */
3 /* Version: 2.0beta8 (also known as "Alexander") */
4 /* Contact: yann.chachkoff@myrealbox.com */
5 /*****************************************************************************/
6 /* That code is placed under the GNU General Public Licence (GPL) */
7 /* (C)2001-2005 by Chachkoff Yann (Feel free to deliver your complaints) */
8 /*****************************************************************************/
9 /* CrossFire, A Multiplayer game for X-windows */
10 /* */
11 /* Copyright (C) 2000 Mark Wedel */
12 /* Copyright (C) 1992 Frank Tore Johansen */
13 /* */
14 /* This program is free software; you can redistribute it and/or modify */
15 /* it under the terms of the GNU General Public License as published by */
16 /* the Free Software Foundation; either version 2 of the License, or */
17 /* (at your option) any later version. */
18 /* */
19 /* This program is distributed in the hope that it will be useful, */
20 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
21 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
22 /* GNU General Public License for more details. */
23 /* */
24 /* You should have received a copy of the GNU General Public License */
25 /* along with this program; if not, write to the Free Software */
26 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
27 /* */
28 /*****************************************************************************/
29 
30 #include <cfpython.h>
31 #include <map>
32 
33 #define EXISTCHECK(ob) { \
34  if (!ob || !ob->obj || (object_was_destroyed(ob->obj, ob->obj->count))) { \
35  PyErr_SetString(PyExc_ReferenceError, "Crossfire object no longer exists"); \
36  return NULL; \
37  } }
38 
44 #define TYPEEXISTCHECK(ob) { \
45  if (!ob || !PyObject_TypeCheck((PyObject*)ob, &Crossfire_ObjectType) || !ob->obj || (object_was_destroyed(ob->obj, ob->obj->count))) { \
46  PyErr_SetString(PyExc_ReferenceError, "Not a Crossfire object or Crossfire object no longer exists"); \
47  return NULL; \
48  } }
49 
50 #define EXISTCHECK_INT(ob) { \
51  if (!ob || !ob->obj || (object_was_destroyed(ob->obj, ob->obj->count))) { \
52  PyErr_SetString(PyExc_ReferenceError, "Crossfire object no longer exists"); \
53  return -1; \
54  } }
55 
56 /* Map for keeping track of which PyObject goes with with Crossfire object */
57 static std::map<object *, PyObject *> object_assoc_table;
58 
59 static void add_object_assoc(object *key, PyObject *value) {
60  object_assoc_table[key] = value;
61 }
62 
63 static PyObject *find_assoc_pyobject(object *key) {
64  auto f = object_assoc_table.find(key);
65  return f == object_assoc_table.end() ? nullptr : f->second;
66 }
67 
68 static void free_object_assoc(object *key) {
69  object_assoc_table.erase(key);
70 }
71 
72 static PyObject *Player_GetTitle(Crossfire_Object *whoptr, void *closure) {
73  char title[MAX_NAME];
74  (void)closure;
75  EXISTCHECK(whoptr);
76  return Py_BuildValue("s", cf_player_get_title(whoptr->obj, title, MAX_NAME));
77 }
78 
79 static int Player_SetTitle(Crossfire_Object *whoptr, PyObject *value, void *closure) {
80  char *val;
81  (void)closure;
82 
83  EXISTCHECK_INT(whoptr);
84  if (value == NULL) {
85  PyErr_SetString(PyExc_TypeError, "Cannot delete the Title attribute");
86  return -1;
87  }
88  if (!CF_IS_PYSTR(value)) {
89  PyErr_SetString(PyExc_TypeError, "The Title attribute must be a string");
90  return -1;
91  }
92  if (!PyArg_Parse(value, "s", &val))
93  return -1;
94 
95  cf_player_set_title(whoptr->obj, val);
96  return 0;
97 }
98 
99 static PyObject *Player_GetIP(Crossfire_Player *whoptr, void *closure) {
100  (void)closure;
101  EXISTCHECK(whoptr);
102  return Py_BuildValue("s", cf_player_get_ip(whoptr->obj));
103 }
104 
105 static PyObject *Player_GetMarkedItem(Crossfire_Player *whoptr, void *closure) {
106  (void)closure;
107  EXISTCHECK(whoptr);
109 }
110 
111 static int Player_SetMarkedItem(Crossfire_Player *whoptr, PyObject *value, void *closure) {
112  Crossfire_Object *ob;
113  (void)closure;
114 
115  EXISTCHECK_INT(whoptr);
116  if (value == Py_None)
117  cf_player_set_marked_item(whoptr->obj, NULL);
118  else if (!PyArg_Parse(value, "O!", &Crossfire_ObjectType, &ob))
119  return -1;
120  else
121  cf_player_set_marked_item(whoptr->obj, ob->obj);
122  return 0;
123 }
124 
125 static PyObject *Crossfire_Player_Message(Crossfire_Player *who, PyObject *args) {
126  char *message;
127  int color = NDI_UNIQUE|NDI_ORANGE;
128 
129  EXISTCHECK(who);
130  if (!PyArg_ParseTuple(args, "s|i", &message, &color))
131  return NULL;
132 
133  cf_player_message(who->obj, message, color);
134  Py_INCREF(Py_None);
135  return Py_None;
136 }
137 
138 static PyObject *Player_KnowledgeKnown(Crossfire_Player *who, PyObject *args) {
139  const char *knowledge;
140 
141  EXISTCHECK(who);
142  if (!PyArg_ParseTuple(args, "s", &knowledge))
143  return NULL;
144 
145  return Py_BuildValue("i", cf_player_knowledge_has(who->obj, knowledge));
146 }
147 
148 static PyObject *Player_GiveKnowledge(Crossfire_Player *who, PyObject *args) {
149  const char *knowledge;
150 
151  EXISTCHECK(who);
152  if (!PyArg_ParseTuple(args, "s", &knowledge))
153  return NULL;
154 
155  cf_player_knowledge_give(who->obj, knowledge);
156 
157  Py_INCREF(Py_None);
158  return Py_None;
159 }
160 
161 static PyObject *Player_GetParty(Crossfire_Player *whoptr, void *closure) {
162  (void)closure;
163  EXISTCHECK(whoptr);
165 }
166 
167 static int Player_SetParty(Crossfire_Player *whoptr, PyObject *value, void *closure) {
168  Crossfire_Party *ob;
169  (void)closure;
170 
171  EXISTCHECK_INT(whoptr);
172  if (!PyArg_Parse(value, "O!", &Crossfire_PartyType, &ob))
173  return -1;
174  cf_player_set_party(whoptr->obj, ob->party);
175  return 0;
176 }
177 
178 static PyObject *Crossfire_Player_CanPay(Crossfire_Player *who, PyObject *args) {
179  (void)args;
180  EXISTCHECK(who);
181  return Py_BuildValue("i", cf_player_can_pay(who->obj));
182 }
183 
184 static PyObject *Player_GetBedMap(Crossfire_Player *whoptr, void *closure) {
185  char bed[200];
186  (void)closure;
187 
188  EXISTCHECK(whoptr);
189  return Py_BuildValue("s", cf_object_get_string_property(whoptr->obj, CFAPI_PLAYER_PROP_BED_MAP, bed, sizeof(bed)));
190 }
191 
192 static int Player_SetBedMap(Crossfire_Player *whoptr, PyObject *value, void *closure) {
193  char *location;
194  (void)closure;
195 
196  EXISTCHECK_INT(whoptr);
197  if (!PyArg_Parse(value, "s", &location))
198  return -1;
200  return 0;
201 }
202 
203 static PyObject *Player_GetBedX(Crossfire_Player *whoptr, void *closure) {
204  (void)closure;
205  EXISTCHECK(whoptr);
206  return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_PLAYER_PROP_BED_X));
207 }
208 
209 static int Player_SetBedX(Crossfire_Player *whoptr, PyObject *value, void *closure) {
210  int x;
211  (void)closure;
212 
213  EXISTCHECK_INT(whoptr);
214  if (!PyArg_Parse(value, "i", &x))
215  return -1;
217  return 0;
218 }
219 
220 static PyObject *Player_GetBedY(Crossfire_Player *whoptr, void *closure) {
221  (void)closure;
222  EXISTCHECK(whoptr);
223  return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, CFAPI_PLAYER_PROP_BED_Y));
224 }
225 
226 static int Player_SetBedY(Crossfire_Player *whoptr, PyObject *value, void *closure) {
227  int y;
228  (void)closure;
229 
230  EXISTCHECK_INT(whoptr);
231  if (!PyArg_Parse(value, "i", &y))
232  return -1;
234  return 0;
235 }
236 
237 static PyObject *Player_QuestStart(Crossfire_Player *whoptr, PyObject *args) {
238  char *code;
239  int state;
240  sstring quest_code;
241 
242  EXISTCHECK(whoptr);
243  if (!PyArg_ParseTuple(args, "si", &code, &state))
244  return NULL;
245 
246  quest_code = cf_add_string(code);
247  cf_quest_start(whoptr->obj, quest_code, state);
248  cf_free_string(quest_code);
249 
250  Py_INCREF(Py_None);
251  return Py_None;
252 }
253 
254 static PyObject *Player_QuestGetState(Crossfire_Player *whoptr, PyObject *args) {
255  char *code;
256  int state;
257  sstring quest_code;
258 
259  EXISTCHECK(whoptr);
260  if (!PyArg_ParseTuple(args, "s", &code))
261  return NULL;
262 
263  quest_code = cf_add_string(code);
264  state = cf_quest_get_player_state(whoptr->obj, quest_code);
265  cf_free_string(quest_code);
266 
267  return Py_BuildValue("i", state);
268 }
269 
270 static PyObject *Player_QuestSetState(Crossfire_Player *whoptr, PyObject *args) {
271  char *code;
272  int state;
273  sstring quest_code;
274 
275  EXISTCHECK(whoptr);
276  if (!PyArg_ParseTuple(args, "si", &code, &state))
277  return NULL;
278 
279  quest_code = cf_add_string(code);
280  cf_quest_set_player_state(whoptr->obj, quest_code, state);
281  cf_free_string(quest_code);
282 
283  Py_INCREF(Py_None);
284  return Py_None;
285 }
286 
287 static PyObject *Player_QuestWasCompleted(Crossfire_Player *whoptr, PyObject *args) {
288  char *code;
289  int completed;
290  sstring quest_code;
291 
292  EXISTCHECK(whoptr);
293  if (!PyArg_ParseTuple(args, "s", &code))
294  return NULL;
295 
296  quest_code = cf_add_string(code);
297  completed = cf_quest_was_completed(whoptr->obj, quest_code);
298  cf_free_string(quest_code);
299 
300  return Py_BuildValue("i", completed);
301 }
302 
303 /* Object properties. Get and maybe set. */
304 static PyObject *Object_GetSStringProperty(Crossfire_Object *whoptr, void *closure) {
305  (void)closure;
306  EXISTCHECK(whoptr);
307  return Py_BuildValue("s", cf_object_get_sstring_property(whoptr->obj, (int)(intptr_t)closure));
308 }
309 
310 static PyObject *Object_GetIntProperty(Crossfire_Object *whoptr, void *closure) {
311  (void)closure;
312  EXISTCHECK(whoptr);
313  return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, (int)(intptr_t)closure));
314 }
315 
316 static PyObject *Object_GetFloatProperty(Crossfire_Object *whoptr, void *closure) {
317  (void)closure;
318  EXISTCHECK(whoptr);
319  return Py_BuildValue("f", cf_object_get_float_property(whoptr->obj, (int)(intptr_t)closure));
320 }
321 
322 static PyObject *Object_GetFlagProperty(Crossfire_Object *whoptr, void *closure) {
323  (void)closure;
324  EXISTCHECK(whoptr);
325  return Py_BuildValue("i", cf_object_get_flag(whoptr->obj, (int)(intptr_t)closure));
326 }
327 
328 static PyObject *Object_GetObjectProperty(Crossfire_Object *whoptr, void *closure) {
329  object *op;
330  (void)closure;
331 
332  EXISTCHECK(whoptr);
333  op = cf_object_get_object_property(whoptr->obj, (int)(intptr_t)closure);
334  return Crossfire_Object_wrap(op);
335 }
336 
337 static PyObject *Object_GetName(Crossfire_Object *whoptr, void *closure) {
338  char name[200];
339  (void)closure;
340 
341  EXISTCHECK(whoptr);
342  return Py_BuildValue("s", cf_query_name(whoptr->obj, name, sizeof(name)));
343 }
344 
345 static PyObject *Object_GetNamePl(Crossfire_Object *whoptr, void *closure) {
346  (void)closure;
347  EXISTCHECK(whoptr);
348  return Py_BuildValue("s", (char *)cf_query_name_pl(whoptr->obj));
349 }
350 
351 static PyObject *Object_GetMap(Crossfire_Object *whoptr, void *closure) {
352  mapstruct *m;
353  (void)closure;
354 
355  EXISTCHECK(whoptr);
357  return Crossfire_Map_wrap(m);
358 }
359 
360 static PyObject *Object_GetExp(Crossfire_Object *whoptr, void *closure) {
361  (void)closure;
362  EXISTCHECK(whoptr);
363  return Py_BuildValue("L", cf_object_get_int64_property(whoptr->obj, CFAPI_OBJECT_PROP_EXP));
364 }
365 
366 static PyObject *Object_GetTotalExp(Crossfire_Object *whoptr, void *closure) {
367  (void)closure;
368  EXISTCHECK(whoptr);
369  return Py_BuildValue("L", cf_object_get_int64_property(whoptr->obj, CFAPI_OBJECT_PROP_TOTAL_EXP));
370 }
371 
372 static PyObject *Object_GetExpMul(Crossfire_Object *whoptr, void *closure) {
373  (void)closure;
374  EXISTCHECK(whoptr);
375  return Py_BuildValue("d", cf_object_get_double_property(whoptr->obj, CFAPI_OBJECT_PROP_EXP_MULTIPLIER));
376 }
377 
378 static PyObject *Object_GetPickable(Crossfire_Object *whoptr, void *closure) {
379  (void)closure;
380  EXISTCHECK(whoptr);
381  return Py_BuildValue("i", !cf_object_get_flag(whoptr->obj, FLAG_NO_PICK));
382 }
383 
384 static PyObject *Object_GetMoney(Crossfire_Object *whoptr, void *closure) {
385  (void)closure;
386  EXISTCHECK(whoptr);
387  return Py_BuildValue("i", cf_object_query_money(whoptr->obj));
388 }
389 
390 static PyObject *Object_GetValue(Crossfire_Object *whoptr, void *closure) {
391  (void)closure;
392  EXISTCHECK(whoptr);
393  return Py_BuildValue("l", cf_object_get_long_property(whoptr->obj, CFAPI_OBJECT_PROP_VALUE));
394 }
395 
396 static PyObject *Object_GetArchetype(Crossfire_Object *whoptr, void *closure) {
397  (void)closure;
398  EXISTCHECK(whoptr);
400 }
401 
402 static PyObject *Object_GetOtherArchetype(Crossfire_Object *whoptr, void *closure) {
403  (void)closure;
404  EXISTCHECK(whoptr);
406 }
407 
408 static PyObject *Object_GetExists(Crossfire_Object *whoptr, void *closure) {
409  (void)closure;
410  if (!object_was_destroyed(whoptr->obj, whoptr->obj->count)) {
411  Py_INCREF(Py_True);
412  return Py_True;
413  } else {
414  Py_INCREF(Py_False);
415  return Py_False;
416  }
417 }
418 
419 static PyObject *Object_GetMoveType(Crossfire_Object *whoptr, void *closure) {
420  (void)closure;
421  EXISTCHECK(whoptr);
422  return Py_BuildValue("i", cf_object_get_movetype_property(whoptr->obj, CFAPI_OBJECT_PROP_MOVE_TYPE));
423 }
424 
425 static PyObject *Object_GetMoveBlock(Crossfire_Object *whoptr, void *closure) {
426  (void)closure;
427  EXISTCHECK(whoptr);
428  return Py_BuildValue("i", cf_object_get_movetype_property(whoptr->obj, CFAPI_OBJECT_PROP_MOVE_BLOCK));
429 }
430 
431 static PyObject *Object_GetMoveAllow(Crossfire_Object *whoptr, void *closure) {
432  (void)closure;
433  EXISTCHECK(whoptr);
434  return Py_BuildValue("i", cf_object_get_movetype_property(whoptr->obj, CFAPI_OBJECT_PROP_MOVE_ALLOW));
435 }
436 
437 static PyObject *Object_GetMoveOn(Crossfire_Object *whoptr, void *closure) {
438  (void)closure;
439  EXISTCHECK(whoptr);
440  return Py_BuildValue("i", cf_object_get_movetype_property(whoptr->obj, CFAPI_OBJECT_PROP_MOVE_ON));
441 }
442 
443 static PyObject *Object_GetMoveOff(Crossfire_Object *whoptr, void *closure) {
444  (void)closure;
445  EXISTCHECK(whoptr);
446  return Py_BuildValue("i", cf_object_get_movetype_property(whoptr->obj, CFAPI_OBJECT_PROP_MOVE_OFF));
447 }
448 
449 static PyObject *Object_GetMoveSlow(Crossfire_Object *whoptr, void *closure) {
450  (void)closure;
451  EXISTCHECK(whoptr);
452  return Py_BuildValue("i", cf_object_get_movetype_property(whoptr->obj, CFAPI_OBJECT_PROP_MOVE_SLOW));
453 }
454 
455 static PyObject *Object_GetMaterial(Crossfire_Object *whoptr, void *closure) {
456  (void)closure;
457  EXISTCHECK(whoptr);
458  return Py_BuildValue("{s:s,s:i}", "Name", cf_object_get_sstring_property(whoptr->obj, CFAPI_OBJECT_PROP_MATERIAL_NAME), "Number", cf_object_get_int_property(whoptr->obj, CFAPI_OBJECT_PROP_MATERIAL));
459 }
460 
462 static int Object_SetStringProperty(Crossfire_Object *whoptr, PyObject *value, void *closure) {
463  char *val;
464 
465  EXISTCHECK_INT(whoptr);
466  if (value == NULL) {
467  PyErr_SetString(PyExc_TypeError, "Cannot delete the attribute");
468  return -1;
469  }
470  if (!CF_IS_PYSTR(value)) {
471  PyErr_SetString(PyExc_TypeError, "The attribute must be a string");
472  return -1;
473  }
474  if (!PyArg_Parse(value, "s", &val))
475  return -1;
476 
477  cf_object_set_string_property(whoptr->obj, (int)(intptr_t)closure, val);
478  return 0;
479 }
480 
481 static int Object_SetIntProperty(Crossfire_Object *whoptr, PyObject *value, void *closure) {
482  int val;
483 
484  EXISTCHECK_INT(whoptr);
485  if (!PyArg_Parse(value, "i", &val))
486  return -1;
487 
488  cf_object_set_int_property(whoptr->obj, (int)(intptr_t)closure, val);
489  return 0;
490 }
491 
492 static int Object_SetFloatProperty(Crossfire_Object *whoptr, PyObject *value, void *closure) {
493  float val;
494 
495  EXISTCHECK_INT(whoptr);
496  if (!PyArg_Parse(value, "f", &val))
497  return -1;
498 
499  cf_object_set_float_property(whoptr->obj, (int)(intptr_t)closure, val);
500  return 0;
501 }
502 
503 static int Object_SetFlagProperty(Crossfire_Object *whoptr, PyObject *value, void *closure) {
504  int val;
505 
506  EXISTCHECK_INT(whoptr);
507  if (!PyArg_Parse(value, "i", &val))
508  return -1;
509 
510  cf_object_set_flag(whoptr->obj, (int)(intptr_t)closure, val);
511  return 0;
512 }
513 
514 static int Object_SetName(Crossfire_Object *whoptr, PyObject *value, void *closure) {
515  char *val;
516  (void)closure;
517 
518  EXISTCHECK_INT(whoptr);
519  if (value == NULL) {
520  PyErr_SetString(PyExc_TypeError, "Cannot delete the Name attribute");
521  return -1;
522  }
523  if (!CF_IS_PYSTR(value)) {
524  PyErr_SetString(PyExc_TypeError, "The Name attribute must be a string");
525  return -1;
526  }
527  if (!PyArg_Parse(value, "s", &val))
528  return -1;
529 
532  return 0;
533 }
534 
535 static int Object_SetNamePl(Crossfire_Object *whoptr, PyObject *value, void *closure) {
536  char *val;
537  (void)closure;
538 
539  EXISTCHECK_INT(whoptr);
540  if (value == NULL) {
541  PyErr_SetString(PyExc_TypeError, "Cannot delete the NamePl attribute");
542  return -1;
543  }
544  if (!CF_IS_PYSTR(value)) {
545  PyErr_SetString(PyExc_TypeError, "The NamePl attribute must be a string");
546  return -1;
547  }
548  if (!PyArg_Parse(value, "s", &val))
549  return -1;
550 
552  return 0;
553 }
554 
555 static int Object_SetPickable(Crossfire_Object *whoptr, PyObject *value, void *closure) {
556  int val;
557  (void)closure;
558 
559  EXISTCHECK_INT(whoptr);
560  if (!PyArg_Parse(value, "i", &val))
561  return -1;
562 
563  cf_object_set_flag(whoptr->obj, FLAG_NO_PICK, !val);
564  return 0;
565 }
566 
567 static int Object_SetMap(Crossfire_Object *whoptr, PyObject *value, void *closure) {
568  Crossfire_Map *val;
569  (void)closure;
570 
571  EXISTCHECK_INT(whoptr);
572  if (!PyArg_Parse(value, "O!", &Crossfire_MapType, &val))
573  return -1;
574 
575  cf_object_change_map(whoptr->obj, val->map, NULL, 0, -1, -1);
576  return 0;
577 }
578 
579 static int Object_SetQuantity(Crossfire_Object *whoptr, PyObject *value, void *closure) {
580  int val;
581  (void)closure;
582 
583  EXISTCHECK_INT(whoptr);
584  if (!PyArg_Parse(value, "i", &val))
585  return -1;
586 
587  if (cf_object_set_nrof(whoptr->obj, val) != 0) {
588  PyErr_SetString(PyExc_TypeError, "Invalid quantity");
589  return -1;
590  }
591 
592 /* cf_fix_object(whoptr->obj);*/
593  return 0;
594 }
595 
596 static int Object_SetFace(Crossfire_Object *whoptr, PyObject *value, void *closure) {
597  char *face;
598  (void)closure;
599 
600  EXISTCHECK_INT(whoptr);
601  if (!PyArg_Parse(value, "s", &face))
602  return -1;
603 
604  if (!cf_object_set_face(whoptr->obj, face)) {
605  PyErr_SetString(PyExc_TypeError, "Unknown face.");
606  return -1;
607  }
608  return 0;
609 }
610 
611 static int Object_SetAnim(Crossfire_Object *whoptr, PyObject *value, void *closure) {
612  char *anim;
613  (void)closure;
614 
615  EXISTCHECK_INT(whoptr);
616  if (!PyArg_Parse(value, "s", &anim))
617  return -1;
618 
619  if (!cf_object_set_animation(whoptr->obj, anim)) {
620  PyErr_SetString(PyExc_TypeError, "Unknown animation.");
621  return -1;
622  }
623 
624  return 0;
625 }
626 
627 static int Object_SetValue(Crossfire_Object *whoptr, PyObject *value, void *closure) {
628  long val;
629  (void)closure;
630 
631  EXISTCHECK_INT(whoptr);
632  if (!PyArg_Parse(value, "l", &val))
633  return -1;
634 
636  return 0;
637 }
638 
639 static int Object_SetOwner(Crossfire_Object *whoptr, PyObject *value, void *closure) {
640  Crossfire_Object *ob;
641  (void)closure;
642 
643  EXISTCHECK_INT(whoptr);
644  if (!PyArg_Parse(value, "O!", &Crossfire_ObjectType, &ob))
645  return -1;
647  return 0;
648 }
649 
650 static int Object_SetEnemy(Crossfire_Object *whoptr, PyObject *value, void *closure) {
651  Crossfire_Object *ob;
652  (void)closure;
653 
654  EXISTCHECK_INT(whoptr);
655  if (!PyArg_Parse(value, "O!", &Crossfire_ObjectType, &ob))
656  return -1;
658  return 0;
659 }
660 
661 static int Object_SetExp(Crossfire_Object *whoptr, PyObject *value, void *closure) {
662  int64_t val;
663  (void)closure;
664 
665  EXISTCHECK_INT(whoptr);
666  if (!PyArg_Parse(value, "L", &val))
667  return -1;
668 
670  return 0;
671 }
672 
673 static int Object_SetMoveType(Crossfire_Object *whoptr, PyObject *value, void *closure) {
674  MoveType move;
675  (void)closure;
676 
677  EXISTCHECK_INT(whoptr);
678  if (!PyArg_Parse(value, "B", &move))
679  return -1;
681  return 0;
682 }
683 
684 static int Object_SetMoveBlock(Crossfire_Object *whoptr, PyObject *value, void *closure) {
685  MoveType move;
686  (void)closure;
687 
688  EXISTCHECK_INT(whoptr);
689  if (!PyArg_Parse(value, "B", &move))
690  return -1;
692  return 0;
693 }
694 
695 static int Object_SetMoveAllow(Crossfire_Object *whoptr, PyObject *value, void *closure) {
696  MoveType move;
697  (void)closure;
698 
699  EXISTCHECK_INT(whoptr);
700  if (!PyArg_Parse(value, "B", &move))
701  return -1;
703  return 0;
704 }
705 
706 static int Object_SetMoveOn(Crossfire_Object *whoptr, PyObject *value, void *closure) {
707  MoveType move;
708  (void)closure;
709 
710  EXISTCHECK_INT(whoptr);
711  if (!PyArg_Parse(value, "B", &move))
712  return -1;
714  return 0;
715 }
716 
717 static int Object_SetMoveOff(Crossfire_Object *whoptr, PyObject *value, void *closure) {
718  MoveType move;
719  (void)closure;
720 
721  EXISTCHECK_INT(whoptr);
722  if (!PyArg_Parse(value, "B", &move))
723  return -1;
725  return 0;
726 }
727 
728 static int Object_SetMoveSlow(Crossfire_Object *whoptr, PyObject *value, void *closure) {
729  MoveType move;
730  (void)closure;
731 
732  EXISTCHECK_INT(whoptr);
733  if (!PyArg_Parse(value, "B", &move))
734  return -1;
736  return 0;
737 }
738 
739 /* Methods. */
740 
741 static PyObject *Crossfire_Object_Remove(Crossfire_Object *who, PyObject *args) {
742  (void)args;
743  EXISTCHECK(who);
744 
745  if ((current_context->who != NULL) && (((Crossfire_Object *)current_context->who)->obj == who->obj))
746  current_context->who = NULL;
747 
748  if (!cf_object_get_flag(who->obj, FLAG_REMOVED)) {
749  cf_object_remove(who->obj);
750  }
751 
753  Py_INCREF(Py_None);
754  return Py_None;
755 }
756 
757 static PyObject *Crossfire_Object_Apply(Crossfire_Object *who, PyObject *args) {
758  Crossfire_Object *whoptr;
759  int flags;
760 
761  if (!PyArg_ParseTuple(args, "O!i", &Crossfire_ObjectType, &whoptr, &flags))
762  return NULL;
763  EXISTCHECK(who);
764  EXISTCHECK(whoptr);
765 
766  return Py_BuildValue("i", cf_object_apply(whoptr->obj, who->obj, flags));
767 }
768 
769 static PyObject *Crossfire_Object_Drop(Crossfire_Object *who, PyObject *args) {
770  /* Note that this function uses the METH_O calling convention. */
771  Crossfire_Object *whoptr = (Crossfire_Object*)args;
772 
773  EXISTCHECK(who);
774  TYPEEXISTCHECK(whoptr);
775 
776  cf_object_drop(whoptr->obj, who->obj);
777  Py_INCREF(Py_None);
778  return Py_None;
779 }
780 
781 static PyObject *Crossfire_Object_Clone(Crossfire_Object *who, PyObject *args) {
782  int clone_type;
783  object *clone;
784 
785  if (!PyArg_ParseTuple(args, "i", &clone_type))
786  return NULL;
787 
788  if (clone_type != 0 && clone_type != 1)
789  {
790  PyErr_SetString(PyExc_ValueError, "Clone type must be 0 (object_create_clone) or 1 (object_copy).");
791  return NULL;
792  }
793 
794  clone = cf_object_clone(who->obj, clone_type);
795 
796  if (clone == NULL)
797  {
798  PyErr_SetString(PyExc_RuntimeError, "Clone failed.");
799  return NULL;
800  }
801 
802  return Crossfire_Object_wrap(clone);
803 }
804 
805 static PyObject *Crossfire_Object_Split(Crossfire_Object *who, PyObject *args) {
806  int count;
807  char err[255];
808  object *split;
809 
810  err[0] = '\0'; /* Just in case. */
811 
812  if (!PyArg_ParseTuple(args, "i", &count))
813  return NULL;
814 
815  split = cf_object_split(who->obj, count, err, 255);
816 
817  if (split == NULL)
818  {
819  PyErr_SetString(PyExc_ValueError, err);
820  return NULL;
821  }
822 
823  return Crossfire_Object_wrap(split);
824 }
825 
826 static PyObject *Crossfire_Object_Fix(Crossfire_Object *who, PyObject *args) {
827  (void)args;
828  cf_fix_object(who->obj);
829  Py_INCREF(Py_None);
830  return Py_None;
831 }
832 
833 static PyObject *Crossfire_Object_Take(Crossfire_Object *who, PyObject *args) {
834  /* Note that this function uses the METH_O calling convention. */
835  Crossfire_Object *whoptr = (Crossfire_Object*)args;
836 
837  EXISTCHECK(who);
838  TYPEEXISTCHECK(whoptr);
839 
840  int val = cf_object_pickup(who->obj, whoptr->obj);
841  if (val)
842  Py_RETURN_TRUE;
843  Py_RETURN_FALSE;
844 }
845 
846 static PyObject *Crossfire_Object_Teleport(Crossfire_Object *who, PyObject *args) {
847  Crossfire_Map *where;
848  int x, y;
849  int val;
850 
851  EXISTCHECK(who);
852  if (!PyArg_ParseTuple(args, "O!ii", &Crossfire_MapType, &where, &x, &y))
853  return NULL;
854 
855  val = cf_object_teleport(who->obj, where->map, x, y);
856 
857  return Py_BuildValue("i", val);
858 }
859 
860 static PyObject *Crossfire_Object_ActivateRune(Crossfire_Object *who, PyObject *args) {
861  /* Note that this function uses the METH_O calling convention. */
862  object *trap;
863  object *victim;
864  Crossfire_Object *pcause = (Crossfire_Object*)args;
865 
866  EXISTCHECK(who);
867  TYPEEXISTCHECK(pcause);
868  trap = who->obj;
869  victim = pcause->obj;
870  cf_spring_trap(trap, victim);
871  Py_INCREF(Py_None);
872  return Py_None;
873 }
874 
875 static PyObject *Crossfire_Object_CheckTrigger(Crossfire_Object *who, PyObject *args) {
876  /* Note that this function uses the METH_O calling convention. */
877  object *trigger;
878  object *cause;
879  int result;
880  Crossfire_Object *pcause = (Crossfire_Object*)args;
881 
882  EXISTCHECK(who);
883  TYPEEXISTCHECK(pcause);
884  trigger = who->obj;
885  cause = pcause->obj;
886  result = cf_object_check_trigger(trigger, cause);
887 
888  return Py_BuildValue("i", result);
889 }
890 
891 static PyObject *Crossfire_Object_Say(Crossfire_Object *who, PyObject *args) {
892  char *message, buf[2048];
893 
894  EXISTCHECK(who);
895  if (!PyArg_ParseTuple(args, "s", &message))
896  return NULL;
897 
898  /* compatibility */
899  if (current_context->talk == NULL) {
900  cf_object_say(who->obj, message);
901  Py_INCREF(Py_None);
902  return Py_None;
903  }
904 
906  PyErr_SetString(PyExc_ValueError, "too many NPCs");
907  return NULL;
908  }
909 
910  if (strlen(message) >= sizeof(buf) - 1)
911  cf_log(llevError, "warning, too long message in npcSay, will be truncated");
913  snprintf(buf, sizeof(buf), "%s says: %s", who->obj->name, message);
914 
917 
918  Py_INCREF(Py_None);
919  return Py_None;
920 
921 }
922 
923 static PyObject *Crossfire_Object_Reposition(Crossfire_Object *who, PyObject *args) {
924  int x, y;
925 
926  EXISTCHECK(who);
927  if (!PyArg_ParseTuple(args, "ii", &x, &y))
928  return NULL;
929 
930  cf_object_transfer(who->obj, x, y, 0, NULL);
931  Py_INCREF(Py_None);
932  return Py_None;
933 }
934 
935 static PyObject *Crossfire_Object_QueryName(Crossfire_Object *who, PyObject *args) {
936  char name[200];
937  (void)args;
938 
939  EXISTCHECK(who);
940  return Py_BuildValue("s", cf_query_name(who->obj, name, sizeof(name)));
941 }
942 
943 static PyObject *Crossfire_Object_GetResist(Crossfire_Object *who, PyObject *args) {
944  int resist;
945 
946  EXISTCHECK(who);
947  if (!PyArg_ParseTuple(args, "i", &resist))
948  return NULL;
949  if ((resist < 0) || (resist >= NROFATTACKS)) {
950  return Py_BuildValue("l", 0);
951  }
952  return Py_BuildValue("i", cf_object_get_resistance(who->obj, resist));
953 }
954 
955 static PyObject *Crossfire_Object_SetResist(Crossfire_Object *who, PyObject *args) {
956  int resist, value;
957 
958  EXISTCHECK(who);
959  if (!PyArg_ParseTuple(args, "ii", &resist, &value))
960  return NULL;
961  if ((resist >= 0) && (resist < NROFATTACKS))
962  cf_object_set_resistance(who->obj, resist, value);
963  Py_INCREF(Py_None);
964  return Py_None;
965 }
966 
967 static PyObject *Crossfire_Object_Cast(Crossfire_Object *who, PyObject *args) {
968  int dir;
969  char *op;
970  Crossfire_Object *pspell;
971 
972  if (!PyArg_ParseTuple(args, "O!is", &Crossfire_ObjectType, &pspell, &dir, &op))
973  return NULL;
974  EXISTCHECK(who);
975  EXISTCHECK(pspell);
976 
977  cf_object_cast_spell(who->obj, who->obj, dir, pspell->obj, op);
978 
979  Py_INCREF(Py_None);
980  return Py_None;
981 }
982 
983 static PyObject *Crossfire_Object_LearnSpell(Crossfire_Object *who, PyObject *args) {
984  /* Note that this function uses the METH_O calling convention. */
985  Crossfire_Object *pspell = (Crossfire_Object*)args;
986 
987  EXISTCHECK(who);
988  TYPEEXISTCHECK(pspell);
989 
990  cf_object_learn_spell(who->obj, pspell->obj, 0);
991 
992  Py_INCREF(Py_None);
993  return Py_None;
994 }
995 
996 static PyObject *Crossfire_Object_ForgetSpell(Crossfire_Object *who, PyObject *args) {
997  /* Note that this function uses the METH_O calling convention. */
998  Crossfire_Object *pspell = (Crossfire_Object*)args;
999 
1000  EXISTCHECK(who);
1001  TYPEEXISTCHECK(pspell);
1002 
1003  cf_object_forget_spell(who->obj, pspell->obj);
1004  Py_INCREF(Py_None);
1005  return Py_None;
1006 }
1007 
1008 static PyObject *Crossfire_Object_KnowSpell(Crossfire_Object *who, PyObject *args) {
1009  char *spellname;
1010  object *op;
1011 
1012  EXISTCHECK(who);
1013  if (!PyArg_ParseTuple(args, "s", &spellname))
1014  return NULL;
1015 
1016  op = cf_object_check_for_spell(who->obj, spellname);
1017 
1018  return Crossfire_Object_wrap(op);
1019 }
1020 
1021 static PyObject *Crossfire_Object_CastAbility(Crossfire_Object *who, PyObject *args) {
1022  Crossfire_Object *pspell;
1023  int dir;
1024  char *str;
1025 
1026  if (!PyArg_ParseTuple(args, "O!is", &Crossfire_ObjectType, &pspell, &dir, &str))
1027  return NULL;
1028  EXISTCHECK(who);
1029  EXISTCHECK(pspell);
1030 
1031  cf_log_plain(llevError, "CastAbility is deprecated and will be removed, use 'Cast'.\n");
1032  cf_object_cast_spell(who->obj, who->obj, dir, pspell->obj, str);
1033 
1034  Py_INCREF(Py_None);
1035  return Py_None;
1036 }
1037 
1038 static PyObject *Crossfire_Object_PayAmount(Crossfire_Object *who, PyObject *args) {
1039  uint64_t to_pay;
1040  int val;
1041 
1042  EXISTCHECK(who);
1043  if (!PyArg_ParseTuple(args, "L", &to_pay))
1044  return NULL;
1045 
1046  val = cf_object_pay_amount(who->obj, to_pay);
1047 
1048  return Py_BuildValue("i", val);
1049 }
1050 
1051 static PyObject *Crossfire_Object_Pay(Crossfire_Object *who, PyObject *args) {
1052  /* Note that this function uses the METH_O calling convention. */
1053  Crossfire_Object *op = (Crossfire_Object*)args;
1054  int val;
1055 
1056  EXISTCHECK(who);
1057  TYPEEXISTCHECK(op);
1058 
1059  val = cf_object_pay_item(who->obj, op->obj);
1060 
1061  return Py_BuildValue("i", val);
1062 }
1063 
1064 static PyObject *Crossfire_Object_ReadKey(Crossfire_Object *who, PyObject *args) {
1065  const char *val;
1066  char *keyname;
1067 
1068  EXISTCHECK(who);
1069  if (!PyArg_ParseTuple(args, "s", &keyname))
1070  return NULL;
1071 
1072  val = cf_object_get_key(who->obj, keyname);
1073 
1074  return Py_BuildValue("s", val ? val : "");
1075 }
1076 
1077 static PyObject *Crossfire_Object_WriteKey(Crossfire_Object *who, PyObject *args) {
1078  char *keyname;
1079  char *value;
1080  int add_key = 0;
1081 
1082  EXISTCHECK(who);
1083  if (!PyArg_ParseTuple(args, "sz|i", &keyname, &value, &add_key))
1084  return NULL;
1085 
1086  return Py_BuildValue("i", cf_object_set_key(who->obj, keyname, value, add_key));
1087 }
1088 
1089 static PyObject *Crossfire_Object_CreateTimer(Crossfire_Object *who, PyObject *args) {
1090  int mode;
1091  long delay;
1092 
1093  EXISTCHECK(who);
1094  if (!PyArg_ParseTuple(args, "li", &delay, &mode))
1095  return NULL;
1096 
1097  return Py_BuildValue("i", cf_timer_create(who->obj, delay, mode));
1098 }
1099 
1100 static PyObject *Crossfire_Object_CheckInventory(Crossfire_Object *who, PyObject *args) {
1101  char *whatstr;
1102  object *foundob;
1103 
1104  EXISTCHECK(who);
1105  if (!PyArg_ParseTuple(args, "s", &whatstr))
1106  return NULL;
1107 
1108  foundob = cf_object_present_archname_inside(who->obj, whatstr);
1109 
1110  return Crossfire_Object_wrap(foundob);
1111 /* FOR_INV_PREPARE(WHO, tmp) {
1112  if (!strncmp(PyQueryName(tmp), whatstr, strlen(whatstr))) {
1113  return Py_BuildValue("l", (long)(tmp));
1114  }
1115  if (!strncmp(tmp->name, whatstr, strlen(whatstr))) {
1116  return Py_BuildValue("l", (long)(tmp));
1117  }
1118  } FOR_INV_FINISH();
1119 
1120  return Py_BuildValue("l", (long)0);*/
1121 }
1122 
1123 static PyObject *Crossfire_Object_CheckArchInventory(Crossfire_Object *who, PyObject *args) {
1124  char *whatstr;
1125  object *tmp;
1126 
1127  EXISTCHECK(who);
1128  if (!PyArg_ParseTuple(args, "s", &whatstr))
1129  return NULL;
1130 
1131  tmp = cf_object_find_by_arch_name(who->obj, whatstr);
1132  return Crossfire_Object_wrap(tmp);
1133 }
1134 
1135 static PyObject *Crossfire_Object_GetOutOfMap(Crossfire_Object *who, PyObject *args) {
1136  int x, y;
1137 
1138  EXISTCHECK(who);
1139  if (!PyArg_ParseTuple(args, "ii", &x, &y))
1140  return NULL;
1141 
1142  return Py_BuildValue("i", cf_object_out_of_map(who->obj, x, y));
1143 }
1144 
1145 static PyObject *Crossfire_Object_CreateInside(Crossfire_Object *who, PyObject *args) {
1146  char *txt;
1147  object *myob;
1148 
1149  EXISTCHECK(who);
1150  if (!PyArg_ParseTuple(args, "s", &txt))
1151  return NULL;
1152 
1153  myob = cf_create_object_by_name(txt);
1154  if (myob)
1155  myob = cf_object_insert_object(myob, who->obj);
1156 
1157  return Crossfire_Object_wrap(myob);
1158 }
1159 
1160 static PyObject *Crossfire_Object_InsertInto(Crossfire_Object *who, PyObject *args) {
1161  /* Note that this function uses the METH_O calling convention. */
1162  Crossfire_Object *op = (Crossfire_Object*)args;
1163  object *myob;
1164 
1165  EXISTCHECK(who);
1166  TYPEEXISTCHECK(op);
1167 
1168  /* we can only insert removed object, so first remove it
1169  * from it's current container
1170  */
1171  if (!cf_object_get_flag(who->obj, FLAG_REMOVED)) {
1172  cf_object_remove(who->obj);
1173  }
1174  myob = cf_object_insert_in_ob(who->obj, op->obj);
1175 
1176  return Crossfire_Object_wrap(myob);
1177 }
1178 
1179 static PyObject *Crossfire_Object_ChangeAbil(Crossfire_Object *who, PyObject *args) {
1180  /* Note that this function uses the METH_O calling convention. */
1181  Crossfire_Object *op = (Crossfire_Object*)args;
1182 
1183  EXISTCHECK(who);
1184  TYPEEXISTCHECK(op);
1185 
1186  return Py_BuildValue("i", cf_object_change_abil(who->obj, op->obj));
1187 }
1188 
1189 static PyObject *Crossfire_Object_AddExp(Crossfire_Object *who, PyObject *args) {
1190  int64_t exp;
1191  const char *skill = NULL;
1192  int arg = 0;
1193 
1194  if (!PyArg_ParseTuple(args, "L|si", &exp, &skill, &arg))
1195  return NULL;
1196  EXISTCHECK(who);
1197  cf_object_change_exp(who->obj, exp, skill, arg);
1198  Py_INCREF(Py_None);
1199  return Py_None;
1200 }
1201 
1202 static PyObject *Crossfire_Object_PermExp(Crossfire_Object *who, PyObject *args) {
1203  (void)args;
1204  EXISTCHECK(who);
1205  return Py_BuildValue("L", cf_object_perm_exp(who->obj));
1206 }
1207 
1208 static PyObject *Crossfire_Object_Move(Crossfire_Object *who, PyObject *args) {
1209  int dir;
1210 
1211  if (!PyArg_ParseTuple(args, "i", &dir))
1212  return NULL;
1213  EXISTCHECK(who);
1214  return Py_BuildValue("i", cf_object_move(who->obj, dir, who->obj));
1215 }
1216 
1217 static PyObject *Crossfire_Object_MoveTo(Crossfire_Object *who, PyObject *args) {
1218  int x,y;
1219 
1220  if (!PyArg_ParseTuple(args, "ii", &x, &y))
1221  return NULL;
1222  EXISTCHECK(who);
1223  return Py_BuildValue("i", cf_object_move_to(who->obj, x, y));
1224 }
1225 
1226 static PyObject *Crossfire_Object_Event(Crossfire_Object *who, PyObject *args) {
1227  int fix;
1228  const char *message = NULL;
1229  object *op1 = NULL;
1230  object *op2 = NULL;
1231  object *op3 = NULL;
1232  Crossfire_Object *activator = NULL;
1233  Crossfire_Object *third = NULL;
1234 
1235  if (!PyArg_ParseTuple(args, "O!O!si", &Crossfire_ObjectType, &activator, &Crossfire_ObjectType, &third, &message, &fix))
1236  return NULL;
1237  EXISTCHECK(who);
1238  EXISTCHECK(activator);
1239  EXISTCHECK(third);
1240  op1 = who->obj;
1241  op2 = activator->obj;
1242  op3 = third->obj;
1243  return Py_BuildValue("i", cf_object_user_event(op1, op2, op3, message, fix));
1244 }
1245 
1246 static PyObject *Crossfire_Object_RemoveDepletion(Crossfire_Object *who, PyObject *args) {
1247  int level;
1248 
1249  if (!PyArg_ParseTuple(args, "i", &level))
1250  return NULL;
1251  EXISTCHECK(who);
1252 
1253  return Py_BuildValue("i", cf_object_remove_depletion(who->obj, level));
1254 }
1255 
1256 static PyObject *Crossfire_Object_Arrest(Crossfire_Object *who, PyObject *args) {
1257  (void)args;
1258  EXISTCHECK(who);
1259  return Py_BuildValue("i", cf_player_arrest(who->obj));
1260 }
1261 
1263  EXISTCHECK_INT(left);
1264  EXISTCHECK_INT(right);
1265  return (left->obj < right->obj ? -1 : (left->obj == right->obj ? 0 : 1));
1266 }
1267 
1268 static PyObject *Crossfire_Object_RichCompare(Crossfire_Object *left, Crossfire_Object *right, int op) {
1269  int result;
1270  if (!left
1271  || !right
1272  || !PyObject_TypeCheck((PyObject*)left, &Crossfire_ObjectType)
1273  || !PyObject_TypeCheck((PyObject*)right, &Crossfire_ObjectType)) {
1274  Py_INCREF(Py_NotImplemented);
1275  return Py_NotImplemented;
1276  }
1277  result = Crossfire_Object_InternalCompare(left, right);
1278  /* Handle removed objects. */
1279  if (result == -1 && PyErr_Occurred())
1280  return NULL;
1281  /* Based on how Python 3.0 (GPL compatible) implements it for internal types: */
1282  switch (op) {
1283  case Py_EQ:
1284  result = (result == 0);
1285  break;
1286  case Py_NE:
1287  result = (result != 0);
1288  break;
1289  case Py_LE:
1290  result = (result <= 0);
1291  break;
1292  case Py_GE:
1293  result = (result >= 0);
1294  break;
1295  case Py_LT:
1296  result = (result == -1);
1297  break;
1298  case Py_GT:
1299  result = (result == 1);
1300  break;
1301  }
1302  return PyBool_FromLong(result);
1303 }
1304 
1305 /* Legacy code: convert to long so that non-object functions work correctly */
1306 static PyObject *Crossfire_Object_Long(PyObject *obj) {
1307  return Py_BuildValue("l", ((Crossfire_Object *)obj)->obj);
1308 }
1309 
1310 /* Python binding */
1311 static PyGetSetDef Object_getseters[] = {
1312  { "Name", (getter)Object_GetName, (setter)Object_SetName, NULL, NULL },
1313  { "NamePl", (getter)Object_GetNamePl, (setter)Object_SetNamePl, NULL, NULL },
1314  { "NameSingular", (getter)Object_GetSStringProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_RAW_NAME },
1315  { "Title", (getter)Object_GetSStringProperty, (setter)Object_SetStringProperty, NULL, (void*)CFAPI_OBJECT_PROP_TITLE },
1316  { "Race", (getter)Object_GetSStringProperty, (setter)Object_SetStringProperty, NULL, (void*)CFAPI_OBJECT_PROP_RACE },
1317  { "Skill", (getter)Object_GetSStringProperty, (setter)Object_SetStringProperty, NULL, (void*)CFAPI_OBJECT_PROP_SKILL },
1318  { "Map", (getter)Object_GetMap, (setter)Object_SetMap, NULL, NULL },
1319  { "Cha", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_CHA },
1320  { "Con", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_CON },
1321  { "Dex", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_DEX },
1322  { "Int", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_INT },
1323  { "Pow", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_POW },
1324  { "Str", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_STR },
1325  { "Wis", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_WIS },
1326  { "HP", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_HP },
1327  { "MaxHP", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_MAXHP },
1328  { "SP", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_SP },
1329  { "MaxSP", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_MAXSP },
1330  { "Grace", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_GP },
1331  { "MaxGrace", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_MAXGP },
1332  { "Food", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_FP },
1333  { "AC", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_AC },
1334  { "WC", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_WC },
1335  { "Dam", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_DAM },
1336  { "Luck", (getter)Object_GetIntProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_LUCK },
1337  { "Exp", (getter)Object_GetExp, (setter)Object_SetExp, NULL, NULL },
1338  { "ExpMul", (getter)Object_GetExpMul, NULL, NULL, NULL },
1339  { "TotalExp", (getter)Object_GetTotalExp, NULL, NULL, NULL },
1340  { "Message", (getter)Object_GetSStringProperty, (setter)Object_SetStringProperty, NULL, (void*)CFAPI_OBJECT_PROP_MESSAGE },
1341  { "Slaying", (getter)Object_GetSStringProperty, (setter)Object_SetStringProperty, NULL, (void*)CFAPI_OBJECT_PROP_SLAYING },
1342  { "Cursed", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_CURSED },
1343  { "Damned", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_DAMNED },
1344  { "Weight", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_WEIGHT },
1345  { "WeightLimit", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_WEIGHT_LIMIT },
1346  { "Above", (getter)Object_GetObjectProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_OB_ABOVE },
1347  { "Below", (getter)Object_GetObjectProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_OB_BELOW },
1348  { "Inventory", (getter)Object_GetObjectProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_INVENTORY },
1349  { "X", (getter)Object_GetIntProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_X },
1350  { "Y", (getter)Object_GetIntProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_Y },
1351  { "Direction", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_DIRECTION },
1352  { "Facing", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_FACING },
1353  { "Unaggressive", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_UNAGGRESSIVE },
1354  { "God", (getter)Object_GetSStringProperty, (setter)Object_SetFlagProperty, NULL, (void*)CFAPI_OBJECT_PROP_GOD },
1355  { "Pickable", (getter)Object_GetPickable, (setter)Object_SetPickable, NULL, NULL },
1356  { "Quantity", (getter)Object_GetIntProperty, (setter)Object_SetQuantity, NULL, (void*)CFAPI_OBJECT_PROP_NROF },
1357  { "Invisible", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_INVISIBLE },
1358  { "Speed", (getter)Object_GetFloatProperty, (setter)Object_SetFloatProperty, NULL, (void*)CFAPI_OBJECT_PROP_SPEED },
1359  { "SpeedLeft", (getter)Object_GetFloatProperty, (setter)Object_SetFloatProperty, NULL, (void*)CFAPI_OBJECT_PROP_SPEED_LEFT },
1360  { "LastSP", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_LAST_SP },
1361  { "LastGrace", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_LAST_GRACE },
1362  { "LastEat", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_LAST_EAT },
1363  { "Level", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_LEVEL },
1364  { "Face", (getter)Object_GetSStringProperty, (setter)Object_SetFace, NULL, (void*)CFAPI_OBJECT_PROP_FACE },
1365  { "Anim", (getter)Object_GetSStringProperty, (setter)Object_SetAnim, NULL, (void*)CFAPI_OBJECT_PROP_ANIMATION },
1366  { "AnimSpeed", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_ANIM_SPEED },
1367  { "AttackType", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_ATTACK_TYPE },
1368  { "BeenApplied", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_BEEN_APPLIED },
1369  { "Identified", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_IDENTIFIED },
1370  { "Alive", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_ALIVE },
1371  { "DungeonMaster", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_WIZ },
1372  { "WasDungeonMaster", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_WAS_WIZ },
1373  { "Applied", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_APPLIED },
1374  { "Unpaid", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_UNPAID },
1375  { "Monster", (getter)Object_GetFlagProperty, NULL, NULL, (void*)FLAG_MONSTER },
1376  { "Friendly", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_FRIENDLY },
1377  { "Generator", (getter)Object_GetFlagProperty, NULL, NULL, (void*)FLAG_GENERATOR },
1378  { "Thrown", (getter)Object_GetFlagProperty, NULL, NULL, (void*)FLAG_IS_THROWN },
1379  { "CanSeeInvisible", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_SEE_INVISIBLE },
1380  { "Rollable", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_CAN_ROLL },
1381  { "Turnable", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_IS_TURNABLE },
1382  { "UsedUp", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_IS_USED_UP },
1383  { "Splitting", (getter)Object_GetFlagProperty, NULL, NULL, (void*)FLAG_SPLITTING },
1384  { "Blind", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_BLIND },
1385  { "CanUseSkill", (getter)Object_GetFlagProperty, NULL, NULL, (void*)FLAG_CAN_USE_SKILL },
1386  { "KnownCursed", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_KNOWN_CURSED },
1387  { "Stealthy", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_STEALTH },
1388  { "Confused", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_CONFUSED },
1389  { "Sleeping", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_SLEEP },
1390  { "Lifesaver", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_LIFESAVE },
1391  { "Floor", (getter)Object_GetFlagProperty, NULL, NULL, (void*)FLAG_IS_FLOOR },
1392  { "HasXRays", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_XRAYS },
1393  { "CanUseRing", (getter)Object_GetFlagProperty, NULL, NULL, (void*)FLAG_USE_RING },
1394  { "CanUseBow", (getter)Object_GetFlagProperty, NULL, NULL, (void*)FLAG_USE_BOW },
1395  { "CanUseWand", (getter)Object_GetFlagProperty, NULL, NULL, (void*)FLAG_USE_RANGE },
1396  { "CanSeeInDark", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_SEE_IN_DARK },
1397  { "KnownMagical", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_KNOWN_MAGICAL },
1398  { "CanUseWeapon", (getter)Object_GetFlagProperty, NULL, NULL, (void*)FLAG_USE_WEAPON },
1399  { "CanUseArmour", (getter)Object_GetFlagProperty, NULL, NULL, (void*)FLAG_USE_ARMOUR },
1400  { "CanUseScroll", (getter)Object_GetFlagProperty, NULL, NULL, (void*)FLAG_USE_SCROLL },
1401  { "CanCastSpell", (getter)Object_GetFlagProperty, NULL, NULL, (void*)FLAG_CAST_SPELL },
1402  { "ReflectSpells", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_REFL_SPELL },
1403  { "ReflectMissiles", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_REFL_MISSILE },
1404  { "Unique", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_UNIQUE },
1405  { "RunAway", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_RUN_AWAY },
1406  { "Scared", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_SCARED },
1407  { "Undead", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_UNDEAD },
1408  { "BlocksView", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_BLOCKSVIEW },
1409  { "HitBack", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_HITBACK },
1410  { "StandStill", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_STAND_STILL },
1411  { "OnlyAttack", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_ONLY_ATTACK },
1412  { "MakeInvisible", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_MAKE_INVIS },
1413  { "Money", (getter)Object_GetMoney, NULL, NULL, NULL },
1414  { "Type", (getter)Object_GetIntProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_TYPE },
1415  { "Subtype", (getter)Object_GetIntProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_SUBTYPE },
1416  { "Value", (getter)Object_GetValue, (setter)Object_SetValue, NULL, NULL },
1417  { "ArchName", (getter)Object_GetSStringProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_ARCH_NAME },
1418  { "Archetype", (getter)Object_GetArchetype, NULL, NULL, NULL },
1419  { "OtherArchetype", (getter)Object_GetOtherArchetype,NULL, NULL, NULL },
1420  { "Exists", (getter)Object_GetExists, NULL, NULL, NULL },
1421  { "NoSave", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_NO_SAVE },
1422  { "Env", (getter)Object_GetObjectProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_ENVIRONMENT },
1423  { "MoveType", (getter)Object_GetMoveType, (setter)Object_SetMoveType, NULL, NULL },
1424  { "MoveBlock", (getter)Object_GetMoveBlock, (setter)Object_SetMoveBlock, NULL, NULL },
1425  { "MoveAllow", (getter)Object_GetMoveAllow, (setter)Object_SetMoveAllow, NULL, NULL },
1426  { "MoveOn", (getter)Object_GetMoveOn, (setter)Object_SetMoveOn, NULL, NULL },
1427  { "MoveOff", (getter)Object_GetMoveOff, (setter)Object_SetMoveOff, NULL, NULL },
1428  { "MoveSlow", (getter)Object_GetMoveSlow, (setter)Object_SetMoveSlow, NULL, NULL },
1429  { "MoveSlowPenalty", (getter)Object_GetFloatProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY },
1430  { "Owner", (getter)Object_GetObjectProperty, (setter)Object_SetOwner, NULL, (void*)CFAPI_OBJECT_PROP_OWNER },
1431  { "Enemy", (getter)Object_GetObjectProperty, (setter)Object_SetEnemy, NULL, (void*)CFAPI_OBJECT_PROP_ENEMY },
1432  { "Count", (getter)Object_GetIntProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_COUNT },
1433  { "GodGiven", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_STARTEQUIP },
1434  { "IsPet", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_FRIENDLY },
1435  { "AttackMovement", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_ATTACK_MOVEMENT },
1436  { "Duration", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_DURATION },
1437  { "GlowRadius", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_GLOW_RADIUS },
1438  { "Animated", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_ANIMATE },
1439  { "NoDamage", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_NO_DAMAGE },
1440  { "RandomMovement", (getter)Object_GetFlagProperty, (setter)Object_SetFlagProperty, NULL, (void*)FLAG_RANDOM_MOVE },
1441  { "Material", (getter)Object_GetMaterial, NULL, NULL, NULL },
1442  { "Container", (getter)Object_GetObjectProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_CONTAINER },
1443  { "ItemPower", (getter)Object_GetIntProperty, (setter)Object_SetIntProperty, NULL, (void*)CFAPI_OBJECT_PROP_ITEM_POWER },
1444  { "CurrentWeapon", (getter)Object_GetObjectProperty, NULL, NULL, (void*)CFAPI_OBJECT_PROP_CURRENT_WEAPON },
1445  { NULL, NULL, NULL, NULL, NULL }
1446 };
1447 
1448 static PyMethodDef ObjectMethods[] = {
1449  { "Remove", (PyCFunction)Crossfire_Object_Remove, METH_NOARGS, NULL },
1450  { "Apply", (PyCFunction)Crossfire_Object_Apply, METH_VARARGS, NULL },
1451  { "Drop", (PyCFunction)Crossfire_Object_Drop, METH_O, NULL },
1452  { "Clone", (PyCFunction)Crossfire_Object_Clone, METH_VARARGS, NULL },
1453  { "Split", (PyCFunction)Crossfire_Object_Split, METH_VARARGS, NULL },
1454  { "Fix", (PyCFunction)Crossfire_Object_Fix, METH_NOARGS, NULL },
1455  { "Say", (PyCFunction)Crossfire_Object_Say, METH_VARARGS, NULL },
1456  { "Speak", (PyCFunction)Crossfire_Object_Say, METH_VARARGS, NULL },
1457  { "Take", (PyCFunction)Crossfire_Object_Take, METH_O, NULL },
1458  { "Teleport", (PyCFunction)Crossfire_Object_Teleport, METH_VARARGS, NULL },
1459  { "Reposition", (PyCFunction)Crossfire_Object_Reposition, METH_VARARGS, NULL },
1460  { "QueryName", (PyCFunction)Crossfire_Object_QueryName, METH_NOARGS, NULL },
1461  { "GetResist", (PyCFunction)Crossfire_Object_GetResist, METH_VARARGS, NULL },
1462  { "SetResist", (PyCFunction)Crossfire_Object_SetResist, METH_VARARGS, NULL },
1463  { "ActivateRune", (PyCFunction)Crossfire_Object_ActivateRune, METH_O, NULL },
1464  { "CheckTrigger", (PyCFunction)Crossfire_Object_CheckTrigger, METH_O, NULL },
1465  { "Cast", (PyCFunction)Crossfire_Object_Cast, METH_VARARGS, NULL },
1466  { "LearnSpell", (PyCFunction)Crossfire_Object_LearnSpell, METH_O, NULL },
1467  { "ForgetSpell", (PyCFunction)Crossfire_Object_ForgetSpell, METH_O, NULL },
1468  { "KnowSpell", (PyCFunction)Crossfire_Object_KnowSpell, METH_VARARGS, NULL },
1469  { "CastAbility", (PyCFunction)Crossfire_Object_CastAbility, METH_VARARGS, NULL },
1470  { "PayAmount", (PyCFunction)Crossfire_Object_PayAmount, METH_VARARGS, NULL },
1471  { "Pay", (PyCFunction)Crossfire_Object_Pay, METH_O, NULL },
1472  { "CheckInventory", (PyCFunction)Crossfire_Object_CheckInventory, METH_VARARGS, NULL },
1473  { "CheckArchInventory", (PyCFunction)Crossfire_Object_CheckArchInventory, METH_VARARGS, NULL },
1474  { "OutOfMap", (PyCFunction)Crossfire_Object_GetOutOfMap, METH_VARARGS, NULL },
1475  { "CreateObject", (PyCFunction)Crossfire_Object_CreateInside, METH_VARARGS, NULL },
1476  { "InsertInto", (PyCFunction)Crossfire_Object_InsertInto, METH_O, NULL },
1477  { "ReadKey", (PyCFunction)Crossfire_Object_ReadKey, METH_VARARGS, NULL },
1478  { "WriteKey", (PyCFunction)Crossfire_Object_WriteKey, METH_VARARGS, NULL },
1479  { "CreateTimer", (PyCFunction)Crossfire_Object_CreateTimer, METH_VARARGS, NULL },
1480  { "AddExp", (PyCFunction)Crossfire_Object_AddExp, METH_VARARGS, NULL },
1481  { "Move", (PyCFunction)Crossfire_Object_Move, METH_VARARGS, NULL },
1482  { "MoveTo", (PyCFunction)Crossfire_Object_MoveTo, METH_VARARGS, NULL },
1483  { "ChangeAbil", (PyCFunction)Crossfire_Object_ChangeAbil, METH_O, NULL },
1484  { "Event", (PyCFunction)Crossfire_Object_Event, METH_VARARGS, NULL },
1485  { "RemoveDepletion",(PyCFunction)Crossfire_Object_RemoveDepletion, METH_VARARGS, NULL },
1486  { "Arrest", (PyCFunction)Crossfire_Object_Arrest, METH_VARARGS, NULL },
1487  { "PermExp", (PyCFunction)Crossfire_Object_PermExp, METH_NOARGS, NULL },
1488  { NULL, NULL, 0, NULL }
1489 };
1490 
1492 
1493 static PyObject *Crossfire_Object_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
1494  Crossfire_Object *self;
1495  (void)args;
1496  (void)kwds;
1497 
1498  self = (Crossfire_Object *)type->tp_alloc(type, 0);
1499  if (self) {
1500  self->obj = NULL;
1501  self->count = 0;
1502  }
1503 
1504  return (PyObject *)self;
1505 }
1506 
1507 static void Crossfire_Object_dealloc(PyObject *obj) {
1508  Crossfire_Object *self;
1509 
1510  self = (Crossfire_Object *)obj;
1511  if (self) {
1512  if (self->obj) {
1513  free_object_assoc(self->obj);
1514  }
1515  Py_TYPE(self)->tp_free(obj);
1516  }
1517 }
1518 
1519 static PyObject *Crossfire_Player_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
1520  Crossfire_Player *self;
1521  (void)args;
1522  (void)kwds;
1523 
1524  self = (Crossfire_Player *)type->tp_alloc(type, 0);
1525  if (self) {
1526  self->obj = NULL;
1527  self->count = 0;
1528  }
1529 
1530  return (PyObject *)self;
1531 }
1532 
1533 static void Crossfire_Player_dealloc(PyObject *obj) {
1534  Crossfire_Player *self;
1535 
1536  self = (Crossfire_Player *)obj;
1537  if (self) {
1538  if (self->obj) {
1539  free_object_assoc(self->obj);
1540  }
1541  Py_TYPE(self)->tp_free(obj);
1542  }
1543 }
1544 
1545 static PyObject *Player_GetIntProperty(Crossfire_Player *whoptr, void *closure) {
1546  (void)closure;
1547  EXISTCHECK(whoptr);
1548  return Py_BuildValue("i", cf_object_get_int_property(whoptr->obj, (int)(intptr_t)closure));
1549 }
1550 
1551 static PyObject *Player_GetObjectProperty(Crossfire_Player *whoptr, void *closure) {
1552  EXISTCHECK(whoptr);
1553  object *ob = cf_object_get_object_property(whoptr->obj, (int)(intptr_t)closure);
1554  return Crossfire_Object_wrap(ob);
1555 }
1556 
1557 /* Our actual Python ObjectType */
1558 CF_PYTHON_OBJECT(Object,
1560  &ObjectConvert,
1561  PyObject_HashNotImplemented,
1562  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
1563  "Crossfire objects",
1564  (richcmpfunc) Crossfire_Object_RichCompare,
1565  ObjectMethods,
1567  NULL,
1569  );
1570 
1571 static PyGetSetDef Player_getseters[] = {
1572  { "CmdCount", (getter)Player_GetIntProperty,NULL, NULL, (void*)CFAPI_PLAYER_PROP_COUNT},
1573  { "Title", (getter)Player_GetTitle, (setter)Player_SetTitle, NULL, NULL },
1574  { "IP", (getter)Player_GetIP, NULL, NULL, NULL },
1575  { "MarkedItem", (getter)Player_GetMarkedItem, (setter)Player_SetMarkedItem, NULL, NULL },
1576  { "Party", (getter)Player_GetParty, (setter)Player_SetParty, NULL, NULL },
1577  { "BedMap", (getter)Player_GetBedMap, (setter)Player_SetBedMap, NULL, NULL },
1578  { "BedX", (getter)Player_GetBedX, (setter)Player_SetBedX, NULL, NULL },
1579  { "BedY", (getter)Player_GetBedY, (setter)Player_SetBedY, NULL, NULL },
1580  { "Transport", (getter)Player_GetObjectProperty,NULL, NULL, (void*)CFAPI_PLAYER_PROP_TRANSPORT},
1581  { NULL, NULL, NULL, NULL, NULL }
1582 };
1583 
1584 static PyMethodDef PlayerMethods[] = {
1585  { "Message", (PyCFunction)Crossfire_Player_Message, METH_VARARGS, NULL },
1586  { "Write", (PyCFunction)Crossfire_Player_Message, METH_VARARGS, NULL },
1587  { "CanPay", (PyCFunction)Crossfire_Player_CanPay, METH_NOARGS, NULL },
1588  { "QuestStart", (PyCFunction)Player_QuestStart, METH_VARARGS, NULL },
1589  { "QuestGetState", (PyCFunction)Player_QuestGetState, METH_VARARGS, NULL },
1590  { "QuestSetState", (PyCFunction)Player_QuestSetState, METH_VARARGS, NULL },
1591  { "QuestWasCompleted", (PyCFunction)Player_QuestWasCompleted, METH_VARARGS, NULL },
1592  { "KnowledgeKnown", (PyCFunction)Player_KnowledgeKnown, METH_VARARGS, NULL },
1593  { "GiveKnowledge", (PyCFunction)Player_GiveKnowledge, METH_VARARGS, NULL },
1594  { NULL, NULL, 0, NULL }
1595 };
1596 
1597 /* Our actual Python ObjectPlayerType */
1598 CF_PYTHON_OBJECT(Player,
1600  NULL,
1601  NULL,
1602  Py_TPFLAGS_DEFAULT,
1603  "Crossfire player",
1604  NULL,
1605  PlayerMethods,
1609  );
1610 
1614 PyObject *Crossfire_Object_wrap(object *what) {
1615  Crossfire_Object *wrapper;
1616  Crossfire_Player *plwrap;
1617  PyObject *pyobj;
1618 
1619  /* return None if no object was to be wrapped */
1620  if (what == NULL) {
1621  Py_INCREF(Py_None);
1622  return Py_None;
1623  }
1624 
1625  pyobj = find_assoc_pyobject(what);
1626  if ((!pyobj) || (object_was_destroyed(((Crossfire_Object *)pyobj)->obj, ((Crossfire_Object *)pyobj)->count))) {
1627  if (what->type == PLAYER) {
1628  plwrap = PyObject_NEW(Crossfire_Player, &Crossfire_PlayerType);
1629  if (plwrap != NULL) {
1630  plwrap->obj = what;
1631  plwrap->count = what->count;
1632  }
1633  pyobj = (PyObject *)plwrap;
1634  } else {
1635  wrapper = PyObject_NEW(Crossfire_Object, &Crossfire_ObjectType);
1636  if (wrapper != NULL) {
1637  wrapper->obj = what;
1638  wrapper->count = what->count;
1639  }
1640  pyobj = (PyObject *)wrapper;
1641  }
1642  add_object_assoc(what, pyobj);
1643  } else {
1644  Py_INCREF(pyobj);
1645  }
1646  return pyobj;
1647 }
#define CFAPI_OBJECT_PROP_STR
Definition: plugin.h:197
#define CFAPI_OBJECT_PROP_MAP
Definition: plugin.h:128
static PyObject * Crossfire_Object_Cast(Crossfire_Object *who, PyObject *args)
Error, serious thing.
Definition: logger.h:11
int cf_object_set_nrof(object *, int nrof)
#define CFAPI_PLAYER_PROP_TRANSPORT
Definition: plugin.h:238
CF_PYTHON_NUMBER_METHODS(Object, Crossfire_Object_Long)
static PyObject * Object_GetIntProperty(Crossfire_Object *whoptr, void *closure)
static PyObject * Crossfire_Object_Apply(Crossfire_Object *who, PyObject *args)
static PyObject * Object_GetMoveAllow(Crossfire_Object *whoptr, void *closure)
#define FLAG_SEE_IN_DARK
if set ob not effected by darkness
Definition: define.h:325
long cf_object_get_long_property(object *op, long propcode)
#define CFAPI_OBJECT_PROP_MATERIAL
Definition: plugin.h:153
void cf_object_free_drop_inventory(object *ob)
Wrapper for object_free_drop_inventory().
#define CFAPI_OBJECT_PROP_ANIMATION
Definition: plugin.h:218
#define FLAG_DAMNED
The object is very cursed.
Definition: define.h:305
#define FLAG_UNPAID
Object hasn&#39;t been paid for yet.
Definition: define.h:223
int npc_msg_count
How many NPCs reacted to the text being said.
Definition: dialog.h:58
static int Object_SetPickable(Crossfire_Object *whoptr, PyObject *value, void *closure)
#define CFAPI_OBJECT_PROP_SP
Definition: plugin.h:207
PyObject_HEAD object * obj
static PyObject * Object_GetObjectProperty(Crossfire_Object *whoptr, void *closure)
static PyObject * Crossfire_Object_Arrest(Crossfire_Object *who, PyObject *args)
#define CFAPI_OBJECT_PROP_NAME
Definition: plugin.h:130
static PyObject * Object_GetOtherArchetype(Crossfire_Object *whoptr, void *closure)
static PyObject * Player_GetTitle(Crossfire_Object *whoptr, void *closure)
#define CFAPI_OBJECT_PROP_OB_BELOW
Definition: plugin.h:121
int cf_player_knowledge_has(object *op, const char *knowledge)
Wrapper for knowledge_player_has().
static void Crossfire_Player_dealloc(PyObject *obj)
object * cf_object_change_map(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Wrapper for object_insert_in_map_at().
static PyObject * Crossfire_Object_LearnSpell(Crossfire_Object *who, PyObject *args)
#define CFAPI_OBJECT_PROP_RACE
Definition: plugin.h:133
static int Object_SetMoveType(Crossfire_Object *whoptr, PyObject *value, void *closure)
#define FLAG_SLEEP
NPC is sleeping.
Definition: define.h:295
static int Player_SetBedX(Crossfire_Player *whoptr, PyObject *value, void *closure)
void cf_spring_trap(object *trap, object *victim)
Wrapper for spring_trap().
static PyObject * Player_QuestSetState(Crossfire_Player *whoptr, PyObject *args)
#define FLAG_HITBACK
Object will hit back when hit.
Definition: define.h:254
#define CFAPI_OBJECT_PROP_WEIGHT
Definition: plugin.h:166
#define CFAPI_OBJECT_PROP_ARCHETYPE
Definition: plugin.h:181
#define CFAPI_OBJECT_PROP_ATTACK_TYPE
Definition: plugin.h:149
void cf_free_string(sstring str)
Wrapper for free_string().
#define FLAG_USE_SCROLL
(Monster) can read scroll
Definition: define.h:279
static int Object_SetMoveAllow(Crossfire_Object *whoptr, PyObject *value, void *closure)
#define CFAPI_OBJECT_PROP_FACE
Definition: plugin.h:217
static PyObject * Player_GetParty(Crossfire_Player *whoptr, void *closure)
static int Object_SetFloatProperty(Crossfire_Object *whoptr, PyObject *value, void *closure)
const char * cf_object_get_key(object *op, const char *keyname)
Gets value for specified key, equivalent of object_get_value().
static PyObject * Object_GetPickable(Crossfire_Object *whoptr, void *closure)
#define CFAPI_OBJECT_PROP_GOD
Definition: plugin.h:214
static PyObject * Crossfire_Object_ForgetSpell(Crossfire_Object *who, PyObject *args)
PyObject_HEAD partylist * party
#define CFAPI_OBJECT_PROP_DIRECTION
Definition: plugin.h:143
#define FLAG_USE_ARMOUR
(Monster) can wear armour/shield/helmet
Definition: define.h:283
static PyObject * Object_GetExists(Crossfire_Object *whoptr, void *closure)
#define FLAG_STAND_STILL
NPC will not (ever) move.
Definition: define.h:296
void cf_object_set_flag(object *ob, int flag, int value)
static std::vector< std::string > split(const std::string &field, const std::string &by)
Definition: mapper.cpp:2734
int cf_object_set_animation(object *op, const char *animation)
Set the object&#39;s animation.
static PyObject * Crossfire_Object_Remove(Crossfire_Object *who, PyObject *args)
#define CFAPI_OBJECT_PROP_MAXGP
Definition: plugin.h:212
#define NDI_ORANGE
Definition: newclient.h:250
static PyObject * Object_GetNamePl(Crossfire_Object *whoptr, void *closure)
PyObject * Crossfire_Map_wrap(mapstruct *what)
#define FLAG_FRIENDLY
Will help players.
Definition: define.h:233
#define FLAG_IS_FLOOR
Can&#39;t see what&#39;s underneath this object.
Definition: define.h:290
static int Player_SetParty(Crossfire_Player *whoptr, PyObject *value, void *closure)
PyTypeObject Crossfire_MapType
static PyObject * Crossfire_Object_ActivateRune(Crossfire_Object *who, PyObject *args)
static int Crossfire_Object_InternalCompare(Crossfire_Object *left, Crossfire_Object *right)
object * cf_object_insert_in_ob(object *op, object *where)
Wrapper for object_insert_in_ob().
partylist * cf_player_get_party(object *op)
int level
Definition: readable.cpp:1561
#define CFAPI_OBJECT_PROP_SUBTYPE
Definition: plugin.h:146
void cf_object_set_resistance(object *op, int rtype, int16_t value)
int16_t cf_object_get_resistance(object *op, int rtype)
#define CFAPI_OBJECT_PROP_CONTAINER
Definition: plugin.h:127
static PyObject * Player_GetObjectProperty(Crossfire_Player *whoptr, void *closure)
#define CFAPI_OBJECT_PROP_INVENTORY
Definition: plugin.h:124
static PyObject * Object_GetMoney(Crossfire_Object *whoptr, void *closure)
static int Object_SetNamePl(Crossfire_Object *whoptr, PyObject *value, void *closure)
static PyObject * Player_GetIntProperty(Crossfire_Player *whoptr, void *closure)
#define FLAG_BLIND
If set, object cannot see (visually)
Definition: define.h:324
static PyObject * Crossfire_Object_Say(Crossfire_Object *who, PyObject *args)
#define CFAPI_OBJECT_PROP_NAME_PLURAL
Definition: plugin.h:131
static int Object_SetAnim(Crossfire_Object *whoptr, PyObject *value, void *closure)
static PyObject * Crossfire_Object_ReadKey(Crossfire_Object *who, PyObject *args)
PyObject * Crossfire_Archetype_wrap(archetype *what)
int cf_object_pay_item(object *op, object *pl)
Wrapper for pay_for_item().
#define FLAG_CONFUSED
Will also be unable to cast spells.
Definition: define.h:299
#define FLAG_STEALTH
Will wake monsters with less range.
Definition: define.h:300
static PyObject * Object_GetArchetype(Crossfire_Object *whoptr, void *closure)
unsigned char MoveType
Typdef here to define type large enough to hold bitmask of all movement types.
Definition: define.h:424
#define FLAG_RANDOM_MOVE
NPC will move randomly.
Definition: define.h:297
#define CFAPI_OBJECT_PROP_OWNER
Definition: plugin.h:191
#define FLAG_USE_WEAPON
(Monster) can wield weapons
Definition: define.h:284
#define CFAPI_OBJECT_PROP_MOVE_ON
Definition: plugin.h:223
static PyObject * Player_QuestWasCompleted(Crossfire_Player *whoptr, PyObject *args)
#define CFAPI_OBJECT_PROP_MESSAGE
Definition: plugin.h:136
static int Object_SetName(Crossfire_Object *whoptr, PyObject *value, void *closure)
#define CFAPI_OBJECT_PROP_EXP_MULTIPLIER
Definition: plugin.h:180
static PyObject * Crossfire_Object_SetResist(Crossfire_Object *who, PyObject *args)
void cf_fix_object(object *op)
Wrapper for fix_object().
int cf_object_remove_depletion(object *op, int level)
Wrapper for remove_depletion().
PyObject * Crossfire_Object_wrap(object *what)
Python initialized.
#define object_was_destroyed(op, old_tag)
Checks if an object still exists.
Definition: object.h:70
int cf_player_arrest(object *who)
Wrapper for player_arrest().
static PyObject * Crossfire_Object_RichCompare(Crossfire_Object *left, Crossfire_Object *right, int op)
static PyObject * Crossfire_Object_CreateInside(Crossfire_Object *who, PyObject *args)
int cf_object_set_face(object *op, const char *face)
Set the object&#39;s face.
static PyObject * Object_GetSStringProperty(Crossfire_Object *whoptr, void *closure)
static PyObject * Object_GetExp(Crossfire_Object *whoptr, void *closure)
object * cf_player_get_marked_item(object *op)
char * cf_object_get_string_property(object *op, int propcode, char *buf, int size)
PyTypeObject Crossfire_PlayerType
void cf_player_knowledge_give(object *op, const char *knowledge)
Wrapper for knowledge_give();.
sstring cf_add_string(const char *str)
Wrapper for add_string().
#define CFAPI_OBJECT_PROP_SLAYING
Definition: plugin.h:134
int cf_object_get_int_property(object *op, int propcode)
int64_t cf_object_perm_exp(object *op)
Wrapper for PERM_EXP macro.
static PyObject * Crossfire_Object_CreateTimer(Crossfire_Object *who, PyObject *args)
#define FLAG_USE_RING
(Monster) can use rings, boots, gauntlets, etc
Definition: define.h:285
static PyObject * Player_KnowledgeKnown(Crossfire_Player *who, PyObject *args)
PyObject * who
Definition: cfpython.h:96
static PyObject * Object_GetMoveType(Crossfire_Object *whoptr, void *closure)
static void add_object_assoc(object *key, PyObject *value)
#define CFAPI_OBJECT_PROP_OTHER_ARCH
Definition: plugin.h:182
#define CFAPI_OBJECT_PROP_LAST_SP
Definition: plugin.h:159
#define FLAG_REMOVED
Object is not in any map or invenory.
Definition: define.h:219
#define CFAPI_OBJECT_PROP_LAST_GRACE
Definition: plugin.h:160
int cf_object_transfer(object *op, int x, int y, int randomly, object *originator)
Wrapper for transfer_ob().
void cf_object_forget_spell(object *op, object *sp)
Wrapper for do_forget_spell(), except takes an object, not a string.
#define CFAPI_OBJECT_PROP_COUNT
Definition: plugin.h:129
#define FLAG_CAN_ROLL
Object can be rolled.
Definition: define.h:241
static int Object_SetMoveOff(Crossfire_Object *whoptr, PyObject *value, void *closure)
#define FLAG_KNOWN_MAGICAL
The object is known to be magical.
Definition: define.h:307
void cf_log(LogLevel logLevel, const char *format,...)
Wrapper for LOG().
float cf_object_get_float_property(object *op, int propcode)
void cf_object_learn_spell(object *op, object *spell, int special_prayer)
Wrapper for do_learn_spell().
#define FLAG_IS_USED_UP
When (–food<0) the object will exit.
Definition: define.h:247
#define NROFATTACKS
Definition: attack.h:15
#define MOVE_ALL
Mask of all movement types.
Definition: define.h:404
int cf_object_check_trigger(object *op, object *cause)
Wrapper for check_trigger().
void cf_quest_start(object *pl, sstring quest_code, int state)
Wrapper for quest_start().
#define FLAG_SEE_INVISIBLE
Will see invisible player.
Definition: define.h:240
sstring cf_object_get_sstring_property(object *op, int propcode)
void cf_log_plain(LogLevel logLevel, const char *message)
Wrapper for LOG() that uses directly a buffer, without format.
static PyObject * Object_GetMoveOff(Crossfire_Object *whoptr, void *closure)
#define FLAG_UNDEAD
Monster is undead.
Definition: define.h:257
void cf_object_say(object *op, const char *msg)
#define CFAPI_PLAYER_PROP_BED_X
Definition: plugin.h:234
#define EXISTCHECK(ob)
void cf_quest_set_player_state(object *pl, sstring quest_code, int state)
Wrapper for quest_set_player_state();.
static PyObject * Crossfire_Object_QueryName(Crossfire_Object *who, PyObject *args)
MoveType cf_object_get_movetype_property(object *op, int propcode)
void cf_player_set_marked_item(object *op, object *ob)
static PyObject * Object_GetMaterial(Crossfire_Object *whoptr, void *closure)
int cf_player_can_pay(object *op)
Wrapper for can_pay().
PyObject_HEAD object * obj
#define CFAPI_OBJECT_PROP_FACING
Definition: plugin.h:144
#define TYPEEXISTCHECK(ob)
This is meant to be used for parameters where you don&#39;t know if the type of the object is correct...
static PyObject * Player_GetBedX(Crossfire_Player *whoptr, void *closure)
static void free_object_assoc(object *key)
PyObject * Crossfire_Party_wrap(partylist *what)
static PyObject * Crossfire_Object_CheckInventory(Crossfire_Object *who, PyObject *args)
int cf_timer_create(object *ob, long delay, int mode)
Creates a timer, equivalent of calling cftimer_create().
#define FLAG_ALIVE
Object can fight (or be fought)
Definition: define.h:217
#define CFAPI_OBJECT_PROP_ENVIRONMENT
Definition: plugin.h:125
#define FLAG_REFL_SPELL
Spells (some) will reflect from object.
Definition: define.h:262
#define CFAPI_OBJECT_PROP_GP
Definition: plugin.h:208
#define CFAPI_OBJECT_PROP_CHA
Definition: plugin.h:203
static PyObject * Crossfire_Object_Fix(Crossfire_Object *who, PyObject *args)
#define CFAPI_PLAYER_PROP_COUNT
Definition: plugin.h:239
#define CFAPI_OBJECT_PROP_MOVE_SLOW_PENALTY
Definition: plugin.h:226
static PyObject * Crossfire_Object_GetResist(Crossfire_Object *who, PyObject *args)
static int Object_SetFace(Crossfire_Object *whoptr, PyObject *value, void *closure)
#define CFAPI_OBJECT_PROP_INT
Definition: plugin.h:201
static PyObject * Crossfire_Object_AddExp(Crossfire_Object *who, PyObject *args)
void cf_object_set_int_property(object *op, int propcode, int value)
static int Player_SetBedY(Crossfire_Player *whoptr, PyObject *value, void *closure)
#define EXISTCHECK_INT(ob)
#define FLAG_CAN_USE_SKILL
The monster can use skills.
Definition: define.h:309
#define CFAPI_OBJECT_PROP_LEVEL
Definition: plugin.h:157
object * cf_object_clone(object *op, int clonetype)
Clone an object.
#define CFAPI_PLAYER_PROP_BED_MAP
Definition: plugin.h:233
#define FLAG_UNAGGRESSIVE
Monster doesn&#39;t attack players.
Definition: define.h:259
#define CFAPI_OBJECT_PROP_MOVE_ALLOW
Definition: plugin.h:222
Information on one title.
Definition: readable.cpp:108
#define FLAG_USE_RANGE
(Monster) can apply and use range items
Definition: define.h:280
static int Object_SetStringProperty(Crossfire_Object *whoptr, PyObject *value, void *closure)
Setters.
void cf_object_set_float_property(object *op, int propcode, float value)
static PyObject * Object_GetMoveSlow(Crossfire_Object *whoptr, void *closure)
static int Object_SetOwner(Crossfire_Object *whoptr, PyObject *value, void *closure)
int cf_object_user_event(object *op, object *activator, object *third, const char *message, int fix)
#define CFAPI_OBJECT_PROP_RAW_NAME
Definition: plugin.h:228
#define FLAG_NO_SAVE
If set (through plugins), the object is not saved on maps.
Definition: define.h:231
double cf_object_get_double_property(object *op, int propcode)
#define FLAG_IDENTIFIED
Item is identifiable (e.g.
Definition: define.h:248
static PyObject * Crossfire_Object_Teleport(Crossfire_Object *who, PyObject *args)
This is a game-map.
Definition: map.h:320
#define CFAPI_OBJECT_PROP_FP
Definition: plugin.h:209
#define FLAG_BLOCKSVIEW
Object blocks view.
Definition: define.h:256
sstring cf_query_name_pl(object *ob)
static PyObject * Object_GetMoveOn(Crossfire_Object *whoptr, void *closure)
static PyObject * Object_GetName(Crossfire_Object *whoptr, void *closure)
void cf_player_message(object *op, const char *txt, int flags)
#define CFAPI_OBJECT_PROP_LAST_EAT
Definition: plugin.h:161
static PyObject * Object_GetFloatProperty(Crossfire_Object *whoptr, void *closure)
#define CFAPI_OBJECT_PROP_MOVE_OFF
Definition: plugin.h:224
#define CFAPI_OBJECT_PROP_WEIGHT_LIMIT
Definition: plugin.h:167
object * cf_object_insert_object(object *op, object *container)
static PyObject * Crossfire_Object_RemoveDepletion(Crossfire_Object *who, PyObject *args)
#define CFAPI_OBJECT_PROP_CURRENT_WEAPON
Definition: plugin.h:171
static PyObject * Crossfire_Object_InsertInto(Crossfire_Object *who, PyObject *args)
static PyObject * Crossfire_Object_Event(Crossfire_Object *who, PyObject *args)
PyObject_HEAD mapstruct * map
Definition: cfpython_map.h:34
#define CFAPI_OBJECT_PROP_X
Definition: plugin.h:138
static PyMethodDef PlayerMethods[]
static PyObject * Object_GetMap(Crossfire_Object *whoptr, void *closure)
struct talk_info * talk
Definition: cfpython.h:105
#define FLAG_SCARED
Monster is scared (mb player in future)
Definition: define.h:258
static int Object_SetMoveSlow(Crossfire_Object *whoptr, PyObject *value, void *closure)
#define CFAPI_OBJECT_PROP_ENEMY
Definition: plugin.h:172
int cf_object_query_money(const object *op)
Wrapper for query_money().
#define FLAG_ONLY_ATTACK
NPC will evaporate if there is no enemy.
Definition: define.h:298
#define FLAG_XRAYS
X-ray vision.
Definition: define.h:288
static int Object_SetIntProperty(Crossfire_Object *whoptr, PyObject *value, void *closure)
int64_t cf_object_get_int64_property(object *op, int propcode)
static int Player_SetBedMap(Crossfire_Player *whoptr, PyObject *value, void *closure)
object * cf_object_present_archname_inside(object *op, char *whatstr)
Kinda wrapper for arch_present_in_ob().
#define FLAG_WIZ
Object has special privilegies.
Definition: define.h:218
#define CFAPI_OBJECT_PROP_ITEM_POWER
Definition: plugin.h:164
#define FLAG_BEEN_APPLIED
Object was ever applied, for identification purposes.
Definition: define.h:311
static PyObject * Player_QuestGetState(Crossfire_Player *whoptr, PyObject *args)
object * cf_object_find_by_arch_name(const object *who, const char *name)
Wrapper for object_find_by_arch_name().
static PyObject * Crossfire_Object_GetOutOfMap(Crossfire_Object *who, PyObject *args)
PyTypeObject Crossfire_PartyType
static PyObject * Crossfire_Object_ChangeAbil(Crossfire_Object *who, PyObject *args)
static PyObject * Crossfire_Object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
#define FLAG_CAST_SPELL
(Monster) can learn and cast spells
Definition: define.h:278
static PyObject * Player_GiveKnowledge(Crossfire_Player *who, PyObject *args)
static PyObject * Crossfire_Object_Reposition(Crossfire_Object *who, PyObject *args)
void cf_object_set_movetype_property(object *op, int propcode, MoveType value)
#define CFAPI_OBJECT_PROP_EXP
Definition: plugin.h:190
mapstruct * cf_object_get_map_property(object *op, int propcode)
void cf_object_remove(object *op)
Wrapper for object_remove().
#define FLAG_RUN_AWAY
Object runs away from nearest player \ but can still attack at a distance.
Definition: define.h:267
#define FLAG_IS_THROWN
Object is designed to be thrown.
Definition: define.h:236
static PyMethodDef ObjectMethods[]
static PyObject * Player_QuestStart(Crossfire_Player *whoptr, PyObject *args)
static PyObject * Crossfire_Object_Move(Crossfire_Object *who, PyObject *args)
#define CFAPI_OBJECT_PROP_TOTAL_EXP
Definition: plugin.h:170
static int Object_SetMoveOn(Crossfire_Object *whoptr, PyObject *value, void *closure)
int cf_object_apply(object *op, object *author, int flags)
Wrapper for apply_manual().
static const flag_definition flags[]
Flag mapping.
int cf_quest_was_completed(object *pl, sstring quest_code)
Wrapper for quest_was_completed().
#define FLAG_KNOWN_CURSED
The object is known to be cursed.
Definition: define.h:308
void cf_player_set_party(object *op, partylist *party)
object * cf_object_get_object_property(object *op, int propcode)
#define FLAG_CURSED
The object is cursed.
Definition: define.h:304
#define CFAPI_OBJECT_PROP_DAM
Definition: plugin.h:213
See Player.
Definition: object.h:112
#define CFAPI_OBJECT_PROP_MOVE_TYPE
Definition: plugin.h:220
#define CFAPI_OBJECT_PROP_SKILL
Definition: plugin.h:135
static PyObject * Object_GetMoveBlock(Crossfire_Object *whoptr, void *closure)
#define CFAPI_OBJECT_PROP_AC
Definition: plugin.h:205
#define FLAG_ANIMATE
The object looks at archetype for faces.
Definition: define.h:229
int cf_object_pay_amount(object *pl, uint64_t to_pay)
Wrapper for pay_for_amount().
#define FLAG_NO_DAMAGE
monster can&#39;t be damaged
Definition: define.h:351
#define FLAG_GENERATOR
Will generate type ob->stats.food.
Definition: define.h:235
char * cf_player_get_title(object *op, char *title, int size)
static event_registration m
Definition: citylife.cpp:424
static PyObject * Object_GetTotalExp(Crossfire_Object *whoptr, void *closure)
int cf_object_get_flag(object *ob, int flag)
void cf_object_set_int64_property(object *op, int propcode, int64_t value)
#define MAX_NPC
How many NPCs maximum will reply to the player.
Definition: dialog.h:45
#define CFAPI_OBJECT_PROP_SPEED_LEFT
Definition: plugin.h:141
static PyObject * Object_GetValue(Crossfire_Object *whoptr, void *closure)
static PyObject * Crossfire_Player_CanPay(Crossfire_Player *who, PyObject *args)
int cf_object_move(object *op, int dir, object *originator)
static PyObject * Object_GetFlagProperty(Crossfire_Object *whoptr, void *closure)
sstring name
The name of the object, obviously...
Definition: object.h:319
sstring cf_player_get_ip(object *op)
#define CFAPI_OBJECT_PROP_HP
Definition: plugin.h:206
static PyObject * Crossfire_Object_Drop(Crossfire_Object *who, PyObject *args)
#define CFAPI_OBJECT_PROP_TITLE
Definition: plugin.h:132
static PyObject * Crossfire_Object_MoveTo(Crossfire_Object *who, PyObject *args)
static PyObject * Crossfire_Object_KnowSpell(Crossfire_Object *who, PyObject *args)
#define CFAPI_PLAYER_PROP_BED_Y
Definition: plugin.h:235
static PyObject * Crossfire_Object_PayAmount(Crossfire_Object *who, PyObject *args)
#define CFAPI_OBJECT_PROP_SPEED
Definition: plugin.h:140
#define CFAPI_OBJECT_PROP_FRIENDLY
Definition: plugin.h:185
static PyObject * Player_GetMarkedItem(Crossfire_Player *whoptr, void *closure)
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:348
void cf_object_change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Wrapper for change_exp().
static int Player_SetMarkedItem(Crossfire_Player *whoptr, PyObject *value, void *closure)
int cf_object_pickup(object *op, object *what)
#define CFAPI_OBJECT_PROP_ANIM_SPEED
Definition: plugin.h:184
#define FLAG_SPLITTING
Object splits into stats.food other objs.
Definition: define.h:253
void cf_object_drop(object *op, object *author)
#define CFAPI_OBJECT_PROP_LUCK
Definition: plugin.h:189
static std::map< object *, PyObject * > object_assoc_table
#define FLAG_APPLIED
Object is ready for use by living.
Definition: define.h:222
static int Object_SetQuantity(Crossfire_Object *whoptr, PyObject *value, void *closure)
#define CFAPI_OBJECT_PROP_ARCH_NAME
Definition: plugin.h:215
static PyObject * Crossfire_Object_Clone(Crossfire_Object *who, PyObject *args)
#define FLAG_LIFESAVE
Saves a players&#39; life once, then destr.
Definition: define.h:293
#define CFAPI_OBJECT_PROP_DEX
Definition: plugin.h:198
#define CFAPI_OBJECT_PROP_ATTACK_MOVEMENT
Definition: plugin.h:178
static PyObject * Crossfire_Object_Split(Crossfire_Object *who, PyObject *args)
#define FLAG_MAKE_INVIS
(Item) gives invisibility when applied
Definition: define.h:316
#define CFAPI_OBJECT_PROP_CON
Definition: plugin.h:199
#define FLAG_STARTEQUIP
Object was given to player at start.
Definition: define.h:255
PyTypeObject Crossfire_ObjectType
static int Player_SetTitle(Crossfire_Object *whoptr, PyObject *value, void *closure)
#define CFAPI_OBJECT_PROP_NROF
Definition: plugin.h:142
void cf_player_set_title(object *op, const char *title)
#define CFAPI_OBJECT_PROP_MAXSP
Definition: plugin.h:211
#define FLAG_MONSTER
Will attack players.
Definition: define.h:232
static PyObject * Crossfire_Object_PermExp(Crossfire_Object *who, PyObject *args)
CF_PYTHON_OBJECT(Object, Crossfire_Object_dealloc, &ObjectConvert, PyObject_HashNotImplemented, Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, "Crossfire objects",(richcmpfunc) Crossfire_Object_RichCompare, ObjectMethods, Object_getseters, NULL, Crossfire_Object_new)
static PyObject * Crossfire_Object_CastAbility(Crossfire_Object *who, PyObject *args)
int cf_quest_get_player_state(object *pl, sstring quest_code)
Wrapper for quest_get_player_state().
#define NDI_UNIQUE
Print immediately, don&#39;t buffer.
Definition: newclient.h:270
static int Object_SetMap(Crossfire_Object *whoptr, PyObject *value, void *closure)
object * cf_object_check_for_spell(object *op, const char *name)
Wrapper for check_spell_known().
static PyObject * Player_GetBedMap(Crossfire_Player *whoptr, void *closure)
static int Object_SetEnemy(Crossfire_Object *whoptr, PyObject *value, void *closure)
#define CFAPI_OBJECT_PROP_INVISIBLE
Definition: plugin.h:216
sstring npc_msgs[MAX_NPC]
What the NPCs will say.
Definition: dialog.h:59
int cf_object_teleport(object *ob, mapstruct *map, int x, int y)
#define CFAPI_OBJECT_PROP_TYPE
Definition: plugin.h:145
#define CFAPI_OBJECT_PROP_POW
Definition: plugin.h:202
static PyObject * Object_GetExpMul(Crossfire_Object *whoptr, void *closure)
static int Object_SetFlagProperty(Crossfire_Object *whoptr, PyObject *value, void *closure)
static PyObject * Player_GetBedY(Crossfire_Player *whoptr, void *closure)
#define FLAG_WAS_WIZ
Player was once a wiz.
Definition: define.h:221
#define MAX_NAME
Definition: define.h:41
StringBuffer * buf
Definition: readable.cpp:1563
#define CFAPI_OBJECT_PROP_GLOW_RADIUS
Definition: plugin.h:169
archetype * cf_object_get_archetype_property(object *op, int propcode)
static PyObject * Crossfire_Object_Long(PyObject *obj)
static int Object_SetValue(Crossfire_Object *whoptr, PyObject *value, void *closure)
CFPContext * current_context
Definition: cfpython.cpp:106
static int Object_SetExp(Crossfire_Object *whoptr, PyObject *value, void *closure)
void cf_object_set_string_property(object *op, int propcode, const char *value)
#define CFAPI_OBJECT_PROP_WC
Definition: plugin.h:204
void cf_object_set_long_property(object *op, int propcode, long value)
static PyGetSetDef Object_getseters[]
#define CFAPI_OBJECT_PROP_MOVE_SLOW
Definition: plugin.h:225
#define CFAPI_OBJECT_PROP_MATERIAL_NAME
Definition: plugin.h:154
static PyObject * Crossfire_Object_Take(Crossfire_Object *who, PyObject *args)
const char * sstring
Definition: sstring.h:2
#define CF_IS_PYSTR(cfpy_obj)
Definition: cfpython.h:65
#define CFAPI_OBJECT_PROP_MAXHP
Definition: plugin.h:210
static PyObject * Crossfire_Object_WriteKey(Crossfire_Object *who, PyObject *args)
int cf_object_out_of_map(object *op, int x, int y)
tag_t count
Unique object number for this object.
Definition: object.h:307
#define FLAG_UNIQUE
Item is really unique (UNIQUE_ITEMS)
Definition: define.h:275
static PyObject * find_assoc_pyobject(object *key)
#define FLAG_NO_PICK
Object can&#39;t be picked up.
Definition: define.h:226
int cf_object_change_abil(object *op, object *tmp)
Wrapper for change_abil().
#define CFAPI_OBJECT_PROP_VALUE
Definition: plugin.h:156
static PyObject * Crossfire_Player_Message(Crossfire_Player *who, PyObject *args)
#define FLAG_REFL_MISSILE
Arrows will reflect from object.
Definition: define.h:260
#define CFAPI_OBJECT_PROP_WIS
Definition: plugin.h:200
#define CFAPI_OBJECT_PROP_DURATION
Definition: plugin.h:227
#define CFAPI_OBJECT_PROP_OB_ABOVE
Definition: plugin.h:120
object * cf_create_object_by_name(const char *name)
Wrapper for create_archetype() and create_archetype_by_object_name().
char * cf_query_name(object *ob, char *name, int size)
int cf_object_move_to(object *op, int x, int y)
Wrapper for move_to().
static PyObject * Crossfire_Object_Pay(Crossfire_Object *who, PyObject *args)
#define CFAPI_OBJECT_PROP_Y
Definition: plugin.h:139
#define FLAG_USE_BOW
(Monster) can apply and fire bows
Definition: define.h:281
static int Object_SetMoveBlock(Crossfire_Object *whoptr, PyObject *value, void *closure)
int cf_object_cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
Wrapper for cast_spell().
static PyObject * Crossfire_Player_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * Crossfire_Object_CheckArchInventory(Crossfire_Object *who, PyObject *args)
static PyObject * Player_GetIP(Crossfire_Player *whoptr, void *closure)
static PyObject * Crossfire_Object_CheckTrigger(Crossfire_Object *who, PyObject *args)
#define CFAPI_OBJECT_PROP_MOVE_BLOCK
Definition: plugin.h:221
static void Crossfire_Object_dealloc(PyObject *obj)
void cf_object_set_object_property(object *op, int propcode, object *value)
object * cf_object_split(object *orig_ob, uint32_t nr, char *err, size_t size)
Wrapper for object_split().
int cf_object_set_key(object *op, const char *keyname, const char *value, int add_key)
Sets a value for specified key, equivalent to object_set_value().
#define FLAG_IS_TURNABLE
Object can change face with direction.
Definition: define.h:243
static PyGetSetDef Player_getseters[]