Process all AI Notify events
| 3908 | |
| 3909 | // Process all AI Notify events |
| 3910 | bool AlienOrganism::DoNotify(int me, tOSIRISEventInfo *data) { |
| 3911 | if (IsGoalFinishedNotify(data->evt_ai_notify.notify_type)) { |
| 3912 | // Handle goal complete events |
| 3913 | switch (data->evt_ai_notify.goal_uid) { |
| 3914 | case ALIEN_GUID_GOT_HOME: |
| 3915 | memory->done_moving = true; |
| 3916 | break; |
| 3917 | case ALIEN_GUID_LANDED: |
| 3918 | memory->done_moving = true; |
| 3919 | break; |
| 3920 | case ALIEN_GUID_GOT_TO_DEST_OBJ: |
| 3921 | memory->dest_object_handle = OBJECT_HANDLE_NONE; |
| 3922 | SetMode(me, memory->mode); |
| 3923 | mprintf(0, "Alien got to destination object.\n"); |
| 3924 | break; |
| 3925 | } |
| 3926 | } else if (data->evt_ai_notify.notify_type == AIN_SCRIPTED_ORIENT) { |
| 3927 | // Handle custom orientation events |
| 3928 | if (memory->mode == ALIEN_LANDING_AT_HOME) { |
| 3929 | memory->done_turning = (AI_TurnTowardsVectors(me, &memory->home_fvec, &memory->home_uvec) != 0); |
| 3930 | } |
| 3931 | } else if (data->evt_ai_notify.notify_type == AIN_FIRED_WEAPON) { |
| 3932 | mprintf(0, "Energy weapon fired...\n"); |
| 3933 | |
| 3934 | // Subtract energy it took to fire energy bolt |
| 3935 | memory->energy_charges -= ALIEN_ENERGY_BOLT_COST; |
| 3936 | if (memory->energy_charges < 0.0f) |
| 3937 | memory->energy_charges = 0.0f; |
| 3938 | } else if (data->evt_ai_notify.notify_type == AIN_SCRIPTED_GOAL) { |
| 3939 | // mprintf(0,"Custom goal called.\n"); |
| 3940 | vector my_pos, dir; |
| 3941 | |
| 3942 | Obj_Value(me, VF_GET, OBJV_V_POS, &my_pos); |
| 3943 | SendCommand(me, memory->leader_handle, ALIEN_COM_GET_GOAL_POS, &memory->squad_goal_pos); |
| 3944 | dir = memory->squad_goal_pos - my_pos; |
| 3945 | vm_VectorNormalize(&dir); |
| 3946 | |
| 3947 | AI_Value(me, VF_SET, AIV_V_MOVEMENT_DIR, &dir); |
| 3948 | } else if (data->evt_ai_notify.notify_type == AIN_SCRIPTED_ENABLER) { |
| 3949 | // mprintf(0,"Custom enabler called.\n"); |
| 3950 | bool is_visible; |
| 3951 | |
| 3952 | // Ask leader if he can see me |
| 3953 | SendCommand(me, memory->leader_handle, ALIEN_COM_CAN_YOU_SEE_ME, &is_visible); |
| 3954 | |
| 3955 | // If I'm visible, do straight line to position, otherwise deactivate this goal |
| 3956 | return is_visible; |
| 3957 | } else if (data->evt_ai_notify.notify_type == AIN_MELEE_HIT) { |
| 3958 | // Make sure we are doing the energy suck attack |
| 3959 | if (data->evt_ai_notify.attack_num == 0) { |
| 3960 | int target = data->evt_ai_notify.it_handle; |
| 3961 | |
| 3962 | // Check if target has energy (if not a player, assume it does have energy) |
| 3963 | bool target_has_energy = true; |
| 3964 | int type; |
| 3965 | Obj_Value(target, VF_GET, OBJV_I_TYPE, &type); |
| 3966 | if (type == OBJ_PLAYER) { |
| 3967 | if (qObjEnergy(target) <= 0.0f) { |
nothing calls this directly
no test coverage detected