From abda5fb4937716069d57b06bca19f220b446d0af Mon Sep 17 00:00:00 2001 From: Jack Back Date: Thu, 21 Mar 2024 10:18:08 +0100 Subject: [PATCH] iw5: more cursed macros --- iw5/scripts/mp/_jump.gsc | 15 +++++---------- iw5/scripts/mp/_utility.gsh | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/iw5/scripts/mp/_jump.gsc b/iw5/scripts/mp/_jump.gsc index a272ea7..29d565e 100644 --- a/iw5/scripts/mp/_jump.gsc +++ b/iw5/scripts/mp/_jump.gsc @@ -30,7 +30,8 @@ _ON_PLAYER_CNCT_BEGIN player thread jumper(); player thread displaySpeed(); - player thread onPlayerSpawned(); + + _ON_PLAYER_SPAWNED_COROUTINE( player ); _ON_PLAYER_CNCT_END @@ -119,14 +120,8 @@ jumper() } } -onPlayerSpawned() -{ - GENERIC_COROUTINE_END; - - while ( true ) - { - self waittill( "spawned_player" ); +_ON_PLAYER_SPAWNED_BEGIN self setPerk( "specialty_marathon", true, false ); - } -} + +_ON_PLAYER_SPAWNED_END diff --git a/iw5/scripts/mp/_utility.gsh b/iw5/scripts/mp/_utility.gsh index fd4cb7e..0506e39 100644 --- a/iw5/scripts/mp/_utility.gsh +++ b/iw5/scripts/mp/_utility.gsh @@ -55,6 +55,21 @@ } \ } +#define _ON_PLAYER_SPAWNED_COROUTINE(ent) \ + ent thread onPlayerSpawned() + +/* Captures a "spawned" event. Perform your action(s) using the "self" variable */ +#define _ON_PLAYER_SPAWNED_BEGIN onPlayerSpawned() \ + { \ + GENERIC_COROUTINE_END \ + while ( true ) \ + { \ + self waittill( "spawned_player" ); + +#define _ON_PLAYER_SPAWNED_END \ + } \ + } + /* IW4x MP has printConsole Built-in. __VA_OPT__ requires C++20 compliant preprocessor */ /* Do not use the + to concatenate strings, let the GSC VM do it for you */ /* Other clients will have print available */