Skip to content

Commit

Permalink
Starting custom_weapon
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikk155 committed Sep 30, 2024
1 parent bd1e9fc commit 4ae1fe9
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 0 deletions.
Empty file added src/custom_weapon/changelog.md
Empty file.
82 changes: 82 additions & 0 deletions src/custom_weapon/custom_weapon.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#include "../../mikk/json"

namespace custom_weapon
{
bool Register( const string &in JsonFile )
{
json pJson;

if( !pJson.load( JsonFile ) )
g_EngineFuncs.ServerPrint( "WARNING! Failed to load \"" + JsonFile + "\"\n" );

g_ItemRegistry.RegisterWeapon( "custom_weapon::CWeaponBase", pJson[ "txt sprites" ], pJson[ "ammo" ], "", "custom_weapon::CAmmoBase" );
g_CustomEntityFuncs.RegisterCustomEntity( "custom_weapon::CWeaponBase", pJson[ "classname" ] );
}

class CWeaponBase : ScriptBasePlayerWeaponEntity
{
private CBasePlayer@ m_pPlayer = null;

void Spawn()
{

}

void Precache()
{

}

bool GetItemInfo( ItemInfo& out info )
{
return true;
}

bool AddToPlayer(CBasePlayer@ pPlayer)
{
return true;
}

bool PlayEmptySound()
{
return false;
}

bool Deploy()
{
return bResult;
}

void Holster( int skiplocal = 0 )
{
}

void PrimaryAttack()
{
}

void SecondaryAttack()
{
}

void WeaponIdle()
{
}

void Reload()
{
}
}

class CAmmoBase : ScriptBasePlayerAmmoEntity
{
void Spawn()
{
}

bool AddAmmo( CBaseEntity@ pOther )
{
return false;
}
}
}
10 changes: 10 additions & 0 deletions src/custom_weapon/custom_weapon.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"path" "scripts/plugins/mikk/"
"custom_weapon/custom_weapon.as"
"custom_weapon/schema.json"
"custom_weapon/weapon_test.json"
"utils/json.as"
"utils/EntityFuncs.as"
"utils/fft.as"
"utils/PlayerFuncs.as"
"utils/UserMessages.as"
"utils/CustomKeyValues.as"
32 changes: 32 additions & 0 deletions src/custom_weapon/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties":
{
"$schema":
{
"type": "string"
},
"classname":
{
"type": "string",
"description": "Weapon entity classname"
},
"txt sprites":
{
"type": "string",
"description": "Folder to weapon's txt"
},
"ammo":
{
"type": "string",
"description": "Ammo entity"
}
},
"required":
[
"$schema",
"classname"
],
"additionalProperties": false
}
9 changes: 9 additions & 0 deletions src/custom_weapon/weapon_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"classname": "weapon_test",

"txt sprites": "",

"ammo": "ammo_test",

"$schema": "schema.json"
}

0 comments on commit 4ae1fe9

Please sign in to comment.