Downloads containing turtlevania.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Castle Turtlevania Speaktrap Single player 6.9 Download file

File preview

  1. //this script is a MESS!
  2.  
  3. int maxhealth = 3;
  4. int health = maxhealth;
  5.  
  6. const uint tweedleMaxClones = 4;
  7. const uint tweedleCooldown = 128; //192
  8. const uint bubbaLifesteal = 4;
  9.  
  10. //abilities
  11. bool running_boots = false;
  12. bool super_jump = false;
  13. bool mega_jump = false;
  14. int lastWep = 0;
  15.  
  16. //cheats ;)
  17. //bool running_boots = true;
  18. //bool super_jump = true;
  19.  
  20. //RU-RU-RU-RURKOWCE
  21. bool doopy = true;
  22. //I CO TERAS?
  23.  
  24.  
  25.  
  26. //a lot of variables
  27. bool sjumping = false;
  28. bool firstmusic = false;
  29. bool chaos_on = false;
  30. bool noHUD = false;
  31. bool alreadyStoned = false;
  32. bool spazm = false;
  33.  
  34. bool paintingbossFight = false;
  35. bool bubbaFight = false;
  36. bool tweedleFight = false;
  37. bool paintingDefeated = false;
  38. bool bubbaDefeated = false;
  39. bool tweedleDefeated = false;
  40. bool paintfrozen = false;
  41.  
  42.  
  43. uint paintingFrameID = 0;
  44. uint psubFrameID = 0;
  45. int bubbaID = 0;
  46. int tweedleID = 0;
  47. int tweedleGhosts = 0;
  48. int ammodrop;
  49. int place = 1;
  50. int paintingbossID;
  51.  
  52. array<bool> CollectedWeapons(9,false);
  53.  
  54. jjOBJ@ enemy;
  55. //jjOBJ@ tweedleObj;
  56.  
  57.  
  58. const uint dnCYCLELENGTH=700; // Day Length.
  59. const uint dnEVERYXTICKS=4; //the amount ticks the pallette refreshes it's colours.
  60. const uint dnINITIALTICKS=256; //determines the initial time of the day. 0 means dawn, 256 means noon, 512 means dusk, 768 means midnight and 1024 means dawn again. All values allowed.
  61. const string dnNIGHTTILESET="Inferno1.j2t"; // the name of the tileset whose palette should be used in midnight.
  62. const string dnDAYTILESET="InfernoN.j2t";
  63. jjPAL PaletteNight;
  64. jjPAL PaletteDay;
  65.  
  66. bool onDrawHealth(jjPLAYER@ player, jjCANVAS@ canvas) {
  67.         if (!noHUD){
  68.       canvas.drawString(
  69.                         24,
  70.                         jjSubscreenHeight - 445,
  71.                         (health + "/" + maxhealth),
  72.                         STRING::MEDIUM,
  73.                         STRING::NORMAL
  74.                 );
  75.                
  76.                 canvas.drawString(
  77.                         16,
  78.                         jjSubscreenHeight - 460,
  79.                         "Health",
  80.                         STRING::SMALL,
  81.                         STRING::NORMAL
  82.                 );}
  83.     return true;
  84. }
  85.  
  86. bool onDrawLives(jjPLAYER@ player, jjCANVAS@ canvas) {
  87.        
  88.         return true;
  89.         }
  90.        
  91. bool onDrawAmmo(jjPLAYER@ p, jjCANVAS@ canvas) {
  92.         return noHUD;
  93. }
  94.  
  95. bool onDrawScore(jjPLAYER@ p, jjCANVAS@ canvas) {
  96.         return true;
  97. }      
  98.  
  99. /***Constants***/
  100. const float cMaxSpeed = 10; //The maximum speed the boomerang can have
  101. const float cAcceleration = 0.2; //The acceleration of the boomerang
  102. const float cReturnAccMult = 1; //When the boomerang is returning, this is a multiplier for the acceleration (so a value of 2 let's the boomerang return with 2x acceleration)
  103. const float cVerSpdMult = 0.7; //When the boomerang is shot vertical and not returning, this is a multiplier for the acceleration (a higher value lets the boomerang go faster and higher upward)
  104. const float cReturnSpeed = 0.4; //At what speed the boomerang returns back to the player (WARNING! This constant should always be higher than cAcceleration)
  105. const float cReturnRadius = 32; //Radius in pixels at which the player takes the boomerang back
  106.  
  107. const float cBombSpeed = 7; //xSpeed of the bomb
  108. const float cBombPlayerSpeed = 10; //xSpeed the bomb can gain by player speed (if a player is running full speed it will add 6 xSpeed)
  109. const int cBombLifeTime = 60; //Time till the bomb explodes (run away! run away!!!1)
  110.  
  111.  
  112. /***Variables***/
  113. array<bool> returning(32, false);
  114. array<bool> boomerangfired(32, false);
  115. array<float> speed(32, cMaxSpeed);
  116.  
  117. /***Math functions***/
  118. //Calculates the distance between two points
  119. float distance(float x1, float y1, float x2, float y2) {
  120.   return sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
  121. }
  122.  
  123. void CreateBomb(int objectID) {
  124.   int playerID = jjObjects[objectID].creator - 32768;
  125.   int bombID = jjAddObject(OBJECT::APPLE, jjPlayers[playerID].xPos, jjPlayers[playerID].yPos - 24, jjPlayers[playerID].playerID, CREATOR::PLAYER);
  126.   jjObjects[bombID].objType = 3;
  127.   jjObjects[bombID].determineCurAnim(ANIM::BUBBA, 6, true);
  128.   jjObjects[bombID].special = 11;
  129.   jjObjects[bombID].xSpeed = cBombSpeed*jjPlayers[playerID].direction + cBombPlayerSpeed*jjPlayers[playerID].xSpeed/16;
  130.   jjObjects[bombID].ySpeed = -1;
  131. }
  132.  
  133. void DestroyBomb(int bombID) {
  134.   int explosionID = jjAddObject(OBJECT::TNT, jjObjects[bombID].xPos, jjObjects[bombID].yPos, jjObjects[bombID].creator, CREATOR::PLAYER);
  135.   jjDeleteObject(bombID);
  136.   jjObjects[explosionID].determineCurAnim(ANIM::BUBBA, 8, true);
  137.   jjObjects[explosionID].killAnim = ANIM::AMMO;
  138.   jjObjects[explosionID].state = STATE::EXPLODE;
  139. }
  140.  
  141. /***Other functions***/
  142. void BoomerangGun(int boomerangID) {
  143.   int playerID = jjObjects[boomerangID].creator - 32768;
  144.  
  145.   if ((abs(jjObjects[boomerangID].xSpeed) < cReturnSpeed && jjObjects[boomerangID].direction != 0) || (abs(jjObjects[boomerangID].ySpeed) < cReturnSpeed && jjObjects[boomerangID].direction == 0) && !returning[playerID])
  146.     returning[playerID] = true;
  147.  
  148.   if (jjObjects[boomerangID].counter == 1) {
  149.     if (playerID == p.playerID)
  150.       p.noFire = true;
  151.     jjObjects[boomerangID].determineCurAnim(ANIM::TUFBOSS, 3);
  152.     jjObjects[boomerangID].counterEnd = 254;
  153.   }
  154.  
  155.   if (returning[playerID]) {
  156.     if (distance(jjPlayers[playerID].xPos, jjPlayers[playerID].yPos, jjObjects[boomerangID].xPos, jjObjects[boomerangID].yPos) < cReturnRadius)
  157.       jjKillObject(boomerangID);
  158.    
  159.     if (speed[playerID] < cMaxSpeed)
  160.       speed[playerID] = speed[playerID] + cAcceleration*cReturnAccMult;
  161.  
  162.     jjObjects[boomerangID].ySpeed = speed[playerID]*(jjPlayers[playerID].yPos - jjObjects[boomerangID].yPos)/distance(jjPlayers[playerID].xPos, jjPlayers[playerID].yPos, jjObjects[boomerangID].xPos, jjObjects[boomerangID].yPos);
  163.     jjObjects[boomerangID].xSpeed = speed[playerID]*(jjPlayers[playerID].xPos - jjObjects[boomerangID].xPos)/distance(jjPlayers[playerID].xPos, jjPlayers[playerID].yPos, jjObjects[boomerangID].xPos, jjObjects[boomerangID].yPos);
  164.   } else {
  165.     if (speed[playerID] > 0)
  166.       speed[playerID] = speed[playerID] - cAcceleration;
  167.     if (jjObjects[boomerangID].direction == 0)
  168.       jjObjects[boomerangID].ySpeed = -speed[playerID]*cVerSpdMult;
  169.     else
  170.       jjObjects[boomerangID].xSpeed = speed[playerID]*jjObjects[boomerangID].direction;
  171.   }
  172.  
  173.   if (jjObjects[boomerangID].counter > 200)
  174.     jjObjects[boomerangID].counter = 30;
  175. }
  176.  
  177. void ChaoticRealm(){
  178.         for(int i=1;i<4096;i++) jjTileType[i] = 5;
  179.         PaletteNight.load(dnNIGHTTILESET);
  180.         PaletteDay.load(dnDAYTILESET);
  181.         jjLayerHasTiles[7] = false;
  182.         jjTexturedBGTexture = TEXTURE::XARGON;
  183.         jjTexturedBGStyle = TEXTURE::TILEMENU;
  184.         jjLocalPlayers[0].showText("@@@@@@@@CHAOTIC REALM", STRING::MEDIUM);
  185.         chaos_on = true;
  186. }
  187.  
  188. void onLevelLoad()
  189. {
  190.         jjWaterLighting = WATERLIGHT::GLOBAL;
  191.         jjSetWaterLevel(32*104, true);
  192.        
  193.         //jjSetWaterGradient(167, 19, 239, 7, 0, 19);
  194.         jjSetWaterGradient(45, 0, 62, 7, 0, 9);
  195.         jjObjectPresets[OBJECT::PEAR].determineCurAnim(ANIM::PICKUPS,33);
  196.         jjObjectPresets[OBJECT::LIME].determineCurAnim(ANIM::PICKUPS,40);
  197.         //jjObjectPresets[OBJECT::PRETZEL].determineCurAnim(ANIM::PICKUPS,40);
  198.         jjObjectPresets[OBJECT::SPIKEBOLL].energy = 80;
  199.         jjObjectPresets[OBJECT::SPIKEBOLL].bulletHandling = HANDLING::HURTBYBULLET;
  200.         jjObjectPresets[OBJECT::SPIKEBOLL].behavior = paintbossB;
  201.         jjObjectPresets[OBJECT::BEE].energy = 80;
  202.         jjObjectPresets[OBJECT::PRETZEL].lightType = LIGHT::LASER;
  203.         jjObjectPresets[OBJECT::PRETZEL].light = 40;
  204.         jjObjectPresets[OBJECT::PEAR].lightType = LIGHT::LASER;
  205.         jjObjectPresets[OBJECT::PEAR].light = 40;
  206.         jjObjectPresets[OBJECT::LIME].lightType = LIGHT::LASER;
  207.         jjObjectPresets[OBJECT::LIME].light = 40;
  208.         jjObjectPresets[OBJECT::BEE].bulletHandling = HANDLING::HURTBYBULLET;
  209.        
  210.        
  211.         jjPIXELMAP painting(64, 13*32, 64, 64);
  212.                 paintingFrameID = jjAnimations[jjAnimSets[ANIM::SPIKEBOLL].firstAnim].firstFrame;
  213.                 jjANIMFRAME@ frame = jjAnimFrames[paintingFrameID];
  214.                 painting.save(frame);
  215.                 frame.hotSpotX = -32;
  216.                 frame.hotSpotY = -32;
  217.                
  218.         //jjPIXELMAP psub(22*32, 9*32, 23*32, 10*32);
  219.                 psubFrameID = jjAnimations[jjAnimSets[ANIM::SPIKEBOLL].firstAnim].firstFrame;
  220.                 jjANIMFRAME@ frameChain = jjAnimFrames[psubFrameID+1];
  221.                 //psub.save(frameChain);
  222.                 //frame2.hotSpotX = -32;
  223.                 //frame2.hotSpotY = -32;
  224. }
  225. void onLevelBegin(){
  226.         p.yPos = 32*99+16;
  227. }
  228.  
  229. void paintbossB(jjOBJ@ paint) {
  230.         paint.behave(BEHAVIOR::PLATFORM, false);
  231.         jjDrawSpriteFromCurFrame(paint.xPos, paint.yPos, (ANIM::SPIKEBOLL), paint.direction);
  232. }
  233.  
  234. void onFunction0(jjPLAYER@ p) {
  235. //Painting Boss
  236. if (!paintingbossFight && !paintingDefeated){
  237.   paintingbossFight = true;
  238.   jjMusicLoad("Pip Malt - Redemption.it");
  239.   p.boss = paintingbossID;
  240.   jjObjects[paintingbossID].light = 25;
  241.   jjObjects[paintingbossID].lightType = LIGHT::NORMAL;
  242.   //p.boss = jjAddObject(OBJECT::SPIKEBOLL, 101*32, 96*32);
  243.   p.bossActivated = true;
  244.   p.cameraFreeze(182*32, 98*32, true, false);
  245.   jjTriggers[0] = true;}
  246. }
  247.  
  248. void onFunction1(jjPLAYER@ p) {
  249. //Bubba Boss
  250. if (!bubbaFight && !bubbaDefeated){
  251.   jjMusicLoad("Pip Malt - Amiable Arachnids.it");
  252.   bubbaID = jjAddObject(OBJECT::BUBBA, 201*32, 38*32);
  253.   p.boss = bubbaID;
  254.   p.bossActivated = true;
  255.   p.cameraFreeze(200*32, 36*32, true, false);
  256.   jjTriggers[28] = true;
  257.   bubbaFight = true;}
  258. }
  259.  
  260. void onFunction2(jjPLAYER@ p) {
  261.         if (place != 2){
  262.         jjMusicLoad("whisper.s3m");
  263.         //jjAlert("||CLOCKTOWER");
  264.         jjLocalPlayers[0].showText("@@@@@@@@CLOCKTOWER", STRING::MEDIUM);
  265.         place = 2;
  266.         }
  267. }
  268.  
  269. void onFunction3(jjPLAYER@ p) {
  270.         if (place != 3){
  271.         jjMusicLoad("life_of_stagelife.mod");
  272.         jjLocalPlayers[0].showText("@@@@@@@@DEVIL'S GALLERY", STRING::MEDIUM);
  273.         //jjAlert("||DEVIL'S GALLERY");
  274.         place = 3;
  275.         }
  276. }
  277.  
  278. void onFunction4(jjPLAYER@ p) {
  279.         if (place != 1){
  280.         jjMusicLoad("fear2.mod");
  281.         place = 1;
  282. }
  283. }
  284.  
  285. void onFunction5(jjPLAYER@ p) {
  286.         if (place != 4){
  287.         jjMusicLoad("knew.s3m");
  288.         jjLocalPlayers[0].showText("@@@@@@@@CASTLE WALL", STRING::MEDIUM);
  289.         //jjAlert("||CASTLE WALL");
  290.         place = 4;
  291.         }
  292. }
  293.  
  294. void onFunction6(jjPLAYER@ p) {
  295.         //Tweedle boss!!!//
  296.         if (!tweedleFight && !tweedleDefeated){
  297.         jjMusicLoad("Pip Malt - The Serpent's Wings.it");
  298.         tweedleID = jjAddObject(OBJECT::BEE, 399*32, 11*32);
  299.         jjObjects[tweedleID].determineCurAnim(ANIM::TWEEDLE, 1);
  300.         p.boss = jjObjects[tweedleID].objectID;
  301.         p.bossActivated = true;
  302.         p.cameraFreeze(398*32, 11*32, true, false);
  303.         jjTriggers[23] = true;
  304.         tweedleFight = true;
  305.         }
  306. }
  307. void onFunction7(jjPLAYER@ p) {
  308.         p.xPos = p.xPos + 9376;
  309.         p.yPos = p.yPos - 160;
  310.         jjMusicLoad("goodbye_world.mod");
  311.         ChaoticRealm();
  312. }
  313.  
  314. void onFunction8(jjPLAYER@ p) {
  315.         jjMusicLoad("turtlevania-music.mod");
  316.         //ChaoticRealm();
  317. }
  318.  
  319. void onPlayerInput(jjPLAYER@ play) {
  320. //if (play.keySelect){
  321.  
  322. //}
  323.  
  324. if (!running_boots && health > 0) play.keyRun = false;
  325. //if (sjumping && p.keyJump) sjumping = false;
  326. //if (super_jump && p.keyDown && p.keyJump && p.ySpeed < 0) sjumping = true;
  327.  
  328. if (super_jump && p.keySelect && p.keyUp && p.charCurr != CHAR::BIRD) {
  329.                 p.morphTo(CHAR::BIRD);
  330.                 lastWep = p.currWeapon;
  331.                
  332.          }
  333.          
  334.          if (super_jump && p.keySelect && p.keyDown && p.charCurr == CHAR::BIRD) {
  335.                 p.revertMorph();
  336.                 p.currWeapon = lastWep - 2;
  337.                
  338.          }
  339.  
  340.  
  341.         //GRAVITY BOOTS
  342.        if (mega_jump && p.ySpeed != 0 && p.keyUp && !p.antiGrav && p.charCurr != CHAR::BIRD) {
  343.                 p.antiGrav = true;
  344.                 p.buttstomp = 2;
  345.                         }
  346.         if (p.antiGrav){
  347.                         if (p.buttstomp > 118 || p.charCurr == CHAR::BIRD){
  348.                                 p.antiGrav = false; }
  349.        
  350.                         if (p.keyDown && !p.keyUp){
  351.                                 p.antiGrav = false;
  352.                                 p.buttstomp = 2;
  353.                         }
  354.         }
  355.  
  356.  
  357. if (health <= 0){
  358.         play.keyRight = false;
  359.         play.keyLeft = false;
  360.         play.keyFire = false;
  361.         play.keyRun = true;
  362.         play.keyJump = false;
  363.   }
  364. if (p.lives != 3) health = 0;
  365. }
  366.  
  367. void onPlayer() {
  368.        
  369.         if (doopy){
  370.                 if (p.xPos <= 768) doopy = false; //RURURURURURRURURUU
  371.                 if (p.xPos > 768) health = 0;
  372.         }
  373.        
  374.        
  375.         /*if (p.charOrig==CHAR::SPAZ && !spazm){
  376.                 jjAlert("|||||SPAZ MODE ACTIVATED");
  377.                 running_boots = true;
  378.                 spazm = true;
  379.         }*/
  380.         //if (spazm && p.ySpeed > 0) p.alreadyDoubleJumped = false;
  381.         jjCHARACTER@ char = jjCharacters[p.charCurr];
  382.         char.airJump =  AIR::HELICOPTER;
  383.         char.groundJump = GROUND::JAZZ;
  384.        
  385.        
  386.   if (!firstmusic && p.xPos > 32*92){
  387.     jjMusicLoad("fear2.mod");
  388.     firstmusic = true;
  389.     }
  390.    
  391.   if (!firstmusic && p.xPos > 768 && p.xPos < 1024 && p.health == 5) p.health = 3;  
  392.   //p.alreadyDoubleJumped = false;
  393.   if (health <= 0 && p.xPos > 24*32){
  394.           p.bossActivated = false;
  395.           tweedleFight = false;
  396.           paintingbossFight = false;
  397.           bubbaFight = false;
  398.           noHUD = true;
  399.           p.cameraUnfreeze();
  400.           p.yPos = 40*32;
  401.           jjMusicStop();
  402.   }
  403.   if (health <= 0) p.xPos = (21*32)-30;
  404.   if (p.health == 5 && p.xPos > 768){
  405.           maxhealth = maxhealth + 1;
  406.           p.health = 3;
  407.           health = maxhealth;
  408.           jjAlert("            |            |            Maximum health increased!");
  409.           //jjDrawString(p.cameraX + 40,  p.cameraY + (jjResolutionHeight * 0.75), "Maximum health increased", STRING::MEDIUM, STRING::NORMAL, 0, 1);
  410.   }
  411.   else if (p.health == 4){
  412.           if (health != maxhealth) health = health + 1;
  413.           p.health = 3;
  414.   }
  415.   else if (p.health == 2){
  416.           health = health - 1;
  417.           p.health = 3;
  418.           jjTriggers[19] = true;
  419.           if (bubbaFight){
  420.                   jjObjects[bubbaID].energy = jjObjects[bubbaID].energy  + bubbaLifesteal;
  421.                   jjPARTICLE@ particle = jjAddParticle(PARTICLE::STRING);
  422.                                         if (particle !is null) {
  423.                                                 particle.xPos = jjObjects[bubbaID].xPos;
  424.                                                 particle.yPos = jjObjects[bubbaID].yPos;
  425.                                                 particle.string.text = "|+HEALTH";
  426.                                                 particle.ySpeed = -0.25;               
  427.                                         }
  428.           }
  429.   }
  430.  
  431.  
  432.  
  433.   if (!CollectedWeapons[2] && p.ammo[WEAPON::BOUNCER] > 0) CollectedWeapons[2]=true;
  434.   if (!CollectedWeapons[3] && p.ammo[WEAPON::ICE] > 0) CollectedWeapons[3]=true;
  435.   if (!CollectedWeapons[6] && p.ammo[WEAPON::TOASTER] > 0) CollectedWeapons[6]=true;
  436.   if (!CollectedWeapons[5] && p.ammo[WEAPON::RF] > 0) CollectedWeapons[5]=true;
  437.  
  438.  
  439.   /*if (sjumping){
  440.     p.ySpeed = -20;
  441.     if (jjMaskedHLine(p.xPos, 24, p.yPos - 32)) sjumping = false;
  442.     }*/
  443.   if (p.food >= 1 && !running_boots && p.xPos > 80*32 && p.xPos < 90*32 && p.yPos < 97*32) {
  444.     running_boots = true;
  445.     jjLocalPlayers[0].showText("@@@@@@@@YOU GOT SNEAKERS OF MERCURY!", STRING::MEDIUM);
  446.     //jjAlert("            |            |        YOU GOT SNEAKERS OF MERCURY!");
  447.     jjAlert("            |            |               Now you can sprint");
  448.     jjSample(p.xPos, p.yPos, SOUND::COMMON_HARP1);
  449.     p.food = 0;
  450.     }
  451.    if (p.food >= 1 && !super_jump && p.xPos > 430*32 && p.xPos < 445*32) {
  452.     super_jump = true;
  453.     jjLocalPlayers[0].showText("@@@@@@@@YOU GOT THE CARROT OF FLIGHT!", STRING::MEDIUM);
  454.     //jjAlert("            |            |       YOU GOT THE CARROT OF FLIGHT!");
  455.     jjAlert("            |        |     Press select weapon + up to fly");
  456.     jjAlert("            |        |     and select weapon + down to revert");
  457.     jjSample(p.xPos, p.yPos, SOUND::COMMON_HARP1);
  458.     p.food = 0;
  459.     }
  460.     if (p.food >= 1 && !mega_jump && p.xPos > 80*32 && p.xPos < 90*32 && p.yPos > 97*32) {
  461.     mega_jump = true;
  462.     jjSetWaterLevel(32*127, false);
  463.     jjLocalPlayers[0].showText("@@@@@@@@YOU GOT GRAVITY PRETZEL!", STRING::MEDIUM);
  464.     //jjAlert("            |            |        YOU GOT GRAVITY PRETZEL!");
  465.     jjAlert("            |            |               Press up while airborne");
  466.     jjSample(p.xPos, p.yPos, SOUND::COMMON_HARP1);
  467.     p.food = 0;
  468.     }
  469.   for (int i = 1; i < jjObjectCount; i++) {
  470.     @enemy = jjObjects[i];
  471.     //if (enemy.eventID == OBJECT::BUBBA) @bubbaObj = jjObjects[i];
  472.     if (enemy.objType >= 16 && enemy.state == STATE::KILL && enemy.isActive && jjGameTicks%3 == 0) {
  473.       switch (enemy.eventID) {
  474.         //case OBJECT::BAT: ammodrop = OBJECT::BOUNCERAMMO3; break;
  475.         case OBJECT::DRAGON: ammodrop = OBJECT::TOASTERAMMO3; break;
  476.         case OBJECT::FISH: ammodrop = OBJECT::ICEAMMO3; break;
  477.         case OBJECT::SPARK: ammodrop = OBJECT::GUN9AMMO3; break;
  478.         case OBJECT::HELMUT: ammodrop = OBJECT::RFAMMO3; break;
  479.         default: {
  480.         switch (jjRandom()%8) {
  481.           case 0: if (CollectedWeapons[2]) ammodrop = OBJECT::BOUNCERAMMO3; break;
  482.           case 1: if (CollectedWeapons[3]) ammodrop = OBJECT::ICEAMMO3; break;
  483.           case 2: if (p.ammo[WEAPON::SEEKER] > 0) ammodrop = OBJECT::SEEKERAMMO3; break;
  484.           case 3: if (CollectedWeapons[5]) ammodrop = OBJECT::RFAMMO3; break;
  485.           case 4: if (CollectedWeapons[6]) ammodrop = OBJECT::TOASTERAMMO3; break;
  486.           case 5: if (p.ammo[WEAPON::TNT] > 0) ammodrop = OBJECT::TNTAMMO3; break;
  487.           case 6: if (p.ammo[WEAPON::GUN8] > 0) ammodrop = OBJECT::GUN8AMMO3; break;
  488.           case 7: if (p.ammo[WEAPON::GUN9] > 0) ammodrop = OBJECT::GUN9AMMO3; break;
  489.           }
  490.         }
  491.       }
  492.         jjAddObject(ammodrop, enemy.xPos, enemy.yPos, p.playerID, CREATOR::PLAYER);
  493.     }
  494.   }
  495.   if (p.stoned == 0 && alreadyStoned) alreadyStoned = false;
  496.   if (p.stoned>0 && !alreadyStoned){
  497.                 jjPARTICLE@ particle = jjAddParticle(PARTICLE::STRING);
  498.                                         if (particle !is null) {
  499.                                                 particle.xPos = p.xPos;
  500.                                                 particle.yPos = p.yPos;
  501.                                                 particle.string.text = "||CURSE";
  502.                                                 particle.ySpeed = -0.25;               
  503.                                         }
  504.                                         alreadyStoned = true;
  505.                                 }
  506. }
  507.  
  508. /***Gameplay functions***/
  509. void onMain() {
  510.        
  511.         if(chaos_on && jjGameTicks%dnEVERYXTICKS==0) {
  512.     jjPalette=PaletteNight;
  513.     jjPalette.copyFrom(2,252,2,PaletteDay,(jjSin(1024*jjGameTicks/dnCYCLELENGTH+dnINITIALTICKS)+1)/2);
  514.     jjPalette.apply();
  515.         }
  516.        
  517.         //jjObjects[paintingbossID].xPos = 183*32;
  518.         //jjObjects[paintingbossID].yPos = 100+jjSin(jjGameTicks);
  519.        
  520.        
  521.   for (int i = 0;  i < jjObjectCount; i++){
  522.     if (paintingbossID == 0 && jjObjects[i].eventID == OBJECT::SPIKEBOLL)
  523.          paintingbossID = i;
  524.     /*if (tweedleID == 0 && jjObjects[i].eventID == OBJECT::BEE){
  525.          tweedleID = i;
  526.          @tweedleObj = jjObjects[i];
  527.          }*/
  528.     if (jjObjects[i].isActive && jjObjects[i].creatorType == CREATOR::PLAYER) {
  529.       //Maintain boomerang gun
  530.       if (jjObjects[i].eventID == OBJECT::BLASTERBULLET) {
  531.         BoomerangGun(i);
  532.         if (jjGameTicks%20 == 0) jjSample(jjObjects[i].xPos, jjObjects[i].yPos, SOUND::TUFBOSS_CATCH);
  533.         jjObjects[i].animSpeed = 3;
  534.         boomerangfired[jjObjects[i].creator - 32768] = true;
  535.         continue;
  536.       }
  537.       if (jjObjects[i].eventID == OBJECT::TNT && jjObjects[i].state != STATE::EXPLODE) {
  538.         jjDeleteObject(i);
  539.         CreateBomb(i);
  540.         continue;
  541.       }
  542.       if (jjObjects[i].eventID == OBJECT::APPLE && jjObjects[i].special == 11) {
  543.         jjObjects[i].age++;
  544.         if (jjObjects[i].age > cBombLifeTime)
  545.           DestroyBomb(i);
  546.         continue;
  547.       }
  548.     }
  549.    }
  550.   for (int i = 0; i < 32; i++)
  551.     if (!boomerangfired[i]) {
  552.       speed[i] = cMaxSpeed;
  553.       returning[i] = false;
  554.       if (i == p.playerID)
  555.         p.noFire = false;
  556.     } else boomerangfired[i] = false;
  557.  
  558.  
  559. if (paintingbossFight) { //.causesRicochet = true;
  560. //Painting Boss
  561.   if (jjObjects[paintingbossID].state == STATE::FREEZE && jjGameTicks%6==0){
  562.         if (jjObjects[paintingbossID].justHit>0)
  563.                 jjObjects[paintingbossID].unfreeze(jjRandom()%2);
  564.         paintfrozen = true;
  565.         }
  566.         else paintfrozen = false;
  567.   if (jjObjects[paintingbossID].justHit>0 && jjGameTicks%4==0){
  568.                 int paintrav = jjAddObject(OBJECT::RAVEN, jjObjects[paintingbossID].xPos+jjRandom()%64-32, jjObjects[paintingbossID].yPos-jjRandom()%64);
  569.                 jjObjects[paintrav].lightType = LIGHT::FLICKER;
  570.                 jjObjects[paintrav].light = 60;
  571.   }
  572.   if (jjObjects[paintingbossID].state==STATE::KILL || jjObjects[paintingbossID].energy<0){
  573.                 jjObjects[paintingbossID].fireBullet(OBJECT::EXPLOSION);
  574.                 jjAddObject(OBJECT::FULLENERGY, jjObjects[paintingbossID].xPos, jjObjects[paintingbossID].yPos);
  575.                 paintingbossFight = false;
  576.                 paintingDefeated = true;
  577.                 p.bossActivated = false;
  578.                 p.cameraUnfreeze();
  579.                 jjTriggers[0] = false;
  580.                 jjMusicLoad("fear2.mod");
  581.                 for (int i = 0;  i < jjObjectCount; i++)
  582.                         if (jjObjects[i].eventID == OBJECT::RAVEN && jjObjects[i].xPos > 172*32 && jjObjects[i].xPos < 192*32 && jjObjects[i].yPos > 87*32 && jjObjects[i].yPos < 108*32)
  583.                                 jjObjects[i].state=STATE::KILL;
  584.                 }
  585.   }
  586.  
  587. if (bubbaFight){
  588.         if (jjGameTicks%75==0)
  589.                 jjObjects[bubbaID].fireBullet(OBJECT::SMOKERING);
  590.         if (jjObjects[bubbaID].energy<6){
  591.                 jjDeleteObject(bubbaID);
  592.           jjAddObject(OBJECT::FULLENERGY, jjObjects[bubbaID].xPos, jjObjects[bubbaID].yPos);
  593.           for (int j=0; j<4; j++)
  594.                 for (int i=0; i<4; i++)
  595.                         jjAddObject(OBJECT::TNTAMMO3, (199*32)+(32*i), (32*32)+(32*j));
  596.           jjAddObject(OBJECT::EXPLOSION, jjObjects[bubbaID].xPos, jjObjects[bubbaID].yPos);
  597.           bubbaFight = false;
  598.           bubbaDefeated = true;
  599.           p.bossActivated = false;
  600.           p.cameraUnfreeze();
  601.           jjTriggers[28] = false;
  602.           jjTriggers[17] = true;
  603.           for (int i=0; i <3 ;i++)
  604.                 jjTileSet(3,209,38+i,(jjTileGet(4,8,11+i)));
  605.         }
  606. }
  607.  
  608. if (tweedleFight) {
  609.         tweedleGhosts = 0;
  610.         for (int i = 0;  i < jjObjectCount; i++)
  611.                 if (jjObjects[i].eventID == OBJECT::PACMANGHOST){
  612.                         //jjObjects[i].determineCurAnim(ANIM::TWEEDLE, 1);
  613.                         tweedleGhosts++;/*
  614.                         if (jjObjects[i].state==STATE::KILL){
  615.                                 jjDeleteObject(i);
  616.                                 for (int j = 0;  j < jjObjectCount; j++)
  617.                                         if (jjObjects[j].eventID == OBJECT::PACMANGHOST)
  618.                                                 jjDeleteObject(j);
  619.                                                 //jjObjects[j].state=STATE::KILL;
  620.                                 break;
  621.                                 }*/
  622.                         }
  623.         if (tweedleGhosts<tweedleMaxClones && jjGameTicks % tweedleCooldown == 0){
  624.                 int tweedleClone =
  625.                         jjAddObject(OBJECT::PACMANGHOST, jjObjects[tweedleID].xPos, jjObjects[tweedleID].yPos);
  626.                 jjObjects[tweedleClone].determineCurAnim(ANIM::TWEEDLE, 1);
  627.                 jjObjects[tweedleClone].energy = 1;
  628.                 jjSample(jjObjects[tweedleID].xPos, jjObjects[tweedleID].yPos, SOUND::DEVILDEVAN_JUMPUP);
  629.                 for (int i = 0; i<48;i++){
  630.                         jjPARTICLE@ particle = jjAddParticle(PARTICLE::SPARK);
  631.                         if (particle !is null) {
  632.                                 particle.xPos = jjObjects[tweedleID].xPos;
  633.                                 particle.yPos = jjObjects[tweedleID].yPos;
  634.                                 particle.xSpeed = (jjRandom()%4);
  635.                                 particle.ySpeed = (jjRandom()%4);
  636.                                 }
  637.                         }
  638.         }
  639.         if (jjObjects[tweedleID].state==STATE::KILL){
  640.                 tweedleFight = false;
  641.                 tweedleDefeated = true;
  642.                 jjAddObject(OBJECT::FULLENERGY, jjObjects[tweedleID].xPos, jjObjects[tweedleID].yPos);
  643.                 p.bossActivated = false;
  644.                 p.cameraUnfreeze();
  645.                 jjTriggers[23] = false;
  646.                 jjMusicLoad("life_of_stagelife.mod");
  647.                 for (int i = 0;  i < jjObjectCount; i++)
  648.                         if (jjObjects[i].eventID == OBJECT::PACMANGHOST)
  649.                                 jjObjects[i].state=STATE::KILL;
  650.                 }
  651.  
  652.   }
  653.  
  654. }
  655. void onDrawLayer4(jjPLAYER@ play, jjCANVAS@ screen) {
  656.        
  657. if (paintingbossFight){
  658.         if (!paintfrozen){
  659.         screen.drawRotatedSpriteFromCurFrame(
  660.                 jjObjects[paintingbossID].xPos,
  661.                 jjObjects[paintingbossID].yPos,
  662.                 paintingFrameID,
  663.                 jjGameTicks << 1, 2, 1,
  664.                 SPRITE::TINTED,
  665.                 uint(abs(jjSin(jjGameTicks)) * 256)
  666.                 );
  667.         screen.drawSpriteFromCurFrame(
  668.                 jjObjects[paintingbossID].xPos,
  669.                 jjObjects[paintingbossID].yPos,
  670.                 paintingFrameID,
  671.                 0,
  672.                 SPRITE::NORMAL
  673.                 );
  674.         screen.drawRotatedSpriteFromCurFrame(
  675.                 jjObjects[paintingbossID].xPos,
  676.                 jjObjects[paintingbossID].yPos,
  677.                 paintingFrameID,
  678.                 jjGameTicks << 2, 2, 1,
  679.                 SPRITE::BLEND_OVERLAY,
  680.                 uint(abs(jjSin(jjGameTicks)) * 128)
  681.                 );
  682.         }
  683.         else screen.drawSpriteFromCurFrame(
  684.                 jjObjects[paintingbossID].xPos,
  685.                 jjObjects[paintingbossID].yPos,
  686.                 paintingFrameID,
  687.                 0,
  688.                 SPRITE::FROZEN
  689.                 );
  690. }
  691.        
  692. if (jjTriggers[24]) jjDrawString(p.cameraX + 238,  p.cameraY + (jjResolutionHeight * 0.75), "GAME OVER", STRING::MEDIUM, STRING::NORMAL, 1, 1);
  693. if (jjResolutionHeight != 480 || jjResolutionWidth != 640) {
  694.         jjDrawString(p.cameraX + 8,  p.cameraY + 16, "PLEASE SET", STRING::MEDIUM, STRING::NORMAL, 1, 1);
  695.         jjDrawString(p.cameraX + 8,  p.cameraY + 16 + 24, "RESOLUTION", STRING::MEDIUM, STRING::NORMAL, 1, 1);
  696.         jjDrawString(p.cameraX + 8,  p.cameraY + 16 + 48, "TO 640x480!", STRING::MEDIUM, STRING::NORMAL, 1, 1);
  697. }
  698. }
  699.