Name | Author | Game Mode | Rating | |||||
---|---|---|---|---|---|---|---|---|
Weapon Mega | Violet CLM | Mutator | 8.7 |
#pragma name "Weapon Mega: Boomerang"
#pragma require "weaponMega1.mut"
#include "weaponMega.asc"
bool LoadWeaponMega1() {
if (!SafeToReplaceWeapon(WEAPON::BLASTER))
return false;
Preset1.behavior = ApplyBoomerang;
Preset2.behavior = ApplyBoomerang;
Preset1.special = Preset1.determineCurAnim(AnimSet, 0);
Preset2.special = Preset2.determineCurAnim(AnimSet, 0);
Preset1.isBlastable = false; Preset2.isBlastable = false;
return true;
}
const bool WeaponMega1Loaded = LoadWeaponMega1();
void ApplyBoomerang(jjOBJ@ obj) { obj.behavior = Boomerang(obj); obj.behave(); }
class Boomerang : WeaponMega {
float xSpeed, ySpeed;
uint counter = 0;
Boomerang(jjOBJ@ objectOfAttachment) {
@obj = @objectOfAttachment;
xSpeed = (obj.xSpeed + obj.var[7] / 65536.f) * 32;
ySpeed = obj.ySpeed * 32;
obj.state = STATE::FLY;
}
void onBehave(jjOBJ@) override {
counter += 8;
const float lastX = obj.xPos, lastY = obj.yPos;
obj.xPos = obj.xOrg + jjSin(counter) * xSpeed;
obj.yPos = obj.yOrg + jjSin(counter) * ySpeed;
obj.xSpeed = obj.xPos - lastX;
obj.ySpeed = obj.yPos - lastY;
obj.frameID = ((jjGameTicks + obj.objectID) / 3) & 7;
if (obj.frameID >= 4)
obj.frameID = 7 - obj.frameID;
obj.curFrame = jjAnimations[obj.curAnim] + obj.frameID;
if (counter >= 512 || maskedPixelAtBullet() || obj.state == STATE::EXPLODE) {
obj.delete();
if (obj.creatorType == CREATOR::PLAYER) {
const jjPLAYER@ play = jjPlayers[obj.creator];
if (abs(obj.xPos - play.xPos) <= 20 && abs(obj.yPos - play.yPos) <= 20)
return; //inside shooter; no explosion anim needed
}
jjObjects[jjAddObject(OBJECT::EXPLOSION, obj.xPos, obj.yPos, obj.objectID, CREATOR::OBJECT)].curAnim = obj.killAnim;
} else if (counter == 256 && obj.creatorType == CREATOR::PLAYER) {
xSpeed = obj.xPos - (obj.xOrg = jjPlayers[obj.creator].xPos);
ySpeed = obj.yPos - (obj.yOrg = jjPlayers[obj.creator].yPos);
}
}
void onDraw(jjOBJ@) override {
jjDrawRotatedSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, getBulletAngle(), getBulletDirection(), 1, SPRITE::SINGLEHUE, !isPowerup() ? 65 : 72);
}
}
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.