Name | Author | Game Mode | Rating | |||||
---|---|---|---|---|---|---|---|---|
Custom MLLE Naps WeaponPack | Naps | Other | N/A | |||||
Anniversary Bash 25 Battle | Jazz2Online | Battle | N/A | |||||
Honey CataCombs | Rysice | Battle | N/A | |||||
Anniversary Bash 24 Battle | Jazz2Online | Battle | N/A |
#pragma require "HornetGun.asc" //Scripted by Naps
#include "MLLE-Weapons.asc"
#pragma require "HornetGun.j2a" //Spritework by Lynx and Naps
#pragma offer "HornetGun.wav" //https://elements.envato.com/knife-stab-9RLRTRP
namespace NapsWeapons {
class HornetGun : MLLEWeapons::WeaponInterface {
bool PierceFlies = true;
bool AttackCaterpillars = true;
bool SPBehavior = true;
HornetGun() {
super(
regularObjectTemplate: MLLEWeapons::ObjectTemplate(
xSpeed: 2,
xAcc: 0.25,
yAcc: 0.00390625f,
animSpeed: 2,
killAnim: 6,
curAnim: 0,
lightType: LIGHT::POINT2,
counterEnd: 105
),
powerupObjectTemplate: MLLEWeapons::ObjectTemplate(
xSpeed: 1.5,
xAcc: 0.25,
yAcc: -0.0915527344f,
animSpeed: 3,
killAnim: 7,
curAnim: 1,
lightType: LIGHT::POINT2,
counterEnd: 105
),
style: WEAPON::MISSILE,
animSetFilename: "HornetGun.j2a",
sampleFilenames: array<string> = {"HornetGun.wav"},
pickupAnimation: 2,
poweredUpPickupAnimation: 3,
ammoCrateAnimation: 4,
powerupAnimation: 5,
traits: se::weapon_default_traits | se::weapon_goes_through_thin_walls | se::weapon_works_in_all_modes | se::weapon_fails_underwater,
behavior: MLLEWeapons::behaviorFunction(DetermineBehavior),
apply: MLLEWeapons::applyFunction(ApplyCustomParameters)
);
}
void DetermineBehavior(jjOBJ@ obj, bool powerup) const {
if (obj.creatorType == CREATOR::PLAYER && jjPlayers[obj.creatorID].isLocal)
jjSample(obj.xPos, obj.yPos, Samples[0],64, powerup? 15000 : 18000);
obj.var[8] = powerup? 1 : 0;
obj.behavior = jjVOIDFUNCOBJ(Behavior);
}
void Behavior(jjOBJ@ obj) const {
const float PI = 3.1415927f;
int destination;
const bool goUp =jjMaskedPixel(int(obj.xPos),int(obj.yPos) - 8);
const bool detectSafeEvents = checkForUnsolidEvents(int(obj.xPos/32),int(obj.yPos/32));
const bool goDown =jjMaskedPixel(int(obj.xPos),int(obj.yPos) + 8);
const bool aboveWaterLevel = (obj.yPos < (jjWaterLevel - 8))? false : true;
const bool goLeft =jjMaskedPixel(int(obj.xPos) - 8,int(obj.yPos));
const bool goRight =jjMaskedPixel(int(obj.xPos) + 8,int(obj.yPos));
const bool isPowerup = MLLEWeapons::HelpfulBulletFunctions::IsPowerup(obj);
obj.var[9] = 1;
obj.var[10] = 1;
if (obj.state == STATE::START) {
obj.var[1] = -1;
obj.xSpeed += obj.var[7] / 65536.f;
obj.state = STATE::FLY;
if ((jjGameMode <= GAME::COOP || SPBehavior) && checkForSPParameters() && obj.creatorType == CREATOR::PLAYER ) {
checkObjectCollision(obj);
obj.var[6] = 16;
}
} else if (obj.state == STATE::FLY) {
if (obj.var[1] < 0) {
if ((jjGameMode <= GAME::COOP || SPBehavior) && obj.creatorType == CREATOR::PLAYER) {
if (obj.counter >= 20) {
int targetID = GetNearestWaspEnemyObject(obj,isPowerup? 220 : 180);
if (targetID > -1) {
obj.var[1] = targetID;
obj.var[2] = 1;
}
}
if (checkForSPParameters())
checkObjectCollision(obj);
}
if ((jjGameMode > GAME::COOP || obj.creatorType != CREATOR::PLAYER)) {
if (obj.counter >= 20) {
int targetID = MLLEWeapons::HelpfulBulletFunctions::GetNearestEnemyPlayer(obj,isPowerup? 220 : 180);
if (targetID > -1) {
obj.var[1] = targetID;
obj.var[2] = 2;
}
}
}
obj.draw();
} else {
if ((jjGameMode <= GAME::COOP || SPBehavior)) {
if (obj.var[2] == 1) {
jjOBJ@ enemy = jjObjects[obj.var[1]];
destination = int(atan2(enemy.yPos - obj.yPos ,enemy.xPos - obj.xPos) * (512 / PI));
if (enemy.energy < 1 || !enemy.isActive) {
obj.var[1] = -1;
}
}
if (checkForSPParameters())
checkObjectCollision(obj);
}
if ((jjGameMode > GAME::COOP || obj.creatorType != CREATOR::PLAYER)) {
if (obj.var[1] < 32) {
if (obj.var[2] == 2) {
jjPLAYER@ play = jjPlayers[obj.var[1]];
destination = int(atan2(play.yPos - obj.yPos ,play.xPos - obj.xPos) * (512 / PI));
float distance = sqrt(pow(play.xPos - obj.xPos,2) + pow(play.yPos - obj.yPos,2));
if (play.health < 1 || !play.isInGame || distance > 400) {
obj.var[1] = -1;
}
}
}
}
obj.xSpeed += 0.7 * jjCos(destination);
obj.ySpeed += 0.7 * jjSin(destination);
float maxSpeed = (isPowerup? 3 : 4);
if (obj.xSpeed > maxSpeed) {
obj.xSpeed = maxSpeed;
}
if (obj.xSpeed < -maxSpeed) {
obj.xSpeed = -maxSpeed;
}
if (obj.ySpeed > maxSpeed) {
obj.ySpeed = maxSpeed;
}
if (obj.ySpeed < -maxSpeed) {
obj.ySpeed = -maxSpeed;
}
if ((obj.ySpeed < 0) && (goUp == true && !detectSafeEvents)) {
obj.ySpeed = 0;
} else
if ((obj.ySpeed > 0) && ((goDown == true && !detectSafeEvents) || aboveWaterLevel == true)) {
obj.ySpeed = 0;
}
if (obj.xSpeed < 0 && goLeft == true) {
obj.xSpeed = 0;
} else
if ((obj.xSpeed > 0 ) && (goRight == true)) {
obj.xSpeed = 0;
}
jjDrawRotatedSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame, 128 - destination, 1, 1);
}
obj.xPos += obj.xSpeed;
obj.yPos += obj.ySpeed;
obj.counter += 1;
if ((obj.counter&3)==0) {
obj.frameID++;
if (obj.frameID >= int(jjAnimations[obj.curAnim].frameCount))
obj.frameID = 0;
obj.curFrame = jjAnimations[obj.curAnim].firstFrame + obj.frameID;
}
if (obj.counter > int(obj.counterEnd) || (obj.var[1] < 0 && (MLLEWeapons::HelpfulBulletFunctions::MaskedPixel(obj))) || obj.yPos > jjWaterLevel) {
obj.state = STATE::EXPLODE;
obj.curFrame = 0;
obj.counter = 0;
obj.lightType = 0;
}
}
if (obj.state == STATE::EXPLODE) {
obj.draw();
obj.behavior = BEHAVIOR::EXPLOSION2;
obj.frameID = 0;
}
}
int GetNearestWaspEnemyObject(jjOBJ@ obj, uint maxDistance) {
if (obj.creatorType != CREATOR::PLAYER)
return -1;
int nearestObjectID = -1;
uint minDistance = maxDistance * maxDistance;
for (int i = 1; i < jjObjectCount; ++i) {
const jjOBJ@ potentialWaspEnemy = jjObjects[i];
if (!potentialWaspEnemy.isActive)
continue;
if (!potentialWaspEnemy.isTarget && !(potentialWaspEnemy.eventID == OBJECT::CATERPILLAR && AttackCaterpillars))
continue;
const float dx = potentialWaspEnemy.xPos - obj.xPos, dy = potentialWaspEnemy.yPos - obj.yPos;
const uint distance = uint(dx * dx + dy * dy);
if (distance < minDistance) {
minDistance = distance;
nearestObjectID = i;
}
}
return nearestObjectID;
}
void checkObjectCollision(jjOBJ@ obj) {
for (int i = 0; i < jjObjectCount;i++) {
jjOBJ@ obj2 = jjObjects[i];
if (!obj2.isActive || obj2 is obj)
continue;
if (!obj.doesCollide(obj2,true))
continue;
if (obj2.eventID == OBJECT::CATERPILLAR && AttackCaterpillars) {
obj2.particlePixelExplosion(0);
obj2.state = STATE::KILL;
if (obj.creatorType == CREATOR::PLAYER)
jjPlayers[obj.creatorID].setScore(jjPlayers[obj.creatorID].score + obj2.points);
}
if (obj.var[6] == 16 && (obj2.behavior == BEHAVIOR::MONITOR || (obj2.eventID >= OBJECT::BOMBCRATE && obj2.eventID <= OBJECT::TOASTERAMMO15) || obj2.eventID == OBJECT::GUNCRATE || obj2.eventID == OBJECT::GEMCRATE || obj2.eventID == OBJECT::CARROTCRATE || (obj2.isTarget && !checkForBees(obj2)) || obj2.eventID == OBJECT::DESTRUCTSCENERY || (((obj2.bulletHandling == HANDLING::HURTBYBULLET && obj2.energy > 0) || obj2.bulletHandling == HANDLING::DETECTBULLET) && !checkForBees(obj2) && !obj.causesRicochet))) {
obj.state = STATE::EXPLODE;
}
}
}
bool checkForBees(jjOBJ@ target) {
if (!PierceFlies) return false;
if (target.eventID == OBJECT::BEES || target.eventID == OBJECT::BEEBOY || target.eventID == OBJECT::BUMBEE || target.eventID == OBJECT::DRAGONFLY || target.eventID == OBJECT::BUTTERFLY) return true;
return false;
}
bool checkForSPParameters() {
if (PierceFlies || AttackCaterpillars) return true;
return false;
}
bool checkForUnsolidEvents(int xPos,int yPos) {
if (jjEventGet(xPos, yPos) == AREA::ONEWAY) return true;
if (jjEventGet(xPos, yPos) == AREA::VINE) return true;
return false;
}
bool ApplyCustomParameters(uint, se::WeaponHook@, jjSTREAM@ parameter) {
if (parameter !is null && parameter.getSize() >= 3) {
parameter.pop(PierceFlies);
parameter.pop(AttackCaterpillars);
parameter.pop(SPBehavior);
}
return true;
}
}
}
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.