Skip to content

Commit

Permalink
Added function for temporally blocking a player's melee.
Browse files Browse the repository at this point in the history
Note: this will also prevent the player from firing/reloading/aiming his weapon. And weapon switching will be delayed too.
  • Loading branch information
M-itch committed May 21, 2015
1 parent 6dee9a7 commit c388945
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions gsc.cpp
Expand Up @@ -376,6 +376,7 @@ Scr_Method scriptMethods[] = {
{"resetNextReliableTime" , gsc_player_resetNextReliableTime, 0},
{"setg_speed" , gsc_player_setg_speed , 0},
{"setg_gravity" , gsc_player_setg_gravity , 0},
{"setweaponfiremeleedelay", gsc_player_setweaponfiremeleedelay, 0},
#if COD_VERSION < COD4_1_7
{"setmovespeedscale" , gsc_player_setmovespeedscale , 0},
{"ismantling" , gsc_player_ismantling , 0},
Expand Down
20 changes: 20 additions & 0 deletions gsc_player.cpp
Expand Up @@ -687,6 +687,26 @@ void hook_player_g_speed(int client) {
calc_client_speed(client);
}

void gsc_player_setweaponfiremeleedelay(int id) {
int delay;
if ( ! stackGetParams("i", &delay)) {
printf("scriptengine> ERROR: gsc_player_setweaponfiremeleedelay(): param \"delay\"[1] has to be an int!\n");
stackPushUndefined();
return;
}

if(delay < 0) {
printf("scriptengine> ERROR: gsc_player_setweaponfiremeleedelay(): param \"delay\"[1] must be equal or above zero!\n");
stackPushUndefined();
return;
}

int state = PLAYERSTATE(id);
int* weapondelay = (int *)(state + 0x34);
*weapondelay = delay;
*(int *)(state + 216) = 11;
}

// entity functions (could be in own file, but atm not many pure entity functions)

void gsc_entity_setalive(int id) { // as in isAlive?
Expand Down
1 change: 1 addition & 0 deletions gsc_player.hpp
Expand Up @@ -57,6 +57,7 @@ void hook_player_g_speed(int client);
void gsc_player_setmovespeedscale(int id);
void gsc_player_setg_speed(int id);
void gsc_player_setg_gravity(int id);
void gsc_player_setweaponfiremeleedelay(int id);

// entity functions
void gsc_entity_setalive(int id);
Expand Down

0 comments on commit c388945

Please sign in to comment.