static void Execute_PAQNS_Approach(STRATEGYBLOCK *sbPtr) { PAQ_STATUS_BLOCK *paqStatusPointer; VECTORCH velocityDirection = {0,0,0}; DYNAMICSBLOCK *dynPtr; VECTORCH targetPosition; int targetIsAirduct = 0; LOCALASSERT(sbPtr); paqStatusPointer = (PAQ_STATUS_BLOCK *)(sbPtr->SBdataptr); LOCALASSERT(paqStatusPointer); LOCALASSERT(sbPtr->DynPtr); dynPtr = sbPtr->DynPtr; /* check for state changes... */ if(!(PAQShouldAttackPlayer())) { paqStatusPointer->NearBehaviourState = PAQNS_Wait; paqStatusPointer->stateTimer = PAQ_NEARWAITTIME; SetPAQAnimationSequence(sbPtr,PaqSQ_Stand,10); return; } /* check if we want to close-attack */ if(VectorDistance((&Player->ObStrategyBlock->DynPtr->Position),(&sbPtr->DynPtr->Position)) < PAQ_CLOSE_ATTACK_RANGE) { paqStatusPointer->NearBehaviourState = PAQNS_Attack; paqStatusPointer->stateTimer = PAQ_NEAR_CLOSEATTACK_TIME; /* choice of two animations for pred-alien */ if(sbPtr->I_SBtype==I_BehaviourPredatorAlien) { if(FastRandom()&0x01) SetPAQAnimationSequence(sbPtr,PaqSQ_Attack,10); else SetPAQAnimationSequence(sbPtr,PaqSQ_Attack2,10); } else SetPAQAnimationSequence(sbPtr,PaqSQ_Attack,10); return; } /* Do some approach sound */ { unsigned int random=FastRandom(); switch (random & 255) { case 0: { Sound_Play(SID_ALIEN_SCREAM,"d",&dynPtr->Position); break; } case 1: { Sound_Play(SID_ALIEN_HISS,"d",&dynPtr->Position); break; } case 2: { Sound_Play(SID_ALIEN_HISS1,"d",&dynPtr->Position); break; } case 3: { Sound_Play(SID_ALIEN_HIT,"d",&dynPtr->Position); break; } case 4: { Sound_Play(SID_ALIEN_HIT2,"d",&dynPtr->Position); break; } default: { break; } } if(sbPtr->I_SBtype==I_BehaviourPredatorAlien) { switch ((random >> 8) & 255) { case 0: { Sound_Play(SID_PRED_SNARL,"d",&dynPtr->Position); break; } case 1: { Sound_Play(SID_PRED_SCREAM1,"d",&dynPtr->Position); break; } case 2: { Sound_Play(SID_PRED_LOUDROAR,"d",&dynPtr->Position); break; } case 3: { Sound_Play(SID_PRED_SHORTROAR,"d",&dynPtr->Position); break; } default: { break; } } } } /*still approaching then... first, find point to aim for*/ NPCGetMovementTarget(sbPtr, Player->ObStrategyBlock, &targetPosition, &targetIsAirduct); NPCGetMovementDirection(sbPtr, &velocityDirection, &targetPosition,1); NPCSetVelocity(sbPtr, &velocityDirection, paqStatusPointer->nearSpeed); { STRATEGYBLOCK *destructableObject = NULL; NPC_OBSTRUCTIONREPORT obstruction; NPC_IsObstructed(sbPtr,&(paqStatusPointer->moveData),&obstruction,&destructableObject); if(obstruction.environment) { /* go to avoidance */ NPC_InitMovementData(&(paqStatusPointer->moveData)); NPCGetAvoidanceDirection(sbPtr, &(paqStatusPointer->moveData.avoidanceDirn),&obstruction); paqStatusPointer->NearBehaviourState = PAQNS_Avoidance; paqStatusPointer->stateTimer = NPC_AVOIDTIME; /* no sequence change required */ return; } if(obstruction.destructableObject) { LOCALASSERT(destructableObject); CauseDamageToObject(destructableObject,&TemplateAmmo[AMMO_NPC_OBSTACLE_CLEAR].MaxDamage, ONE_FIXED,NULL); } } if(NPC_CannotReachTarget(&(paqStatusPointer->moveData), &targetPosition, &velocityDirection)) { /* go to avoidance */ NPC_OBSTRUCTIONREPORT obstruction = {1,0,0}; NPC_InitMovementData(&(paqStatusPointer->moveData)); NPCGetAvoidanceDirection(sbPtr, &(paqStatusPointer->moveData.avoidanceDirn),&obstruction); paqStatusPointer->NearBehaviourState = PAQNS_Avoidance; paqStatusPointer->stateTimer = NPC_AVOIDTIME; /* no sequence change required */ return; } }
static void Execute_PAQNS_Attack(STRATEGYBLOCK *sbPtr) { VECTORCH orientationDirn; PAQ_STATUS_BLOCK *paqStatusPointer; DYNAMICSBLOCK *dynPtr; int i; LOCALASSERT(sbPtr); paqStatusPointer = (PAQ_STATUS_BLOCK *)(sbPtr->SBdataptr); LOCALASSERT(paqStatusPointer); LOCALASSERT(sbPtr->DynPtr); dynPtr = sbPtr->DynPtr; /* Orientate towards player, just to make sure we're facing */ orientationDirn.vx = Player->ObWorld.vx - sbPtr->DynPtr->Position.vx; orientationDirn.vy = 0; orientationDirn.vz = Player->ObWorld.vz - sbPtr->DynPtr->Position.vz; i = NPCOrientateToVector(sbPtr, &orientationDirn,NPC_TURNRATE,NULL); if(VectorDistance(&(sbPtr->DynPtr->Position), &(Player->ObStrategyBlock->DynPtr->Position)) > PAQ_CLOSE_ATTACK_RANGE) { /* switch to approach state: don't need to directly test if we should switch to wander, as approach state will do this anyway... */ NPC_InitMovementData(&(paqStatusPointer->moveData)); paqStatusPointer->NearBehaviourState = PAQNS_Approach; paqStatusPointer->stateTimer = 0; SetPAQAnimationSequence(sbPtr,PaqSQ_Run,10); return; } /* Make the attack sound */ if (paqStatusPointer->stateTimer == PAQ_NEAR_CLOSEATTACK_TIME) { if(sbPtr->I_SBtype==I_BehaviourPredatorAlien) { #define PREDALIEN_ATTACK_PITCH 350 unsigned int rand=FastRandom(); switch (rand & 7) { case 0: { Sound_Play(SID_SWIPE,"dp",&dynPtr->Position,(rand&255)-128-PREDALIEN_ATTACK_PITCH); break; } case 1: { Sound_Play(SID_SWIPE2,"dp",&dynPtr->Position,(rand&255)-128-PREDALIEN_ATTACK_PITCH); break; } case 2: { Sound_Play(SID_SWIPE3,"dp",&dynPtr->Position,(rand&255)-128-PREDALIEN_ATTACK_PITCH); break; } case 3: { Sound_Play(SID_TAIL,"dp",&dynPtr->Position,(rand & 255)-PREDALIEN_ATTACK_PITCH); break; } case 4: { Sound_Play(SID_PRED_SLASH,"dp",&dynPtr->Position,(rand&255)-128); break; } case 5: { Sound_Play(SID_RIP,"dp",&dynPtr->Position,(rand&255)-128); break; } case 6: { Sound_Play(SID_SWISH,"dp",&dynPtr->Position,-(rand & 255)-PREDALIEN_ATTACK_PITCH); break; } case 7: { Sound_Play(SID_ALIEN_HISS,"dp",&dynPtr->Position,-(rand & 255)-PREDALIEN_ATTACK_PITCH); break; } default: { break; } } } else { unsigned int rand=FastRandom(); switch (rand & 7) { case 0: { Sound_Play(SID_SWIPE,"dp",&dynPtr->Position,(rand&255)-128); break; } case 1: { Sound_Play(SID_SWIPE2,"dp",&dynPtr->Position,(rand&255)-128); break; } case 2: { Sound_Play(SID_SWIPE3,"dp",&dynPtr->Position,(rand&255)-128); break; } case 3: { Sound_Play(SID_TAIL,"dp",&dynPtr->Position,-(rand & 255)); break; } case 4: { Sound_Play(SID_ALIEN_HISS1,"dp",&dynPtr->Position,(rand&255)-128); break; } case 5: { Sound_Play(SID_ALIEN_SCREAM,"dp",&dynPtr->Position,(rand&255)-128); break; } case 6: { Sound_Play(SID_SWISH,"dp",&dynPtr->Position,-(rand & 255)); break; } case 7: { Sound_Play(SID_ALIEN_HISS,"dp",&dynPtr->Position,-(rand & 255)); break; } default: { break; } } } } /* Decrement the near state timer */ paqStatusPointer->stateTimer -= NormalFrameTime; if(paqStatusPointer->stateTimer > 0) { /* DAMAGE PLAYER HERE: NB USE STATUS BLOCK DAMAGEINFLICTED*/ CauseDamageToObject(Player->ObStrategyBlock,&TemplateAmmo[AMMO_NPC_PAQ_CLAW].MaxDamage, ONE_FIXED,NULL); /* Note, might want to personalise this more. * * I'd love to use a #warning here. */ paqStatusPointer->stateTimer = PAQ_NEAR_CLOSEATTACK_TIME; } }
void PAQIsDamaged(STRATEGYBLOCK *sbPtr, DAMAGE_PROFILE *damage, int multiple) { int rand = FastRandom(); int pitch = (rand & 255) - 128; PAQ_STATUS_BLOCK *paqStatusPointer; LOCALASSERT(sbPtr); paqStatusPointer = (PAQ_STATUS_BLOCK *)(sbPtr->SBdataptr); LOCALASSERT(paqStatusPointer); LOCALASSERT(sbPtr->containingModule); /* if we're dying, do nothing */ if(paqStatusPointer->NearBehaviourState==PAQNS_Dying) { /* PAQFS should be dying, too */ return; } if(!(sbPtr->SBdptr)) { DestroyAnyStrategyBlock(sbPtr); return; } #define QUEEN_PITCH_CHANGE 150 #define PREDALIEN_PITCH_CHANGE 300 if (sbPtr->I_SBtype == I_BehaviourQueenAlien) { switch (rand % 5) { case 0: Sound_Play(SID_ALIEN_SCREAM,"dp",&(sbPtr->DynPtr->Position),QUEEN_PITCH_CHANGE + pitch); break; case 1: Sound_Play(SID_ALIEN_HIT,"dp",&(sbPtr->DynPtr->Position),QUEEN_PITCH_CHANGE + pitch); break; case 2: Sound_Play(SID_ALIEN_HIT2,"dp",&(sbPtr->DynPtr->Position),QUEEN_PITCH_CHANGE + pitch); break; case 3: Sound_Play(SID_ALIEN_HISS1,"dp",&(sbPtr->DynPtr->Position),QUEEN_PITCH_CHANGE + pitch); break; default: Sound_Play(SID_ALIEN_HISS,"dp",&(sbPtr->DynPtr->Position),QUEEN_PITCH_CHANGE + pitch); break; } } else { switch (rand % 7) { case 0: Sound_Play(SID_PRED_SNARL,"dp",&(sbPtr->DynPtr->Position),pitch); break; case 1: Sound_Play(SID_PRED_HISS,"dp",&(sbPtr->DynPtr->Position),pitch); break; case 2: Sound_Play(SID_PRED_SHORTROAR,"dp",&(sbPtr->DynPtr->Position),pitch); break; case 3: Sound_Play(SID_PRED_SCREAM1,"dp",&(sbPtr->DynPtr->Position),pitch); break; case 4: Sound_Play(SID_RIP,"dp",&(sbPtr->DynPtr->Position),pitch); break; case 5: Sound_Play(SID_PRED_SLASH,"dp",&(sbPtr->DynPtr->Position),pitch); break; default: Sound_Play(SID_HIT_FLESH,"dp",&(sbPtr->DynPtr->Position),pitch); break; } switch ((rand >> 4) % 5) { case 0: Sound_Play(SID_ALIEN_SCREAM,"dp",&(sbPtr->DynPtr->Position),-PREDALIEN_PITCH_CHANGE+pitch); break; case 1: Sound_Play(SID_ALIEN_HIT,"dp",&(sbPtr->DynPtr->Position),-PREDALIEN_PITCH_CHANGE+pitch); break; case 2: Sound_Play(SID_ALIEN_HIT2,"dp",&(sbPtr->DynPtr->Position),-PREDALIEN_PITCH_CHANGE+pitch); break; case 3: Sound_Play(SID_ALIEN_HISS1,"dp",&(sbPtr->DynPtr->Position),-PREDALIEN_PITCH_CHANGE+pitch); break; default: Sound_Play(SID_ALIEN_HISS,"dp",&(sbPtr->DynPtr->Position),-PREDALIEN_PITCH_CHANGE+pitch); break; } } /* reduce pa-q health */ //paqStatusPointer->health -= damage; if(sbPtr->SBDamageBlock.Health > 0) return; /* we have been killed... */ paqStatusPointer->NearBehaviourState=PAQNS_Dying; paqStatusPointer->FarBehaviourState=PAQFS_Dying; paqStatusPointer->stateTimer=PAQ_DIETIME; SetPAQAnimationSequence(sbPtr,PaqSQ_Dying,10); /* stop motion */ LOCALASSERT(sbPtr->DynPtr); sbPtr->DynPtr->LinVelocity.vx = sbPtr->DynPtr->LinVelocity.vy = sbPtr->DynPtr->LinVelocity.vz = 0; /* turn off collisions */ if(sbPtr->DynPtr) { sbPtr->DynPtr->IsStatic = 1; sbPtr->DynPtr->DynamicsType = DYN_TYPE_NO_COLLISIONS; sbPtr->DynPtr->GravityOn = 0; } }
void Sound_Laser(void){ Sound_Play(Centipede_Fire1, 1848); };
bool AIScriptMutant2::UpdateAnimation(int *animation, int *frame) { switch (_animationState) { case 0: *animation = 903; _animationFrame++; if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(903)) { _animationFrame = 0; } break; case 1: *animation = 901; _animationFrame++; if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(901)) { _animationFrame = 0; } break; case 2: *animation = 902; _animationFrame++; if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(902)) { _animationFrame = 0; } break; case 3: if (!_animationFrame && _flag) { *animation = 903; _animationState = 0; } else { *animation = 905; _animationFrame++; if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(905)) { _animationFrame = 0; } } break; case 4: *animation = 905; _animationFrame++; if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(905)) { _animationFrame = 0; _animationState = 3; *animation = 904; } break; case 5: *animation = 906; _animationFrame++; if (_animationFrame == 7) { int snd; if (Random_Query(1, 2) == 1) { snd = 9010; } else { snd = 9015; } Sound_Play_Speech_Line(kActorMutant2, snd, 75, 0, 99); } if (_animationFrame == 9) { Actor_Combat_AI_Hit_Attempt(kActorMutant2); } if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(906)) { Actor_Change_Animation_Mode(kActorMutant2, 0); } break; case 6: *animation = 907; _animationFrame++; if (_animationFrame == 1) { Sound_Play(401, 100, 0, 0, 50); } if (_animationFrame >= Slice_Animation_Query_Number_Of_Frames(*animation)) { Actor_Change_Animation_Mode(kActorMutant2, 88); } break; case 7: *animation = 907; _animationFrame = Slice_Animation_Query_Number_Of_Frames(907) - 2; break; case 8: *animation = 907; _animationFrame += _var1; if (_animationFrame == 4) { _var1 = -1; Sound_Play(399, 100, 0, 0, 50); } else { if (!_animationFrame) { Actor_Change_Animation_Mode(kActorMutant2, 0); } } break; default: break; } *frame = _animationFrame; return true; }
void SceneScriptUG18::DialogueQueueFlushed(int a1) { switch (Actor_Query_Goal_Number(kActorGuzza)) { case kGoalGuzzaUG18Target: Actor_Set_Goal_Number(kActorGuzza, kGoalGuzzaUG18WillGetShotBySadik); Actor_Change_Animation_Mode(kActorSadik, kAnimationModeCombatAttack); Sound_Play(14, 100, 0, 0, 50); Actor_Change_Animation_Mode(kActorGuzza, kAnimationModeCombatHit); ADQ_Add(kActorClovis, 630, 13); Actor_Set_Goal_Number(kActorClovis, kGoalClovisUG18SadikWillShootGuzza); break; case kGoalGuzzaUG18ShotByMcCoy: // Bug in the game, shot animation is not reset so McCoy looks still while he is shooting Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeCombatAttack); Sound_Play(13, 100, 0, 0, 50); Actor_Change_Animation_Mode(kActorGuzza, kAnimationModeCombatHit); Delay(900); Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeCombatAttack); Sound_Play(14, 100, 0, 0, 50); Actor_Change_Animation_Mode(kActorGuzza, kAnimationModeCombatHit); Delay(1100); Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeCombatAttack); Sound_Play(12, 100, 0, 0, 50); Actor_Change_Animation_Mode(kActorGuzza, kAnimationModeCombatHit); Delay(900); Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeCombatAttack); Sound_Play(14, 100, 0, 0, 50); Actor_Change_Animation_Mode(kActorGuzza, 61); Overlay_Play("UG18over", 1, false, true, 0); Actor_Set_Goal_Number(kActorGuzza, kGoalGuzzaUG18FallDown); Player_Gains_Control(); ADQ_Add_Pause(2000); ADQ_Add(kActorSadik, 360, -1); ADQ_Add_Pause(2000); ADQ_Add(kActorClovis, 650, 14); ADQ_Add(kActorSadik, 370, 14); ADQ_Add(kActorClovis, 1320, 14); Actor_Set_Goal_Number(kActorClovis, kGoalClovisUG18GuzzaDied); break; case kGoalGuzzaUG18ShootMcCoy: Actor_Change_Animation_Mode(kActorGuzza, kAnimationModeCombatAttack); Sound_Play(13, 100, 0, 0, 50); Actor_Force_Stop_Walking(kActorMcCoy); Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeDie); Player_Loses_Control(); Actor_Retired_Here(kActorMcCoy, 6, 6, true, kActorGuzza); Actor_Set_Goal_Number(kActorGuzza, kGoalGuzzaUG18FallDown); break; } switch (Actor_Query_Goal_Number(kActorClovis)) { case kGoalClovisUG18SadikWillShootGuzza: Actor_Change_Animation_Mode(kActorSadik, kAnimationModeCombatAttack); Sound_Play(14, 100, 0, 0, 50); Actor_Change_Animation_Mode(kActorGuzza, kAnimationModeCombatHit); ADQ_Add(kActorClovis, 640, 13); ADQ_Add(kActorGuzza, 1210, 13); Actor_Set_Goal_Number(kActorClovis, kGoalClovisUG18SadikIsShootingGuzza); break; case kGoalClovisUG18SadikIsShootingGuzza: Actor_Change_Animation_Mode(kActorSadik, kAnimationModeCombatAttack); Sound_Play(14, 100, 0, 0, 50); Actor_Change_Animation_Mode(kActorGuzza, 61); ADQ_Add_Pause(2000); ADQ_Add(kActorClovis, 650, 14); ADQ_Add(kActorSadik, 370, 14); ADQ_Add(kActorClovis, 1320, 14); Actor_Set_Goal_Number(kActorGuzza, kGoalGuzzaUG18ShotBySadik); Actor_Retired_Here(kActorGuzza, 72, 32, true, kActorSadik); Actor_Set_Goal_Number(kActorClovis, kGoalClovisUG18GuzzaDied); Scene_Exits_Enable(); break; case kGoalClovisUG18GuzzaDied: Actor_Set_Goal_Number(kActorSadik, kGoalSadikUG18Move); break; } if (Actor_Query_Goal_Number(kActorSadik) == kGoalSadikUG18WillShootMcCoy) { Actor_Change_Animation_Mode(kActorSadik, kAnimationModeDie); Actor_Set_Goal_Number(kActorSadik, kGoalSadikUG18PrepareShootMcCoy); Actor_Set_Goal_Number(kActorClovis, kGoalClovisUG18Leave); } }
void SceneScriptUG18::ActorChangedGoal(int actorId, int newGoal, int oldGoal, bool currentSet) { if (actorId == kActorGuzza) { switch (newGoal) { case kGoalGuzzaUG18HitByMcCoy: Game_Flag_Set(kFlagMcCoyRetiredHuman); ADQ_Flush(); Actor_Modify_Friendliness_To_Other(kActorClovis, kActorMcCoy, 7); Actor_Modify_Friendliness_To_Other(kActorSadik, kActorMcCoy, 10); Player_Loses_Control(); Actor_Face_Actor(kActorGuzza, kActorMcCoy, true); ADQ_Add(kActorGuzza, 1220, 58); Scene_Exits_Enable(); Actor_Set_Goal_Number(kActorGuzza, kGoalGuzzaUG18ShotByMcCoy); break; case kGoalGuzzaUG18MissedByMcCoy: ADQ_Flush(); Actor_Modify_Friendliness_To_Other(kActorClovis, kActorMcCoy, 7); Actor_Modify_Friendliness_To_Other(kActorSadik, kActorMcCoy, 10); Player_Loses_Control(); Actor_Face_Actor(kActorGuzza, kActorMcCoy, true); ADQ_Add(kActorGuzza, 1220, 58); Scene_Exits_Enable(); Actor_Set_Goal_Number(kActorGuzza, kGoalGuzzaUG18ShootMcCoy); break; } return; } if (actorId == kActorSadik) { switch (newGoal) { case kGoalSadikUG18Decide: if (Actor_Query_Friendliness_To_Other(kActorClovis, kActorMcCoy) > 55 && Game_Flag_Query(kFlagMcCoyRetiredHuman) ) { Actor_Says(kActorClovis, 660, 13); Actor_Says(kActorMcCoy, 5995, 13); Actor_Says(kActorClovis, 670, 13); Actor_Says(kActorMcCoy, 6000, 13); Actor_Says_With_Pause(kActorClovis, 680, 2.0f, 13); Actor_Says(kActorClovis, 690, 13); Actor_Says(kActorClovis, 700, 13); Actor_Set_Goal_Number(kActorSadik, kGoalSadikUG18Leave); Actor_Set_Goal_Number(kActorClovis, kGoalClovisUG18Leave); } else { Actor_Set_Goal_Number(kActorSadik, kGoalSadikUG18PrepareShootMcCoy); Actor_Set_Goal_Number(kActorClovis, kGoalClovisUG18Leave); } break; // goals 303, 304 and 305 are never set, cut out part of game? case 304: Actor_Modify_Friendliness_To_Other(kActorClovis, kActorMcCoy, -3); ADQ_Add(kActorSadik, 380, -1); Actor_Set_Goal_Number(kActorSadik, kGoalSadikUG18WillShootMcCoy); break; case 305: Actor_Change_Animation_Mode(kActorSadik, kAnimationModeCombatAttack); Sound_Play(12, 100, 0, 0, 50); Actor_Force_Stop_Walking(kActorMcCoy); Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeDie); Player_Loses_Control(); Actor_Retired_Here(kActorMcCoy, 6, 6, true, kActorSadik); break; } } }