1 #ifndef LUA_SCRIPT_H 2 #define LUA_SCRIPT_H 3 4 /* 5 LUA_SCRIPT.H 6 7 Copyright (C) 2003 and beyond by Matthew Hielscher 8 and the "Aleph One" developers 9 10 This program is free software; you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation; either version 3 of the License, or 13 (at your option) any later version. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 This license is contained in the file "COPYING", 21 which is included with this source code; it is available online at 22 http://www.gnu.org/licenses/gpl.html 23 24 Controls the loading and execution of Lua scripts. 25 */ 26 27 #include "cseries.h" 28 #include "world.h" 29 #include "ActionQueues.h" 30 #include "shape_descriptors.h" 31 32 #include <map> 33 #include <string> 34 35 void L_Error(const char *message); 36 void L_Call_Init(bool fRestoringSaved); 37 void L_Call_Cleanup(); 38 void L_Call_Idle(); 39 void L_Call_PostIdle(); 40 void L_Call_Start_Refuel(short type, short player_index, short panel_side_index); 41 void L_Call_End_Refuel(short type, short player_index, short panel_side_index); 42 void L_Call_Tag_Switch(short tag, short player_index, short side_index); 43 void L_Call_Light_Switch(short light, short player_index, short side_index); 44 void L_Call_Platform_Switch(short platform, short player_index, short side_index); 45 void L_Call_Terminal_Enter(short terminal_id, short player_index); 46 void L_Call_Terminal_Exit(short terminal_id, short player_index); 47 void L_Call_Pattern_Buffer(short side_index, short player_index); 48 void L_Call_Projectile_Switch(short side_index, short projectile_index); 49 void L_Call_Got_Item(short type, short player_index); 50 void L_Call_Light_Activated(short index); 51 void L_Call_Platform_Activated(short index); 52 void L_Call_Player_Revived(short player_index); 53 void L_Call_Player_Killed(short player_index, short aggressor_player_index, short action, short projectile_index); 54 void L_Call_Monster_Killed(short monster_index, short aggressor_player_index, short projectile_index); 55 void L_Call_Monster_Damaged(short monster_index, short aggressor_monster_index, int16 damage_type, short damage_amount, short projectile_index); 56 void L_Call_Player_Damaged(short player_index, short aggressor_player_index, short aggressor_monster_index, int16 damage_type, short damage_amount, short projectile_index); 57 void L_Call_Projectile_Detonated(short type, short owner_index, short polygon, world_point3d location); 58 void L_Call_Projectile_Created(short projectile_index); 59 void L_Call_Item_Created(short item_index); 60 61 void L_Invalidate_Effect(short effect_index); 62 void L_Invalidate_Monster(short monster_index); 63 void L_Invalidate_Projectile(short projectile_index); 64 void L_Invalidate_Object(short object_index); 65 66 enum ScriptType { 67 _embedded_lua_script, 68 _lua_netscript, 69 _solo_lua_script, 70 _stats_lua_script 71 }; 72 73 void *L_Persistent_Table_Key(); 74 75 bool LoadLuaScript(const char *buffer, size_t len, ScriptType type); 76 bool RunLuaScript(); 77 void CloseLuaScript(); 78 void ResetPassedLua(); 79 80 void ExecuteLuaString(const std::string&); 81 void LoadSoloLua(); 82 void LoadReplayNetLua(); 83 84 void LoadStatsLua(); 85 bool CollectLuaStats(std::map<std::string, std::string>& table, std::map<std::string, std::string>& parameters); 86 87 void ToggleLuaMute(); 88 void ResetLuaMute(); 89 90 bool UseLuaCameras(); 91 92 void unpack_lua_states(uint8* data, size_t length); 93 size_t save_lua_states(); 94 void pack_lua_states(uint8* data, size_t length); 95 96 ActionQueues* GetLuaActionQueues(); 97 98 void MarkLuaCollections(bool active); 99 100 void LuaTexturePaletteClear(); 101 int LuaTexturePaletteSize(); 102 shape_descriptor LuaTexturePaletteTexture(size_t); 103 short LuaTexturePaletteTextureType(size_t); 104 int LuaTexturePaletteSelected(); 105 106 bool LuaPlayerCanWieldWeapons(short player_index); 107 108 /* Custom game scoring modes */ 109 enum { 110 _game_of_most_points, 111 _game_of_most_time, 112 _game_of_least_points, 113 _game_of_least_time, 114 NUMBER_OF_GAME_SCORING_MODES 115 }; 116 117 /* Game end conditions */ 118 enum { 119 _game_normal_end_condition, 120 _game_no_end_condition, 121 _game_end_now_condition, 122 NUMBER_OF_GAME_END_CONDITIONS 123 }; 124 125 int GetLuaScoringMode(); 126 int GetLuaGameEndCondition(); 127 128 // camera data structures 129 struct timed_point 130 { 131 int polygon; 132 world_point3d point; 133 int32 delta_time; //for REALLY long cutscenes 134 }; 135 136 struct timed_angle 137 { 138 short yaw, pitch; 139 int32 delta_time; 140 }; 141 142 struct lua_path 143 { 144 short index; 145 std::vector<timed_point> path_points; 146 short current_point_index; 147 int32 last_point_time; 148 std::vector<timed_angle> path_angles; 149 short current_angle_index; 150 int32 last_angle_time; 151 }; 152 153 struct lua_camera //an expanded version of script_camera; uses Lua's path scheme 154 { 155 short index; 156 lua_path path; 157 int32 time_elapsed; 158 int player_active; 159 }; 160 161 #endif 162