Downloads containing healthdisplay.mut

Downloads
Name Author Game Mode Rating
JJ2+ Only: Health Display XxMoNsTeRXM Mutator N/A Download file

File preview

#pragma name "Health Display"

const string Filename = "healthdp.asdat";

enum displayType {teammates, all, enemy, none};

int display = teammates;
int size = 32;

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

void onPlayer() {
	for (int i = 0; i < 32; i++) {
	    jjPLAYER@ p = jjPlayers[i];
		if (((display == all || jjGameMode != GAME::CTF) && jjPlayers[i].playerID != jjLocalPlayers[0].playerID) && display != none) {
			int health = p.health;
			float xPos = p.xPos - 0.5 * p.health;
			float xPos2 = p.xPos - 0.5 * p.health-6;
			float yPos = p.yPos - 45;
			while (health > 0) {
				jjDrawSprite(xPos - 12.25, yPos, ANIM::PICKUPS, 41, 0, 0, SPRITE::RESIZED, size);
				xPos += 9;
				health -= 1;
			}
		}
		if (display == teammates && jjGameMode == GAME::CTF) {
			if (jjPlayers[i].team == jjLocalPlayers[0].team && jjPlayers[i].playerID != jjLocalPlayers[0].playerID) {
				int health = p.health;
				float xPos = p.xPos - 0.5 * p.health;
				float xPos2 = p.xPos - 0.5 * p.health-6;
				float yPos = p.yPos - 45;
				while (health > 0) {
					jjDrawSprite(xPos - 12.25, yPos, ANIM::PICKUPS, 41, 0, 0, SPRITE::RESIZED, size);
					xPos += 9;
					health -= 1;
				}
			}
		}
		if (display == enemy && jjGameMode == GAME::CTF) {
			if (jjPlayers[i].team != jjLocalPlayers[0].team && jjPlayers[i].playerID != jjLocalPlayers[0].playerID) {
				int health = p.health;
				float xPos = p.xPos - 0.5 * p.health;
				float xPos2 = p.xPos - 0.5 * p.health-6;
				float yPos = p.yPos - 45;
				while (health > 0) {
					jjDrawSprite(xPos - 12.25, yPos, ANIM::PICKUPS, 41, 0, 0, SPRITE::RESIZED, size);
					xPos += 9;
					health -= 1;
				}
			}
		}
	}
}

void onChat(int clientID, string &in stringReceived, CHAT::Type chatType) {
	if (clientID == 0 || jjPlayers[clientID].isAdmin) {
		if (stringReceived == "!health display teammates") {
			display = teammates;
			jjAlert("Health Display is now for |||TEAMMATES", false, STRING::SMALL);
		}
		if (stringReceived == "!health display enemy") {
			display = enemy;
			jjAlert("Health Display is now for |ENEMY", false, STRING::SMALL);
		}
		if (stringReceived == "!health display all") {
			display = all;
			jjAlert("Health Display is now for ||ALL", false, STRING::SMALL);
		}
		if (stringReceived == "!health display none") {
			display = none;
			jjAlert("Health Display is now for |NONE", false, STRING::SMALL);
		}
		if (stringReceived == "!health size small") {
			size = 16;
			jjAlert("Health Size is now |SMALL", false, STRING::SMALL);
		}
		if (stringReceived == "!health size medium") {
			size = 24;
			jjAlert("Health Size is now ||MEDIUM", false, STRING::SMALL);
		}
		if (stringReceived == "!health size normal") {
			size = 32;
			jjAlert("Health Size is now |||NORMAL", false, STRING::SMALL);
		}
		if (stringReceived == "!health size big") {
			size = 48;
			jjAlert("Health Size is now ||||BIG", false, STRING::SMALL);
		}
		saveFile();
	}
}

void saveFile() {
	jjSTREAM stream;
	stream.push(display);
	stream.push(size);
	stream.save(Filename);
}