Osiris_CallEvent Purpose: Triggers an event for an object. Pass in the event number and the associated structure of data. All events will be chained through the associated scripts of the object (as long as they are available) in the order: custom script, level script, mission script, and finally it's default script. The chain breaks if one of the scripts returns false on the call to their CallI
| 2120 | // mission script, and finally it's default script. The chain breaks if one of the scripts |
| 2121 | // returns false on the call to their CallInstanceEvent(). |
| 2122 | bool Osiris_CallEvent(object *obj, int event, tOSIRISEventInfo *data) { |
| 2123 | if ((Game_mode & GM_MULTI) && (Netgame.local_role != LR_SERVER)) { |
| 2124 | // no scripts for a client! |
| 2125 | return true; |
| 2126 | } |
| 2127 | |
| 2128 | if (!(Osiris_event_mask & OEM_OBJECTS)) |
| 2129 | return true; // object events are disabled |
| 2130 | |
| 2131 | if (!Osiris_IsEventEnabled(event)) |
| 2132 | return true; |
| 2133 | |
| 2134 | // make sure the object is valid |
| 2135 | if (!CANHAVEANYSCRIPT(obj)) { |
| 2136 | // invalid object |
| 2137 | return true; |
| 2138 | } |
| 2139 | |
| 2140 | if (!obj->osiris_script) { |
| 2141 | // mprintf(0,"OSIRIS: Unhandled event (%d) for object id=%d\n",event,obj->id); |
| 2142 | return true; // no script for this object...hmm |
| 2143 | } |
| 2144 | |
| 2145 | int dll_id; |
| 2146 | int aux_event = -1; // event value |
| 2147 | tOSIRISScript *os; |
| 2148 | int16_t ret = CONTINUE_CHAIN | CONTINUE_DEFAULT; |
| 2149 | |
| 2150 | if (event == EVT_AI_NOTIFY) { |
| 2151 | switch (data->evt_ai_notify.notify_type) { |
| 2152 | case AIN_OBJ_KILLED: |
| 2153 | aux_event = EVT_AIN_OBJKILLED; |
| 2154 | break; |
| 2155 | case AIN_SEE_TARGET: |
| 2156 | aux_event = EVT_AIN_SEEPLAYER; |
| 2157 | break; |
| 2158 | case AIN_WHIT_OBJECT: |
| 2159 | aux_event = EVT_AIN_WHITOBJECT; |
| 2160 | break; |
| 2161 | case AIN_GOAL_COMPLETE: |
| 2162 | aux_event = EVT_AIN_GOALCOMPLETE; |
| 2163 | break; |
| 2164 | case AIN_GOAL_INVALID: |
| 2165 | aux_event = EVT_AIN_GOALFAIL; |
| 2166 | break; |
| 2167 | case AIN_GOAL_FAIL: |
| 2168 | aux_event = EVT_AIN_GOALFAIL; |
| 2169 | break; |
| 2170 | case AIN_GOAL_ERROR: |
| 2171 | aux_event = EVT_AIN_GOALFAIL; |
| 2172 | break; |
| 2173 | case AIN_MELEE_HIT: |
| 2174 | aux_event = EVT_AIN_MELEE_HIT; |
| 2175 | break; |
| 2176 | case AIN_MELEE_ATTACK_FRAME: |
| 2177 | aux_event = EVT_AIN_MELEE_ATTACK_FRAME; |
| 2178 | break; |
| 2179 | case AIN_MOVIE_START: |
no test coverage detected