| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #ifndef GAMEEVENT_H |
| 20 | #define GAMEEVENT_H |
| 21 | |
| 22 | #include "game.h" |
| 23 | #include "object.h" |
| 24 | |
| 25 | #define MAX_EVENTS 500 |
| 26 | |
| 27 | // Game event types |
| 28 | #define OBJECT_EVENT 1 |
| 29 | #define RENDER_EVENT 2 |
| 30 | |
| 31 | // IDs |
| 32 | #define UNKNOWN_EVENT 0 |
| 33 | #define FUSION_EFFECT 1 |
| 34 | #define DAMAGE_EFFECT 2 |
| 35 | #define SCREEN_BLEND 3 |
| 36 | #define BLAST_RING_EVENT 4 |
| 37 | #define FOV_CHANGE_EVENT 5 |
| 38 | #define EDRAIN_EFFECT 6 |
| 39 | |
| 40 | #define D3X_TIMED_EVENT 256 |
| 41 | |
| 42 | struct game_event { |
| 43 | int type; |
| 44 | int id; |
| 45 | int objhandle_detonator; // watch this object, if it dies/gets killed than cancel this game event |
| 46 | uint8_t used; |
| 47 | float start_time, end_time; |
| 48 | int frame_born; |
| 49 | |
| 50 | void *data; |
| 51 | |
| 52 | void (*subfunction)(int, void *); |
| 53 | }; |
| 54 | |
| 55 | // Adds and event to the list. The event will trigger at Gametime+length |
| 56 | int CreateNewEvent(int type, int id, float length, void *data, int size, void (*subfunction)(int eventnum, void *data), |
| 57 | int objhandle_detonator = OBJECT_HANDLE_NONE); |
| 58 | |
| 59 | // Processes all pending events, removing the ones that are expired |
| 60 | void ProcessNormalEvents(); |
| 61 | void ProcessRenderEvents(); |
| 62 | |
| 63 | // Does a specific action according to an event |
| 64 | void HandleEvent(game_event *); |
| 65 | |
| 66 | // Clears the event list |
| 67 | void ClearAllEvents(); |
| 68 | |
| 69 | // Returns -1 if can't find event, else index of event int GameEvent array |
| 70 | int FindEventID(int id); |
| 71 | |
| 72 | // Frees an event for use by others |
| 73 | void FreeEvent(int index); |
| 74 | |
| 75 | extern game_event GameEvent[MAX_EVENTS]; |
| 76 | extern int Num_events; |
| 77 | |
| 78 | #endif |