Downloads containing xlmsalem.j2as

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Salem Loon Battle N/A Download file

File preview

  1. const bool MLLESetupSuccessful = MLLE::Setup(array<MLLEWeaponApply@> = {null, null, null, null, null, ArcaneWeapons::SanguineSpear::Weapon(), null, null, null}); ///@MLLE-Generated
  2. #include "MLLE-Include-1.5w.asc" ///@MLLE-Generated
  3. #pragma require "xlmsalem-MLLE-Data-3.j2l" ///@MLLE-Generated
  4. #pragma require "xlmsalem-MLLE-Data-2.j2l" ///@MLLE-Generated
  5. #pragma require "xlmsalem-MLLE-Data-1.j2l" ///@MLLE-Generated
  6. #pragma require "xlmsalem.j2l" ///@MLLE-Generated
  7. #include "ArcaneWeapon8.asc" ///@MLLE-Generated
  8. #pragma require "ArcaneWeapon8.asc" ///@MLLE-Generated
  9.  
  10. array<Witch> Witches;
  11.  
  12.  
  13. void onLevelLoad() {
  14.         jjTexturedBGTexture = TEXTURE::MEDIVO;
  15.  
  16.         jjTexturedBGFadePositionY = 0.40;
  17.         jjUseLayer8Speeds = true;
  18.        
  19.         generateCustomSpringSprites(jjAnimSets[ANIM::CUSTOM[9]], array<uint> = {40, 16, 64, 88});
  20.     turnIntoCustomSpring(jjObjectPresets[OBJECT::FROZENSPRING], 0, 19.75f, false);
  21.     turnIntoCustomSpring(jjObjectPresets[OBJECT::HORREDSPRING], 1, 28.50f, false);
  22.     turnIntoCustomSpring(jjObjectPresets[OBJECT::HORGREENSPRING], 2, 17.75f, false);
  23.     turnIntoCustomSpring(jjObjectPresets[OBJECT::HORBLUESPRING], 3, 33.3f, false);
  24.        
  25.         jjObjectPresets[OBJECT::HORREDSPRING].causesRicochet = jjObjectPresets[OBJECT::HORBLUESPRING].causesRicochet = jjObjectPresets[OBJECT::HORGREENSPRING].causesRicochet = false;
  26.        
  27.         jjWeapons[WEAPON::GUN8].spread = SPREAD::NORMAL;
  28.         jjObjectPresets[OBJECT::FIREBALLBULLETPU].var[6] = 8 + 16;
  29.        
  30.         jjObjectPresets[OBJECT::RFPOWERUP].direction = 0;
  31.        
  32.         jjAnimSets[ANIM::WITCH].load();
  33.         for (uint i = 35; i <= 39; ++i)
  34.                 jjAnimations[jjAnimSets[ANIM::AMMO] + i] = jjAnimations[jjAnimSets[ANIM::WITCH] + 3];
  35.         jjAnimations[jjAnimSets[ANIM::AMMO] + 34] = jjAnimations[jjAnimSets[ANIM::WITCH] + 3];
  36. //        jjObjectPresets[OBJECT::SEEKERBULLET].playerHandling = HANDLING::SPECIAL;
  37. //        jjObjectPresets[OBJECT::SEEKERBULLET].scriptedCollisions = true;
  38.         jjObjectPresets[OBJECT::SEEKERBULLET].behavior = WitchSeeker();
  39.  
  40. }
  41.  
  42. void onLevelBegin() {
  43.     for (int x = 0; x < jjLayerWidth[4]; x++) {
  44.         for (int y = 0; y < jjLayerHeight[4]; y++) {
  45.             if (jjEventGet(x, y) == OBJECT::GENERATOR && jjParameterGet(x, y, 0, 8) == 188) {
  46.                 jjEventSet(x, y, AREA::ONEWAY);
  47.             }
  48.         }
  49.     }
  50.        
  51.         Witch newWitch;
  52.         newWitch.setParameters(newWitch, 0, 5*32, 1, 2, 20);
  53.         Witches.insertLast(newWitch);
  54. }
  55.  
  56. void onMain() {
  57.         jjWeapons[WEAPON::GUN8].comesFromGunCrates = true;
  58.     jjWeapons[WEAPON::GUN9].comesFromGunCrates = true;
  59.                 /* for (int i = 1; i < jjObjectCount; i++) {
  60.         jjOBJ@ obj = jjObjects[i];
  61.                         if (jjObjects[i].eventID == OBJECT::RFPOWERUP) {
  62.                                 jjObjects[i].yPos = 45.8*32;
  63.                                 jjObjects[i].ySpeed = 0;
  64.                 }
  65.         } */
  66. }
  67.        
  68. void onPlayer(jjPLAYER@ player){
  69.         player.lightType = LIGHT::NONE;
  70.        
  71.         handleFastCustomSpringSpeeds(player);
  72.        
  73.         if (!jjLowDetail && jjGameTicks % 1400 == 0) {
  74.                 jjSample(player.xPos, player.yPos, SOUND::WITCH_LAUGH, 25, 0);
  75.         }
  76. }
  77.  
  78. jjANIMSET@ customSpringSprite;
  79. array<int> fastCustomSpringSpeeds(jjLocalPlayerCount);
  80. bool generateCustomSpringSprites(jjANIMSET@ anim, const array<uint> &in colors) {
  81.     int length = colors.length();
  82.     bool success = (@customSpringSprite = anim).allocate(array<uint>(length * 3, 5)) !is null;
  83.     if (success) {
  84.         uint srcSet = jjAnimSets[ANIM::SPRING];
  85.         for (int i = 0; i < length; i++) {
  86.             uint color = colors[i];
  87.             uint destAnimOffset = anim + i * 3;
  88.             for (int j = 0; j < 3; j++) {
  89.                 uint srcAnim = jjAnimations[srcSet + j];
  90.                 uint destAnim = jjAnimations[destAnimOffset + j];
  91.                 for (int k = 0; k < 5; k++) {
  92.                     jjPIXELMAP image(jjAnimFrames[destAnim + k] = jjAnimFrames[srcAnim + k]);
  93.                     int width = image.width;
  94.                     int height = image.height;
  95.                     for (int l = 0; l < height; l++) {
  96.                         for (int m = 0; m < width; m++) {
  97.                             int pixel = image[m, l];
  98.                             if (pixel >= 32 && pixel < 40)
  99.                                 image[m, l] = color + (pixel & 7);
  100.                         }
  101.                     }
  102.                     if (!image.save(jjAnimFrames[destAnim + k]))
  103.                         return false;
  104.                 }
  105.             }
  106.         }
  107.     }
  108.     return success;
  109. }
  110. void initializeCustomSpring(jjOBJ@ obj) {
  111.     int anim = obj.curAnim;
  112.     obj.behave(obj.behavior = BEHAVIOR::SPRING, false);
  113.     if (obj.curAnim != anim) {
  114.         obj.curAnim = anim + 2;
  115.         obj.determineCurFrame();
  116.     }
  117.     obj.draw();
  118. }
  119.  
  120. void turnIntoCustomSpring(jjOBJ@ obj, uint color, float power, bool horizontal) {
  121.     if (horizontal) {
  122.         obj.xSpeed = power;
  123.         obj.ySpeed = 0.f;
  124.     } else {
  125.         obj.xSpeed = 0.f;
  126.         obj.ySpeed = -power;
  127.         if (obj.state == STATE::START && obj.creatorType == CREATOR::LEVEL) {
  128.             int x = int(obj.xPos) >> 5;
  129.             int y = int(obj.yPos) >> 5;
  130.             if (jjParameterGet(x, y, 0, 1) != 0) {
  131.                 jjParameterSet(x, y, 0, 1, 0);
  132.                 obj.yPos -= 4.f;
  133.                 obj.ySpeed = power;
  134.             }
  135.         }
  136.     }
  137.     obj.behavior = initializeCustomSpring;
  138.     obj.curAnim = customSpringSprite + color * 3 + (horizontal ? 1 : 0);
  139.     obj.energy = obj.frameID = obj.freeze = obj.justHit = obj.light = obj.points = 0;
  140.     obj.isBlastable = obj.isTarget = obj.scriptedCollisions = obj.triggersTNT = false;
  141.     obj.deactivates = obj.isFreezable = true;
  142.     obj.bulletHandling = HANDLING::IGNOREBULLET;
  143.     obj.playerHandling = HANDLING::SPECIAL;
  144.     obj.lightType = LIGHT::NORMAL;
  145.     obj.determineCurFrame();
  146. }
  147.  
  148. void handleFastCustomSpringSpeeds(jjPLAYER@ play) {
  149.         if (play.ySpeed < -32.f) {
  150.                 fastCustomSpringSpeeds[play.localPlayerID] = int(ceil((play.ySpeed + 32.f) / -0.125f));
  151.         } else if (fastCustomSpringSpeeds[play.localPlayerID] != 0) {
  152.                 if (play.ySpeed < -31.f) {
  153.                         fastCustomSpringSpeeds[play.localPlayerID]--;
  154.                         play.ySpeed = -32.f;
  155.                 } else {
  156.                         fastCustomSpringSpeeds[play.localPlayerID] = 0;
  157.                 }
  158.         }
  159. }
  160. void onPlayerInput(jjPLAYER@ player) {
  161.         MLLE::WeaponHook.processPlayerInput(player);
  162. }
  163.  
  164. bool onDrawAmmo(jjPLAYER@ player, jjCANVAS@ canvas) {
  165.         return MLLE::WeaponHook.drawAmmo(player, canvas);
  166. }
  167.  
  168. class WitchSeeker : jjBEHAVIORINTERFACE {
  169.         void onBehave(jjOBJ@ obj) {
  170.                 if (obj.state == STATE::START)
  171.                         jjSample(obj.xPos, obj.yPos, SOUND::WITCH_MAGIC);
  172.                 obj.behave(BEHAVIOR::SEEKERBULLET);
  173.         }
  174. }
  175.  
  176. class Witch {
  177.     private float xPos, yPos, xOrg, yOrg, xSpeed;
  178.     private int direction, newDirection, param;
  179.    
  180.     void setParameters(Witch@ witch, float xOrg, float yOrg, int direction, float xSpeed, int param) {
  181.         witch.xOrg = xOrg;
  182.         witch.yOrg = yOrg;
  183.         witch.direction = direction;
  184.                 witch.xSpeed = xSpeed;
  185.         witch.param = param;
  186.     }
  187.    
  188.     void getPosition(Witch@ witch) {
  189.                 witch.xPos = witch.xPos + witch.xSpeed * witch.direction;
  190.                
  191.                 if (witch.xPos > 48*32) { // jjLayerWidth[7]*32) {
  192.                         witch.direction = -1;
  193.                 } else if (witch.xPos < 0) {
  194.                         witch.direction = 1;
  195.                 }
  196.         witch.yPos = (jjCos(jjGameTicks*4)*64*witch.direction) + witch.yOrg;
  197.     }
  198.    
  199.     void draw(Witch@ witch, jjCANVAS@ canvas) {
  200.         canvas.drawResizedSprite(int(witch.xPos), int(witch.yPos), ANIM::WITCH, 2, jjGameTicks >> 2, witch.direction, 1, SPRITE::BRIGHTNESS, param);
  201.     }
  202. }
  203.  
  204. void onDrawLayer7(jjPLAYER@ play, jjCANVAS@ canvas) {
  205.         Witch@ witch = Witches[0];
  206.     witch.getPosition(witch);
  207.         witch.draw(witch, canvas);
  208. }