Downloads containing DiagShoot.mut

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Diagonal Shooting ThunDerDraGon Mutator N/A Download file

File preview

#pragma name "Diagonal Shooting"
#pragma require "sevk.asc"
#include "sevk.asc"

bool keyHeld;
const string Filename = "DS_KEY.asdat";
int DS_Key = 0;
int ffCounter = -1;

string lowercase(string &in text) {
	for (int i = text.length(); i-- != 0;) {
		if (text[i] > 64 && text[i] < 91)
			text[i] ^= 32;
	}
	return text;
}

void onLevelLoad() {
	jjSTREAM savedStrings(Filename);
	while (!savedStrings.isEmpty()) {
		savedStrings.pop(DS_Key);
	}
}

bool onLocalChat(string &in msg, CHAT::Type chatType) {
	array<string> result;
	if (jjRegexMatch(msg, "!dskey " + """(.+)""", result, true)) {
		int keyCode = getKeyCodeByName(lowercase(result[1]));
		if (keyCode != 0) {
			DS_Key = keyCode;
			jjSTREAM key;
			key.push(DS_Key);
			key.save(Filename);
			jjAlert(">> Diagonal Shooting bound to Key " + getNameByKeyCode(keyCode));
		} else {
			jjAlert("|>> Invalid Input");
		}
		return true;
	}
	return false;
}

void onMain() {
	if (jjGameTicks == 140 && DS_Key == 0)
		jjAlert("|||>> Type '!dskey <key>' to assign the diagonal shooting key");
}

void onPlayerInput(jjPLAYER@ play) {
	if (((play.keyRight && play.keyUp) || (play.keyLeft && play.keyUp)) && DS_Key != 0 && !play.noFire && jjWeapons[play.currWeapon].style != WEAPON::CAPPED 
		&& play.warpID == 0 && play.ballTime == 0 && play.curAnim - jjAnimSets[play.setID].firstAnim != RABBIT::ROLLING && play.specialMove == 0 && play.buttstomp >= 121) {
		if (jjKey[DS_Key]) {
			switch (jjWeapons[play.currWeapon].style) {
				case WEAPON::MISSILE:
					if (!keyHeld) {
						play.fireBullet(WEAPON::CURRENT, true, true, (play.keyRight) ?  0.25*22/7.f : 1.75*22/7.f);
						keyHeld = true;
					}
					break;
				case WEAPON::NORMAL:
					if (++ffCounter%play.fastfire == 0)
						play.fireBullet(WEAPON::CURRENT, true, true, (play.keyRight) ?  0.25*22/7.f : 1.75*22/7.f);
					break;
				case WEAPON::POPCORN:
					if (++ffCounter%4 == 0)
							play.fireBullet(WEAPON::CURRENT, true, true, (play.keyRight) ?  0.25*22/7.f : 1.75*22/7.f);
					break;
			}
			if (play.ammo[play.currWeapon] == 0)
				play.keySelect = true;
		} else {
			keyHeld = false;
			ffCounter = -1;
		}
		play.keyFire = false;
	}
}