Downloads containing emoticonz.mut

Downloads
Name Author Game Mode Rating
JJ2+ Only: EmoticonZFeatured Download szmol96 Mutator 9.3 Download file

File preview

#pragma name "EmoticonZ"
#pragma require "emoticonz.j2a"

/**EmoticonZ**/
/**Author: szmol96**/

uint customAnimID = 0;
const array<string> commands = {"!:)", "!:(", "!:D", "!:O", "!XD", "!:@", "!:P", "!:'(", "!;)", "!B)", "!:3", "!:S", "!:$", "!<3", "!(y)", "!(n)", "!!", "!?"};
array<uint> playerEmoticons(32, 0);
array<int> emoticonTimers(32, 0);

void findCustomAnimID() { //This function is copied from Bunny Must Die! guns
	while (jjAnimSets[ANIM::CUSTOM[customAnimID]].firstAnim != 0) ++customAnimID;
	
	jjAnimSets[ANIM::CUSTOM[customAnimID]].load(0, "emoticonz.j2a");
}

void setEmoticon(uint8 emoticonNumber, uint16 playerNumber) {
	playerEmoticons[playerNumber] = emoticonNumber;
	emoticonTimers[playerNumber] = 350;
}

void setOwnEmoticon(uint8 emoticonNumber) {
	jjPLAYER@ p = jjLocalPlayers[0];
	playerEmoticons[p.playerID] = emoticonNumber;
	emoticonTimers[p.playerID] = 350;
}

void sendEmoticon(uint8 emoticonNumber) {
	jjSTREAM packet;
	packet.push(emoticonNumber);
	jjSendPacket(packet);
}

void serverSendEmoticon(uint8 emoticonNumber, uint16 playerNumber) {
	jjSTREAM packet;
	packet.push(emoticonNumber);
	packet.push(playerNumber);
	jjSendPacket(packet);
}

void doEmoticonThings(uint8 emoticonNumber) {
	setOwnEmoticon(emoticonNumber);
	if (jjIsServer){
		serverSendEmoticon(emoticonNumber, 0);
	} else {
		sendEmoticon(emoticonNumber);
	}
}

void onLevelLoad() {
	findCustomAnimID();
}

void onMain() {
	for (int i = 0; i < 32; i++) {
		if (emoticonTimers[i] > 0) {
			emoticonTimers[i]--;
			jjDrawSprite(jjPlayers[i].xPos + 16, jjPlayers[i].yPos - 32, ANIM::CUSTOM[customAnimID], 0, playerEmoticons[i], 0, SPRITE::NORMAL, 0, 1, 4, -1);
		}
	}
}

bool onLocalChat(string &in stringReceived, CHAT::Type chatType) {
	for(uint i = 0; i < commands.length; i++) {
		if (stringReceived == commands[i]) {
			doEmoticonThings(i);
			return true;
		}
	}
	return false;
}

void onReceive(jjSTREAM &in packet, int clientID) {
	if (jjIsServer) {
		uint8 emoticonNumber;
		uint16 playerNumber;
		playerNumber = clientID;
		packet.pop(emoticonNumber);
		setEmoticon(emoticonNumber, clientID);
		serverSendEmoticon(emoticonNumber, playerNumber);
	} else {
		uint8 emoticonNumber;
		uint16 playerNumber;
		packet.pop(emoticonNumber);
		packet.pop(playerNumber);
		setEmoticon(emoticonNumber, playerNumber);
	}
}