Powerups as Pickups

Version:

2.0

Added on:

19 Jan 2015 23:00

Tags:

Description:
Replaces all Powerup monitors with special +3 Ammo pickups. Your powerup status for any given ammo type (except blaster) will reflect whichever ammo pickup you last collected, specifically whether it was itself powered-up or not.
array<OBJECT::Object> BasicPickups = {OBJECT::BOUNCERAMMO3, OBJECT::ICEAMMO3, OBJECT::SEEKERAMMO3, OBJECT::RFAMMO3, OBJECT::TOASTERAMMO3, OBJECT::TNTAMMO3, OBJECT::GUN8AMMO3, OBJECT::GUN9AMMO3};
array<OBJECT::Object> Powerups = {OBJECT::BOUNCERPOWERUP, OBJECT::ICEPOWERUP, OBJECT::SEEKERPOWERUP, OBJECT::RFPOWERUP, OBJECT::TOASTERPOWERUP, OBJECT::TNTPOWERUP, OBJECT::GUN8POWERUP, OBJECT::GUN9POWERUP};
array<uint> PowerupPickupAnimations = {24, 28, 33, 48, 56, 59, 61, 67};
void onLevelLoad() {
  for (uint i = 0; i < BasicPickups.length; ++i) {
    jjWeapons[i + 2].maximum = 50;
    jjOBJ@ pickup = jjObjectPresets[BasicPickups[i]];
    jjOBJ@ powerup = jjObjectPresets[Powerups[i]];
    pickup.var[3] = powerup.var[3] = 0; //so that JJ2 doesn't realize it's an ammo pickup and recolor it according to players' powerup status
    pickup.var[4] = powerup.var[4] = i + 2; //firetype
    powerup.var[5] = 1; //is powerup
    powerup.behavior = pickup.behavior;
    powerup.playerHandling = pickup.playerHandling;
    powerup.bulletHandling = pickup.bulletHandling;
    powerup.killAnim = pickup.killAnim;
    powerup.determineCurAnim(ANIM::AMMO, PowerupPickupAnimations[i]);
    powerup.determineCurFrame();
    pickup.scriptedCollisions = powerup.scriptedCollisions = true;
  }
}

int min(int a, int b) {
  if (a < b) return a;
  return b;
}
void onObjectHit(jjOBJ@ obj, jjOBJ@ bull, jjPLAYER@ play, int force) {
  int fireType = obj.var[4];
  if (play.ammo[fireType] >= jjWeapons[fireType].maximum) return;
  if (play.ammo[fireType] == 0) play.currWeapon = fireType;
  play.ammo[fireType] = min(jjWeapons[fireType].maximum, play.ammo[fireType] + 3);
  play.powerup[fireType] = (obj.var[5] == 1);
  obj.behavior = BEHAVIOR::EXPLOSION2;
  obj.playerHandling = HANDLING::EXPLOSION;
  obj.frameID = 0;
  jjSample(obj.xPos, obj.yPos, SOUND::COMMON_PICKUPW1);
}