Name | Author | Game Mode | Rating | |||||
---|---|---|---|---|---|---|---|---|
Mover Weapons | Violet CLM | Other | 6.5 |
#pragma require "Wagnus.asc"
#include "MLLE-Weapons.asc"
#pragma require "Wagnus.j2a"
namespace WAGNUS {
array<int> TargetX(jjLocalPlayerCount), TargetY(jjLocalPlayerCount);
class Weapon : MLLEWeapons::WeaponInterface {
bool Forwards = true, Upwards = false, ForwardsPU = true, UpwardsPU = true;
uint Range = 160, RangePU = 280;
Weapon() {
super(
regularObjectTemplate: MLLEWeapons::ObjectTemplate(
xSpeed: 10,
curAnim: jjAnimSets[ANIM::AMMO] + 12
),
powerupObjectTemplate: MLLEWeapons::ObjectTemplate(
xSpeed: 10,
curAnim: jjAnimSets[ANIM::AMMO] + 12
),
animSetFilename: "Wagnus.j2a",
pickupAnimation: 0,
poweredUpPickupAnimation: 1,
traits: se::weapon_default_traits | se::weapon_increases_mobility | se::weapon_causes_splash_damage,
onPlayer: se::PlayerCallback(FindTarget),
behavior: MLLEWeapons::behaviorFunction(Fire),
apply: MLLEWeapons::applyFunction(GetParameters)
);
}
bool GetParameters(uint, se::WeaponHook@, jjSTREAM@ parameters) {
if (parameters !is null && parameters.getSize() >= 12) {
parameters.pop(Forwards);
parameters.pop(Upwards);
parameters.pop(Range);
parameters.pop(ForwardsPU);
parameters.pop(UpwardsPU);
parameters.pop(RangePU);
}
return true;
}
void FindTarget(jjPLAYER@ p, int number) {
if (int(p.currWeapon) == number && p.frozen == 0 && !p.noFire) {
const bool powerup = p.powerup[number];
float stepX, stepY;
int angle;
if (jjAllowsMouseAim && jjMouseAim && jjLocalPlayerCount==1) {
angle = int(atan2(
(jjMouseX + p.cameraX - p.xPos),
(jjMouseY + p.cameraY - p.yPos)
) * 512.0 * 0.318309886142228);
stepX = jjSin(angle) * 16;
stepY = jjCos(angle) * 16;
angle -= 256;
} else {
uint rabbitAnim;
if (
((powerup ? UpwardsPU : Upwards) || (p.keyUp = false)) && (
(rabbitAnim = p.curAnim - jjAnimSets[p.setID].firstAnim) == RABBIT::LOOKUP ||
rabbitAnim == RABBIT::FIREUP ||
rabbitAnim == RABBIT::HANGFIREUP ||
rabbitAnim == RABBIT::FIREUPQUIT ||
((rabbitAnim == RABBIT::HANGFIREUP || rabbitAnim == RABBIT::HANGIDLE1 || rabbitAnim == RABBIT::HANGIDLE2) && p.keyUp)
)
) {
stepX = 0;
stepY = -16;
angle = 256;
} else {
stepX = (p.direction >= 0) == (powerup ? ForwardsPU : Forwards) ? 16 : -16;
stepY = 0;
angle = 256 - int(stepX) * 16;
}
}
float currentX = p.xPos;
float currentY = p.yPos;
int scale = 0;
int distance = powerup ? RangePU : Range;
uint stepSize = 16;
while (distance > 0) {
const auto proposedX = currentX + stepX;
const auto proposedY = currentY + stepY;
bool masked = false;
for (int y = -10; y < 22; y += 4)
if (jjMaskedHLine(int(proposedX) - 12, 24, int(proposedY) + y)) {
masked = true;
break;
}
if (masked) {
if ((stepSize >>= 1) == 2) {
break;
} else {
stepX /= 2;
stepY /= 2;
continue;
}
}
distance -= stepSize;
scale += stepSize;
currentX = proposedX;
currentY = proposedY;
}
TargetX[p.localPlayerID] = int(currentX);
TargetY[p.localPlayerID] = int(currentY);
if (scale != 0)
jjDrawRotatedSpriteFromCurFrame(p.xPos, p.yPos, jjAnimations[PickupAnimation + 2], angle, (scale + 12) / 128.f, 1, p.powerup[number] ? SPRITE::TRANSLUCENTPALSHIFT : SPRITE::TRANSLUCENT, 40, -99);
jjObjectPresets[(p.powerup[number] ? se::getPoweredBulletOfWeapon : se::getBasicBulletOfWeapon)(number)].counterEnd = scale / 16;
}
}
void Fire(jjOBJ@ obj, bool powerup) {
if (obj.creatorType == CREATOR::PLAYER) {
jjPLAYER@ p = jjPlayers[obj.creatorID];
if (p.isLocal) {
p.xPos = TargetX[p.localPlayerID];
p.yPos = TargetY[p.localPlayerID];
p.offsetPosition(0,0);
}
jjSample(p.xPos, p.yPos, SOUND::AMMO_LASER3, 29);
jjSample(p.xPos, p.yPos, SOUND::COMMON_TELPORT1, 56);
uint angle = uint(atan2(obj.xSpeed, obj.ySpeed) * 512.0 * 0.318309886142228);
const bool backwards = obj.ySpeed == 0 && !(powerup ? ForwardsPU : Forwards);
if (backwards)
angle += 512;
const auto stepX = jjSin(angle) * 16, stepY = jjCos(angle) * 16;
uint count = obj.counterEnd;
if (obj.xSpeed == 0 && !jjAllowsMouseAim)
count = count * 3 / 2;
while (count != 0) {
jjOBJ@ spark = jjObjects[jjAddObject(obj.eventID, obj.xPos + stepX * count, obj.yPos + stepY * count, obj.creatorID, obj.creatorType, Spark)];
spark.xSpeed = backwards ? -obj.xSpeed : obj.xSpeed; //just for knocking down pickups
spark.ySpeed = obj.ySpeed;
--count;
}
}
obj.delete();
}
}
void Spark(jjOBJ@ obj) {
if (obj.state == STATE::START) {
obj.state = STATE::DELAYEDSTART;
obj.playerHandling = HANDLING::PLAYERBULLET;
} else {
obj.behave(BEHAVIOR::EXPLOSION, false);
}
jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, obj.direction, SPRITE::PALSHIFT, MLLEWeapons::HelpfulBulletFunctions::IsPowerup(obj) ? 8 : 224);
}
}
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.