Skip to content

Commit

Permalink
add setStance() for players
Browse files Browse the repository at this point in the history
Note that old one was renamed to setBotStance()
  • Loading branch information
voron00 committed Oct 24, 2017
1 parent 87b63f3 commit d242a8a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
9 changes: 9 additions & 0 deletions functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1183,4 +1183,13 @@ static const G_LocationalTrace_t G_LocationalTrace = (G_LocationalTrace_t)0x0810
static const G_LocationalTrace_t G_LocationalTrace = (G_LocationalTrace_t)0x0810A5CC;
#endif

typedef void (*G_AddEvent_t)(int ent, int event, int eventParm);
#if COD_VERSION == COD2_1_0
static const G_AddEvent_t G_AddEvent = (G_AddEvent_t)0x0811CDA2;
#elif COD_VERSION == COD2_1_2
static const G_AddEvent_t G_AddEvent = (G_AddEvent_t)0x0811F0D6;
#elif COD_VERSION == COD2_1_3
static const G_AddEvent_t G_AddEvent = (G_AddEvent_t)0x0811F232;
#endif

#endif
3 changes: 2 additions & 1 deletion gsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ scr_method_t scriptMethods[] =

#if COMPILE_PLAYER == 1
{"getStance", gsc_player_stance_get, 0},
{"setStance", gsc_player_stance_set, 0},
{"setVelocity", gsc_player_velocity_set, 0},
{"addVelocity", gsc_player_velocity_add, 0},
{"getVelocity", gsc_player_velocity_get, 0},
Expand Down Expand Up @@ -342,7 +343,7 @@ scr_method_t scriptMethods[] =
#if COMPILE_BOTS == 1
{"setwalkdir", gsc_bots_set_walkdir, 0},
{"setlean", gsc_bots_set_lean, 0},
{"setstance", gsc_bots_set_stance, 0},
{"setbotstance", gsc_bots_set_stance, 0},
{"thrownade", gsc_bots_thrownade, 0},
{"fireweapon", gsc_bots_fireweapon, 0},
{"meleeweapon", gsc_bots_meleeweapon, 0},
Expand Down
31 changes: 31 additions & 0 deletions gsc_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,37 @@ void gsc_player_stance_get(int id)
stackPushString(stance);
}

void gsc_player_stance_set(int id)
{
char* stance;

if ( ! stackGetParams("s", &stance))
{
stackError("gsc_player_stance_set() argument is undefined or has a wrong type");
stackPushUndefined();
return;
}

int event;

if (strcmp(stance, "stand") == 0)
event = EV_STANCE_FORCE_STAND;
else if (strcmp(stance, "crouch") == 0)
event = EV_STANCE_FORCE_CROUCH;
else if (strcmp(stance, "prone") == 0)
event = EV_STANCE_FORCE_PRONE;
else
{
stackError("gsc_player_stance_set() invalid argument '%s'. Valid arguments are: 'stand' 'crouch' 'prone'", stance);
stackPushUndefined();
return;
}

G_AddEvent(G_ENTITY(id), event, 0);

stackPushInt(1);
}

void gsc_player_spectatorclient_get(int id)
{
int spectatorClient = *(unsigned char *)(PLAYERSTATE(id) + 0xCC);
Expand Down
1 change: 1 addition & 0 deletions gsc_player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void gsc_player_button_frag(int id);
void gsc_player_button_smoke(int id);

void gsc_player_stance_get(int id);
void gsc_player_stance_set(int id);

void gsc_player_spectatorclient_get(int id);
void gsc_get_userinfo(int id);
Expand Down

0 comments on commit d242a8a

Please sign in to comment.