2.0
28 Mar 2014 21:23
/*Flash Grenade*/
/*Author: szmol96*/
bool doOnce = false;
const float gravity = 0.5;
int flashCount = 0;
int blindTime = 3; //The time your screen stays white in seconds.
jjPAL myPal;
void onLevelLoad() {
jjObjectPresets[OBJECT::FIREBALLBULLET].behavior = flashNade;
jjObjectPresets[OBJECT::FIREBALLBULLET].bulletHandling = HANDLING::IGNOREBULLET;
jjObjectPresets[OBJECT::FIREBALLBULLET].playerHandling = HANDLING::PARTICLE;
jjObjectPresets[OBJECT::FIREBALLBULLET].counterEnd = 5;
}
void flashNade(jjOBJ@ grenade) {
jjPLAYER@ p = jjLocalPlayers[0];
if (grenade.state == STATE::START) {
grenade.xSpeed = p.direction * 5 + p.xSpeed;
grenade.ySpeed = p.ySpeed - 5;
grenade.state = STATE::FLY;
}
grenade.age++;
if (grenade.age > 150) {
grenade.state = STATE::EXPLODE;
grenade.delete();
jjPARTICLE@ smoke = jjAddParticle(PARTICLE::SMOKE);
if (smoke !is null) {
smoke.xPos = grenade.xPos;
smoke.yPos = grenade.yPos;
}
jjPARTICLE@ smoke2 = jjAddParticle(PARTICLE::SMOKE);
if (smoke2 !is null) {
smoke2.xPos = grenade.xPos + 4;
smoke2.yPos = grenade.yPos;
}
jjPARTICLE@ smoke3 = jjAddParticle(PARTICLE::SMOKE);
if (smoke3 !is null) {
smoke3.xPos = grenade.xPos - 4;
smoke3.yPos = grenade.yPos;
}
jjPARTICLE@ spark = jjAddParticle(PARTICLE::SPARK);
if (spark !is null) {
spark.xPos = grenade.xPos;
spark.yPos = grenade.yPos + 5;
spark.ySpeed = -2;
}
jjPARTICLE@ spark2 = jjAddParticle(PARTICLE::SPARK);
if (spark2 !is null) {
spark2.xPos = grenade.xPos + 2;
spark2.yPos = grenade.yPos - 5;
spark2.xSpeed = -1;
}
jjPARTICLE@ spark3 = jjAddParticle(PARTICLE::SPARK);
if (spark3 !is null) {
spark3.xPos = grenade.xPos - 2;
spark3.yPos = grenade.yPos - 5;
spark3.xSpeed = 1;
}
}
if (jjMaskedPixel(grenade.xPos + grenade.xSpeed, grenade.yPos)) {
grenade.xSpeed = -1 * (grenade.xSpeed / 2);
}
if (jjMaskedPixel(grenade.xPos, grenade.yPos + grenade.ySpeed)) {
grenade.ySpeed = -1 * (grenade.ySpeed / 2);
} else {
grenade.ySpeed = grenade.ySpeed + gravity;
}
grenade.xPos = grenade.xPos + grenade.xSpeed;
grenade.yPos = grenade.yPos + grenade.ySpeed;
if ((grenade.xPos - p.xPos) * p.direction > 0 && grenade.xPos > p.cameraX && grenade.yPos > p.cameraY && grenade.xPos < p.cameraX + 640 && grenade.yPos < p.cameraY + 480 && grenade.state==STATE::EXPLODE) {
flashCount = blindTime * 70;
}
grenade.determineCurAnim(ANIM::AMMO, 1, true);
grenade.determineCurFrame();
grenade.draw();
}
void onPlayer(jjPLAYER@ p) {
if (flashCount > 0) {
if (doOnce == false) {
myPal.fill(255, 255, 255, 1);
myPal.apply();
doOnce = true;
}
flashCount--;
} else {
if (doOnce == true) {
myPal.reset();
myPal.apply();
doOnce = false;
}
}
}
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.