Downloads containing SEweapon.asc

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Frosted PeaksFeatured Download PurpleJazz Capture the flag 9.3 Download file
TSF with JJ2+ Only: Goliath WoodsFeatured Download PurpleJazz Capture the flag 8.9 Download file
TSF with JJ2+ Only: Hollow of the HauntedFeatured Download cooba Capture the flag 9.2 Download file
TSF with JJ2+ Only: street fight!!!!!!! cooba Battle N/A Download file
TSF with JJ2+ Only: Giant's StepsFeatured Download PurpleJazz Capture the flag 9.2 Download file
TSF with JJ2+ Only: HellfireFeatured Download FawFul Battle 9.7 Download file
TSF with JJ2+ Only: Anniversary Bash 22 levels Jazz2Online Multiple N/A Download file
TSF with JJ2+ Only: Party Crash LandingFeatured Download cooba Battle 9.5 Download file
TSF with JJ2+ Only: The AbyssFeatured Download PurpleJazz Battle 9.8 Download file
TSF with JJ2+ Only: Forgotten empire Rysice Capture the flag 7.4 Download file
TSF with JJ2+ Only: Umbral ThicketFeatured Download PurpleJazz Battle 9.5 Download file
JJ2+ Only: Tech Tree Violet CLM Capture the flag 7.8 Download file
TSF with JJ2+ Only: Relic ValleyFeatured Download FireSworD Battle 9 Download file
TSF with JJ2+ Only: Isla de MuertaFeatured Download Loon Battle 9.5 Download file
TSF with JJ2+ Only: Anniversary Bash 21 Levels Jazz2Online Multiple N/A Download file
TSF with JJ2+ Only: The Fingers of IcarusFeatured Download cooba Battle 8.8 Download file
TSF with JJ2+ Only: Academy Superjazz Battle N/A Download file
JJ2+ Only: CleanseFeatured Download Seren Capture the flag 8.7 Download file
TSF with JJ2+ Only: Carrot FarmFeatured Download Loon Capture the flag 9.3 Download file
TSF with JJ2+ Only: Painted GardenFeatured Download PurpleJazz Capture the flag 8.6 Download file
TSF with JJ2+ Only: Battle of Waterloo 1835Featured Download Seren Capture the flag 8.5 Download file
TSF with JJ2+ Only: Anniversary Bash 20 Levels Jazz2Online Multiple N/A Download file
TSF with JJ2+ Only: Mt. CinderFeatured Download PurpleJazz Capture the flag 9 Download file
TSF with JJ2+ Only: Press GardenFeatured Download SmokeNC Battle 9.2 Download file
TSF with JJ2+ Only: Fishing VillageFeatured Download PurpleJazz Capture the flag 9 Download file
TSF with JJ2+ Only: Orbital BarrageFeatured Download TreyLina Battle 9.1 Download file
JJ2+ Only: RovaniemiFeatured Download Loon Battle 9.1 Download file
TSF with JJ2+ Only: Complete Pipe DreamFeatured Download FireSworD Capture the flag 9.1 Download file
Standard Weapon InterfaceFeatured Download Seren Other 10 Download file

