Downloads containing ArcaneWeapon5.asc

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Necropolis Superjazz Battle 7.5 Download file
Custom Weapons...Featured Download Violet CLM Other 10 Download file

File preview

#pragma require "ArcaneWeapon5.asc"
#include "MLLE-Weapons.asc"
#pragma require "Nail.j2a"
#pragma offer "f_ar3.wav"

namespace ArcaneWeapons {
	namespace NailGun {
		SOUND::Sample FireSound = SOUND::COMMON_GUNSM1;
		class Weapon : MLLEWeapons::WeaponInterface {
			bool ShouldHurt = true;
			Weapon() {
				super(
					regularObjectTemplate: MLLEWeapons::ObjectTemplate(
						xSpeed: 1,
						xAcc: 0.35,
						animSpeed: 2,
						killAnim: jjAnimSets[ANIM::AMMO].firstAnim + 80,
						curAnim: 0,
						var: array<int> = {0,0,0,0,0,0,16},
						lightType: LIGHT::POINT,
						counterEnd: 60
					),
					powerupObjectTemplate: MLLEWeapons::ObjectTemplate(
						xSpeed: 1.5,
						xAcc: 0.4,
						animSpeed: 2,
						killAnim: jjAnimSets[ANIM::AMMO].firstAnim + 80,
						curAnim: 1,
						var: array<int> = {0,0,0,0,0,0,16},
						lightType: LIGHT::POINT,
						counterEnd: 55
					),
					animSetFilename: "Nail.j2a",
					pickupAnimation: 4,
					poweredUpPickupAnimation: 5,
					ammoCrateAnimation: 2,
					powerupAnimation: 3,
					sampleFilenames: array<string> = {"f_ar3.wav"},
					apply: MLLEWeapons::applyFunction(SaveFireSound),
					traits: se::weapon_default_traits | se::weapon_increases_mobility,
					behavior: MLLEWeapons::behaviorFunction(DetermineBehavior)
				);
			}
			bool SaveFireSound(uint number, se::WeaponHook@, jjSTREAM@ parameter) {
				jjObjectPresets[se::getAmmoPickupOfWeapon(number)].lightType = LIGHT::POINT;
				if (SamplesLoaded[0]) FireSound = Samples[0];
				if (parameter !is null && parameter.getSize() >= 1)
					parameter.pop(ShouldHurt);
				return true;
			}
			void DetermineBehavior(jjOBJ@ obj, bool powerup) const {
				if (obj.creatorType == CREATOR::PLAYER && jjPlayers[obj.creatorID].isLocal)
					jjSample(obj.xPos, obj.yPos, FireSound, 48, powerup? 19000:17500);
				if (obj.eventID == OBJECT::ICEBULLET) obj.eventID = OBJECT::BLASTERBULLET;
				if (!ShouldHurt) obj.playerHandling = HANDLING::PARTICLE;//for ground force and such
				obj.behavior = Behavior;
			}
		}
		
		void Behavior(jjOBJ@ obj) {
			const bool powerup = MLLEWeapons::HelpfulBulletFunctions::IsPowerup(obj);
			obj.behave(obj.state == STATE::EXPLODE? BEHAVIOR::BULLET : BEHAVIOR::RFBULLET, obj.state == STATE::EXPLODE);
			
			if (obj.state != STATE::EXPLODE) {
				MLLEWeapons::HelpfulBulletFunctions::DrawAngled(obj);
				
				if (obj.counter > 8)
					for (uint objectID = jjObjectCount; --objectID != 0;) { //explosions generated by BEHAVIOR::RFBULLET should be invisible (but still produce light)
						jjOBJ@ obj2 = jjObjects[objectID];
						if (obj2.xPos == obj.xPos && obj2.yPos == obj.yPos && obj2.behavior == BEHAVIOR::EXPLOSION) {
							obj2.behavior = function(obj2) { obj2.behave(BEHAVIOR::EXPLOSION, false); };
							break;
						}
					}
				
				if ((jjGameMode > GAME::COOP || obj.creatorType != CREATOR::PLAYER) && (jjGameState == GAME::STARTED || jjGameState == GAME::OVERTIME))
					for (int lpid = 0; lpid < jjLocalPlayerCount; ++lpid) {
						jjPLAYER@ victim = jjLocalPlayers[lpid];
						if (victim.blink == 0 && MLLEWeapons::HelpfulBulletFunctions::PlayerIsEnemy(obj, victim)) {
							const float dx = victim.xPos - obj.xPos, dy = victim.yPos - obj.yPos;
							if (dx * dx + dy * dy < 64 * 24) {
								victim.xPos = obj.xPos - (24 * obj.direction);
								victim.ySpeed = obj.ySpeed;
							}
						}
					}
				
				if (jjMaskedPixel(int(obj.xPos + obj.xSpeed + obj.var[7] / 65536.f), int(obj.yPos))) {
					obj.xSpeed = obj.ySpeed = obj.yAcc = 0;
					obj.var[7] = 0;
					obj.playerHandling = HANDLING::PARTICLE;
					obj.bePlatform(obj.xPos, obj.yPos, 32, 8);
					if (obj.var[2] == 0) {
						jjSample(obj.xPos, obj.yPos, SOUND::COMMON_METALHIT, 0, 0);
						obj.counter = 1;
						if (powerup) obj.counterEnd = 90;
						obj.var[2] = 1;
					}
				}
				else if (jjMaskedPixel(int(obj.xPos), int(obj.yPos + obj.ySpeed))) {
					obj.ySpeed = 0;
					obj.playerHandling = HANDLING::PARTICLE;
					if (obj.var[2] == 0) {
						jjSample(obj.xPos, obj.yPos, SOUND::COMMON_METALHIT, 0, 0);
						obj.counter = 1;
						if (powerup) obj.counterEnd = 90;
						obj.var[2] = 1;
					}
				}
			} else
				obj.clearPlatform();
		}
	}
}