/*----------------------------------------------------------------------------- Name : aihFastDefenseNumbersLowHandler Description : Handles the fast roving defense team being decimated Inputs : team - the team being decimated Outputs : Return : void ----------------------------------------------------------------------------*/ void aihFastDefenseNumbersLowHandler(AITeam *team) { AITeamMove *thisMove = team->curMove, *newMove; AlternativeShips alternatives; vector gathering_point; vector origin = ORIGIN_VECTOR; SelectCommand *teamsel = team->shipList.selection; sdword original_number = thisMove->events.numbersLow.watchBaseCount; //later maybe change to "reinforce" move, maybe along with harass team getting out //of there to attack someone else. if (aiCurrentAIPlayer->player->PlayerMothership) { gathering_point = aiCurrentAIPlayer->player->PlayerMothership->posinfo.position; } else { vecZeroVector(gathering_point); } gathering_point = aiuFindRangeStandoffPoint(gathering_point,origin, AIH_FASTDEF_NUMLOW_STANDOFF_DIST); thisMove->processing = FALSE; thisMove->events.numbersLow.triggered = FALSE; //add a move, getships, formation newMove = aimCreateMoveTeamNoAdd(team, gathering_point, AIH_FASTDEF_NUMLOW_FORMATION, FALSE, TRUE); aitAddmoveBeforeAndMakeCurrent(team, newMove, thisMove); if (teamsel->numShips) { if (teamsel->numShips < original_number) { newMove = aimCreateGetShipsNoAdd(team, teamsel->ShipPtr[0]->shiptype, (sbyte)(original_number - teamsel->numShips), 0, TRUE, TRUE); } else { //just add one ship (to prevent infinite loops) newMove = aimCreateGetShipsNoAdd(team, teamsel->ShipPtr[0]->shiptype, 1, 0, TRUE, TRUE); } } else { SetNumAlternativesFlags(alternatives,3, ALTERNATIVE_RANDOM) SetAlternative(alternatives,0,HeavyDefender,14); SetAlternative(alternatives,1,HeavyInterceptor,14); SetAlternative(alternatives,2,AttackBomber,15); newMove = aimCreateFancyGetShipsNoAdd(team, LightInterceptor, 12, &alternatives, 0, TRUE, FALSE); } thisMove->events.numbersLow.watchBaseCount = 0; thisMove->processing = FALSE; listAddNodeBefore(&(thisMove->listNode), &(newMove->listNode), newMove); // newMove = aimCreateFormationNoAdd(team, WALL_FORMATION, FALSE, TRUE); // listAddNodeBefore(&(thisMove->listNode), &(newMove->listNode), newMove); }
/*----------------------------------------------------------------------------- Name : volFindCenter Description : Returns the center point of the volume Inputs : vol - the volume to find the center point Outputs : Return : The center of the volume, or 0,0,0 as an error condition ----------------------------------------------------------------------------*/ vector volFindCenter(Volume *vol) { vector returnvec; switch (vol->type) { case VOLUME_AA_BOX: returnvec.x = (vol->attribs.aaBox.x0 + vol->attribs.aaBox.x1) / 2; returnvec.y = (vol->attribs.aaBox.y0 + vol->attribs.aaBox.y1) / 2; returnvec.z = (vol->attribs.aaBox.z0 + vol->attribs.aaBox.z0) / 2; return returnvec; break; case VOLUME_SPHERE: return vol->attribs.sphere.center; break; default: vecZeroVector(returnvec); return returnvec; break; } }
void defensefightertargetbullet(Ship *ship, Bullet *bullettotarget) { DefenseFighterSpec *spec = (DefenseFighterSpec *)ship->ShipSpecifics; DefenseFighterStatics *defensefighterstatics; DefenseStruct *newdefensestruct; Bullet *laser; GunStatic *gunstatic; Gun *gun; ShipStaticInfo *shipstatic; vector positionInWorldCoordSys,tempvec; real32 floatDamage; udword intDamage; udword intVelocity; udword intLength; etgeffectstatic *stat; etglod *etgLOD; sdword LOD; Effect *newEffect; #ifdef HW_BUILD_FOR_DEBUGGING /* dbgMessagef("B: %d %x %x %f %f %f %x %f %x",universe.univUpdateCounter, bullettotarget->flags, bullettotarget->owner, bullettotarget->timelived, bullettotarget->damage, bullettotarget->damageFull, bullettotarget->SpecialEffectFlag, bullettotarget->BulletSpeed, bullettotarget); */ #endif gun = &ship->gunInfo->guns[0]; gunstatic = gun->gunstatic; shipstatic = (ShipStaticInfo *)ship->staticinfo; defensefighterstatics = (DefenseFighterStatics *) ((ShipStaticInfo *)(ship->staticinfo))->custstatinfo; bitSet(bullettotarget->SpecialEffectFlag, 0x0002); //set the flag laser = memAlloc(sizeof(Bullet),"Bullet",0); memset(laser,0,sizeof(Bullet)); // for safety laser->objtype = OBJ_BulletType; laser->flags = 0; laser->staticinfo = NULL; ClearNode(laser->renderlink); laser->currentLOD = ship->currentLOD; laser->cameraDistanceSquared = ship->cameraDistanceSquared; laser->soundType = gunstatic->gunsoundtype; laser->bulletType = BULLET_Laser; laser->owner = ship; laser->gunowner = gun; laser->target = NULL; laser->bulletColor = etgBulletColor[shipstatic->shiprace][laser->soundType]; laser->bulletmass = 0.0f; //gunstatic->bulletmass; laser->lengthmag = 600.0f; laser->damage = frandombetween(defensefighterstatics->DamageReductionLow, defensefighterstatics->DamageReductionHigh); laser->timelived = 0.0f; laser->totallifetime = 100.0f; //laser will only live for a sec anyways... laser->SpecialEffectFlag = 0; laser->traveldist = gunstatic->bulletlength; laser->beamtraveldist = gunstatic->bulletlength; //SET_MOVING_LINEARLY(laser->posinfo.isMoving); //laser->posinfo.haventCalculatedDist = TRUE; laser->DFGFieldEntryTime = 0.0f; matMultiplyMatByVec(&positionInWorldCoordSys,&ship->rotinfo.coordsys,&gunstatic->position); vecAdd(laser->posinfo.position,positionInWorldCoordSys,ship->posinfo.position); vecSub(laser->lengthvec, bullettotarget->posinfo.position, laser->posinfo.position); // heading tempvec = laser->lengthvec; vecNormalize(&tempvec); //matMultiplyMatByVec(&gunheadingInWorldCoordSys, &ship->rotinfo.coordsys, &tempvec); //laser->bulletheading = gunheadingInWorldCoordSys; laser->bulletheading = tempvec; matCreateCoordSysFromHeading(&laser->rotinfo.coordsys,&tempvec); vecZeroVector(laser->posinfo.velocity); //Laser effect... floatDamage = (real32)laser->damage; intDamage = TreatAsUdword(floatDamage); intVelocity = TreatAsUdword(gunstatic->bulletspeed); intLength = TreatAsUdword(gunstatic->bulletlength); //create an effect for bullet, if applicable etgLOD = etgGunEventTable[shipstatic->shiprace][gunstatic->gunsoundtype][EGT_GunBullet];//get pointer to bullet effect //etgLOD = etgGunEventTable[0][gunstatic->gunsoundtype][EGT_GunBullet];//get pointer to bullet effect //in future change back to proper one above... if (etgLOD != NULL) { if (bullettotarget != NULL) { LOD = min(ship->currentLOD, bullettotarget->currentLOD); } else { LOD = ship->currentLOD; } if (LOD >= etgLOD->nLevels) { stat = NULL; } else { stat = etgLOD->level[LOD]; } } else { stat = NULL; } #if ETG_DISABLEABLE if (stat != NULL && etgBulletEffectsEnabled && etgEffectsEnabled && !etgFrequencyExceeded(stat)) #else if (stat != NULL && etgBulletEffectsEnabled && !etgFrequencyExceeded(stat)) #endif { laser->effect = etgEffectCreate(stat, laser, NULL, NULL, NULL, 1.0f, EAF_AllButNLips, 3, intDamage, intVelocity, intLength); // univAddObjToRenderListIf((SpaceObj *)laser->effect,(SpaceObj *)ship); // add to render list if parent ship is in render list //do length calculations :) ((real32 *)laser->effect->variable)[ETG_LengthVariable] = fsqrt(vecMagnitudeSquared(laser->lengthvec)); } else { laser->effect = NULL; //play no effect for this bullet } // laser->effect = NULL; //need for render...add later? laser->hitEffect = etgGunEventTable[shipstatic->shiprace][bullettotarget->gunowner->gunstatic->gunsoundtype][EGT_BulletDestroyed];//get pointer to bullet effect if (ship->soundevent.burstHandle < 0) { soundEventBurstFire(ship, gun); } etgLOD = etgGunEventTable[shipstatic->shiprace][gunstatic->gunsoundtype][EGT_GunFire];//get pointer to bullet effect if (etgLOD != NULL) { LOD = ship->currentLOD; if (LOD >= etgLOD->nLevels) { stat = NULL; } else { stat = etgLOD->level[LOD]; } } else { stat = NULL; } #if ETG_DISABLEABLE if (stat != NULL && etgEffectsEnabled && etgFireEffectsEnabled && !etgFrequencyExceeded(stat)) #else if (stat != NULL && etgFireEffectsEnabled && !etgFrequencyExceeded(stat)) #endif { //if there is a gun fire effect newEffect = etgEffectCreate(stat, laser, NULL, NULL, NULL, 1.0f, EAF_AllButNLips, 1, intDamage); // univAddObjToRenderListIf((SpaceObj *)newEffect,(SpaceObj *)ship); // add to render list if parent ship is in render list } /* //spawn bullet hitting effect etgLOD = etgTractorBeamEffectTable[ship->shiprace]; //etgLOD = etgGunEventTable[shipstatic->shiprace][gunstatic->gunsoundtype][EGT_GunFire];//get pointer to bullet effect if (etgLOD != NULL) { LOD = ship->currentLOD; if (LOD >= etgLOD->nLevels) { stat = NULL; } else { stat = etgLOD->level[LOD]; } } else { stat = NULL; } #if ETG_DISABLEABLE if (stat != NULL && etgEffectsEnabled) #else if (stat != NULL) #endif { //if there is a gun fire effect // size = etgEffectSize(stat->nParticleBlocks);//compute size of effect size = stat->effectSize; newEffect = memAlloc(size, "DefenseFHittingEffect", 0); //allocate the new effect newEffect->objtype = OBJ_EffectType; newEffect->flags = SOF_Rotatable | SOF_AttachVelocity | SOF_AttachPosition | SOF_AttachCoordsys; newEffect->staticinfo = (StaticInfo *)stat; ClearNode(newEffect->renderlink); newEffect->currentLOD = LOD; newEffect->cameraDistanceSquared = ship->cameraDistanceSquared; newEffect->timeElapsed = 0.0f; //brand new heavies floatDamage = 30.0f; intDamage = TreatAsUdword(floatDamage); newEffect->rotinfo.coordsys = bullettotarget->rotinfo.coordsys; newEffect->posinfo.position = bullettotarget->posinfo.position; //start at same spot as bullet newEffect->posinfo.velocity = bullettotarget->posinfo.velocity; //start at same spot as bullet etgEffectCodeStart(stat, newEffect, 1, intDamage);//get the code a-runnin' SET_MOVING_IMMOBILE(newEffect->posinfo.isMoving); newEffect->posinfo.haventCalculatedDist = TRUE; univUpdateObjRotInfo((SpaceObjRot *)newEffect); // newEffect->owner = NULL; // nothing owns this effect newEffect->owner = (Ship *) bullettotarget; listAddNode(&universe.SpaceObjList,&(newEffect->objlink),newEffect); univAddObjToRenderListIf((SpaceObj *)newEffect,(SpaceObj *)ship); // add to render list if parent ship is in render list } */ //Not sure If I need to add... listAddNode(&universe.SpaceObjList,&(laser->objlink),laser); listAddNode(&universe.BulletList,&(laser->bulletlink),laser); univAddObjToRenderListIf((SpaceObj *)laser,(SpaceObj *)ship); // add to render list if parent ship is in render list newdefensestruct = memAlloc(sizeof(DefenseStruct),"DS(DefenseStruct)",Pyrophoric); newdefensestruct->bullet = bullettotarget; newdefensestruct->CoolDown = FALSE; newdefensestruct->CoolDownTime = 0.0f; newdefensestruct->LaserDead = FALSE; listAddNode(&spec->DefenseList,&newdefensestruct->bulletnode,newdefensestruct); newdefensestruct->laser = laser; if(bitTest(ship->flags,SOF_CloakGenField)) { bitSet(ship->flags,SOF_DeCloaking); bitClear(ship->flags,SOF_Cloaked); bitClear(ship->flags,SOF_Cloaking); } }
/*----------------------------------------------------------------------------- Name : aihHarassNumbersLowHandler Description : Handles the harass team being decimated Inputs : team - the team being decimated Outputs : Return : void ----------------------------------------------------------------------------*/ void aihHarassNumbersLowHandler(AITeam *team) { AITeamMove *thisMove = team->curMove, *newMove; AlternativeShips alternatives; vector gathering_point; vector origin = ORIGIN_VECTOR; //commented code is the reinforce type numbers low handler /* udword i; for (i = 0; i < aiCurrentAIPlayer->numGuardTeams; i++) { //later need to actually remove team from guardTeams array if (bitTest(aiCurrentAIPlayer->guardTeams[i]->teamFlags, FAST_ROVING_GUARD) && (aiCurrentAIPlayer->guardTeams[i]->shipList.selection->numShips)) { bitClear(aiCurrentAIPlayer->guardTeams[i]->teamFlags, FAST_ROVING_GUARD); aiCurrentAIPlayer->guardTeams[i]->curMove = aimCreateReinforce(aiCurrentAIPlayer->guardTeams[i], team, TRUE, FALSE); aimCreateMoveDone(aiCurrentAIPlayer->guardTeams[i], FALSE, FALSE); return; } } */ //later maybe change to "reinforce" move, maybe along with harass team getting out //of there to attack someone else. //later - very important to get the same ships that were requested in the first place // this isn't all that "generic" if (aiCurrentAIPlayer->player->PlayerMothership) { gathering_point = aiCurrentAIPlayer->player->PlayerMothership->posinfo.position; } else { vecZeroVector(gathering_point); } while ((thisMove->type == MOVE_ATTACK) || (thisMove->type == MOVE_ADVANCEDATTACK)) { if (thisMove->remove) { aitDeleteCurrentMove(team); } else { team->curMove = (AITeamMove *)listGetStructOfNode(team->curMove->listNode.next); } thisMove = team->curMove; dbgAssert(thisMove); } gathering_point = aiuFindRangeStandoffPoint(gathering_point,origin, AIH_HARASS_NUMLOW_STANDOFF_DIST); thisMove->processing = FALSE; thisMove->events.numbersLow.triggered = FALSE; //add a move, getships, formation newMove = aimCreateMoveTeamNoAdd(team, gathering_point, AIH_HARASS_NUMLOW_FORMATION, FALSE, TRUE); //band-aid solution... change moveteam move so that tactics are there... newMove->tactics = Evasive; aitAddmoveBeforeAndMakeCurrent(team, newMove, thisMove); SetNumAlternatives(alternatives,2); SetAlternative(alternatives,0,HeavyInterceptor,HARASS_HEAVYINT_EQUIVNUM); SetAlternative(alternatives,1,AttackBomber, HARASS_BOMBER_EQUIVNUM); newMove = aimCreateFancyGetShipsNoAdd(team, LightInterceptor, 16, &alternatives, REQUESTSHIPS_HIPRI, TRUE, TRUE); listAddNodeBefore(&(thisMove->listNode), &(newMove->listNode), newMove); bitClear(team->teamFlags, TEAM_NEEDS_SUPPORT); }