File preview

  1. namespace se {
  2. funcdef void MainCallback(int number);
  3. funcdef void PlayerCallback(::jjPLAYER@ player, int number);
  4. funcdef bool DrawingCallback(::jjPLAYER@ player, ::jjCANVAS@ canvas, const ::jjANIMATION@ anim);
  5. funcdef void PacketCallback(::jjSTREAM& packet, int clientID);
  6. funcdef ::jjSTREAM PacketConstructor();
  7. shared enum WeaponTrait {
  8.         weapon_no_trait                         = 0,
  9.         weapon_deals_damage                     = 1 << 0,
  10.         weapon_causes_splash_damage             = 1 << 1,
  11.         weapon_may_harm_user                    = 1 << 2,
  12.         weapon_may_heal_players                 = 1 << 3,
  13.         weapon_increases_mobility               = 1 << 4,
  14.         weapon_inflicts_status_condition        = 1 << 5,
  15.         weapon_melts_ice                        = 1 << 6,
  16.         weapon_freezes_objects                  = 1 << 7,
  17.         weapon_fails_underwater                 = 1 << 8,
  18.         weapon_fails_in_interiors               = 1 << 9,
  19.         weapon_goes_through_thin_walls          = 1 << 10,
  20.         weapon_goes_through_thick_walls         = 1 << 11,
  21.         weapon_is_super_weapon                  = 1 << 12,
  22.         weapon_is_effective_against_players     = 1 << 13,
  23.         weapon_is_effective_against_sp_enemies  = 1 << 14,
  24.         weapon_destroys_crates                  = 1 << 15,
  25.         weapon_supports_mouse_aim               = 1 << 16,
  26.         weapon_requires_mouse_use               = 1 << 17,
  27.         weapon_works_in_mp                      = 1 << 18,
  28.         weapon_works_in_sp                      = 1 << 19,
  29.         weapon_works_in_coop                    = 1 << 20,
  30.         weapon_works_in_splitscreen             = 1 << 21,
  31.         weapon_works_online                     = 1 << 22,
  32.         weapon_has_ammo_pickups                 = 1 << 23,
  33.         weapon_has_ammo_crates                  = 1 << 24,
  34.         weapon_has_powerup_monitors             = 1 << 25,
  35.         weapon_has_distinct_powerup             = 1 << 26,
  36.         weapon_requires_no_ammo_pickups         = 1 << 27,
  37.         weapon_cannot_be_fired_by_key_press     = 1 << 28,
  38.         weapon_requires_certain_events_in_level = 1 << 29,
  39.         weapon_goes_through_walls               = weapon_goes_through_thin_walls | weapon_goes_through_thick_walls,
  40.         weapon_is_effective_against_all_targets = weapon_is_effective_against_players | weapon_is_effective_against_sp_enemies | weapon_destroys_crates,
  41.         weapon_works_in_all_modes               = weapon_works_in_mp | weapon_works_in_sp | weapon_works_in_coop | weapon_works_in_splitscreen | weapon_works_online,
  42.         weapon_has_all_pickups                  = weapon_has_ammo_pickups | weapon_has_ammo_crates | weapon_has_powerup_monitors | weapon_has_distinct_powerup,
  43.         weapon_default_traits                   = weapon_deals_damage | weapon_is_effective_against_all_targets | weapon_supports_mouse_aim |
  44.                                                   weapon_works_in_all_modes | weapon_has_all_pickups
  45. }
  46. shared interface UserData {}
  47. shared interface WeaponHook {
  48.         void setUserData(uint number, UserData@ data);
  49.         UserData@ getUserData(uint number) const;
  50.         void setWeaponSprite(uint number, bool powerup, const ::jjANIMATION@ anim);
  51.         void resetCallbacks(uint number);
  52.         void setMainCallback(uint number, MainCallback@ callback);
  53.         void setPlayerCallback(uint number, PlayerCallback@ callback);
  54.         void setPlayerInputCallback(uint number, PlayerCallback@ callback);
  55.         void setDrawingCallback(uint number, DrawingCallback@ callback);
  56.         PacketConstructor@ addPacketCallback(PacketCallback@ callback);
  57.         bool drawAmmo(::jjPLAYER@ player, ::jjCANVAS@ canvas);
  58.         void processMain();
  59.         void processPlayer(::jjPLAYER@ player);
  60.         void processPlayerInput(::jjPLAYER@ player);
  61.         bool processPacket(::jjSTREAM &in packet, int clientID);
  62. }
  63. shared interface WeaponInterface {
  64.         ::jjANIMSET@ loadAnims(::jjANIMSET@ animSet);
  65.         ::array<bool>@ loadSamples(const ::array<SOUND::Sample>& samples);
  66.         uint getSampleCount() const;
  67.         uint getTraits(bool powerup) const;
  68.         uint getMaxDamage(bool powerup) const;
  69.         bool setAsWeapon(uint number, WeaponHook@ weaponHook);
  70. }
  71. shared bool isValidWeapon(uint number) {
  72.         return number != 0 && number <= WEAPON::GUN9;
  73. }
  74. shared uint getBasicBulletOfWeapon(uint number) {
  75.         if (isValidWeapon(number)) {
  76.                 if (number < WEAPON::TNT)
  77.                         return OBJECT::BLASTERBULLET + number - WEAPON::BLASTER;
  78.                 if (number > WEAPON::TNT)
  79.                         return OBJECT::FIREBALLBULLET + number - WEAPON::GUN8;
  80.                 return OBJECT::TNT;
  81.         }
  82.         return 0;
  83. }
  84. shared uint getPoweredBulletOfWeapon(uint number) {
  85.         if (isValidWeapon(number)) {
  86.                 if (number < WEAPON::TNT)
  87.                         return OBJECT::BLASTERBULLETPU + number - WEAPON::BLASTER;
  88.                 if (number > WEAPON::TNT)
  89.                         return OBJECT::FIREBALLBULLETPU + number - WEAPON::GUN8;
  90.                 return OBJECT::TNT;
  91.         }
  92.         return 0;
  93. }
  94. shared uint getAmmoPickupOfWeapon(uint number) {
  95.         if (isValidWeapon(number) && number != WEAPON::BLASTER) {
  96.                 if (number == WEAPON::BOUNCER)
  97.                         return OBJECT::BOUNCERAMMO3;
  98.                 if (number == WEAPON::ICE)
  99.                         return OBJECT::ICEAMMO3;
  100.                 return OBJECT::SEEKERAMMO3 + number - WEAPON::SEEKER;
  101.         }
  102.         return 0;
  103. }
  104. shared uint getAmmoCrateOfWeapon(uint number) {
  105.         if (number > WEAPON::BLASTER && number < WEAPON::TNT) {
  106.                 if (number == WEAPON::BOUNCER)
  107.                         return OBJECT::BOUNCERAMMO15;
  108.                 if (number == WEAPON::ICE)
  109.                         return OBJECT::ICEAMMO15;
  110.                 return OBJECT::SEEKERAMMO15 + number - WEAPON::SEEKER;
  111.         }
  112.         return 0;
  113. }
  114. shared uint getPowerupMonitorOfWeapon(uint number) {
  115.         if (isValidWeapon(number)) {
  116.                 if (number < WEAPON::TNT)
  117.                         return OBJECT::BLASTERPOWERUP + number - WEAPON::BLASTER;
  118.                 return OBJECT::TNTPOWERUP + number - WEAPON::TNT;
  119.         }
  120.         return 0;
  121. }
  122. shared class DefaultPacketConstructor {
  123.         private ::jjSTREAM m_result;
  124.         DefaultPacketConstructor(const ::jjSTREAM &in result) {
  125.                 m_result = result;
  126.         }
  127.         ::jjSTREAM opCall() const {
  128.                 return m_result;
  129.         }
  130. }
  131. shared class DefaultWeaponHook : WeaponHook {
  132.         private ::array<::array<const ::jjANIMATION@>> m_anims(9, ::array<const ::jjANIMATION@>(2));
  133.         private ::array<UserData@> m_userData(9);
  134.         private ::array<MainCallback@> m_mainCallbacks(9);
  135.         private ::array<PlayerCallback@> m_playerCallbacks(9), m_playerInputCallbacks(9);
  136.         private ::array<DrawingCallback@> m_drawingCallbacks(9);
  137.         private ::array<PacketCallback@> m_packetCallbacks;
  138.         private bool m_usePacketID;
  139.         private uint8 m_packetID;
  140.         DefaultWeaponHook() {
  141.                 m_usePacketID = false;
  142.         }
  143.         DefaultWeaponHook(uint8 packetID) {
  144.                 m_packetID = packetID;
  145.                 m_usePacketID = true;
  146.         }
  147.         void setUserData(uint number, UserData@ data) override {
  148.                 if (isValidWeapon(number))
  149.                         @m_userData[number - 1] = @data;
  150.         }
  151.         UserData@ getUserData(uint number) const override {
  152.                 return isValidWeapon(number) ? @m_userData[number - 1] : null;
  153.         }
  154.         void setWeaponSprite(uint number, bool powerup, const ::jjANIMATION@ anim) override {
  155.                 if (isValidWeapon(number))
  156.                         @m_anims[number - 1][powerup ? 1 : 0] = @anim;
  157.         }
  158.         void resetCallbacks(uint number) override {
  159.                 if (isValidWeapon(number)) {
  160.                         number--;
  161.                         @m_mainCallbacks[number] = null;
  162.                         @m_playerCallbacks[number] = null;
  163.                         @m_playerInputCallbacks[number] = null;
  164.                         @m_drawingCallbacks[number] = null;
  165.                 }
  166.         }
  167.         void setMainCallback(uint number, MainCallback@ callback) override {
  168.                 if (isValidWeapon(number))
  169.                         @m_mainCallbacks[number - 1] = @callback;
  170.         }
  171.         void setPlayerCallback(uint number, PlayerCallback@ callback) override {
  172.                 if (isValidWeapon(number))
  173.                         @m_playerCallbacks[number - 1] = @callback;
  174.         }
  175.         void setPlayerInputCallback(uint number, PlayerCallback@ callback) override {
  176.                 if (isValidWeapon(number))
  177.                         @m_playerInputCallbacks[number - 1] = @callback;
  178.         }
  179.         void setDrawingCallback(uint number, DrawingCallback@ callback) override {
  180.                 if (isValidWeapon(number))
  181.                         @m_drawingCallbacks[number - 1] = @callback;
  182.         }
  183.         PacketConstructor@ addPacketCallback(PacketCallback@ callback) override {
  184.                 ::jjSTREAM packet;
  185.                 uint index = m_packetCallbacks.length();
  186.                 m_packetCallbacks.insertLast(@callback);
  187.                 if (m_usePacketID)
  188.                         packet.push(m_packetID);
  189.                 if (index >= 0x80) {
  190.                         packet.push(uint8(index >> 24) | 0x80);
  191.                         packet.push(uint8(index >> 16));
  192.                         packet.push(uint8(index >> 8));
  193.                 }
  194.                 packet.push(uint8(index));
  195.                 return @PacketConstructor(DefaultPacketConstructor(packet).opCall);
  196.         }
  197.         protected void drawAmmoSprite(::jjCANVAS@ canvas, int x, int y, const ::jjANIMATION@ anim) const {
  198.                 canvas.drawSpriteFromCurFrame(x, y, anim + (::jjGameTicks >> 2) % anim.frameCount);
  199.         }
  200.         bool drawAmmo(::jjPLAYER@ player, ::jjCANVAS@ canvas) override {
  201.                 if (player !is null) {
  202.                         uint number = player.currWeapon;
  203.                         if (isValidWeapon(number)) {
  204.                                 const ::jjANIMATION@ anim = @m_anims[number - 1][player.powerup[number] ? 1 : 0];
  205.                                 DrawingCallback@ callback = @m_drawingCallbacks[number - 1];
  206.                                 if (callback !is null && callback(@player, @canvas, @anim))
  207.                                         return true;
  208.                                 if (anim !is null) {
  209.                                         if (canvas !is null && !player.noFire && player.charCurr != CHAR::FROG && player.charCurr != CHAR::BIRD) {
  210.                                                 int x, y;
  211.                                                 STRING::Size font;
  212.                                                 ::string text;
  213.                                                 const ::jjWEAPON@ weapon = ::jjWeapons[number];
  214.                                                 if (::jjSubscreenWidth > 400) {
  215.                                                         x = ::jjSubscreenWidth - 88;
  216.                                                         y = ::jjSubscreenHeight - 14;
  217.                                                         font = STRING::MEDIUM;
  218.                                                 } else {
  219.                                                         x = ::jjSubscreenWidth - 48;
  220.                                                         y = ::jjSubscreenHeight - 9;
  221.                                                         font = STRING::SMALL;
  222.                                                 }
  223.                                                 if (weapon.infinite || weapon.replacedByShield && player.shieldTime > 0) {
  224.                                                         text = "x^";
  225.                                                 } else {
  226.                                                         int ammo = player.ammo[number];
  227.                                                         text = "x" + (ammo > 0 ? ammo : 0);
  228.                                                 }
  229.                                                 drawAmmoSprite(@canvas, x, y, @anim);
  230.                                                 canvas.drawString(x + 8, y, text, font);
  231.                                         }
  232.                                         return true;
  233.                                 }
  234.                         }
  235.                 }
  236.                 return false;
  237.         }
  238.         void processMain() override {
  239.                 for (int i = 0, size = m_mainCallbacks.length(); i < size; i++) {
  240.                         if (m_mainCallbacks[i] !is null)
  241.                                 m_mainCallbacks[i](i + 1);
  242.                 }
  243.         }
  244.         void processPlayer(::jjPLAYER@ player) override {
  245.                 for (int i = 0, size = m_playerCallbacks.length(); i < size; i++) {
  246.                         if (m_playerCallbacks[i] !is null)
  247.                                 m_playerCallbacks[i](@player, i + 1);
  248.                 }
  249.         }
  250.         void processPlayerInput(::jjPLAYER@ player) override {
  251.                 for (int i = 0, size = m_playerInputCallbacks.length(); i < size; i++) {
  252.                         if (m_playerInputCallbacks[i] !is null)
  253.                                 m_playerInputCallbacks[i](@player, i + 1);
  254.                 }
  255.         }
  256.         bool processPacket(::jjSTREAM &in packet, int clientID) override {
  257.                 uint8 id, index;
  258.                 if ((!m_usePacketID || packet.pop(id) && id == m_packetID) && packet.pop(index)) {
  259.                         uint fullIndex;
  260.                         if (index & 0x80 != 0) {
  261.                                 index &= ~0x80;
  262.                                 uint8 u1, u2, u3;
  263.                                 if (packet.pop(u1) && packet.pop(u2) && packet.pop(u3))
  264.                                         fullIndex = uint(index) << 24 | uint(u1) << 16 | uint(u2) << 8 | u3;
  265.                                 else
  266.                                         fullIndex = m_packetCallbacks.length();
  267.                         } else {
  268.                                 fullIndex = index;
  269.                         }
  270.                         if (fullIndex < m_packetCallbacks.length()) {
  271.                                 PacketCallback@ callback = @m_packetCallbacks[fullIndex];
  272.                                 if (callback !is null)
  273.                                         callback(packet, clientID);
  274.                                 return true;
  275.                         }
  276.                 }
  277.                 return false;
  278.         }
  279. }
  280. shared class AmmoPickup : ::jjBEHAVIORINTERFACE {
  281.         private const ::jjANIMATION@ m_basic, m_powered;
  282.         private uint m_count;
  283.         private SOUND::Sample m_sample;
  284.         AmmoPickup(const ::jjANIMATION@ basic, const ::jjANIMATION@ powered, uint count = 3, SOUND::Sample sample = SOUND::COMMON_PICKUPW1) {
  285.                 @m_basic = @basic;
  286.                 @m_powered = @powered;
  287.                 m_count = count;
  288.                 m_sample = sample;
  289.         }
  290.         protected void draw(float x, float y, uint sprite, int direction, bool translucent, int playerID) const {
  291.                 ::jjDrawSpriteFromCurFrame(x, y, sprite, direction, translucent ? SPRITE::TRANSLUCENT : SPRITE::NORMAL, 0, 4, 4, playerID);
  292.         }
  293.         protected float getY(const ::jjOBJ@ obj) const {
  294.                 int arg = (((obj.objectID << 3) + ::jjGameTicks) << (obj.yPos > ::jjWaterLevel ? 1 : 4)) + (int(obj.xPos) << 4);
  295.                 return obj.yPos + ::jjSin(arg) * 4.f;
  296.         }
  297.         void setAnimationBasic(const ::jjANIMATION@ basic) {
  298.                 @m_basic = @basic;
  299.         }
  300.         const ::jjANIMATION@ getAnimationBasic() const {
  301.                 return @m_basic;
  302.         }
  303.         void setAnimationPowered(const ::jjANIMATION@ powered) {
  304.                 @m_powered = @powered;
  305.         }
  306.         const ::jjANIMATION@ getAnimationPowered() const {
  307.                 return @m_powered;
  308.         }
  309.         void setCount(uint count) {
  310.                 m_count = count;
  311.         }
  312.         uint getCount() const {
  313.                 return m_count;
  314.         }
  315.         void setSample(SOUND::Sample sample) {
  316.                 m_sample = sample;
  317.         }
  318.         SOUND::Sample getSample() const {
  319.                 return m_sample;
  320.         }
  321.         void onBehave(::jjOBJ@ obj) override {
  322.                 if (obj.state == STATE::START)
  323.                         obj.scriptedCollisions = true;
  324.                 obj.behave(BEHAVIOR::PICKUP, false);
  325.                 for (int i = 0; i < ::jjLocalPlayerCount; i++) {
  326.                         const ::jjPLAYER@ player = @::jjLocalPlayers[i];
  327.                         const ::jjANIMATION@ anim = @(player.powerup[obj.var[3] + 1] ? @m_powered : @m_basic);
  328.                         uint sprite = anim + obj.frameID % anim.frameCount;
  329.                         draw(obj.xPos, getY(obj), sprite, obj.direction, ::jjAnimFrames[sprite].transparent, player.playerID);
  330.                 }
  331.         }
  332.         bool onObjectHit(::jjOBJ@ obj, ::jjOBJ@ bullet, ::jjPLAYER@ player, int) {
  333.                 if (bullet is null) {
  334.                         bool sp = ::jjGameMode == GAME::SP || ::jjGameMode == GAME::COOP;
  335.                         int type = obj.var[3] + 1;
  336.                         int multiplier = ::jjWeapons[type].multiplier;
  337.                         ::jjWeapons[type].multiplier = 1;
  338.                         if (::jjAutoWeaponChange && player.ammo[type] == 0 && (player.shieldType == 0 || !::jjWeapons[player.currWeapon].replacedByShield) && m_count != 0)
  339.                                 player.currWeapon = type;
  340.                         int maximum = ::jjWeapons[type].maximum;
  341.                         if (maximum == -1)
  342.                                 maximum = sp ? 99 : 50;
  343.                         maximum *= multiplier;
  344.                         if (player.ammo[type] >= maximum) {
  345.                                 player.ammo[type] = maximum;
  346.                         } else {
  347.                                 player.ammo[type] = player.ammo[type] + m_count * multiplier;
  348.                                 if (player.ammo[type] >= maximum)
  349.                                         player.ammo[type] = maximum;
  350.                                 obj.frameID = 0;
  351.                                 obj.behavior = BEHAVIOR::EXPLOSION2;
  352.                                 ::jjSample(obj.xPos, obj.yPos, m_sample);
  353.                                 if (sp && obj.points != 0) {
  354.                                         player.score += obj.points;
  355.                                         ::jjPARTICLE@ part = ::jjAddParticle(PARTICLE::STRING);
  356.                                         if (part !is null) {
  357.                                                 part.xPos = obj.xPos;
  358.                                                 part.yPos = obj.yPos;
  359.                                                 part.xSpeed = -0.5f - (jjRandom() & 0x3FFF) / 65536.f;
  360.                                                 part.ySpeed = -1.f - (jjRandom() & 0x7FFF) / 65536.f;
  361.                                                 part.string.text = ::formatInt(obj.points);
  362.                                         }
  363.                                         obj.points = 0;
  364.                                 }
  365.                         }
  366.                         ::jjWeapons[type].multiplier = multiplier;
  367.                         return true;
  368.                 }
  369.                 return false;
  370.         }
  371. }
  372. }
  373.