Downloads containing player_collision_example.mut

Downloads
Name Author Game Mode Rating
TSF with JJ2+ Only: Player-to-Player Collision... froducish Mutator N/A Download file

File preview

#pragma require "player_collision_detector_interface.asc"
#include "player_collision_detector_interface.asc"

COLLIDE::DetectorI@ collisionDetector;

void onLevelLoad() {
	@collisionDetector = COLLIDE::getDetector(true);
	if (collisionDetector !is null) {
		// setHook actually takes two arguments: function that will be called when a collision is detected (COLLIDE::HOOK@) and the module ID (uint)
		// These arguments are already filled for you (setHook assumes you have a global function named onCollide, and the module ID is set to this script module's ID)
		// However, if you want to provide a different funcion instead then you may do say by calling setHook(myFunction). You could even provide a different ID by calling
		// setHook(myFunction, id), but this is not a good idea!
		collisionDetector.setHook();
		// Don't forget to call this to get the hook actually working. If you have any weapons modified
		// in other script files, then make sure this is the last thing that gets called.
		collisionDetector.startDetecting();
	}
}

void onCollide(jjPLAYER@ victim, jjPLAYER@ collider, COLLIDE::Collide collision) {
	array<string> labels = {"BULLET", "BULLETPU", "BUMP", "STOMPORRUSH", "SPECIALMOVE"};
	jjSamplePriority(SOUND::RAPIER_HITCHAR);
	jjAlert("[" + jjLocalPlayers[0].nameUnformatted + "] " + collider.nameUnformatted + " collided with " + victim.nameUnformatted + " via " + labels[collision]);
}