ProjectilePrisonerRock::ProjectilePrisonerRock(bool bDirection, int xPos, int yPos) { /* Set Sprite Number */ SetSprite(1, CR::AssetList::prisoner_rock); /* Set Sprite Direction */ SetDirection(bDirection); /* Set Weapon Bounding Box */ SetWeaponBounds(12,12); /* Set Activate & Delay Timer */ SetActiveTime(3); SetDelayTime(.25); /* Set Velocity Direction */ if(bDirection) SetVelocityVector((float)(rand()%50+75), 0); else SetVelocityVector((float)(-(rand()%50+75)), 0); /* Set Acceleration Vector */ SetAccelerationVector(0, (float)(rand()%75 + 65)); /* Set Start Position */ SetPosition(xPos, yPos); /* Set Damage Value */ SetWeaponDamage(5); proj_flags.S_NON_PROJECTILE = true; /* Initialize Sprite */ SetAnimation(0, 0, true, false, 10, true); }
ProjectileNinjaStar::ProjectileNinjaStar(bool bDirection, int xPos, int yPos) { /* Set Sprite Number */ SetSprite(1, CR::AssetList::ninja_star); /* Set Sprite Direction */ SetDirection(bDirection); /* Set Weapon Bounding Box */ SetWeaponBounds(16,16); /* Set Activate & Delay Timer */ SetActiveTime(4); SetDelayTime(.25); /* Set Velocity Direction */ if(bDirection) SetVelocityVector(80, 0); else SetVelocityVector(-80, 0); /* Set Start Position */ SetPosition(xPos, yPos); /* Set Damage Value */ SetWeaponDamage(2); /* Initialize Sprite */ SetAnimation(0, 0, true, false, 30, true); projectile_spr->EnableFrameSkip(false); }
static void nuke_preprocess (PELEMENT ElementPtr) { COUNT facing; facing = GetFrameIndex (ElementPtr->next.image.frame); if (ElementPtr->turn_wait > 0) --ElementPtr->turn_wait; else { if (TrackShip (ElementPtr, &facing) > 0) { ElementPtr->next.image.frame = SetAbsFrameIndex (ElementPtr->next.image.frame, facing); ElementPtr->state_flags |= CHANGING; } ElementPtr->turn_wait = TRACK_WAIT; } { SIZE speed; #define THRUST_SCALE DISPLAY_TO_WORLD (1) if ((speed = MISSILE_SPEED + ((MISSILE_LIFE - ElementPtr->life_span) * THRUST_SCALE)) > MAX_MISSILE_SPEED) speed = MAX_MISSILE_SPEED; SetVelocityVector (&ElementPtr->velocity, speed, facing); } }
static void buzztrack_preprocess (PELEMENT ElementPtr) { if (ElementPtr->thrust_wait) --ElementPtr->thrust_wait; else { COUNT facing = 0; if (ElementPtr->hTarget == 0 && TrackShip (ElementPtr, &facing) < 0) { ZeroVelocityComponents (&ElementPtr->velocity); } else { #define ACTIVATE_RANGE 224 /* Originally SPACE_WIDTH */ SIZE delta_x, delta_y; ELEMENTPTR eptr; LockElement (ElementPtr->hTarget, &eptr); delta_x = eptr->current.location.x - ElementPtr->current.location.x; delta_y = eptr->current.location.y - ElementPtr->current.location.y; UnlockElement (ElementPtr->hTarget); delta_x = WRAP_DELTA_X (delta_x); delta_y = WRAP_DELTA_Y (delta_y); facing = NORMALIZE_FACING ( ANGLE_TO_FACING (ARCTAN (delta_x, delta_y)) ); if (delta_x < 0) delta_x = -delta_x; if (delta_y < 0) delta_y = -delta_y; delta_x = WORLD_TO_DISPLAY (delta_x); delta_y = WORLD_TO_DISPLAY (delta_y); if (delta_x >= ACTIVATE_RANGE || delta_y >= ACTIVATE_RANGE || (DWORD)((UWORD)delta_x * delta_x) + (DWORD)((UWORD)delta_y * delta_y) >= (DWORD)ACTIVATE_RANGE * ACTIVATE_RANGE) { ZeroVelocityComponents (&ElementPtr->velocity); } else { ElementPtr->thrust_wait = TRACK_WAIT; SetVelocityVector (&ElementPtr->velocity, DISPLAY_TO_WORLD (2), facing); } } } spin_preprocess (ElementPtr); }
static void doggy_preprocess (ELEMENT *ElementPtr) { STARSHIP *StarShipPtr; GetElementStarShip (ElementPtr, &StarShipPtr); ++StarShipPtr->special_counter; if (ElementPtr->thrust_wait > 0) /* could be non-zero after a collision */ --ElementPtr->thrust_wait; else { COUNT facing, orig_facing; SIZE delta_facing; facing = orig_facing = NORMALIZE_FACING (ANGLE_TO_FACING ( GetVelocityTravelAngle (&ElementPtr->velocity) )); if ((delta_facing = TrackShip (ElementPtr, &facing)) < 0) facing = NORMALIZE_FACING (TFB_Random ()); else { ELEMENT *ShipPtr; LockElement (ElementPtr->hTarget, &ShipPtr); facing = NORMALIZE_FACING (ANGLE_TO_FACING ( ARCTAN (ShipPtr->current.location.x - ElementPtr->current.location.x, ShipPtr->current.location.y - ElementPtr->current.location.y) )); delta_facing = NORMALIZE_FACING (facing - GetFrameIndex (ShipPtr->current.image.frame)); UnlockElement (ElementPtr->hTarget); if (delta_facing > ANGLE_TO_FACING (HALF_CIRCLE - OCTANT) && delta_facing < ANGLE_TO_FACING (HALF_CIRCLE + OCTANT)) { if (delta_facing >= ANGLE_TO_FACING (HALF_CIRCLE)) facing -= ANGLE_TO_FACING (QUADRANT); else facing += ANGLE_TO_FACING (QUADRANT); } facing = NORMALIZE_FACING (facing); } if (facing != orig_facing) SetVelocityVector (&ElementPtr->velocity, DOGGY_SPEED, facing); } }
static void spawn_doggy (ELEMENT *ElementPtr) { HELEMENT hDoggyElement; if ((hDoggyElement = AllocElement ()) != 0) { COUNT angle; ELEMENT *DoggyElementPtr; STARSHIP *StarShipPtr; ElementPtr->state_flags |= DEFY_PHYSICS; PutElement (hDoggyElement); LockElement (hDoggyElement, &DoggyElementPtr); DoggyElementPtr->hit_points = DOGGY_HITS; DoggyElementPtr->mass_points = DOGGY_MASS; DoggyElementPtr->thrust_wait = 0; DoggyElementPtr->playerNr = ElementPtr->playerNr; DoggyElementPtr->state_flags = APPEARING; DoggyElementPtr->life_span = NORMAL_LIFE; SetPrimType (&(GLOBAL (DisplayArray))[DoggyElementPtr->PrimIndex], STAMP_PRIM); { DoggyElementPtr->preprocess_func = doggy_preprocess; DoggyElementPtr->postprocess_func = NULL; DoggyElementPtr->collision_func = doggy_collision; DoggyElementPtr->death_func = doggy_death; } GetElementStarShip (ElementPtr, &StarShipPtr); angle = FACING_TO_ANGLE (StarShipPtr->ShipFacing) + HALF_CIRCLE; DoggyElementPtr->current.location.x = ElementPtr->next.location.x + COSINE (angle, DISPLAY_TO_WORLD (CHENJESU_OFFSET + DOGGY_OFFSET)); DoggyElementPtr->current.location.y = ElementPtr->next.location.y + SINE (angle, DISPLAY_TO_WORLD (CHENJESU_OFFSET + DOGGY_OFFSET)); DoggyElementPtr->current.image.farray = StarShipPtr->RaceDescPtr->ship_data.special; DoggyElementPtr->current.image.frame = StarShipPtr->RaceDescPtr->ship_data.special[0]; SetVelocityVector (&DoggyElementPtr->velocity, DOGGY_SPEED, NORMALIZE_FACING (ANGLE_TO_FACING (angle))); SetElementStarShip (DoggyElementPtr, StarShipPtr); ProcessSound (SetAbsSoundIndex ( /* RELEASE_DOGGY */ StarShipPtr->RaceDescPtr->ship_data.ship_sounds, 4), DoggyElementPtr); UnlockElement (hDoggyElement); } }
static void bubble_preprocess (ELEMENT *ElementPtr) { BYTE thrust_wait, turn_wait; thrust_wait = HINIBBLE (ElementPtr->turn_wait); turn_wait = LONIBBLE (ElementPtr->turn_wait); if (thrust_wait > 0) --thrust_wait; else { ElementPtr->next.image.frame = IncFrameIndex (ElementPtr->current.image.frame); ElementPtr->state_flags |= CHANGING; thrust_wait = (BYTE)((COUNT)TFB_Random () & 3); } if (turn_wait > 0) --turn_wait; else { COUNT facing; SIZE delta_facing; facing = NORMALIZE_FACING (ANGLE_TO_FACING ( GetVelocityTravelAngle (&ElementPtr->velocity))); if ((delta_facing = TrackShip (ElementPtr, &facing)) == -1) facing = (COUNT)TFB_Random (); else if (delta_facing <= ANGLE_TO_FACING (HALF_CIRCLE)) facing += (COUNT)TFB_Random () & (ANGLE_TO_FACING (HALF_CIRCLE) - 1); else facing -= (COUNT)TFB_Random () & (ANGLE_TO_FACING (HALF_CIRCLE) - 1); SetVelocityVector (&ElementPtr->velocity, MISSILE_SPEED, facing); #define TRACK_WAIT 2 turn_wait = TRACK_WAIT; } ElementPtr->turn_wait = MAKE_BYTE (turn_wait, thrust_wait); }
ProjectilePoints::ProjectilePoints(int xPos, int yPos, int nPoints, int fnt, bool type) { this->nPoints = static_cast<int>(nPoints*modifier); S_FLICKER = false; /* Set Activate & Delay Timer */ SetActiveTime(3); SetDelayTime(0); /* Set Start Position */ SetPosition(xPos, yPos); SetVelocityVector(0, -20); SetSource(true); proj_flags.S_NON_PROJECTILE = true; bType = type; switch(fnt) { case 0: this->fnt = fnt_yellow; break; case 1: this->fnt = fnt_red; break; case 2: this->fnt = fnt_green; break; case 3: this->fnt = fnt_blue; break; case 4: this->fnt = fnt_blue; S_FLICKER = true; break; } }
static void blaster_preprocess (ELEMENT *ElementPtr) { BYTE wait; switch (ElementPtr->mass_points) { case BLASTER_DAMAGE * 1: if (GetFrameIndex (ElementPtr->current.image.frame) < 8) { ElementPtr->next.image.frame = IncFrameIndex (ElementPtr->current.image.frame); ElementPtr->state_flags |= CHANGING; } break; case BLASTER_DAMAGE * 3: if (GetFrameIndex (ElementPtr->current.image.frame) < 19) ElementPtr->next.image.frame = IncFrameIndex (ElementPtr->current.image.frame); else ElementPtr->next.image.frame = SetAbsFrameIndex (ElementPtr->current.image.frame, 16); ElementPtr->state_flags |= CHANGING; break; } if (LONIBBLE (ElementPtr->turn_wait)) --ElementPtr->turn_wait; else if ((wait = HINIBBLE (ElementPtr->turn_wait))) { COUNT facing; facing = NORMALIZE_FACING (ANGLE_TO_FACING ( GetVelocityTravelAngle (&ElementPtr->velocity))); if (TrackShip (ElementPtr, &facing) > 0) SetVelocityVector (&ElementPtr->velocity, BLASTER_SPEED, facing); ElementPtr->turn_wait = MAKE_BYTE (wait, wait); } }
static void butt_missile_preprocess (ELEMENT *ElementPtr) { if (ElementPtr->turn_wait > 0) --ElementPtr->turn_wait; else { COUNT facing; facing = GetFrameIndex (ElementPtr->next.image.frame); if (TrackShip (ElementPtr, &facing) > 0) { ElementPtr->next.image.frame = SetAbsFrameIndex (ElementPtr->next.image.frame, facing); ElementPtr->state_flags |= CHANGING; SetVelocityVector (&ElementPtr->velocity, DISCRIMINATOR_SPEED, facing); } ElementPtr->turn_wait = TRACK_WAIT; } }
static void androsynth_preprocess (ELEMENT *ElementPtr) { STARSHIP *StarShipPtr; STATUS_FLAGS cur_status_flags; GetElementStarShip (ElementPtr, &StarShipPtr); cur_status_flags = StarShipPtr->cur_status_flags; if (ElementPtr->next.image.farray == StarShipPtr->RaceDescPtr->ship_data.ship) { if (cur_status_flags & SPECIAL) { if (StarShipPtr->RaceDescPtr->ship_info.energy_level < SPECIAL_ENERGY_COST) DeltaEnergy (ElementPtr, -SPECIAL_ENERGY_COST); /* so text will flash */ else { cur_status_flags &= ~WEAPON; ElementPtr->next.image.farray = StarShipPtr->RaceDescPtr->ship_data.special; ElementPtr->next.image.frame = SetEquFrameIndex (StarShipPtr->RaceDescPtr->ship_data.special[0], ElementPtr->next.image.frame); ElementPtr->state_flags |= CHANGING; } } } else { cur_status_flags &= ~(THRUST | WEAPON | SPECIAL); /* protection against vux */ if (StarShipPtr->RaceDescPtr->characteristics.turn_wait > BLAZER_TURN_WAIT) { StarShipPtr->RaceDescPtr->characteristics.special_wait += StarShipPtr->RaceDescPtr->characteristics.turn_wait - BLAZER_TURN_WAIT; StarShipPtr->RaceDescPtr->characteristics.turn_wait = BLAZER_TURN_WAIT; } if (StarShipPtr->RaceDescPtr->ship_info.energy_level == 0) { ZeroVelocityComponents (&ElementPtr->velocity); cur_status_flags &= ~(LEFT | RIGHT | SHIP_AT_MAX_SPEED | SHIP_BEYOND_MAX_SPEED); StarShipPtr->RaceDescPtr->characteristics.turn_wait = StarShipPtr->RaceDescPtr->characteristics.special_wait; StarShipPtr->RaceDescPtr->characteristics.energy_regeneration = ENERGY_REGENERATION; ElementPtr->mass_points = SHIP_MASS; ElementPtr->collision_func = (CollisionFunc *) StarShipPtr->RaceDescPtr->data; ElementPtr->next.image.farray = StarShipPtr->RaceDescPtr->ship_data.ship; ElementPtr->next.image.frame = SetEquFrameIndex (StarShipPtr->RaceDescPtr->ship_data.ship[0], ElementPtr->next.image.frame); ElementPtr->state_flags |= CHANGING; } else { if (ElementPtr->thrust_wait) --ElementPtr->thrust_wait; else { #define BLAZER_THRUST (60 << RESOLUTION_FACTOR) // JMS_GFX COUNT facing; facing = StarShipPtr->ShipFacing; if (ElementPtr->turn_wait == 0 && (cur_status_flags & (LEFT | RIGHT))) { if (cur_status_flags & LEFT) --facing; else ++facing; } SetVelocityVector (&ElementPtr->velocity, BLAZER_THRUST, NORMALIZE_FACING (facing)); cur_status_flags |= SHIP_AT_MAX_SPEED | SHIP_BEYOND_MAX_SPEED; } } } StarShipPtr->cur_status_flags = cur_status_flags; }
static void butt_missile_preprocess (ELEMENT *ElementPtr) { if (ElementPtr->turn_wait > 0) --ElementPtr->turn_wait; else { COUNT facing; // COUNT num_frames; SIZE delta_x, delta_y, delta_facing; ELEMENT *EnemyPtr; facing = GetFrameIndex (ElementPtr->next.image.frame); if (ElementPtr->hTarget) { LockElement (ElementPtr->hTarget, &EnemyPtr); delta_x = EnemyPtr->current.location.x - ElementPtr->current.location.x; delta_x = WRAP_DELTA_X (delta_x); delta_y = EnemyPtr->current.location.y - ElementPtr->current.location.y; delta_y = WRAP_DELTA_Y (delta_y); /* num_frames = (square_root ((long)delta_x * delta_x + (long)delta_y * delta_y)) / DISCRIMINATOR_SPEED; if (num_frames == 0) num_frames = 1; GetNextVelocityComponents (&EnemyPtr->velocity, &delta_x, &delta_y, num_frames); // Lead the target by its apparent trajectory. delta_x = (EnemyPtr->current.location.x + (delta_x / 2)) - ElementPtr->current.location.x; delta_y = (EnemyPtr->current.location.y + (delta_y / 2)) - ElementPtr->current.location.y; */ delta_facing = NORMALIZE_FACING ( ANGLE_TO_FACING (ARCTAN (delta_x, delta_y)) - facing); if (delta_facing > 0 && !OBJECT_CLOAKED(EnemyPtr)) { if (delta_facing == ANGLE_TO_FACING (HALF_CIRCLE)) facing += (((BYTE)TFB_Random () & 1) << 1) - 1; else if (delta_facing < ANGLE_TO_FACING (HALF_CIRCLE)) ++facing; else --facing; } ElementPtr->next.image.frame = SetAbsFrameIndex (ElementPtr->next.image.frame, facing); ElementPtr->state_flags |= CHANGING; SetVelocityVector (&ElementPtr->velocity, DISCRIMINATOR_SPEED, facing); UnlockElement (ElementPtr->hTarget); } else if (TrackShip (ElementPtr, &facing) > 0) { ElementPtr->next.image.frame = SetAbsFrameIndex (ElementPtr->next.image.frame, facing); ElementPtr->state_flags |= CHANGING; SetVelocityVector (&ElementPtr->velocity, DISCRIMINATOR_SPEED, facing); } ElementPtr->turn_wait = TRACK_WAIT; } }
void spawn_asteroid (ELEMENT *ElementPtr) { HELEMENT hAsteroidElement; if ((hAsteroidElement = AllocElement ()) == 0) { if (ElementPtr != 0) { ElementPtr->state_flags &= ~DISAPPEARING; SetPrimType (&DisplayArray[ElementPtr->PrimIndex], NO_PRIM); ElementPtr->life_span = 1; } } else { ELEMENT *AsteroidElementPtr; COUNT val; LockElement (hAsteroidElement, &AsteroidElementPtr); AsteroidElementPtr->playerNr = NEUTRAL_PLAYER_NUM; AsteroidElementPtr->hit_points = 1; AsteroidElementPtr->mass_points = 3; AsteroidElementPtr->state_flags = APPEARING; AsteroidElementPtr->life_span = NORMAL_LIFE; SetPrimType (&DisplayArray[AsteroidElementPtr->PrimIndex], STAMP_PRIM); if ((val = (COUNT)TFB_Random ()) & (1 << 0)) { if (!(val & (1 << 1))) AsteroidElementPtr->current.location.x = 0; else AsteroidElementPtr->current.location.x = LOG_SPACE_WIDTH; AsteroidElementPtr->current.location.y = WRAP_Y (DISPLAY_ALIGN_Y (TFB_Random ())); } else { AsteroidElementPtr->current.location.x = WRAP_X (DISPLAY_ALIGN_X (TFB_Random ())); if (!(val & (1 << 1))) AsteroidElementPtr->current.location.y = 0; else AsteroidElementPtr->current.location.y = LOG_SPACE_HEIGHT; } { // Using these temporary variables because the execution order // of function arguments may vary per system, which may break // synchronisation on network games. SIZE magnitude = DISPLAY_TO_WORLD (((SIZE)TFB_Random () & 7) + 4); COUNT facing = (COUNT)TFB_Random (); SetVelocityVector (&AsteroidElementPtr->velocity, magnitude, facing); } AsteroidElementPtr->current.image.farray = asteroid; AsteroidElementPtr->current.image.frame = SetAbsFrameIndex (asteroid[0], NORMALIZE_FACING (TFB_Random ())); AsteroidElementPtr->turn_wait = AsteroidElementPtr->thrust_wait = (BYTE)TFB_Random () & (BYTE)((1 << 2) - 1); AsteroidElementPtr->thrust_wait |= (BYTE)TFB_Random () & (BYTE)(1 << 7); AsteroidElementPtr->preprocess_func = asteroid_preprocess; AsteroidElementPtr->death_func = spawn_rubble; AsteroidElementPtr->collision_func = collision; AsteroidElementPtr->triggers_teleport_safety = TRUE; UnlockElement (hAsteroidElement); PutElement (hAsteroidElement); } }