Downloads containing AntiGravBouncers.asc

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Copper web Rysice Capture the flag N/A Download file
Custom MLLE Naps WeaponPack Naps Other N/A Download file
TSF with JJ2+ Only: Anniversary Bash 26 CTF Jazz2Online Capture the flag N/A Download file
TSF with JJ2+ Only: Anniversary Bash 26 Battle Jazz2Online Battle N/A Download file
TSF with JJ2+ Only: Saline ShoresFeatured Download PurpleJazz Capture the flag 9.2 Download file
TSF with JJ2+ Only: The Pillar Dragusela Battle N/A Download file
JJ2+ Only: Anniversary Bash 25 CTF Jazz2Online Capture the flag N/A Download file
TSF with JJ2+ Only: Obsidian CaveFeatured Download PurpleJazz Capture the flag 8.7 Download file
TSF with JJ2+ Only: Celestial TemplesFeatured Download Dragusela Capture the flag 8.5 Download file
TSF with JJ2+ Only: Anniversary Bash 24 CTF Jazz2Online Capture the flag N/A Download file
JJ2+ Only: violetclm DOM Episodes I...Featured Download Violet CLM Custom / Concept 9 Download file

File preview

#pragma require "AntiGravBouncers.asc"
#include "MLLE-Weapons.asc"
#pragma require "AntiGravBouncer.j2a"

