void SetAIVecHeading(Ship *ship, SpaceObjRotImpTarg *target, vector *trajectory) { //real32 range; ShipStaticInfo *shipstaticinfo = (ShipStaticInfo *)ship->staticinfo; vector tmpvec; udword target_class; real32 randegf; sdword randeg; matrix tmpmat; vector targetheading; MinelayerCorvetteSpec *spec = (MinelayerCorvetteSpec *)ship->ShipSpecifics; MinelayerCorvetteStatics *minelayercorvettestatics; minelayercorvettestatics = (MinelayerCorvetteStatics *) ((ShipStaticInfo *)(ship->staticinfo))->custstatinfo; matGetVectFromMatrixCol3(targetheading,target->rotinfo.coordsys) if(target != NULL) { if(target->objtype == OBJ_ShipType) target_class = ((Ship *)target)->staticinfo->shipclass; else target_class = CLASS_NonCombat; } if (vecDotProduct(targetheading,*trajectory) > 0) { //Attack accross front of ship :) vecAddTo(spec->aivec,targetheading); vecAddTo(spec->aivec,*trajectory); vecScalarMultiply(spec->aivec,spec->aivec,minelayercorvettestatics->FlyAwayDist[target_class]); } else { //test if(randombetween(1,2) & 1) { vecCrossProduct(spec->aivec,*trajectory, targetheading); } else { vecCrossProduct(spec->aivec, targetheading, *trajectory); } vecAddTo(spec->aivec, *trajectory); vecScalarMultiply(spec->aivec,spec->aivec,minelayercorvettestatics->FlyAwayDist[target_class]); } if(!(target->posinfo.isMoving & ISMOVING_MOVING)) { //if target isn't moving, randomize trajectory randeg = randombetween(5,30); randegf = (real32) ((randeg & 1) ? randeg : -randeg); randegf = (real32) randeg; randegf = DEG_TO_RAD(randegf); matMakeRotAboutZ(&tmpmat,(real32)cos(randegf),(real32)sin(randegf)); matMultiplyMatByVec(&tmpvec,&tmpmat,&spec->aivec); spec->aivec = tmpvec; } vecAddTo(spec->aivec,target->posinfo.position); //need change aishipFlyToPointAvoidingObjs(ship,&spec->aivec,AISHIP_FastAsPossible | AISHIP_PointInDirectionFlying,INTERCEPTORBREAK_MINVELOCITY); }
/*----------------------------------------------------------------------------- Name : madLinkInOpenSpecialShip Description : runs the 'open' special animation of the ships. Inputs : Outputs : Return : ----------------------------------------------------------------------------*/ void madLinkInOpenSpecialShip(Ship *ship) { sdword animIndex; if (ship->madBindings != NULL && ship->staticinfo->madStatic != NULL) { //if ship has mesh animations associated with it if(ship->staticinfo->madStatic->numSpecialOpenIndexes < 1) { //ship doesn't have gun opening animations return; } if(ship->madSpecialStatus == MAD_STATUS_SPECIAL_OPEN || ship->madSpecialStatus == MAD_STATUS_SPECIAL_OPENING) { //guns are currently open...so lets ferget about it return; } else if(ship->madSpecialStatus == MAD_STATUS_SPECIAL_CLOSING) { //toggle Reverse here! //Luke...Make it so. //for now, overwrite animation ship->nextAnim = MAD_ANIMATION_SPECIAL_OPENING; return; } //signal that an animation has been added to the ships cue bitSet(ship->madAnimationFlags,MAD_ANIMATION_NEED_PROC); if(ship->health*ship->staticinfo->oneOverMaxHealth < ship->staticinfo->madGunOpenDamagedHealthThreshold && ship->staticinfo->madStatic->numSpecialOpenDamagedIndexes > 0) { //ships health is below threshold //and ship has damaged animations as well animIndex = randombetween(0,(ship->staticinfo->madStatic->numSpecialOpenDamagedIndexes-1)); ship->cuedAnimationIndex = ship->staticinfo->madStatic->specialOpenDamagedIndexes[animIndex]; ship->soundEventAnimationTypeFlag = ShipCmn_AnimDamagedOpen; } else { //ships health is normalish..use normal gun anims animIndex = randombetween(0,(ship->staticinfo->madStatic->numSpecialOpenIndexes-1)); ship->cuedAnimationIndex = ship->staticinfo->madStatic->specialOpenIndexes[animIndex]; ship->soundEventAnimationTypeFlag = ShipCmn_AnimOpening; } ship->cuedAnimationType = MAD_ANIMATION_SPECIAL_OPENING; ship->madSpecialStatus = MAD_STATUS_SPECIAL_OPENING; bitSet(ship->madAnimationFlags,MAD_NEED_TO_START_NEW_ANIMATION); } }
/*----------------------------------------------------------------------------- Name : madLinkInPreDockingShip Description : utility function for above function Inputs : Outputs : Return : ----------------------------------------------------------------------------*/ void madLinkInPreDockingShip(Ship *ship) { sdword animIndex; if (ship->madBindings != NULL && ship->staticinfo->madStatic != NULL) { //if ship has mesh animations associated with it if(ship->staticinfo->madStatic->numPostDockIndexes < 1) { //ship doesn't have gun opening animations return; } if(ship->madWingStatus == MAD_STATUS_WINGS_CLOSED || ship->madWingStatus == MAD_STATUS_WINGS_CLOSING) { //guns are currently open...so lets ferget about it return; } else if(ship->madWingStatus == MAD_STATUS_WINGS_OPENING) { ship->nextAnim = MAD_ANIMATION_WINGS_CLOSING; return; } //signal that an animation has been added to the ships cue bitSet(ship->madAnimationFlags,MAD_ANIMATION_NEED_PROC); if(ship->health*ship->staticinfo->oneOverMaxHealth < ship->staticinfo->madWingOpenDamagedHealthThreshold && ship->staticinfo->madStatic->numDockDamagedIndexes > 0) { //ships health is below threshold //and ship has damaged animations as well animIndex = randombetween(0,(ship->staticinfo->madStatic->numDockDamagedIndexes-1)); ship->cuedAnimationIndex = ship->staticinfo->madStatic->DockDamagedIndexes[animIndex]; ship->soundEventAnimationTypeFlag = ShipCmn_AnimDamagedClose; } else { //ships health is normalish..use normal gun anims animIndex = randombetween(0,(ship->staticinfo->madStatic->numDockIndexes-1)); ship->cuedAnimationIndex = ship->staticinfo->madStatic->DockIndexes[animIndex]; ship->soundEventAnimationTypeFlag = ShipCmn_AnimClosing; } ship->cuedAnimationType = MAD_ANIMATION_WINGS_CLOSING; ship->madWingStatus = MAD_STATUS_WINGS_CLOSING; bitSet(ship->madAnimationFlags,MAD_NEED_TO_START_NEW_ANIMATION); } }
/*----------------------------------------------------------------------------- Name : madLinkInCloseDoor Description : opens door on R1 mothership (for now) Inputs : Outputs : Return : ----------------------------------------------------------------------------*/ void madLinkInCloseDoor(Ship *ship) { sdword animIndex; if (ship->madBindings != NULL && ship->staticinfo->madStatic != NULL) { //if ship has mesh animations associated with it if(ship->staticinfo->madStatic->numDoorCloseIndexes < 1) { //ship doesn't have gun opening animations return; } if(ship->madDoorStatus == MAD_STATUS_DOOR_CLOSED || ship->madDoorStatus == MAD_STATUS_DOOR_CLOSING) { //guns are currently open...so lets ferget about it return; } else if(ship->madDoorStatus == MAD_STATUS_DOOR_OPENING) { //ALWAYS return; ship->nextAnim = MAD_ANIMATION_DOOR_CLOSING; return; } //signal that an animation has been added to the ships cue bitSet(ship->madAnimationFlags,MAD_ANIMATION_NEED_PROC); animIndex = randombetween(0,(ship->staticinfo->madStatic->numDoorCloseIndexes-1)); ship->cuedAnimationIndex = ship->staticinfo->madStatic->DoorCloseIndexes[animIndex]; ship->cuedAnimationType = MAD_ANIMATION_DOOR_CLOSING; ship->madDoorStatus = MAD_STATUS_DOOR_CLOSING; bitSet(ship->madAnimationFlags,MAD_NEED_TO_START_NEW_ANIMATION); ship->soundEventAnimationTypeFlag = ShipCmn_AnimClosing; } }