This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int MAX_PLAYERS = 4; | |
class script { | |
scene@ g; | |
array<controllable@> players; | |
script() { | |
@g = get_scene(); | |
players.resize(MAX_PLAYERS); | |
} | |
void on_player_hit(controllable@ pl, controllable@ hit, | |
hitbox@ hb, int player_num) { | |
puts("PLAYER HIT " + player_num + " DAMAGE = " + hb.damage()); | |
} | |
void on_player_hurt(controllable@ pl, controllable@ hitter, | |
hitbox@ hb, int player_num) { | |
puts("PLAYER HURT " + player_num + " DAMAGE = " + hb.damage()); | |
} | |
void step(int entities) { | |
for (int i = 0; i < MAX_PLAYERS; i++) { | |
if (@players[i] == null) { | |
entity@ e = controller_entity(i); | |
if (@e != null) { | |
@players[i] = e.as_controllable(); | |
if (@players[i] != null) { | |
players[i].add_on_hit_callback("on_player_hit", i); | |
players[i].add_on_hurt_callback("on_player_hurt", i); | |
} | |
} | |
} | |
} | |
} | |
void checkpoint_load() { | |
for (int i = 0; i < MAX_PLAYERS; i++) { | |
@players[i] = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment