Downloads containing xlmlots.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Land of The Sn00zEFeatured Download Superjazz Capture the flag 10 Download file

File preview

  1. const bool MLLESetupSuccessful = MLLE::Setup(); ///@MLLE-Generated
  2. #include "MLLE-Include-1.6.asc" ///@MLLE-Generated
  3. #pragma require "xlmlots-MLLE-Data-1.j2l" ///@MLLE-Generated
  4. #pragma require "Beach.j2t" ///@MLLE-Generated
  5. #pragma require "Lomat.j2t" ///@MLLE-Generated
  6. #pragma require "loonjungle6.j2t" ///@MLLE-Generated
  7. #pragma require "Aztec2.j2t" ///@MLLE-Generated
  8. #pragma require "CarrFixEve.j2t" ///@MLLE-Generated
  9. #pragma require "xlmlots.j2l" ///@MLLE-Generated
  10.  
  11. jjANIMSET@ customSpringSprite;
  12. array<int> fastCustomSpringSpeeds(jjLocalPlayerCount);
  13.  
  14. class CannotBeShotDown : jjBEHAVIORINTERFACE {
  15.         CannotBeShotDown(const jjBEHAVIOR &in behavior) {
  16.                 originalBehavior = behavior;
  17.         }
  18.         void onBehave(jjOBJ@ obj) {
  19.                 obj.behave(originalBehavior);
  20.                 if (obj.state == STATE::FLOATFALL)
  21.                         obj.state = STATE::FLOAT;
  22.         }
  23.         bool onObjectHit(jjOBJ@ obj, jjOBJ@ bullet, jjPLAYER@ player, int force) {
  24.                 if (bullet is null) {
  25.                         obj.behavior = originalBehavior;
  26.                         if (player.objectHit(obj, force, obj.playerHandling))
  27.                                 return true;
  28.                         obj.behavior = this;
  29.                 }
  30.                 return false;
  31.         }
  32.         private jjBEHAVIOR originalBehavior;
  33. }
  34.  
  35. bool generateCustomSpringSprites(jjANIMSET@ anim, const array<uint> &in colors) {
  36.         int length = colors.length();
  37.         bool success = (@customSpringSprite = anim).allocate(array<uint>(length * 3, 5)) !is null;
  38.         if (success) {
  39.                 uint srcSet = jjAnimSets[ANIM::SPRING];
  40.                 for (int i = 0; i < length; i++) {
  41.                         uint color = colors[i];
  42.                         uint destAnimOffset = anim + i * 3;
  43.                         for (int j = 0; j < 3; j++) {
  44.                                 uint srcAnim = jjAnimations[srcSet + j];
  45.                                 uint destAnim = jjAnimations[destAnimOffset + j];
  46.                                 for (int k = 0; k < 5; k++) {
  47.                                         jjPIXELMAP image(jjAnimFrames[destAnim + k] = jjAnimFrames[srcAnim + k]);
  48.                                         int width = image.width;
  49.                                         int height = image.height;
  50.                                         for (int l = 0; l < height; l++) {
  51.                                                 for (int m = 0; m < width; m++) {
  52.                                                         int pixel = image[m, l];
  53.                                                         if (pixel >= 32 && pixel < 40)
  54.                                                                 image[m, l] = color + (pixel & 7);
  55.                                                 }
  56.                                         }
  57.                                         if (!image.save(jjAnimFrames[destAnim + k]))
  58.                                                 return false;
  59.                                 }
  60.                         }
  61.                 }
  62.         }
  63.         return success;
  64. }
  65.  
  66. void handleFastCustomSpringSpeeds(jjPLAYER@ play) {
  67.         if (play.ySpeed < -32.f) {
  68.                 fastCustomSpringSpeeds[play.localPlayerID] = int(ceil((play.ySpeed + 32.f) / -0.125f));
  69.         } else if (fastCustomSpringSpeeds[play.localPlayerID] != 0) {
  70.                 if (play.ySpeed < -31.f) {
  71.                         fastCustomSpringSpeeds[play.localPlayerID]--;
  72.                         play.ySpeed = -32.f;
  73.                 } else {
  74.                         fastCustomSpringSpeeds[play.localPlayerID] = 0;
  75.                 }
  76.         }
  77. }
  78.  
  79. void initializeCustomSpring(jjOBJ@ obj) {
  80.         int anim = obj.curAnim;
  81.         obj.behave(obj.behavior = BEHAVIOR::SPRING, false);
  82.         if (obj.curAnim != anim) {
  83.                 obj.curAnim = anim + 2;
  84.                 obj.determineCurFrame();
  85.         }
  86.         obj.draw();
  87. }
  88.  
  89. void onLevelBegin() {
  90.         for (int i = 1; i < 255; i++) {
  91.                 jjOBJ@ preset = jjObjectPresets[i];
  92.                 if (preset.playerHandling == HANDLING::PICKUP) {
  93.                         preset.behavior = CannotBeShotDown(preset.behavior);
  94.                 }
  95.         }
  96. }
  97.  
  98. void onLevelLoad() {
  99.         jjUseLayer8Speeds = true;
  100.         generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[0]], array<uint> = {88, 40});
  101.         turnIntoCustomSpring(jjObjectPresets[OBJECT::FROZENSPRING], 0, 27.0f, false);
  102.         recolorBridges();
  103. }
  104.  
  105. void recolorBridges() {
  106.         jjANIMATION@ anim = jjAnimations[jjAnimSets[ANIM::BRIDGE] + 2];
  107.         for (uint i = 0; i < anim.frameCount; i++) {
  108.                 jjANIMFRAME@ frame = jjAnimFrames[anim + i];
  109.                 jjPIXELMAP sprite(frame);
  110.                 for (uint x = 0; x < sprite.width; ++x) {
  111.                         for (uint y = 0; y < sprite.height; ++y) {
  112.                                 if (sprite[x,y] >= 16 && sprite[x,y] <= 23) sprite[x,y] = 160 + (sprite[x,y] & 7) * 2;
  113.                         }
  114.                 }
  115.                 sprite.save(frame);
  116.         }
  117. }
  118.  
  119. void turnIntoCustomSpring(jjOBJ@ obj, uint color, float power, bool horizontal) {
  120.         if (horizontal) {
  121.                 obj.xSpeed = power;
  122.                 obj.ySpeed = 0.f;
  123.         } else {
  124.                 obj.xSpeed = 0.f;
  125.                 obj.ySpeed = -power;
  126.                 if (obj.state == STATE::START && obj.creatorType == CREATOR::LEVEL) {
  127.                         int x = int(obj.xPos) >> 5;
  128.                         int y = int(obj.yPos) >> 5;
  129.                         if (jjParameterGet(x, y, 0, 1) != 0) {
  130.                                 jjParameterSet(x, y, 0, 1, 0);
  131.                                 obj.yPos -= 4.f;
  132.                                 obj.ySpeed = power;
  133.                         }
  134.                 }
  135.         }
  136.         obj.behavior = initializeCustomSpring;
  137.         obj.curAnim = customSpringSprite + color * 3 + (horizontal ? 1 : 0);
  138.         obj.energy = obj.frameID = obj.freeze = obj.justHit = obj.light = obj.points = 0;
  139.         obj.causesRicochet = obj.isTarget = obj.scriptedCollisions = obj.triggersTNT = false;
  140.         obj.isBlastable = false;
  141.         obj.deactivates = true;
  142.         obj.isFreezable = true;
  143.         obj.bulletHandling = HANDLING::IGNOREBULLET;
  144.         obj.playerHandling = HANDLING::SPECIAL;
  145.         obj.lightType = LIGHT::NORMAL;
  146.         obj.determineCurFrame();
  147. }
  148.