Downloads containing mo4a_3-1.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Mystery of the Four... chandie Single player 6.6 Download file

File preview

  1. const bool MLLESetupSuccessful = MLLE::Setup(array<MLLEWeaponApply@> = {null, null, ArcaneWeapons::FusionCannon::Weapon(), DefaultWeapons::Blaster(), WeaponVMega::Backfire::Weapon(), null, ArcaneWeapons::FusionCannon::Weapon(), null, ArcaneWeapons::MortarLauncher::Weapon()}); ///@MLLE-Generated
  2. #include "MLLE-Include-1.5w.asc" ///@MLLE-Generated
  3. #pragma require "mo4a_3-1-MLLE-Data-1.j2l" ///@MLLE-Generated
  4. #pragma require "mo4a_3-1.j2l" ///@MLLE-Generated
  5. #include "ArcaneWeapon4.asc" ///@MLLE-Generated
  6. #pragma require "ArcaneWeapon4.asc" ///@MLLE-Generated
  7. #include "WeaponVMega5.asc" ///@MLLE-Generated
  8. #pragma require "WeaponVMega5.asc" ///@MLLE-Generated
  9. #include "MLLE-DefaultWeapons.asc" ///@MLLE-Generated
  10. #pragma require "MLLE-DefaultWeapons.asc" ///@MLLE-Generated
  11. #include "ArcaneWeapon9.asc" ///@MLLE-Generated
  12. #pragma require "ArcaneWeapon9.asc" ///@MLLE-Generated
  13. #include "Jazz1Enemies v05.asc"
  14. #include "Resize v11.asc"
  15. #include "TrueColor v13.asc"
  16. #include "HH18savegems.asc"
  17.  
  18. int exit = 0;
  19.  
  20. bool onDrawHealth(jjPLAYER@ player, jjCANVAS@ canvas) {
  21.     canvas.drawResizedSprite(150, 585, ANIM::PICKUPS, 91, 4,0.7, 0.7, SPRITE::NORMAL);
  22.     canvas.drawSprite(20, 585, ANIM::PICKUPS, 84, jjGameTicks>>2, -1, SPRITE::PALSHIFT, -8);
  23.     canvas.drawString(170, 585, formatInt(exit%5, "1") + "/4", STRING::SMALL, STRING::NORMAL);
  24.     canvas.drawString(30, 585, formatInt(player.coins%4, "1") + "/3", STRING::SMALL, STRING::NORMAL);
  25.     return false;
  26. }
  27.  
  28. bool onDrawLives(jjPLAYER@ player, jjCANVAS@ canvas) {return true;}
  29.  
  30.  
  31. void onLevelLoad() {
  32.         gem::restorePlayerGems();
  33.         jjLevelName = ("@@@@@@@@@Central Area");
  34.         jjWaterLighting = WATERLIGHT::GLOBAL;
  35.         jjObjectPresets[OBJECT::SAVEPOST].behavior = CheckpointWrapper;
  36.         jjObjectPresets[OBJECT::SAVEPOST].deactivates = false;
  37.  
  38.         Jazz1::MakeEnemy(OBJECT::HATTER, Jazz1::Enemies::Marbelara_Schwarzenguard, true).SetUsesJJ2StyleDeathAnimation(true).SetBulletFireSound(SOUND::INTRO_SHOT1).SetBulletExplosionSound(SOUND::COMMON_GUNSM1);
  39.         Jazz1::MakeEnemy(OBJECT::DRAGONFLY, Jazz1::Enemies::Marbelara_Drageen).SetUsesJJ2StyleDeathAnimation(true);
  40.         Jazz1::MakeEnemy(OBJECT::FLOATSUCKER, Jazz1::Enemies::Marbelara_Firebomb).SetUsesJJ2StyleDeathAnimation(true);
  41.         Jazz1::MakeEnemy(OBJECT::NORMTURTLE, Jazz1::Enemies::Dreempipes_TerrapinSwimmer).SetUsesJJ2StyleDeathAnimation(true);
  42.  
  43.         jjObjectPresets[OBJECT::EVA].behavior = TimeMachine;
  44.         jjObjectPresets[OBJECT::EVA].determineCurAnim(ANIM::FLAG, 1);
  45.         jjObjectPresets[OBJECT::EVA].putOnGround(false);
  46.         jjObjectPresets[OBJECT::EVA].scriptedCollisions = true;
  47.         jjANIMATION@ tmAnim = jjAnimations[jjObjectPresets[OBJECT::EVA].curAnim];
  48.         for (uint i = 0; i < tmAnim.frameCount; ++i)
  49.                 jjAnimFrames[tmAnim.firstFrame + i].coldSpotY = -44;
  50.         for (uint i = 0; i < tmAnim.frameCount; ++i)
  51.                 jjAnimFrames[tmAnim.firstFrame + i].hotSpotY = -64;
  52.         for (uint i = 0; i < tmAnim.frameCount; ++i)
  53.                 jjAnimFrames[tmAnim.firstFrame + i].hotSpotX = -54;
  54.  
  55.         jjObjectPresets[OBJECT::AIRBOARD].behavior = Key();
  56.         jjObjectPresets[OBJECT::AIRBOARD].scriptedCollisions = true;
  57.  
  58.         jjObjectPresets[OBJECT::SANDWICH].behavior = Key2();
  59.         jjObjectPresets[OBJECT::SANDWICH].scriptedCollisions = true;
  60.         jjObjectPresets[OBJECT::SANDWICH].deactivates = false;
  61.  
  62.         jjObjectPresets[OBJECT::ICEAMMO15].behavior = FCannon();
  63.         jjObjectPresets[OBJECT::ICEAMMO15].scriptedCollisions = true;
  64.         jjObjectPresets[OBJECT::ICEAMMO15].playerHandling = HANDLING::SPECIAL;
  65.  
  66.         jjObjectPresets[OBJECT::TNTAMMO3].deactivates = false;
  67.  
  68.         jjObjectPresets[OBJECT::WEENIE].behavior = RedSphere();
  69.         jjObjectPresets[OBJECT::WEENIE].scriptedCollisions = true;
  70.         jjObjectPresets[OBJECT::CHICKENLEG].behavior = BlueSphere();
  71.         jjObjectPresets[OBJECT::CHICKENLEG].scriptedCollisions = true;
  72.         jjObjectPresets[OBJECT::HAM].behavior = GreenSphere();
  73.         jjObjectPresets[OBJECT::HAM].scriptedCollisions = true;
  74.         jjObjectPresets[OBJECT::FRIES].behavior = PurpleSphere();
  75.         jjObjectPresets[OBJECT::FRIES].scriptedCollisions = true;
  76.  
  77.         jjObjectPresets[OBJECT::STOPWATCH].behavior = Fastrun();
  78.         jjObjectPresets[OBJECT::STOPWATCH].scriptedCollisions = true;
  79.  
  80.         jjObjectPresets[OBJECT::CHIPS].behavior = Paint();
  81.         jjObjectPresets[OBJECT::CHIPS].scriptedCollisions = true;
  82.  
  83.         jjObjectPresets[OBJECT::BUTTERFLY].behavior = ButterThief();
  84.         jjObjectPresets[OBJECT::BUTTERFLY].scriptedCollisions = true;
  85.         jjObjectPresets[OBJECT::BUTTERFLY].playerHandling = HANDLING::SPECIAL;
  86.         jjObjectPresets[OBJECT::BUTTERFLY].energy = 10;
  87.  
  88.         jjObjectPresets[OBJECT::BEEBOY].behavior = Tree;
  89.         jjObjectPresets[OBJECT::BEEBOY].scriptedCollisions = true;
  90.         jjObjectPresets[OBJECT::BEEBOY].bulletHandling = HANDLING::IGNOREBULLET;
  91.         jjObjectPresets[OBJECT::BEEBOY].playerHandling = HANDLING::ENEMY;
  92.  
  93.         jjObjectPresets[OBJECT::SILVERCOIN].behavior = PlatinCoin();
  94.         jjObjectPresets[OBJECT::SILVERCOIN].scriptedCollisions = true;
  95.  
  96.         jjPIXELMAP pole(0, 26*32, 1*32, 3*32, 5);
  97.         jjANIMFRAME@ frame = jjAnimFrames[jjAnimations[jjAnimSets[ANIM::CARROTPOLE].firstAnim].firstFrame];
  98.         pole.save(frame);
  99.         frame.hotSpotX = -frame.width/2;
  100.         frame.hotSpotY = -frame.height;
  101.  
  102.         jjObjectPresets[OBJECT::FLYCARROT].determineCurAnim(ANIM::PLUS_WARP, 0);
  103.         jjObjectPresets[OBJECT::FLYCARROT].behavior = Bonus;
  104.         jjObjectPresets[OBJECT::FLYCARROT].scriptedCollisions = true;
  105.         jjANIMATION@ BAnim = jjAnimations[jjObjectPresets[OBJECT::FLYCARROT].curAnim];
  106.         for (uint i = 0; i < BAnim.frameCount; ++i)
  107.                 jjAnimFrames[BAnim.firstFrame + i].hotSpotY = -85;
  108.         for (uint i = 0; i < BAnim.frameCount; ++i)
  109.                 jjAnimFrames[BAnim.firstFrame + i].hotSpotX = 20;
  110.  
  111.         jjObjectPresets[OBJECT::INVINCIBILITY].determineCurAnim(ANIM::PLUS_WARP, 1);
  112.         jjObjectPresets[OBJECT::INVINCIBILITY].behavior = Bonuseye;
  113.         jjObjectPresets[OBJECT::INVINCIBILITY].scriptedCollisions = true;
  114.         jjObjectPresets[OBJECT::INVINCIBILITY].bulletHandling = HANDLING::IGNOREBULLET;
  115.         jjObjectPresets[OBJECT::INVINCIBILITY].playerHandling = HANDLING::PLAYERBULLET;
  116.         jjANIMATION@ BeAnim = jjAnimations[jjObjectPresets[OBJECT::INVINCIBILITY].curAnim];
  117.  
  118.         for (uint i = 0; i < BeAnim.frameCount; ++i)
  119.                 jjAnimFrames[BeAnim.firstFrame + i].hotSpotY = 16;
  120.         for (uint i = 0; i < BeAnim.frameCount; ++i)
  121.                 jjAnimFrames[BeAnim.firstFrame + i].hotSpotX = 26;
  122.  
  123. }
  124.  
  125.  
  126. class PlatinCoin : jjBEHAVIORINTERFACE {
  127.  
  128.         void onBehave(jjOBJ@ obj) {
  129.                 if(p.coins >= 1)
  130.                 {obj.delete();}
  131.                 obj.behave(BEHAVIOR::PICKUP, false);
  132.                 ++obj.counter;
  133.                 obj.yPos = jjSin(obj.counter*15 + 5)*4 + obj.yOrg;
  134.                 if(jjTriggers[1] == true && jjTriggers[2] == true && jjTriggers[4] == true && jjTriggers[5] == true)
  135.                         {jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, -8);}
  136.                 else    {jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::TRANSLUCENTPALSHIFT, -8);}
  137.         }
  138.  
  139.         bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ play, int force) {
  140.                 if(jjTriggers[1] == true && jjTriggers[2] == true && jjTriggers[4] == true && jjTriggers[5] == true)
  141.                         {p.coins += 1;
  142.                         obj.behavior = BEHAVIOR::EXPLOSION2;
  143.                         jjSample(obj.xPos, obj.yPos, SOUND::COMMON_COIN, 1000);}
  144.                 else {if(spheretext == false) {
  145.                                 p.showText("@@Collect the spheres first.");
  146.                                 spheretext = true;}
  147.                 }
  148.         return true;
  149.         }
  150.  
  151. }
  152.  
  153. void Bonuseye(jjOBJ@ obj){
  154.         obj.direction = -1;
  155.         obj.behave(BEHAVIOR::PICKUP, false);
  156.         obj.draw();
  157. }
  158. void Bonus(jjOBJ@ obj){
  159.         obj.putOnGround();
  160.         obj.direction = -1;
  161.         obj.behave(BEHAVIOR::PICKUP, false);
  162.         obj.draw();
  163. }
  164.  
  165. int slope = 0;
  166. int SpeedUpUntil = 0;
  167.  
  168. class FCannon : jjBEHAVIORINTERFACE {
  169.  
  170.         void onBehave(jjOBJ@ obj) {
  171.                 if(p.ammo[WEAPON::TNT] > 1)
  172.                 {obj.delete();}
  173.                 obj.behave(BEHAVIOR::MONITOR); 
  174.         }
  175.         bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ play, int force) {
  176.                 if(bullet !is null && play !is null)
  177.                         {obj.behave(BEHAVIOR::EXPLOSION2);
  178.                         jjAddObject(OBJECT::TNTAMMO3, 186*32, 13*32);
  179.                         jjAddObject(OBJECT::TNTAMMO3, 187*32, 13*32);
  180.                         jjAddObject(OBJECT::TNTAMMO3, 188*32, 13*32);
  181.                         jjAddObject(OBJECT::TNTAMMO3, 186*32, 12*32);                  
  182.                         jjAddObject(OBJECT::TNTAMMO3, 187*32, 12*32);
  183.                         jjAddObject(OBJECT::TNTAMMO3, 188*32, 12*32);
  184.                         jjSample(p.xPos, p.yPos, SOUND::COMMON_HARP1, 1000);}
  185.                 return true;
  186.         }
  187.        
  188. }
  189.  
  190. void onFunction0(jjPLAYER@ play) {
  191.         jjTriggers[26] = true;
  192.         jjSetWaterLevel(1984, false);
  193.         jjSample(p.xPos, p.yPos, SOUND::ROBOT_HYDROPUF);}
  194.  
  195. void onFunction1(jjPLAYER@ p) {
  196.         slope = jjGameTicks + 2*61;}
  197.  
  198. void onFunction2(jjPLAYER@ p) {
  199.         slope = 0;}
  200.  
  201. void onFunction3(jjPLAYER@ p) {
  202.         p.showText("@@@@@@@@@@@@@@@@@@@@@@@@@Atlantius Harbour", STRING::MEDIUM);
  203.         jjEnabledASFunctions[3] = false;}
  204.  
  205. void onFunction4(jjPLAYER@ p) {
  206.         p.showText("@@@@@@@@@@@@@@@@@@@@@@@@@Grand Library", STRING::MEDIUM);
  207.         jjEnabledASFunctions[4] = false;}
  208.  
  209. void onFunction5(jjPLAYER@ p) {
  210.         p.showText("@@@@@@@@@@@@@@@@@@@@@@@@@Underwater City", STRING::MEDIUM);
  211.         jjEnabledASFunctions[5] = false;}
  212.  
  213. void onMain() {
  214. gem::deleteCollectedGems();
  215. if(jjKey[9] && jjKey[0x51]) {
  216. p.morphTo(CHAR::JAZZ, false);
  217. }
  218. if(jjKey[9] && jjKey[0x57]) {
  219. p.morphTo(CHAR::SPAZ, false);
  220. }
  221. if(jjKey[9] && jjKey[0x45]) {
  222. p.morphTo(CHAR::LORI, false);
  223. }
  224.         jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::PEACH].curAnim];
  225.         anim.frameCount = 1;
  226.         jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
  227.         jjPIXELMAP fruit(0, 20*32, 1*32, 1*32, 5);
  228.         fruit.save(frame);
  229.         frame.hotSpotX = -frame.width / 2;
  230. }
  231. bool buyammo = false, doorunblocked = false, startrush = false, readytorush = false, spheretext = false, control = true;
  232.  
  233. void onPlayer(jjPLAYER@ p) {
  234.         gem::trackPlayerGems(p);
  235.         gem::upgradeHealth(p);
  236.         p.lightType = LIGHT::NONE;
  237.  
  238. jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::WEENIE].curAnim];
  239.         anim.frameCount = 1;
  240.         jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
  241.         jjPIXELMAP sphere(0, 21*32, 1*32, 1*32, 5);
  242.         sphere.save(frame);
  243.  
  244.         exit = 0;
  245.         if(jjTriggers[1] == true)
  246.                 {exit += 1;}
  247.         if(jjTriggers[2] == true)
  248.                 {exit += 1;}
  249.         if(jjTriggers[4] == true)
  250.                 {exit += 1;}
  251.         if(jjTriggers[5] == true)
  252.                 {exit += 1;}
  253.  
  254.                 if(control==false)
  255.                 {p.keyLeft = false;
  256.                 p.keyRight = false;
  257.                 p.keyDown = false;}
  258.  
  259.                 if(p.idle > 100)
  260.                 {p.cameraUnfreeze(true);
  261.                 control=true;}
  262.                 else if (p.idle > 5 && (p.keyLeft || p.keyRight || p.keyJump || p.keyFire))
  263.                 {p.cameraUnfreeze(true);
  264.                 control=true;}
  265.  
  266.                
  267.         if (doorunblocked == false && jjTriggers[1]==true && jjTriggers[2]==true && jjTriggers[4]==true && jjTriggers[5]==true) {
  268.                 p.showText("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Spheres collected.");
  269.                 jjTriggers[6] = true;
  270.                 doorunblocked = true;}
  271.  
  272.         if(p.food == 100 && jjKey[0x52] == false && startrush == false)
  273.                 {p.showText("@@@@@@@@@@@@@@@@Press 'R' when you need to use Sugar Rush!", STRING::MEDIUM);
  274.                 p.startSugarRush(0);
  275.                 startrush = true;
  276.                 readytorush = true;}
  277.  
  278.         if(readytorush == true)
  279.                 {p.food = 100;}
  280.  
  281.         if(p.food == 100 && jjKey[0x52])
  282.                 {p.startSugarRush(1400);
  283.                 p.food = 0;
  284.                 readytorush = false;
  285.                 startrush = false;
  286.         }
  287.  
  288.         for (int i = 1; i < jjObjectCount; i++) {
  289.         jjOBJ@ o = jjObjects[i];
  290.                 if (o.isActive && o.eventID == OBJECT::SILVERCOIN && p.coins >= 1) {
  291.                 o.state = STATE::KILL;
  292.                 }
  293.  
  294.         }
  295.  
  296.  
  297.         if(p.xPos<8*32 && p.yPos<20*32 && p.coins < 1)
  298.                 {p.testForCoins(1);}
  299.         if(p.xPos<8*32 && p.yPos<20*32 && p.coins >= 1)
  300.                 {jjNxt("mo4a_3-2_save", false, true);
  301.                 gem::saveGemData();}
  302.         if(leveldone == true && p.xPos > 188*32 && p.yPos >= 40*32 && p.coins <3)
  303.         {p.testForCoins(3);}
  304.         if(leveldone == true && p.xPos > 188*32 && p.yPos >= 40*32 && p.coins >=3)
  305.         {jjNxt("mo4a_3-4_save", false, true);
  306.         gem::saveGemData();}
  307.  
  308.         if(p.ammo[WEAPON::TNT] < 1 && p.xPos>168*32 && p.xPos<171*32 && p.yPos<16*32 && p.yPos>13*32 && jjKey[0x50] && p.gems[GEM::RED]<50 && buyammo == false)
  309.                 {p.testForGems(50, GEM::RED);}
  310.         if(p.ammo[WEAPON::TNT] < 1 && p.xPos>168*32 && p.xPos<171*32 && p.yPos<16*32 && p.yPos>13*32 && jjKey[0x50] && p.gems[GEM::RED]>=50 && buyammo == false)
  311.         {p.testForGems(50, GEM::RED);
  312.         jjTriggers[9]=true;
  313.         buyammo = true;}
  314.         if(p.ammo[WEAPON::TNT] >= 1 && p.xPos>168*32 && p.xPos<171*32 && p.yPos<16*32 && p.yPos>13*32 && jjKey[0x50] && buyammo == false)
  315.                 {p.showText("@@You already have the weapon.");}
  316. if(p.keyUp && slope > jjGameTicks){
  317.         p.yPos = p.yPos - 4;
  318.         p.invisibility = true;
  319.         jjDrawSprite(p.xPos, p.yPos, p.setID, RABBIT::HPOLE, p.curFrame, p.direction, SPRITE::PLAYER);
  320.         }
  321. if(p.keyUp == false && slope > jjGameTicks){
  322.         p.invisibility = false;
  323. }
  324. if(slope < jjGameTicks){
  325.         p.invisibility = false;
  326. }
  327.  
  328.   if (SpeedUpUntil > jjGameTicks) {
  329.         p.invincibility = 10;
  330.         p.keyRun = true;
  331.         if(p.keyRight)
  332.         p.xSpeed = 30;
  333.         if(p.keyLeft)
  334.         p.xSpeed = -30;
  335.   }
  336.  
  337. }
  338. bool thieffly= false;
  339. class Paint : jjBEHAVIORINTERFACE {
  340.         void onBehave(jjOBJ@ obj) {
  341.         jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::CHIPS].curAnim];
  342.         anim.frameCount = 1;
  343.         jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
  344.         jjPIXELMAP paint(0, 102*32, 2*32, 3*32, 1);
  345.         paint.save(frame);
  346.         frame.hotSpotX = -15;
  347.         frame.hotSpotY = -47;
  348.         obj.behave(BEHAVIOR::BUMP,false);
  349.         obj.bulletHandling = HANDLING::IGNOREBULLET;
  350.         obj.draw();
  351.         }
  352.         bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ play, int force) {
  353.         if(p.keyUp==true || bullet !is null)
  354.         {thieffly = true;
  355.         obj.behavior = BEHAVIOR::EXPLOSION2;}
  356.         return true;
  357.  
  358.         }
  359. }
  360. class ButterThief : jjBEHAVIORINTERFACE {
  361.         void onBehave(jjOBJ@ obj) {
  362.                 if(thieffly == false)
  363.                 {obj.playerHandling = HANDLING::PLAYERBULLET;}
  364.                 if(thieffly == true)
  365.                 {obj.behave(BEHAVIOR::BUTTERFLY);
  366.                 obj.lightType = LIGHT::LASER;
  367.                 obj.light = 100;
  368.                 obj.playerHandling = HANDLING::ENEMY;
  369.                 jjDrawTile(obj.xPos - 17, obj.yPos + 2, 870);
  370.                                 if(obj.energy == 0)
  371.                                 {obj.state = STATE::KILL;
  372.                                 obj.behavior = BEHAVIOR::EXPLOSION;
  373.                                 jjAddObject(OBJECT::SANDWICH, obj.xPos, obj.yPos-32);
  374.                                 }
  375.                 }
  376.         }
  377.        
  378. }
  379.  
  380. class Fastrun : jjBEHAVIORINTERFACE {
  381.         void onBehave(jjOBJ@ obj) {
  382.  
  383. obj.behave(BEHAVIOR::PICKUP, false);
  384. obj.determineCurAnim(ANIM::PICKUPS, 33);
  385. ++obj.counter;
  386.                 obj.yPos = jjSin(obj.counter*15 + 5)*4 + obj.yOrg;
  387.  
  388.                 jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, -24);
  389.  
  390. }
  391.  
  392.         bool onObjectHit(jjOBJ@ obj, jjOBJ@, jjPLAYER@ play, int force) {
  393.         play.timerStart(800);
  394.                 SpeedUpUntil = jjGameTicks + 13 * 61;
  395.                 obj.behavior = BEHAVIOR::EXPLOSION2;
  396.                 obj.frameID = 0;
  397.                 jjSample(obj.xPos, obj.yPos, SOUND::COMMON_PICKUP1, 6000);
  398.  
  399.                 return true;
  400.         }
  401.  
  402. }
  403.  
  404.  
  405.  
  406. void TimeMachine(jjOBJ@ obj){
  407.         obj.behave(BEHAVIOR::EVA, false);
  408.                         jjDrawResizedSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, 1, 1, SPRITE::PALSHIFT, 8);
  409.  
  410. }
  411.  
  412. void Tree(jjOBJ@ enemy) {
  413. jjPLAYER@ play = jjLocalPlayers[0];
  414.                 if (enemy.xPos > play.xPos)
  415.                                 enemy.xPos = enemy.xPos - (2+jjDifficulty/4);
  416.                 else if (enemy.xPos < play.xPos)
  417.                                 enemy.xPos = enemy.xPos + (2+jjDifficulty/4);
  418.                 if (enemy.yPos > play.yPos)
  419.                                 enemy.yPos = enemy.yPos - (2+jjDifficulty/4);
  420.                 else if (enemy.yPos < play.yPos)
  421.                                 enemy.yPos = enemy.yPos + (2+jjDifficulty/4);
  422. if (jjMaskedVLine(enemy.xSpeed > 0 ? enemy.xPos + 16 : enemy.xPos - 16, enemy.yPos, 1)) {
  423.                                 enemy.delete();
  424.                   int explosionID = jjAddObject(OBJECT::BLASTERBULLET, enemy.xPos, enemy.yPos, enemy.creator, CREATOR::OBJECT);
  425.                 jjObjects[explosionID].determineCurAnim(ANIM::AMMO, 4, true);
  426.                 jjObjects[explosionID].state = STATE::EXPLODE;
  427.                         }
  428.                 enemy.determineCurAnim(ANIM::WITCH, 3);
  429.                 enemy.determineCurFrame();
  430.                 enemy.frameID = enemy.counter/8;
  431.                 //enemy.draw();
  432.                 ++enemy.counter;
  433.                 enemy.counter += 1;
  434.                  if (enemy.counter >200)
  435.                 {enemy.delete();
  436.                   int explosionID = jjAddObject(OBJECT::BLASTERBULLET, enemy.xPos, enemy.yPos, enemy.creator, CREATOR::OBJECT);
  437.                 jjObjects[explosionID].determineCurAnim(ANIM::AMMO, 4, true);
  438.                 jjObjects[explosionID].state = STATE::EXPLODE;
  439.                 }
  440.         jjDrawSpriteFromCurFrame(enemy.xPos, enemy.yPos, enemy.curFrame, enemy.direction, SPRITE::PALSHIFT, 24);
  441.  
  442. }
  443.  
  444.  
  445. class Key : jjBEHAVIORINTERFACE {
  446.  
  447.         void onBehave(jjOBJ@ obj) {
  448.                 obj.behave(BEHAVIOR::PICKUP, false);
  449.         jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::AIRBOARD].curAnim];
  450.         anim.frameCount = 1;
  451.         jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
  452.         jjPIXELMAP doorkey(0, 29*32, 1*32, 1*32, 5);
  453.         doorkey.save(frame);
  454.                 ++obj.counter;
  455.                 obj.yPos = jjSin(obj.counter*15 + 5)*4 + obj.yOrg;
  456.                 jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);
  457. }
  458.         bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
  459.                 jjTriggers[0] = true;
  460.                 obj.behavior = BEHAVIOR::EXPLOSION2;
  461.                 jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);
  462.  
  463.                 return true;
  464.         }
  465. }
  466. bool leveldone = false;
  467. class Key2 : jjBEHAVIORINTERFACE {
  468.  
  469.         void onBehave(jjOBJ@ obj) {
  470.                 obj.behave(BEHAVIOR::PICKUP, false);
  471.         jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::SANDWICH].curAnim];
  472.         anim.frameCount = 1;
  473.         jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
  474.         jjPIXELMAP doorkey(0, 29*32, 1*32, 1*32, 5);
  475.         doorkey.save(frame);
  476.                 ++obj.counter;
  477.                 obj.yPos = jjSin(obj.counter*15 + 5)*4 + obj.yOrg;
  478.                 jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);
  479. }
  480.         bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
  481.                 jjTriggers[10] = true;
  482.                 obj.behavior = BEHAVIOR::EXPLOSION2;
  483.                 jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);
  484.                 leveldone = true;
  485.                 return true;
  486.         }
  487. }
  488.  
  489. class RedSphere : jjBEHAVIORINTERFACE {
  490.  
  491.         void onBehave(jjOBJ@ obj) {
  492.                 if(jjTriggers[1] == true)
  493.                         {obj.delete();}
  494.                 obj.behave(BEHAVIOR::PICKUP, false);
  495.                 obj.lightType = LIGHT::FLICKER;
  496.         jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::WEENIE].curAnim];
  497.         anim.frameCount = 1;
  498.         jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
  499.         jjPIXELMAP sphere(0, 21*32, 1*32, 1*32, 5);
  500.         sphere.save(frame);
  501.                 ++obj.counter;
  502.                 obj.yPos = jjSin(obj.counter*15 + 5)*4 + obj.yOrg;
  503.                 jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);
  504. }
  505.         bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
  506.                 jjTriggers[1] = true;
  507.                 p.cameraFreeze(89*32,28*32,true, false);
  508.                 exit += 1;
  509.                 obj.behavior = BEHAVIOR::EXPLOSION2;
  510.                 jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);
  511.  
  512.                 return true;
  513.         }
  514. }
  515.  
  516. class BlueSphere : jjBEHAVIORINTERFACE {
  517.  
  518.         void onBehave(jjOBJ@ obj) {
  519.                 if(jjTriggers[2] == true)
  520.                         {obj.delete();}
  521.                 obj.behave(BEHAVIOR::PICKUP, false);
  522.                 obj.lightType = LIGHT::FLICKER;
  523.         jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::CHICKENLEG].curAnim];
  524.         anim.frameCount = 1;
  525.         jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
  526.         jjPIXELMAP sphere(0, 22*32, 1*32, 1*32, 5);
  527.         sphere.save(frame);
  528.                 ++obj.counter;
  529.                 obj.yPos = jjSin(obj.counter*15 + 5)*4 + obj.yOrg;
  530.                 jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);
  531. }
  532.         bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
  533.                 jjTriggers[2] = true;
  534.                 p.cameraFreeze(89*32,23*32,true, false);
  535.                 exit += 1;
  536.                 obj.behavior = BEHAVIOR::EXPLOSION2;
  537.                 jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);
  538.  
  539.                 return true;
  540.         }
  541. }
  542.  
  543.  
  544. class GreenSphere : jjBEHAVIORINTERFACE {
  545.  
  546.         void onBehave(jjOBJ@ obj) {
  547.                 if(jjTriggers[4] == true)
  548.                         {obj.delete();}
  549.                 obj.behave(BEHAVIOR::PICKUP, false);
  550.                 obj.lightType = LIGHT::FLICKER;
  551.         jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::HAM].curAnim];
  552.         anim.frameCount = 1;
  553.         jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
  554.         jjPIXELMAP sphere(0, 24*32, 1*32, 1*32, 5);
  555.         sphere.save(frame);
  556.                 ++obj.counter;
  557.                 obj.yPos = jjSin(obj.counter*15 + 5)*4 + obj.yOrg;
  558.                 jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);
  559. }
  560.         bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
  561.                 jjTriggers[4] = true;
  562.                 exit += 1;
  563.                 p.cameraFreeze(89*32,20*32,true, false);
  564.                 obj.behavior = BEHAVIOR::EXPLOSION2;
  565.                 jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);
  566.  
  567.                 return true;
  568.         }
  569. }
  570.  
  571. class PurpleSphere : jjBEHAVIORINTERFACE {
  572.  
  573.         void onBehave(jjOBJ@ obj) {
  574.                 if(jjTriggers[5] == true)
  575.                         {obj.delete();}
  576.                 obj.behave(BEHAVIOR::PICKUP, false);
  577.                 obj.lightType = LIGHT::FLICKER;
  578.         jjANIMATION@ anim = jjAnimations[jjObjectPresets[OBJECT::FRIES].curAnim];
  579.         anim.frameCount = 1;
  580.         jjANIMFRAME@ frame = jjAnimFrames[anim.firstFrame];
  581.         jjPIXELMAP sphere(0, 25*32, 1*32, 1*32, 5);
  582.         sphere.save(frame);
  583.                 ++obj.counter;
  584.                 obj.yPos = jjSin(obj.counter*15 + 5)*4 + obj.yOrg;
  585.                 jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::NORMAL);
  586. }
  587.         bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
  588.                 jjTriggers[5] = true;
  589.                 exit += 1;
  590.                 p.cameraFreeze(89*32,15*32,true, false);
  591.                 obj.behavior = BEHAVIOR::EXPLOSION2;
  592.                 jjSample(obj.xPos, obj.yPos, SOUND::MENUSOUNDS_TYPEENTER, 1000);
  593.  
  594.                 return true;
  595.         }
  596. }
  597.  
  598. void onLevelReload()  {
  599.         gem::restorePlayerGems();
  600.         jjLocalPlayers[0].lives++;
  601.         buyammo == false;
  602.         jjTriggers[9] = false;
  603.         jjWaterLighting = WATERLIGHT::GLOBAL;
  604.         for (uint i = 0; i < 32; ++i)
  605.                 jjTriggers[i] = SavedTriggers[i];
  606. }
  607.  
  608. jjTEXTAPPEARANCE SignTextAppearance = STRING::NORMAL;
  609. class Sign {
  610.         private int xPos, yPos; //These pixel-based positions will be generated from tile-based positions in the constructor by multiplying by 32
  611.         private string text;
  612.         private uint widthOfText;
  613.         Sign(){} //AngelScript requires any class that appears in any array to have an explicit default constructor, even if it's never called
  614.         Sign(int xTile, int yTile, const string &in t) {
  615.                 xPos = xTile * 32; //Since this is a constant operation, it could strictly be performed in the draw method instead of the constructor, but this way involves fewer multiplication instructions
  616.                 yPos = yTile * 32; //
  617.                 text = t;
  618.                 SignTextAppearance.newline = STRING::SPECIALSIGN; //Causes the drawString method to interpret instances of the \n character as signals to drop down to a new line, similar to the special effect of the @ character in the STRING::SPIN appearance.
  619.                 SignTextAppearance.spacing = -2; //int jjTEXTAPPEARANCE::spacing is new in 5.2, and this particular value is equivalent to prefixing the string with "ยง2". Make sure to check out bool jjTEXTAPPEARANCE::monospace too, though it didn't end up getting used in this level.
  620.                 widthOfText = jjGetStringWidth(text, STRING::SMALL, SignTextAppearance); //Used for determining how large of a dark rectangle should be drawn behind the text. A matching heightOfText value could of course be generated by counting the number of newline characters--for example, "heightOfText = text.split("\n").length * 20;"--but here the rectangles are constant height instead to limit the temptation to ramble on and on.
  621.         }
  622.         void draw(jjCANVAS@ layer, uint8 textIntensity) const { //Because this method will be called from an onDraw method, it's important to have a jjCANVAS@ passed among the arguments.
  623.                 layer.drawRectangle(xPos, yPos - 16, widthOfText + 8, 55, 0, SPRITE::TRANSLUCENT);
  624.                 layer.drawString(xPos, yPos, text, STRING::SMALL, SignTextAppearance, 0, SPRITE::BLEND_HARDLIGHT, textIntensity);
  625.         }
  626. }
  627. const array<Sign> Signs = {
  628.         Sign(16, 20, "Sorry sir. Ships are not\nbe sailing today."),
  629.         Sign(54, 19, "I've lost my Library Pass last week\nduring my visit to Poseidon Island."),
  630.         Sign(146, 22, "Those who have the LIBRARY PASS shall\nexperience the wisdom of THE GRAND LIBRARY."),
  631.         Sign(79, 37, "Poseidon Island would be a nice place to visit.\nBut the harbour's closed due to a volcanic erruption on the island."),
  632.         Sign(1, 17, "Looking for a ship?\nI can help."),
  633.         Sign(117, 37, "Detectors show that the artifact\nis very close around here!."),
  634.         Sign(132, 11, "No entrance to the\nbuildings with powerups..."),
  635.         Sign(171, 13, "Press P if you'd like to\nbuy Fusion Cannon for 50 Gems."),
  636.         Sign(118, 13, "Don't you ever try to get in the library.\nIt's dangerous. And nothing special about it."),
  637. };
  638.  
  639. void onDrawLayer3(jjPLAYER@, jjCANVAS@ layer) {
  640.         if(jjKey[0x54]){
  641.         const uint8 textIntensity = 200 + int(jjSin(jjGameTicks * 16) * 50);
  642.         for (uint signID = 0; signID < Signs.length; ++signID)
  643.                 Signs[signID].draw(layer, textIntensity);
  644. }
  645. }
  646.  
  647. array<bool> SavedTriggers(32, false);
  648. //Extendable Checkpoints by VioletCLM
  649. void CheckpointWrapper(jjOBJ@ obj) {
  650.   if (obj.state == STATE::STOP) { //don't do anything anymore
  651.     jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, 8);
  652.   } else if (obj.state == STATE::DEACTIVATE) { //due to death
  653.     obj.deactivate();
  654.   } else {
  655.     obj.behave(BEHAVIOR::CHECKPOINT);
  656.         jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, 8);
  657.     if (obj.state == STATE::DONE) { //triggered by the player hitting it
  658.       obj.state = STATE::STOP;
  659.       //save the current state of some properties
  660.       for (uint i = 0; i < 32; ++i)
  661.         SavedTriggers[i] = jjTriggers[i];
  662.  
  663.       //OPTIONAL: this loop makes checkpoints reusable, so only the most recent checkpoint you touched is ever active
  664.       for (int i = jjObjectCount; --i > 0;) {
  665.         jjOBJ@ obj2 = jjObjects[i];
  666.         if (obj2.eventID == OBJECT::CHECKPOINT && i != obj.objectID && obj2.isActive) {
  667.           obj2.state = STATE::SLEEP;
  668.           obj2.var[0] = 0;
  669.         }
  670.       }
  671.     }
  672.   }
  673. }
  674. bool onDrawAmmo(jjPLAYER@ player, jjCANVAS@ canvas) {
  675.         return MLLE::WeaponHook.drawAmmo(player, canvas);
  676. }
  677.