Downloads containing AngelsAndDemons.mut

Downloads
Name Author Game Mode Rating
JJ2 1.23 vanilla: Miscellaneous stuff Violet CLM Multiple N/A Download file

File preview

#pragma name "Angels & Demons"

void onLevelLoad() {
	jjObjectPresets[OBJECT::CARROT].behavior = jjObjectPresets[OBJECT::FULLENERGY].behavior = NoCarrotsForMortals();
	jjObjectPresets[OBJECT::CARROT].scriptedCollisions = jjObjectPresets[OBJECT::FULLENERGY].scriptedCollisions = true;
}
void onLevelBegin() {
	if (jjIsServer) {
		if (jjGameCustom != GAME::TB)
			jjChat("/tb");
		bool changesMade = false;
		if (jjEnabledTeams[TEAM::YELLOW]) {
			jjChat("/teams yellow off");
			changesMade = true;
		}
		if (!jjEnabledTeams[TEAM::RED]) {
			jjChat("/teams red on");
			changesMade = true;
		}
		if (!jjEnabledTeams[TEAM::BLUE]) {
			jjChat("/teams blue on");
			changesMade = true;
		}
		if (!jjEnabledTeams[TEAM::GREEN]) {
			jjChat("/teams green on");
			changesMade = true;
		}
		if (changesMade)
			jjChat("/shuffle");
		jjChat("/maxscore 255");
	}
}
class PendingTeamChange {
	string team;
	int playerID;
	int time;
	PendingTeamChange(const string &in e, int p, int i) { team = e; playerID = p; time = i; }
	PendingTeamChange(){}
}
array<PendingTeamChange> PendingTeamChanges;
void onRoast(jjPLAYER@ victim, jjPLAYER@ killer) {
	if (jjIsServer) {
		PendingTeamChanges.insertLast(PendingTeamChange(victim.team == TEAM::GREEN ? killer.team == TEAM::BLUE ? "blue" : "red" : "green", victim.playerID + 1, jjGameTicks + 35));
	}
}
void onMain() {
	for (uint i = 0; i < PendingTeamChanges.length; ++i) {
		const PendingTeamChange@ pending = PendingTeamChanges[i];
		if (pending.time < jjGameTicks) {
			jjChat("/swap " + pending.playerID + " " + pending.team);
			const auto newTeam = jjPlayers[pending.playerID-1].team;
			PendingTeamChanges.removeAt(i);
			for (int j = 0; j < 32; ++j) {
				const auto play = jjPlayers[j];
				if (play.isInGame && play.team != newTeam) //at least two different teams are still active
					return;
			}
			int maxScore = jjTeamScore[TEAM::RED];
			if (maxScore < jjTeamScore[TEAM::BLUE]) maxScore = jjTeamScore[TEAM::BLUE];
			if (maxScore < jjTeamScore[TEAM::GREEN]) maxScore = jjTeamScore[TEAM::GREEN];
			jjChat("/maxscore" + maxScore);
			return;
		}
	}
}
void onPlayer(jjPLAYER@ play) {
	if (play.team == TEAM::GREEN)
		for (int i = 1; i <= 9; ++i)
			play.powerup[i] = false;
}

class NoCarrotsForMortals : jjBEHAVIORINTERFACE {
	void onBehave(jjOBJ@ obj) {
		obj.behave(BEHAVIOR::PICKUP, jjLocalPlayers[0].team != TEAM::GREEN || jjLocalPlayerCount > 1);
	}
	bool onObjectHit(jjOBJ@ obj, jjOBJ@, jjPLAYER@ play, int) {
		if ((play.health < jjMaxHealth && play.team != TEAM::GREEN) || !play.isLocal) {
			obj.scriptedCollisions = false;
		}
		return true;
	}
}