Skip to content

Commit

Permalink
set clipsize/maxammo for weapons
Browse files Browse the repository at this point in the history
  • Loading branch information
damage99 authored and voron00 committed Jan 13, 2019
1 parent 93148a4 commit 4314cb0
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ scr_function_t scriptFunctions[] =

#if COMPILE_WEAPONS == 1
{"getweaponmaxammo", gsc_weapons_getweaponmaxammo, 0},
{"setweaponmaxammo", gsc_weapons_setweaponmaxammo, 0},
{"getweaponclipsize", gsc_weapons_getweaponclipsize, 0},
{"setweaponclipsize", gsc_weapons_setweaponclipsize, 0},
{"getweapondamage", gsc_weapons_getweapondamage, 0},
{"setweapondamage", gsc_weapons_setweapondamage, 0},
{"getweaponmeleedamage", gsc_weapons_getweaponmeleedamage, 0},
Expand Down
50 changes: 50 additions & 0 deletions gsc_weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,56 @@ void gsc_weapons_setweapondamage()
stackPushBool(qtrue);
}

void gsc_weapons_setweaponmaxammo()
{
int id;
int ammo;

if ( ! stackGetParams("ii", &id, &ammo))
{
stackError("gsc_weapons_setweaponmaxammo() one or more arguments is undefined or has a wrong type");
stackPushUndefined();
return;
}

if (!isValidWeaponId(id))
{
stackError("gsc_weapons_setweaponmaxammo() weapon index is out of bounds");
stackPushUndefined();
return;
}

WeaponDef_t *weapon = BG_WeaponDefs(id);
weapon->iMaxAmmo = ammo;

stackPushBool(qtrue);
}

void gsc_weapons_setweaponclipsize()
{
int id;
int clipSize;

if ( ! stackGetParams("ii", &id, &clipSize))
{
stackError("gsc_weapons_setweaponclipsize() one or more arguments is undefined or has a wrong type");
stackPushUndefined();
return;
}

if (!isValidWeaponId(id))
{
stackError("gsc_weapons_setweaponclipsize() weapon index is out of bounds");
stackPushUndefined();
return;
}

WeaponDef_t *weapon = BG_WeaponDefs(id);
weapon->iClipSize = clipSize;

stackPushBool(qtrue);
}

void gsc_weapons_setweaponmeleedamage()
{
int id;
Expand Down
2 changes: 2 additions & 0 deletions gsc_weapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include "gsc.hpp"

void gsc_weapons_getweaponmaxammo();
void gsc_weapons_setweaponmaxammo();
void gsc_weapons_getweaponclipsize();
void gsc_weapons_setweaponclipsize();
void gsc_weapons_getweapondamage();
void gsc_weapons_setweapondamage();
void gsc_weapons_getweaponmeleedamage();
Expand Down

0 comments on commit 4314cb0

Please sign in to comment.