script.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef _SCRIPT_H_
  4. #define _SCRIPT_H_
  5. extern int potion_flag; //For use on Alchemist improved potions/Potion Pitcher. [Skotlex]
  6. extern int potion_hp, potion_per_hp, potion_sp, potion_per_sp;
  7. extern int potion_target;
  8. extern struct Script_Config {
  9. unsigned verbose_mode : 1;
  10. unsigned warn_func_no_comma : 1;
  11. unsigned warn_cmd_no_comma : 1;
  12. unsigned warn_func_mismatch_paramnum : 1;
  13. unsigned warn_cmd_mismatch_paramnum : 1;
  14. int check_cmdcount;
  15. int check_gotocount;
  16. unsigned event_script_type : 1;
  17. unsigned event_requires_trigger : 1;
  18. char die_event_name[NAME_LENGTH];
  19. char kill_pc_event_name[NAME_LENGTH];
  20. char kill_mob_event_name[NAME_LENGTH];
  21. char login_event_name[NAME_LENGTH];
  22. char logout_event_name[NAME_LENGTH];
  23. char loadmap_event_name[NAME_LENGTH];
  24. char baselvup_event_name[NAME_LENGTH];
  25. char joblvup_event_name[NAME_LENGTH];
  26. } script_config;
  27. struct script_data {
  28. int type;
  29. union {
  30. int num;
  31. char *str;
  32. } u;
  33. struct linkdb_node** ref; // リファレンス
  34. };
  35. // Moved defsp from script_state to script_stack since
  36. // it must be saved when script state is RERUNLINE. [Eoe / jA 1094]
  37. struct script_code {
  38. int script_size;
  39. unsigned char* script_buf;
  40. struct linkdb_node* script_vars;
  41. };
  42. struct script_stack {
  43. int sp,sp_max,defsp;
  44. struct script_data *stack_data;
  45. struct linkdb_node **var_function; // 関数依存変数
  46. };
  47. struct script_state {
  48. struct script_stack *stack;
  49. int start,end;
  50. int pos,state;
  51. int rid,oid;
  52. //unsigned char *script,*new_script;
  53. int new_pos,new_defsp;
  54. struct script_code *script, *scriptroot;
  55. struct sleep_data {
  56. int tick,timer,charid;
  57. } sleep;
  58. };
  59. struct script_code *parse_script(unsigned char *,int);
  60. int run_script(struct script_code *rootscript,int pos,int rid,int oid);
  61. int set_var(struct map_session_data *sd, char *name, void *val);
  62. int conv_num(struct script_state *st,struct script_data *data);
  63. char* conv_str(struct script_state *st,struct script_data *data);
  64. void setd_sub(struct script_state *st, struct map_session_data *sd, char *varname, int elem, void *value, struct linkdb_node **ref);
  65. int run_script_timer(int tid, unsigned int tick, int id, int data);
  66. int run_script_main(struct script_state *st);
  67. struct linkdb_node* script_erase_sleepdb(struct linkdb_node *n);
  68. void script_free_code(struct script_code* code);
  69. struct dbt* script_get_label_db(void);
  70. struct dbt* script_get_userfunc_db(void);
  71. int script_config_read(char *cfgName);
  72. void script_free_stack(struct script_stack*);
  73. int do_init_script(void);
  74. int do_final_script(void);
  75. int script_reload(void);
  76. extern char mapreg_txt[];
  77. #endif