Name | Author | Game Mode | Rating | |||||
---|---|---|---|---|---|---|---|---|
Custom Weapons... | Violet CLM | Other | 10 |
#pragma require "dischargeGun.asc"
#pragma require "dischargeGun.j2a"
#include "MLLE-Weapons.asc"
/**Discharge Gun**/
/**Author: szmol96**/
namespace SzmolWeaponPack {
namespace DischargeGun {
array<int8> PreviousDischargeFrameID(32);
class PlayerX {
int8 fastfireBackup = 0;
bool dischargeGunSelected = false;
uint8 warmUp = 0;
uint16 heat = 0;
}
array<PlayerX> PlayersX(jjLocalPlayerCount);
class Weapon : MLLEWeapons::WeaponInterface {
uint HeatMeterFrame;
Weapon() {
super(
regularObjectTemplate: MLLEWeapons::ObjectTemplate(
xSpeed: 4,
special: 2,
doesHurt: 16,
var: array<int> = {0,0,0,0,0,0, 16}
),
powerupObjectTemplate: MLLEWeapons::ObjectTemplate(
xSpeed: 7,
special: 2,
animSpeed: 2,
var: array<int> = {0,0,0,0,0,0, 16}
),
animSetFilename: "dischargeGun.j2a",
poweredUpPickupAnimation: 3,
pickupFrameIDToUseForAmmoCrate: 5,
multiplier: 2,
style: WEAPON::CAPPED,
traits: se::weapon_default_traits | se::weapon_goes_through_walls | se::weapon_may_harm_user,
onDrawAmmo: se::DrawingCallback(DrawHeatMeter),
onPlayer: ManagePlayerX,
weaponHookRequired: true,
behavior: function(obj, powerup) { obj.behavior = Behavior; }
);
}
bool DrawHeatMeter(jjPLAYER@ p, jjCANVAS@ canvas, const jjANIMATION@) {
canvas.drawSprite(jjSubscreenWidth - 128, jjSubscreenHeight + 1, SetID,2,0);
canvas.drawRotatedSprite(jjSubscreenWidth - 128, jjSubscreenHeight, SetID,2,1, 240 - PlayersX[p.localPlayerID].heat);
return false;
}
}
void ManagePlayerX(jjPLAYER@ p, int number) {
PlayerX@ px = PlayersX[p.localPlayerID];
if (int(p.currWeapon) == number) {
if (!px.dischargeGunSelected)
px.fastfireBackup = p.fastfire;
p.fastfire = 6; //constant
} else {
if (px.dischargeGunSelected)
p.fastfire = px.fastfireBackup; //not affected by fastfire pickups collected while dischargeGunSelected is true... oh well, nbd.
}
px.dischargeGunSelected = (int(p.currWeapon) == number);
if (p.keyFire) {
if (px.warmUp < 70 && px.dischargeGunSelected) {
if (px.warmUp == 0) jjSample(p.xPos, p.yPos, SOUND::BONUS_BONUS1, 32, 0);
px.warmUp++;
}
} else {
px.warmUp = 0;
}
if (px.warmUp < 35) {
p.lightType = LIGHT::PLAYER;
} else {
p.lightType = LIGHT::BRIGHT;
}
if (px.heat > 460) p.hurt();
if (!(p.keyFire && px.dischargeGunSelected) && px.heat > 0 && jjGameTicks % 2 == 0) px.heat--;
if (p.health < 1) px.heat = 0;
}
void Behavior(jjOBJ@ obj) {
jjPLAYER@ p = jjPlayers[obj.creatorID];
if (obj.state == STATE::START) {
if (obj.creatorType == CREATOR::PLAYER) {
if (p.lightType != LIGHT::BRIGHT) { //warming up
obj.delete();
return;
}
jjSample(obj.xPos, obj.yPos, SOUND::COMMON_ELECTRICHIT);
if (p.isLocal) {
PlayerX@ px = PlayersX[p.localPlayerID];
if (px.heat < 464) px.heat += 12;
}
obj.direction = p.direction;
} else
obj.direction = (obj.xSpeed >= 0) ? 1 : -1;
obj.frameID = (jjRandom() % 4);
if (obj.frameID == PreviousDischargeFrameID[obj.creatorID & 31]) //not the same frame twice in a row
++obj.frameID;
PreviousDischargeFrameID[obj.creatorID & 31] = obj.frameID;
obj.determineCurFrame();
obj.state = STATE::FLY;
obj.xSpeed = abs(obj.xSpeed);
for (int i = 1; i <= 2; ++i) {
jjPARTICLE@ spark = jjAddParticle(PARTICLE::SPARK);
if (spark !is null) {
spark.spark.color = 32 + obj.doesHurt;
spark.spark.colorDelta = 1;
spark.spark.colorStop = 38 + obj.doesHurt;
if (abs(obj.ySpeed) < abs(obj.xSpeed)) {
spark.xPos = (obj.xPos + obj.direction * 128) + obj.direction * 64 * jjCos(jjRandom() % 512);
spark.yPos = obj.yPos + jjCos(jjRandom() % 512);
} else {
spark.xPos = obj.xPos + jjCos(jjRandom() % 512);
spark.yPos = (obj.yPos - 64) + 64 * jjCos(jjRandom() % 512);
}
spark.xSpeed = i * jjCos(jjRandom() % 512);
spark.ySpeed = i * jjCos(jjRandom() % 512);
}
}
}
if (obj.age++ > 8)
obj.delete();
else {
if (obj.creatorType == CREATOR::PLAYER) {
obj.xPos = p.xPos + obj.xSpeed * 5 * p.direction;
obj.yPos = p.yPos + obj.ySpeed * 5;
obj.direction = p.direction;
}
jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, obj.doesHurt);
}
}
}
}
Jazz2Online © 1999-INFINITY (Site Credits). We have a Privacy Policy. Jazz Jackrabbit, Jazz Jackrabbit 2, Jazz Jackrabbit Advance and all related trademarks and media are ™ and © Epic Games. Lori Jackrabbit is © Dean Dodrill. J2O development powered by Loops of Fury and Chemical Beats.
Eat your lima beans, Johnny.