summaryrefslogtreecommitdiff
path: root/src/players.c
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrik@amftech.nl>2024-01-07 12:24:38 +0100
committerAldrik Ramaekers <aldrik@amftech.nl>2024-01-07 12:24:38 +0100
commit33f39cd8ef08db0007c9690992bad99edbaa1795 (patch)
treee1e48263aaa124ca826b4c5984e3511e56bde70f /src/players.c
parent1f3e6604cf2df6ae11944f99f939b8b697ebd4d9 (diff)
zombie hit player
Diffstat (limited to 'src/players.c')
-rw-r--r--src/players.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/players.c b/src/players.c
index b2ebfae..6ea5205 100644
--- a/src/players.c
+++ b/src/players.c
@@ -61,6 +61,8 @@ void spawn_player(u32 id, network_client client) {
players[i].client = client;
players[i].sprite = create_sprite(img_gunner_blue_run, 6, 48, 48, 0.1f);
players[i].sprite.zoom = 1.1f;
+ players[i].health = 500;
+ players[i].max_health = 500;
players[i].gun_sprite = create_sprite(img_gun_mp5, 4, 256, 256, 0.0f);
players[i].direction = DIRECTION_DOWN;
@@ -353,6 +355,16 @@ void update_players_client() {
}
}
+void hurt_player(u32 id, u32 damage) {
+ player* p = get_player_by_id(id);
+ if (p == 0) {
+ return;
+ }
+
+ p->health -= damage;
+ add_audio_event_to_queue(EVENT_PLAYERHURT, p->id, (vec3f){.x = p->playerx, .y = p->playery, .z = p->height});
+}
+
void update_players_server() {
for (int i = 0; i < MAX_PLAYERS; i++) {
if (!players[i].active) continue;