namespace NapsWeapons {
	class AntiGravityBouncer : MLLEWeapons::WeaponInterface {
		bool ReverseBehaviors = false;
		bool BounceThroughWalls = true;
		bool ReverseUpwardFire = true;
		AntiGravityBouncer() {
			super(
				regularObjectTemplate: MLLEWeapons::ObjectTemplate(
					xSpeed: 5,
					ySpeed: -1,
					xAcc: 0.25,
					yAcc: -0.0915527344f,
					killAnim: jjAnimSets[ANIM::AMMO].firstAnim + 4,
					curAnim: 0,
					lightType: LIGHT::POINT2,
					counterEnd: (70*3)/2
				),
				powerupObjectTemplate: MLLEWeapons::ObjectTemplate(
					xSpeed: 5,
					ySpeed: -1,
					xAcc: 0.25,
					yAcc: -0.0915527344f,
					animSpeed: 2,
					killAnim: jjAnimSets[ANIM::AMMO].firstAnim + 4,
					curAnim: 1,
					lightType: LIGHT::POINT2,
					counterEnd: (70*3)/2
				),
				animSetFilename: "AntiGravBouncer.j2a",
				pickupAnimation: 3,
				poweredUpPickupAnimation: 2,
				powerupAnimation: 4,
				ammoCrateAnimation: 5,
				traits: se::weapon_default_traits | se::weapon_goes_through_thin_walls,
				behavior: MLLEWeapons::behaviorFunction(DetermineBehavior),
				apply: MLLEWeapons::applyFunction(DetermineReversedness)
			);
		}
		void DetermineBehavior(jjOBJ@ obj, bool powerup) const {
			DefaultWeapons::DefaultSample(obj, WEAPON::BOUNCER);
			obj.behavior = jjVOIDFUNCOBJ(Behavior);
		}
		void Behavior(jjOBJ@ obj) const {
			bool goUp,goDown,goLeft,goRight;
			int frame;
			if (obj.state == STATE::START) {
				if (obj.creatorType == CREATOR::OBJECT) {
					jjOBJ@ enemyCreator = jjObjects[obj.creatorID];
					obj.direction = enemyCreator.direction;
					obj.xSpeed = (obj.direction*obj.xSpeed) + enemyCreator.xSpeed;
					obj.xAcc=(obj.direction*obj.xAcc);
				}
				if (ReverseUpwardFire && obj.xAcc == 0) {
					obj.yAcc = -obj.yAcc;
					obj.ySpeed = -obj.ySpeed;
				}
				if (obj.eventID == OBJECT::ICEBULLET)
					obj.eventID = OBJECT::BLASTERBULLET; //just in case...
				obj.state = STATE::BOUNCE;
			} else
			if (obj.state == STATE::EXPLODE) {
				obj.behavior = BEHAVIOR::EXPLOSION2;
				obj.frameID = 0;
			} else
			if ((obj.state == STATE::KILL) || (obj.state == STATE::DEACTIVATE)) {
				obj.delete();
			}
			
			obj.xPos += obj.xSpeed + (obj.var[7] / 65536.0);
			obj.yPos += obj.ySpeed;
			
			if (obj.var[7] > 8192)
				obj.var[7] =  obj.var[7] - 8192;
			else
			if (obj.var[7] < -8192)
				obj.var[7] = obj.var[7] + 8192 ;
			else
				obj.var[7] = 0;
				
			obj.xSpeed += obj.xAcc;
			
			if (obj.yPos > jjWaterLevel)
				obj.ySpeed +=obj.yAcc - 0.125/4;
			else
				obj.ySpeed+=obj.yAcc - 0.125;
			
			if (obj.counter > int(obj.counterEnd)) {
				obj.state = STATE::EXPLODE;
				obj.curFrame = 0;
				obj.counter = 0;
				obj.lightType = 0;
			}
		
			goUp=jjMaskedPixel(int(obj.xPos),int(obj.yPos) - 4);
			goDown=jjMaskedPixel(int(obj.xPos),int(obj.yPos) + 4);
			goLeft=jjMaskedPixel(int(obj.xPos) - 2,int(obj.yPos));
			goRight=jjMaskedPixel(int(obj.xPos) + 2,int(obj.yPos));
			
			obj.counter++;
			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.var[6] == (!ReverseBehaviors? 0 : 8)) {
				if (obj.xSpeed>8) obj.xSpeed=8;
				else
				if (obj.xSpeed<-8) obj.xSpeed=-8;

				if (obj.ySpeed>4) obj.ySpeed=4;
				else
				if (obj.ySpeed<-4) obj.ySpeed=-4;
			
				if ((obj.ySpeed < 0) && (goUp == true)) {
					obj.var[0] = obj.var[0] + 1;
					obj.yPos += obj.ySpeed;
					obj.ySpeed = -(obj.ySpeed*7)/8;
					jjSample(obj.xPos,obj.yPos,SOUND::COMMON_BLOKPLOP,40,0);
				} else
				if ((obj.ySpeed > 0) && (goDown == true)) {
					obj.var[0] = obj.var[0] + 1;
					obj.ySpeed = -(obj.ySpeed*7)/8;
					jjSample(obj.xPos,obj.yPos,SOUND::COMMON_BLOKPLOP,40,0);
				}
				
				if (obj.xSpeed < 0 && goLeft == true) {
					obj.var[0] = obj.var[0] + 1;
					obj.xSpeed = -(obj.xSpeed*7)/8;
					obj.xAcc = -obj.xAcc;
					if (!BounceThroughWalls) {
						obj.var[7] = -obj.var[7];
					}
					jjSample(obj.xPos,obj.yPos,SOUND::COMMON_BLOKPLOP,40,0);
				} else
				if ((obj.xSpeed >0 ) && (goRight == true)) {
					obj.var[0] = obj.var[0] + 1;
					obj.xSpeed = -(obj.xSpeed*7)/8;
					obj.xAcc = -obj.xAcc;
					if (!BounceThroughWalls) {
						obj.var[7] = -obj.var[7];
					}
					jjSample(obj.xPos,obj.yPos,SOUND::COMMON_BLOKPLOP,40,0);
				}
				
				if (obj.var[0] > 16) {
					obj.state = STATE::EXPLODE;
					obj.frameID = 0;
					obj.counter=-1;
					obj.lightType=0;
				}
			} else
			if (obj.var[6] == (!ReverseBehaviors? 8 : 0)) {
				if (obj.xSpeed>6) obj.xSpeed=6;
				else
				if (obj.xSpeed<-6) obj.xSpeed=-6;

				if (obj.ySpeed>6) obj.ySpeed=6;
				else
				if (obj.ySpeed<-6) obj.ySpeed=-6;
		
				if ((obj.ySpeed < 0) && (goUp == true)) {
					obj.var[0] = obj.var[0] + 1;
					obj.ySpeed = -(obj.ySpeed*9)/8;
					jjSample(obj.xPos,obj.yPos,SOUND::COMMON_BLOKPLOP,0,0);
				} else
				if ((obj.ySpeed > 0) && (goDown == true)) {
					obj.var[0] = obj.var[0] + 1;
					obj.ySpeed = -(obj.ySpeed*(9+int(jjRandom() & 7)))/8;
					jjSample(obj.xPos,obj.yPos,SOUND::COMMON_BLOKPLOP,0,0);
				}
			
				if (obj.xSpeed < 0 && goLeft == true) {
					obj.var[0] = obj.var[0] + 1;
					obj.xSpeed = -(obj.xSpeed*9)/8;
					if (int(jjRandom() & (3)) == 0) obj.xAcc = -obj.xAcc;
					if (!BounceThroughWalls) {
						obj.var[7] = -obj.var[7];
					}
					jjSample(obj.xPos,obj.yPos,SOUND::COMMON_BLOKPLOP,0,0);
				} else
				if ((obj.xSpeed >0 ) && (goRight == true)) {
					obj.var[0] = obj.var[0] + 1;
					obj.xSpeed = -(obj.xSpeed*9)/8;
					if (int(jjRandom() & (3)) == 0) obj.xAcc = -obj.xAcc;
					if (!BounceThroughWalls) {
						obj.var[7] = -obj.var[7];
					}
					jjSample(obj.xPos,obj.yPos,SOUND::COMMON_BLOKPLOP,0,0);
				}
				if (obj.var[0] > 32) {
					obj.state = STATE::EXPLODE;
					obj.frameID = 0;
					obj.counter=-1;
					obj.lightType=0;
				}
			}
			if (obj.counter > 4)
			obj.draw();
		}
		bool DetermineReversedness(uint, se::WeaponHook@, jjSTREAM@ parameter) {
			if (parameter !is null && parameter.getSize() >= 3) {
				parameter.pop(ReverseBehaviors);
				parameter.pop(BounceThroughWalls);
				parameter.pop(ReverseUpwardFire);
			}
			return true;
		}
	}
}