… | |
… | |
45 | #include <plugin_common.h> |
45 | #include <plugin_common.h> |
46 | #include <sounds.h> |
46 | #include <sounds.h> |
47 | |
47 | |
48 | #include <stdarg.h> |
48 | #include <stdarg.h> |
49 | |
49 | |
|
|
50 | #include <sproto.h> |
|
|
51 | |
|
|
52 | //#include "EventAPI.h" |
50 | #include "perlxsi.c" |
53 | #include "perlxsi.c" |
|
|
54 | |
|
|
55 | extern sint64 *levels; // the experience table |
51 | |
56 | |
52 | typedef object object_ornull; |
57 | typedef object object_ornull; |
53 | typedef mapstruct mapstruct_ornull; |
58 | typedef mapstruct mapstruct_ornull; |
|
|
59 | |
|
|
60 | typedef double val64; |
|
|
61 | #define newSVval64 newSVnv |
|
|
62 | #define SvVAL64 SvNV |
54 | |
63 | |
55 | static f_plug_api gethook; |
64 | static f_plug_api gethook; |
56 | static f_plug_api registerGlobalEvent; |
65 | static f_plug_api registerGlobalEvent; |
57 | static f_plug_api unregisterGlobalEvent; |
66 | static f_plug_api unregisterGlobalEvent; |
58 | static f_plug_api systemDirectory; |
67 | static f_plug_api systemDirectory; |
… | |
… | |
225 | case CFAPI_INT: |
234 | case CFAPI_INT: |
226 | sv = newSViv (*va_arg (args, int *)); |
235 | sv = newSViv (*va_arg (args, int *)); |
227 | break; |
236 | break; |
228 | |
237 | |
229 | case CFAPI_LONG: |
238 | case CFAPI_LONG: |
230 | sv = newSVnv ((double)*va_arg (args, sint64 *)); /* oh, the humanity! */ |
239 | sv = newSVval64 ((val64)*va_arg (args, sint64 *)); |
231 | break; |
240 | break; |
232 | |
241 | |
233 | case CFAPI_DOUBLE: |
242 | case CFAPI_DOUBLE: |
234 | sv = newSVnv (*va_arg (args, double *)); |
243 | sv = newSVnv (*va_arg (args, double *)); |
235 | break; |
244 | break; |
… | |
… | |
249 | sv = &PL_sv_undef; |
258 | sv = &PL_sv_undef; |
250 | else |
259 | else |
251 | switch (obj->type) |
260 | switch (obj->type) |
252 | { |
261 | { |
253 | case MAP: |
262 | case MAP: |
254 | sv = newSVptr_cached (obj, "cf::object::map"); |
263 | sv = newSVptr_cached (obj, "cf::object::map::wrap"); |
255 | break; |
264 | break; |
256 | |
265 | |
257 | case PLAYER: |
266 | case PLAYER: |
258 | sv = newSVptr_cached (obj, "cf::object::player"); |
267 | sv = newSVptr_cached (obj, "cf::object::player::wrap"); |
259 | break; |
268 | break; |
260 | |
269 | |
261 | default: |
270 | default: |
262 | sv = newSVptr_cached (obj, "cf::object"); |
271 | sv = newSVptr_cached (obj, "cf::object::wrap"); |
263 | break; |
272 | break; |
264 | } |
273 | } |
265 | } |
274 | } |
266 | break; |
275 | break; |
267 | |
276 | |
268 | case CFAPI_PMAP: |
277 | case CFAPI_PMAP: |
269 | sv = newSVptr (va_arg (args, mapstruct *), "cf::map"); |
278 | sv = newSVptr (va_arg (args, mapstruct *), "cf::map::wrap"); |
270 | break; |
279 | break; |
271 | |
280 | |
272 | case CFAPI_PPLAYER: |
281 | case CFAPI_PPLAYER: |
273 | sv = newSVptr (va_arg (args, player *), "cf::player"); |
282 | sv = newSVptr (va_arg (args, player *), "cf::player::wrap"); |
274 | break; |
283 | break; |
275 | |
284 | |
276 | case CFAPI_PARCH: |
285 | case CFAPI_PARCH: |
277 | sv = newSVptr (va_arg (args, archetype *), "cf::arch"); |
286 | sv = newSVptr (va_arg (args, archetype *), "cf::arch::wrap"); |
278 | break; |
287 | break; |
279 | |
288 | |
280 | case CFAPI_PPARTY: |
289 | case CFAPI_PPARTY: |
281 | sv = newSVptr (va_arg (args, partylist *), "cf::party"); |
290 | sv = newSVptr (va_arg (args, partylist *), "cf::party::wrap"); |
282 | break; |
291 | break; |
283 | |
292 | |
284 | case CFAPI_PREGION: |
293 | case CFAPI_PREGION: |
285 | sv = newSVptr (va_arg (args, region *), "cf::region"); |
294 | sv = newSVptr (va_arg (args, region *), "cf::region::wrap"); |
286 | break; |
295 | break; |
287 | |
296 | |
288 | default: |
297 | default: |
289 | assert (("unhandled type in newSVcfapi", 0)); |
298 | assert (("unhandled type in newSVcfapi", 0)); |
290 | } |
299 | } |
… | |
… | |
294 | return sv; |
303 | return sv; |
295 | } |
304 | } |
296 | |
305 | |
297 | ///////////////////////////////////////////////////////////////////////////// |
306 | ///////////////////////////////////////////////////////////////////////////// |
298 | |
307 | |
299 | int |
|
|
300 | initPlugin (const char *iversion, f_plug_api gethooksptr) |
308 | extern "C" int initPlugin (const char *iversion, f_plug_api gethooksptr) |
301 | { |
309 | { |
302 | gethook = gethooksptr; |
310 | gethook = gethooksptr; |
303 | printf (PLUGIN_VERSION " init\n"); |
311 | printf (PLUGIN_VERSION " init\n"); |
304 | |
312 | |
305 | return 0; |
313 | return 0; |
… | |
… | |
338 | LEAVE; |
346 | LEAVE; |
339 | |
347 | |
340 | return returnvalue; |
348 | return returnvalue; |
341 | } |
349 | } |
342 | |
350 | |
343 | void * |
|
|
344 | getPluginProperty (int *type, ...) |
351 | extern "C" void *getPluginProperty (int *type, ...) |
345 | { |
352 | { |
346 | va_list args; |
353 | va_list args; |
347 | char *propname; |
354 | char *propname; |
348 | int i; |
355 | int i; |
349 | va_start (args, type); |
356 | va_start (args, type); |
… | |
… | |
372 | } |
379 | } |
373 | } |
380 | } |
374 | else if (!strcmp (propname, "Identification")) |
381 | else if (!strcmp (propname, "Identification")) |
375 | { |
382 | { |
376 | va_end (args); |
383 | va_end (args); |
377 | return PLUGIN_NAME; |
384 | return (void*) PLUGIN_NAME; |
378 | } |
385 | } |
379 | else if (!strcmp (propname, "FullName")) |
386 | else if (!strcmp (propname, "FullName")) |
380 | { |
387 | { |
381 | va_end (args); |
388 | va_end (args); |
382 | return PLUGIN_VERSION; |
389 | return (void*) PLUGIN_VERSION; |
383 | } |
390 | } |
384 | else |
391 | else |
385 | va_end (args); |
392 | va_end (args); |
386 | |
393 | |
387 | return NULL; |
394 | return NULL; |
388 | } |
395 | } |
389 | |
396 | |
390 | void *globalEventListener (int *type, ...); |
397 | void *globalEventListener (int *type, ...); |
391 | |
398 | |
392 | int |
399 | extern "C" int postInitPlugin () |
393 | postInitPlugin () |
|
|
394 | { |
400 | { |
395 | int hooktype = 1; |
401 | int hooktype = 1; |
396 | int rtype = 0; |
402 | int rtype = 0; |
397 | |
403 | |
398 | printf (PLUGIN_VERSION " post init\n"); |
404 | printf (PLUGIN_VERSION " post init\n"); |
399 | |
405 | |
400 | registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event"); |
406 | registerGlobalEvent = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_system_register_global_event"); |
401 | unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); |
407 | unregisterGlobalEvent = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); |
402 | systemDirectory = gethook (&rtype, hooktype, "cfapi_system_directory"); |
408 | systemDirectory = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_system_directory"); |
403 | object_set_property = gethook (&rtype, hooktype, "cfapi_object_set_property"); |
409 | object_set_property = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_object_set_property"); |
404 | map_get_map = gethook (&rtype, hooktype, "cfapi_map_get_map"); |
410 | map_get_map = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_map_get_map"); |
405 | object_insert = gethook (&rtype, hooktype, "cfapi_object_insert"); |
411 | object_insert = (void* (*)(int*, ...)) gethook (&rtype, hooktype, "cfapi_object_insert"); |
406 | |
412 | |
407 | cf_init_plugin (gethook); |
413 | cf_init_plugin (gethook); |
408 | |
414 | |
409 | /* Pick the global events you want to monitor from this plugin */ |
415 | /* Pick the global events you want to monitor from this plugin */ |
410 | registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener); |
416 | registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener); |
411 | registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener); |
417 | registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener); |
412 | //registerGlobalEvent (NULL, EVENT_CRASH, PLUGIN_NAME, globalEventListener); |
418 | //registerGlobalEvent (NULL, EVENT_CRASH, PLUGIN_NAME, globalEventListener); |
|
|
419 | registerGlobalEvent (NULL, EVENT_FIND_UNARMED_SKILL, PLUGIN_NAME, globalEventListener); |
|
|
420 | registerGlobalEvent (NULL, EVENT_PLAYER_USE_SKILL, PLUGIN_NAME, globalEventListener); |
|
|
421 | registerGlobalEvent (NULL, EVENT_CAST_SPELL, PLUGIN_NAME, globalEventListener); |
|
|
422 | registerGlobalEvent (NULL, EVENT_MONSTER_USE_SKILL, PLUGIN_NAME, globalEventListener); |
413 | registerGlobalEvent (NULL, EVENT_PLAYER_DEATH, PLUGIN_NAME, globalEventListener); |
423 | registerGlobalEvent (NULL, EVENT_PLAYER_DEATH, PLUGIN_NAME, globalEventListener); |
414 | registerGlobalEvent (NULL, EVENT_GKILL, PLUGIN_NAME, globalEventListener); |
424 | registerGlobalEvent (NULL, EVENT_GKILL, PLUGIN_NAME, globalEventListener); |
415 | registerGlobalEvent (NULL, EVENT_LOGIN, PLUGIN_NAME, globalEventListener); |
425 | registerGlobalEvent (NULL, EVENT_LOGIN, PLUGIN_NAME, globalEventListener); |
416 | registerGlobalEvent (NULL, EVENT_LOGOUT, PLUGIN_NAME, globalEventListener); |
426 | registerGlobalEvent (NULL, EVENT_LOGOUT, PLUGIN_NAME, globalEventListener); |
417 | registerGlobalEvent (NULL, EVENT_MAPENTER, PLUGIN_NAME, globalEventListener); |
427 | registerGlobalEvent (NULL, EVENT_MAPENTER, PLUGIN_NAME, globalEventListener); |
… | |
… | |
443 | }; |
453 | }; |
444 | |
454 | |
445 | perl = perl_alloc (); |
455 | perl = perl_alloc (); |
446 | perl_construct (perl); |
456 | perl_construct (perl); |
447 | |
457 | |
|
|
458 | PL_exit_flags |= PERL_EXIT_DESTRUCT_END; |
|
|
459 | |
448 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
460 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
449 | { |
461 | { |
450 | printf ("unable to initialize perl-interpreter, continuing without.\n"); |
462 | printf ("unable to initialize perl-interpreter, continuing without.\n"); |
451 | |
463 | |
452 | perl_destruct (perl); |
464 | perl_destruct (perl); |
… | |
… | |
467 | va_list args; |
479 | va_list args; |
468 | static int rv; |
480 | static int rv; |
469 | int event_code; |
481 | int event_code; |
470 | |
482 | |
471 | if (!perl) |
483 | if (!perl) |
472 | return; |
484 | return NULL; |
473 | |
485 | |
474 | va_start (args, type); |
486 | va_start (args, type); |
475 | event_code = va_arg (args, int); |
487 | event_code = va_arg (args, int); |
476 | |
488 | |
477 | if (event_code == EVENT_FREE_OB) |
489 | if (event_code == EVENT_FREE_OB) |
… | |
… | |
485 | |
497 | |
486 | if (sv) |
498 | if (sv) |
487 | clearSVptr (sv); |
499 | clearSVptr (sv); |
488 | |
500 | |
489 | rv = 0; |
501 | rv = 0; |
|
|
502 | } |
|
|
503 | else if (event_code == EVENT_CLOCK) |
|
|
504 | { |
|
|
505 | dSP; |
|
|
506 | int i, count; |
|
|
507 | |
|
|
508 | clean_obj_cache (); |
|
|
509 | |
|
|
510 | ENTER; |
|
|
511 | SAVETMPS; |
|
|
512 | |
|
|
513 | // service up to 8 events per tick better would be |
|
|
514 | // to check for elapsed time and stop processing after |
|
|
515 | // 0.25 * server_tick or so |
|
|
516 | for (i = 9; --i; ) |
|
|
517 | { |
|
|
518 | PUSHMARK (SP); |
|
|
519 | XPUSHs (sv_2mortal (newSViv (0))); |
|
|
520 | PUTBACK; |
|
|
521 | count = call_pv ("Event::one_event", G_SCALAR | G_EVAL); |
|
|
522 | SPAGAIN; |
|
|
523 | |
|
|
524 | if (!count || !POPi) |
|
|
525 | break; |
|
|
526 | } |
|
|
527 | |
|
|
528 | FREETMPS; |
|
|
529 | LEAVE; |
490 | } |
530 | } |
491 | else |
531 | else |
492 | { |
532 | { |
493 | dSP; |
533 | dSP; |
494 | |
534 | |
… | |
… | |
540 | |
580 | |
541 | case EVENT_SHOUT: |
581 | case EVENT_SHOUT: |
542 | case EVENT_MUZZLE: |
582 | case EVENT_MUZZLE: |
543 | case EVENT_KICK: |
583 | case EVENT_KICK: |
544 | PUSH_OB; |
584 | PUSH_OB; |
|
|
585 | PUSH_PV; |
|
|
586 | break; |
|
|
587 | |
|
|
588 | case EVENT_FIND_UNARMED_SKILL: |
|
|
589 | PUSH_OB; |
|
|
590 | break; |
|
|
591 | |
|
|
592 | case EVENT_PLAYER_USE_SKILL: |
|
|
593 | case EVENT_MONSTER_USE_SKILL: |
|
|
594 | case EVENT_CAST_SPELL: |
|
|
595 | PUSH_OB; |
|
|
596 | PUSH_OB; |
|
|
597 | PUSH_OB; |
|
|
598 | PUSH_IV; |
545 | PUSH_PV; |
599 | PUSH_PV; |
546 | break; |
600 | break; |
547 | |
601 | |
548 | case EVENT_EXTCMD: |
602 | case EVENT_EXTCMD: |
549 | PUSH_PL; |
603 | PUSH_PL; |
… | |
… | |
552 | int len = va_arg (args, int); |
606 | int len = va_arg (args, int); |
553 | PUSHs (sv_2mortal (newSVpvn (buf, len))); |
607 | PUSHs (sv_2mortal (newSVpvn (buf, len))); |
554 | } |
608 | } |
555 | break; |
609 | break; |
556 | |
610 | |
557 | case EVENT_CLOCK: |
|
|
558 | clean_obj_cache (); |
|
|
559 | break; |
|
|
560 | |
|
|
561 | case EVENT_TELL: |
611 | case EVENT_TELL: |
562 | break; |
612 | break; |
563 | } |
613 | } |
564 | |
614 | |
565 | va_end (args); |
615 | va_end (args); |
… | |
… | |
579 | } |
629 | } |
580 | |
630 | |
581 | return &rv; |
631 | return &rv; |
582 | } |
632 | } |
583 | |
633 | |
584 | void * |
|
|
585 | eventListener (int *type, ...) |
634 | extern "C" void * eventListener (int *type, ...) |
586 | { |
635 | { |
587 | static int rv; |
636 | static int rv; |
588 | va_list args; |
637 | va_list args; |
589 | int event_code; |
638 | int event_code; |
590 | object *who, *activator, *third, *event; |
639 | object *who, *activator, *third, *event; |
591 | char *message, *extension, *options; |
640 | char *message, *extension, *options; |
592 | |
641 | |
593 | if (!perl) |
642 | if (!perl) |
594 | return; |
643 | return NULL; |
595 | |
644 | |
596 | va_start (args, type); |
645 | va_start (args, type); |
597 | who = va_arg (args, object *); |
646 | who = va_arg (args, object *); |
598 | event_code = va_arg (args, int); |
647 | event_code = va_arg (args, int); |
599 | activator = va_arg (args, object *); |
648 | activator = va_arg (args, object *); |
… | |
… | |
625 | case EVENT_STOP: // $ob (e.g. arrow) |
674 | case EVENT_STOP: // $ob (e.g. arrow) |
626 | case EVENT_TIME: // $ob |
675 | case EVENT_TIME: // $ob |
627 | case EVENT_TIMER: // $ob |
676 | case EVENT_TIMER: // $ob |
628 | break; |
677 | break; |
629 | |
678 | |
630 | case EVENT_APPLY: // $ob, $who |
679 | case EVENT_APPLY: // $ob, $who |
631 | case EVENT_DROP: // $ob, $who |
680 | case EVENT_DROP: // $ob, $who |
632 | case EVENT_CLOSE: // $ob, $who |
681 | case EVENT_CLOSE: // $ob, $who |
633 | case EVENT_DEATH: // $ob[, $killer] |
682 | case EVENT_DEATH: // $ob[, $killer] |
634 | case EVENT_MOVE: // $ob, $enemy |
683 | case EVENT_MOVE: // $ob, $enemy |
635 | case EVENT_THROW: // $ob, $thrower |
684 | case EVENT_THROW: // $ob, $thrower |
636 | PUSHcfapi (POBJECT, activator); |
685 | PUSHcfapi (POBJECT, activator); |
637 | break; |
686 | break; |
638 | |
687 | |
|
|
688 | case EVENT_DROP_ON: // $ob, $who, $what |
639 | case EVENT_ATTACK: // $ob, $who, $victim (?? please god enlighten me) |
689 | case EVENT_ATTACK: // $ob, $who, $victim (?? please god enlighten me) |
640 | PUSHcfapi (POBJECT, activator); |
690 | PUSHcfapi (POBJECT, activator); |
641 | PUSHcfapi (POBJECT, third); |
691 | PUSHcfapi (POBJECT, third); |
642 | break; |
692 | break; |
643 | |
693 | |
… | |
… | |
672 | } |
722 | } |
673 | |
723 | |
674 | return &rv; |
724 | return &rv; |
675 | } |
725 | } |
676 | |
726 | |
677 | int |
727 | extern "C" int closePlugin () |
678 | closePlugin () |
|
|
679 | { |
728 | { |
680 | printf (PLUGIN_VERSION " closing\n"); |
729 | printf (PLUGIN_VERSION " closing\n"); |
681 | |
730 | |
682 | if (perl) |
731 | if (perl) |
683 | { |
732 | { |
… | |
… | |
1011 | const_iv (F_DAMNED) |
1060 | const_iv (F_DAMNED) |
1012 | const_iv (F_OPEN) |
1061 | const_iv (F_OPEN) |
1013 | const_iv (F_NOPICK) |
1062 | const_iv (F_NOPICK) |
1014 | const_iv (F_LOCKED) |
1063 | const_iv (F_LOCKED) |
1015 | |
1064 | |
|
|
1065 | const_iv (F_BUY) |
|
|
1066 | const_iv (F_SHOP) |
|
|
1067 | const_iv (F_SELL) |
|
|
1068 | |
1016 | const_iv (P_BLOCKSVIEW) |
1069 | const_iv (P_BLOCKSVIEW) |
1017 | const_iv (P_NO_MAGIC) |
1070 | const_iv (P_NO_MAGIC) |
1018 | const_iv (P_IS_ALIVE) |
1071 | const_iv (P_IS_ALIVE) |
1019 | const_iv (P_NO_CLERIC) |
1072 | const_iv (P_NO_CLERIC) |
1020 | const_iv (P_NEED_UPDATE) |
1073 | const_iv (P_NEED_UPDATE) |
… | |
… | |
1127 | const_iv (SOUND_CLOCK) |
1180 | const_iv (SOUND_CLOCK) |
1128 | const_iv (SOUND_TURN_HANDLE) |
1181 | const_iv (SOUND_TURN_HANDLE) |
1129 | const_iv (SOUND_FALL_HOLE) |
1182 | const_iv (SOUND_FALL_HOLE) |
1130 | const_iv (SOUND_DRINK_POISON) |
1183 | const_iv (SOUND_DRINK_POISON) |
1131 | const_iv (SOUND_CAST_SPELL_0) |
1184 | const_iv (SOUND_CAST_SPELL_0) |
|
|
1185 | |
|
|
1186 | const_iv (PREFER_LOW) |
|
|
1187 | const_iv (PREFER_HIGH) |
|
|
1188 | |
|
|
1189 | const_iv (ATNR_PHYSICAL) |
|
|
1190 | const_iv (ATNR_MAGIC) |
|
|
1191 | const_iv (ATNR_FIRE) |
|
|
1192 | const_iv (ATNR_ELECTRICITY) |
|
|
1193 | const_iv (ATNR_COLD) |
|
|
1194 | const_iv (ATNR_CONFUSION) |
|
|
1195 | const_iv (ATNR_ACID) |
|
|
1196 | const_iv (ATNR_DRAIN) |
|
|
1197 | const_iv (ATNR_WEAPONMAGIC) |
|
|
1198 | const_iv (ATNR_GHOSTHIT) |
|
|
1199 | const_iv (ATNR_POISON) |
|
|
1200 | const_iv (ATNR_SLOW) |
|
|
1201 | const_iv (ATNR_PARALYZE) |
|
|
1202 | const_iv (ATNR_TURN_UNDEAD) |
|
|
1203 | const_iv (ATNR_FEAR) |
|
|
1204 | const_iv (ATNR_CANCELLATION) |
|
|
1205 | const_iv (ATNR_DEPLETE) |
|
|
1206 | const_iv (ATNR_DEATH) |
|
|
1207 | const_iv (ATNR_CHAOS) |
|
|
1208 | const_iv (ATNR_COUNTERSPELL) |
|
|
1209 | const_iv (ATNR_GODPOWER) |
|
|
1210 | const_iv (ATNR_HOLYWORD) |
|
|
1211 | const_iv (ATNR_BLIND) |
|
|
1212 | const_iv (ATNR_INTERNAL) |
|
|
1213 | const_iv (ATNR_LIFE_STEALING) |
|
|
1214 | const_iv (ATNR_DISEASE) |
|
|
1215 | |
|
|
1216 | const_iv (MAP_FLUSH) |
|
|
1217 | const_iv (MAP_PLAYER_UNIQUE) |
|
|
1218 | const_iv (MAP_BLOCK) |
|
|
1219 | const_iv (MAP_STYLE) |
|
|
1220 | const_iv (MAP_OVERLAY) |
|
|
1221 | |
|
|
1222 | const_iv (MAP_IN_MEMORY) |
|
|
1223 | const_iv (MAP_SWAPPED) |
|
|
1224 | const_iv (MAP_LOADING) |
|
|
1225 | const_iv (MAP_SAVING) |
1132 | }; |
1226 | }; |
1133 | |
1227 | |
1134 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1228 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1135 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1229 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1136 | |
1230 | |
… | |
… | |
1142 | const_event (NONE) |
1236 | const_event (NONE) |
1143 | const_event (APPLY) |
1237 | const_event (APPLY) |
1144 | const_event (ATTACK) |
1238 | const_event (ATTACK) |
1145 | const_event (DEATH) |
1239 | const_event (DEATH) |
1146 | const_event (DROP) |
1240 | const_event (DROP) |
|
|
1241 | const_event (DROP_ON) |
1147 | const_event (PICKUP) |
1242 | const_event (PICKUP) |
1148 | const_event (SAY) |
1243 | const_event (SAY) |
1149 | const_event (STOP) |
1244 | const_event (STOP) |
1150 | const_event (TIME) |
1245 | const_event (TIME) |
1151 | const_event (THROW) |
1246 | const_event (THROW) |
… | |
… | |
1153 | const_event (CLOSE) |
1248 | const_event (CLOSE) |
1154 | const_event (TIMER) |
1249 | const_event (TIMER) |
1155 | const_event (MOVE) |
1250 | const_event (MOVE) |
1156 | |
1251 | |
1157 | const_event (BORN) |
1252 | const_event (BORN) |
1158 | const_event (CLOCK) |
1253 | //const_event (CLOCK) |
1159 | const_event (CRASH) |
1254 | const_event (CRASH) |
1160 | const_event (PLAYER_DEATH) |
1255 | const_event (PLAYER_DEATH) |
1161 | const_event (PLAYER_LOAD) |
1256 | const_event (PLAYER_LOAD) |
1162 | const_event (PLAYER_SAVE) |
1257 | const_event (PLAYER_SAVE) |
1163 | const_event (GKILL) |
1258 | const_event (GKILL) |
… | |
… | |
1173 | const_event (REMOVE) |
1268 | const_event (REMOVE) |
1174 | const_event (SHOUT) |
1269 | const_event (SHOUT) |
1175 | const_event (TELL) |
1270 | const_event (TELL) |
1176 | const_event (MUZZLE) |
1271 | const_event (MUZZLE) |
1177 | const_event (KICK) |
1272 | const_event (KICK) |
|
|
1273 | const_event (PLAYER_USE_SKILL) |
|
|
1274 | const_event (MONSTER_USE_SKILL) |
|
|
1275 | const_event (CAST_SPELL) |
|
|
1276 | const_event (FIND_UNARMED_SKILL) |
1178 | const_event (EXTCMD) |
1277 | const_event (EXTCMD) |
1179 | //const_event (FREE_OB) |
1278 | //const_event (FREE_OB) |
1180 | }; |
1279 | }; |
1181 | |
1280 | |
1182 | AV *av = get_av ("cf::EVENT", 1); |
1281 | AV *av = get_av ("cf::EVENT", 1); |
… | |
… | |
1317 | for (cprop = prop_table + sizeof (prop_table) / sizeof (prop_table [0]); cprop-- > prop_table; ) |
1416 | for (cprop = prop_table + sizeof (prop_table) / sizeof (prop_table [0]); cprop-- > prop_table; ) |
1318 | { |
1417 | { |
1319 | hv_store (prop_type, cprop->name, strlen (cprop->name), newSViv (cprop->dtype), 0); |
1418 | hv_store (prop_type, cprop->name, strlen (cprop->name), newSViv (cprop->dtype), 0); |
1320 | hv_store (prop_idx, cprop->name, strlen (cprop->name), newSViv (cprop->idx ), 0); |
1419 | hv_store (prop_idx, cprop->name, strlen (cprop->name), newSViv (cprop->idx ), 0); |
1321 | } |
1420 | } |
|
|
1421 | |
|
|
1422 | //I_EVENT_API (PACKAGE); |
1322 | } |
1423 | } |
|
|
1424 | |
|
|
1425 | NV floor (NV x) |
|
|
1426 | |
|
|
1427 | NV ceil (NV x) |
1323 | |
1428 | |
1324 | void |
1429 | void |
1325 | LOG (int level, char *msg) |
1430 | LOG (int level, char *msg) |
1326 | PROTOTYPE: $$ |
1431 | PROTOTYPE: $$ |
1327 | C_ARGS: level, "%s", msg |
1432 | C_ARGS: (LogLevel)level, "%s", msg |
|
|
1433 | |
|
|
1434 | char *path_combine (char *base, char *path) |
|
|
1435 | PROTOTYPE: $$ |
|
|
1436 | |
|
|
1437 | char *path_combine_and_normalize (char *base, char *path) |
|
|
1438 | PROTOTYPE: $$ |
1328 | |
1439 | |
1329 | char * |
1440 | char * |
1330 | cf_get_maps_directory (char *path) |
1441 | cf_get_maps_directory (char *path) |
1331 | PROTOTYPE: $ |
1442 | PROTOTYPE: $ |
1332 | ALIAS: maps_directory = 0 |
1443 | ALIAS: maps_directory = 0 |
|
|
1444 | |
|
|
1445 | void |
|
|
1446 | sub_generation_inc () |
|
|
1447 | CODE: |
|
|
1448 | PL_sub_generation++; |
1333 | |
1449 | |
1334 | char * |
1450 | char * |
1335 | mapdir () |
1451 | mapdir () |
1336 | PROTOTYPE: |
1452 | PROTOTYPE: |
1337 | ALIAS: |
1453 | ALIAS: |
… | |
… | |
1351 | |
1467 | |
1352 | int |
1468 | int |
1353 | cf_find_animation (char *text) |
1469 | cf_find_animation (char *text) |
1354 | PROTOTYPE: $ |
1470 | PROTOTYPE: $ |
1355 | |
1471 | |
|
|
1472 | int random_roll(int min, int max, object *op, int goodbad); |
|
|
1473 | |
|
|
1474 | const char *cost_string_from_value(uint64 cost, int approx = 0) |
|
|
1475 | |
|
|
1476 | int |
|
|
1477 | exp_to_level (val64 exp) |
|
|
1478 | CODE: |
|
|
1479 | { |
|
|
1480 | int i = 0; |
|
|
1481 | |
|
|
1482 | RETVAL = settings.max_level; |
|
|
1483 | |
|
|
1484 | for (i = 1; i <= settings.max_level; i++) |
|
|
1485 | { |
|
|
1486 | if (levels[i] > exp) |
|
|
1487 | { |
|
|
1488 | RETVAL = i - 1; |
|
|
1489 | break; |
|
|
1490 | } |
|
|
1491 | } |
|
|
1492 | } |
|
|
1493 | OUTPUT: RETVAL |
|
|
1494 | |
|
|
1495 | val64 |
|
|
1496 | level_to_min_exp (int level) |
|
|
1497 | CODE: |
|
|
1498 | if (level > settings.max_level) |
|
|
1499 | RETVAL = levels[settings.max_level]; |
|
|
1500 | else if (level < 1) |
|
|
1501 | RETVAL = 0; |
|
|
1502 | else |
|
|
1503 | RETVAL = levels[level]; |
|
|
1504 | OUTPUT: RETVAL |
|
|
1505 | |
|
|
1506 | SV * |
|
|
1507 | resistance_to_string (int atnr) |
|
|
1508 | CODE: |
|
|
1509 | if (atnr >= 0 && atnr < NROFATTACKS) |
|
|
1510 | RETVAL = newSVpv (resist_plus[atnr], 0); |
|
|
1511 | else |
|
|
1512 | XSRETURN_UNDEF; |
|
|
1513 | OUTPUT: RETVAL |
|
|
1514 | |
1356 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1515 | MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1357 | |
1516 | |
1358 | SV * |
1517 | SV * |
1359 | get_property (object *obj, int type, int idx) |
1518 | get_property (object *obj, int type, int idx) |
1360 | CODE: |
1519 | CODE: |
… | |
… | |
1368 | { |
1527 | { |
1369 | case CFAPI_INT: |
1528 | case CFAPI_INT: |
1370 | cf_object_set_int_property (obj, idx, SvIV (newval)); |
1529 | cf_object_set_int_property (obj, idx, SvIV (newval)); |
1371 | break; |
1530 | break; |
1372 | case CFAPI_LONG: |
1531 | case CFAPI_LONG: |
1373 | cf_object_set_long_property (obj, idx, SvNV (newval)); |
1532 | cf_object_set_long_property (obj, idx, (long) SvVAL64 (newval)); |
1374 | break; |
1533 | break; |
1375 | case CFAPI_DOUBLE: |
1534 | case CFAPI_DOUBLE: |
1376 | { |
1535 | { |
1377 | int unused_type; |
1536 | int unused_type; |
1378 | object_set_property (&unused_type, obj, idx, (double)SvNV (newval)); |
1537 | object_set_property (&unused_type, obj, idx, (double)SvNV (newval)); |
… | |
… | |
1436 | int cf_object_get_flag (object *op, int flag) |
1595 | int cf_object_get_flag (object *op, int flag) |
1437 | ALIAS: flag = 0 |
1596 | ALIAS: flag = 0 |
1438 | |
1597 | |
1439 | void cf_object_set_flag (object *op, int flag, int value) |
1598 | void cf_object_set_flag (object *op, int flag, int value) |
1440 | |
1599 | |
|
|
1600 | int need_identify (const object *obj); |
|
|
1601 | |
|
|
1602 | int apply_shop_mat (object *shop_mat, object *op); |
|
|
1603 | |
1441 | void cf_object_move (object *op, int dir, object *originator = op) |
1604 | void cf_object_move (object *op, int dir, object *originator = op) |
1442 | |
1605 | |
1443 | void cf_object_apply (object *op, object *author, int flags = 0) |
1606 | void cf_object_apply (object *op, object *author, int flags = 0) |
1444 | |
1607 | |
1445 | void cf_object_apply_below (object *op) |
1608 | void cf_object_apply_below (object *op) |
… | |
… | |
1456 | |
1619 | |
1457 | object *cf_object_clone (object *op, int clonetype = 0) |
1620 | object *cf_object_clone (object *op, int clonetype = 0) |
1458 | |
1621 | |
1459 | int cf_object_pay_item (object *op, object *buyer) |
1622 | int cf_object_pay_item (object *op, object *buyer) |
1460 | |
1623 | |
1461 | int cf_object_pay_amount (object *op, double amount) |
1624 | int cf_object_pay_amount (object *op, uint64 amount) |
|
|
1625 | |
|
|
1626 | void pay_player (object *op, uint64 amount) |
|
|
1627 | |
|
|
1628 | val64 pay_player_arch (object *op, const char *arch, uint64 amount) |
1462 | |
1629 | |
1463 | int cf_object_cast_spell (object *caster, object *ctoo, int dir, object *spell_ob, char *stringarg = 0) |
1630 | int cf_object_cast_spell (object *caster, object *ctoo, int dir, object *spell_ob, char *stringarg = 0) |
1464 | |
1631 | |
1465 | int cf_object_cast_ability (object *caster, object *ctoo, int dir, object *sp_, char *stringarg = 0) |
1632 | int cf_object_cast_ability (object *caster, object *ctoo, int dir, object *sp_, char *stringarg = 0) |
1466 | |
1633 | |
… | |
… | |
1503 | |
1670 | |
1504 | void cf_object_pickup (object *op, object *what) |
1671 | void cf_object_pickup (object *op, object *what) |
1505 | |
1672 | |
1506 | object *cf_create_object_by_name (const char *name) |
1673 | object *cf_create_object_by_name (const char *name) |
1507 | |
1674 | |
1508 | void change_exp (object *op, double exp, const char *skill_name = 0, int flag = 0) |
1675 | void change_exp (object *op, uint64 exp, const char *skill_name = 0, int flag = 0) |
1509 | |
1676 | |
1510 | void player_lvl_adj (object *who, object *skill = 0) |
1677 | void player_lvl_adj (object *who, object *skill = 0) |
1511 | |
1678 | |
1512 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
1679 | int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) |
|
|
1680 | |
|
|
1681 | int calc_skill_exp (object *who, object *op, object *skill); |
|
|
1682 | |
|
|
1683 | void push_button (object *op); |
|
|
1684 | |
|
|
1685 | void use_trigger (object *op); |
|
|
1686 | |
|
|
1687 | void add_button_link (object *button, mapstruct *map, int connected); |
|
|
1688 | |
|
|
1689 | void remove_button_link (object *op); |
|
|
1690 | |
|
|
1691 | void |
|
|
1692 | cf_object_set_resistance (object *op, int rtype, int val) |
|
|
1693 | CODE: |
|
|
1694 | if (rtype >= 0 && rtype < NROFATTACKS) |
|
|
1695 | op->resist[rtype] = val; |
|
|
1696 | |
1513 | |
1697 | |
1514 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
1698 | MODULE = cf PACKAGE = cf::object PREFIX = cf_ |
1515 | |
1699 | |
1516 | void cf_fix_object (object *pl) |
1700 | void cf_fix_object (object *pl) |
1517 | ALIAS: fix = 0 |
1701 | ALIAS: fix = 0 |
… | |
… | |
1540 | const char *options (object *op) |
1724 | const char *options (object *op) |
1541 | CODE: |
1725 | CODE: |
1542 | RETVAL = op->name; |
1726 | RETVAL = op->name; |
1543 | OUTPUT: |
1727 | OUTPUT: |
1544 | RETVAL |
1728 | RETVAL |
|
|
1729 | |
|
|
1730 | player *contr (object *op) |
|
|
1731 | CODE: |
|
|
1732 | RETVAL = op->contr; |
|
|
1733 | OUTPUT: RETVAL |
1545 | |
1734 | |
1546 | const char *get_ob_key_value (object *op, const char *key) |
1735 | const char *get_ob_key_value (object *op, const char *key) |
1547 | |
1736 | |
1548 | bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1) |
1737 | bool set_ob_key_value (object *op, const char *key, const char *value = 0, int add_key = 1) |
1549 | |
1738 | |
… | |
… | |
1593 | |
1782 | |
1594 | void cf_player_message (object *obj, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE) |
1783 | void cf_player_message (object *obj, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE) |
1595 | |
1784 | |
1596 | object *cf_player_send_inventory (object *op) |
1785 | object *cf_player_send_inventory (object *op) |
1597 | |
1786 | |
1598 | player *contr (object *op) |
|
|
1599 | CODE: |
|
|
1600 | RETVAL = op->contr; |
|
|
1601 | OUTPUT: RETVAL |
|
|
1602 | |
|
|
1603 | char *cf_player_get_ip (object *op) |
1787 | char *cf_player_get_ip (object *op) |
1604 | ALIAS: ip = 0 |
1788 | ALIAS: ip = 0 |
1605 | |
1789 | |
1606 | object *cf_player_get_marked_item (object *op) |
1790 | object *cf_player_get_marked_item (object *op) |
1607 | ALIAS: marked_item = 0 |
1791 | ALIAS: marked_item = 0 |
… | |
… | |
1610 | |
1794 | |
1611 | partylist *cf_player_get_party (object *op) |
1795 | partylist *cf_player_get_party (object *op) |
1612 | ALIAS: party = 0 |
1796 | ALIAS: party = 0 |
1613 | |
1797 | |
1614 | void cf_player_set_party (object *op, partylist *party) |
1798 | void cf_player_set_party (object *op, partylist *party) |
1615 | |
|
|
1616 | void change_skill (object *op, double exp, char *skill_name = 0, int flag = 0) |
|
|
1617 | |
1799 | |
1618 | void kill_player (object *op) |
1800 | void kill_player (object *op) |
1619 | |
1801 | |
1620 | MODULE = cf PACKAGE = cf::object::map PREFIX = cf_ |
1802 | MODULE = cf PACKAGE = cf::object::map PREFIX = cf_ |
1621 | |
1803 | |
… | |
… | |
1743 | mapstruct *new (int width, int height) |
1925 | mapstruct *new (int width, int height) |
1744 | PROTOTYPE: |
1926 | PROTOTYPE: |
1745 | CODE: |
1927 | CODE: |
1746 | { |
1928 | { |
1747 | int unused_type; |
1929 | int unused_type; |
1748 | RETVAL = map_get_map (&unused_type, 0, width, height); |
1930 | RETVAL = (mapstruct*) map_get_map (&unused_type, 0, width, height); |
1749 | } |
1931 | } |
1750 | OUTPUT: |
1932 | OUTPUT: |
1751 | RETVAL |
1933 | RETVAL |
1752 | |
1934 | |
1753 | void delete_map (mapstruct *map) |
1935 | void delete_map (mapstruct *map) |
1754 | |
1936 | |
1755 | void clean_tmp_map (mapstruct *map) |
1937 | void clean_tmp_map (mapstruct *map) |
1756 | |
1938 | |
1757 | void play_sound_map (mapstruct *map, int x, int y, int sound_num) |
1939 | void play_sound_map (mapstruct *map, int x, int y, int sound_num) |
|
|
1940 | |
|
|
1941 | mapstruct *tile_map (mapstruct *map, unsigned int dir) |
|
|
1942 | CODE: |
|
|
1943 | RETVAL = dir < 4 ? map->tile_map [dir] : 0; |
|
|
1944 | OUTPUT: |
|
|
1945 | RETVAL |
|
|
1946 | |
|
|
1947 | char *tile_path (mapstruct *map, unsigned int dir) |
|
|
1948 | CODE: |
|
|
1949 | if (dir >= 4) |
|
|
1950 | XSRETURN_UNDEF; |
|
|
1951 | RETVAL = map->tile_path [dir]; |
|
|
1952 | OUTPUT: |
|
|
1953 | RETVAL |
1758 | |
1954 | |
1759 | mapstruct *cf_map_get_map (char *name) |
1955 | mapstruct *cf_map_get_map (char *name) |
1760 | PROTOTYPE: $ |
1956 | PROTOTYPE: $ |
1761 | ALIAS: map = 0 |
1957 | ALIAS: map = 0 |
1762 | |
1958 | |
|
|
1959 | mapstruct *has_been_loaded (char *name) |
|
|
1960 | PROTOTYPE: $ |
|
|
1961 | |
1763 | mapstruct *cf_map_get_first () |
1962 | mapstruct *cf_map_get_first () |
1764 | PROTOTYPE: |
1963 | PROTOTYPE: |
1765 | ALIAS: first = 0 |
1964 | ALIAS: first = 0 |
1766 | |
1965 | |
1767 | # whoever "designed" the plug-in api should have wasted |
1966 | # whoever "designed" the plug-in api should have wasted |
1768 | # his/her time with staying away form the project - would have |
1967 | # his/her time with staying away from the project - would have |
1769 | # saved others a lot of time, without doubt. |
1968 | # saved others a lot of time, without doubt. |
1770 | void set_path (mapstruct *where, char *path) |
1969 | void set_path (mapstruct *where, char *path) |
1771 | CODE: |
1970 | CODE: |
1772 | strcpy (where->path, path); |
1971 | strcpy (where->path, path); |
|
|
1972 | |
|
|
1973 | int in_memory (mapstruct *map) |
|
|
1974 | CODE: |
|
|
1975 | RETVAL = map->in_memory; |
|
|
1976 | OUTPUT: |
|
|
1977 | RETVAL |
1773 | |
1978 | |
1774 | bool unique (mapstruct *map) |
1979 | bool unique (mapstruct *map) |
1775 | CODE: |
1980 | CODE: |
1776 | RETVAL = map->unique; |
1981 | RETVAL = map->unique; |
1777 | OUTPUT: |
1982 | OUTPUT: |
… | |
… | |
1940 | ALIAS: more = 0 |
2145 | ALIAS: more = 0 |
1941 | |
2146 | |
1942 | const char *cf_archetype_get_name (archetype *arch) |
2147 | const char *cf_archetype_get_name (archetype *arch) |
1943 | ALIAS: name = 0 |
2148 | ALIAS: name = 0 |
1944 | |
2149 | |
|
|
2150 | object *cf_archetype_get_clone (archetype *arch) |
|
|
2151 | ALIAS: clone = 0 |
|
|
2152 | |
1945 | MODULE = cf PACKAGE = cf::party PREFIX = cf_party_ |
2153 | MODULE = cf PACKAGE = cf::party PREFIX = cf_party_ |
1946 | |
2154 | |
1947 | partylist *cf_party_get_first () |
2155 | partylist *cf_party_get_first () |
1948 | PROTOTYPE: |
2156 | PROTOTYPE: |
1949 | ALIAS: first = 0 |
2157 | ALIAS: first = 0 |
… | |
… | |
1985 | ALIAS: message = 0 |
2193 | ALIAS: message = 0 |
1986 | |
2194 | |
1987 | |
2195 | |
1988 | MODULE = cf PACKAGE = cf::living PREFIX = cf_living_ |
2196 | MODULE = cf PACKAGE = cf::living PREFIX = cf_living_ |
1989 | |
2197 | |
1990 | double |
2198 | val64 |
1991 | exp (living *liv, double new_val = 0.) |
2199 | exp (living *liv, val64 new_val = 0) |
1992 | PROTOTYPE: $;$ |
2200 | PROTOTYPE: $;$ |
1993 | ALIAS: |
2201 | ALIAS: |
1994 | Str = 1 |
2202 | Str = 1 |
1995 | Dex = 2 |
2203 | Dex = 2 |
1996 | Con = 3 |
2204 | Con = 3 |
… | |
… | |
2008 | maxgrace = 15 |
2216 | maxgrace = 15 |
2009 | food = 16 |
2217 | food = 16 |
2010 | dam = 17 |
2218 | dam = 17 |
2011 | luck = 18 |
2219 | luck = 18 |
2012 | CODE: |
2220 | CODE: |
2013 | # define LIVING_ACC(acc,idx) case idx: RETVAL = liv->acc; if (items > 1) liv->acc = new_val; break |
2221 | # define LIVING_ACC(acc,idx) case idx: RETVAL = liv->acc; if (items > 1) liv->acc = (sint64)new_val; break |
2014 | switch (ix) |
2222 | switch (ix) |
2015 | { |
2223 | { |
2016 | LIVING_ACC (exp , 0); |
2224 | LIVING_ACC (exp , 0); |
2017 | LIVING_ACC (Str , 1); |
2225 | LIVING_ACC (Str , 1); |
2018 | LIVING_ACC (Dex , 2); |
2226 | LIVING_ACC (Dex , 2); |