#include <acknex.h>
#include "inventory.c"
#define PRAGMA_PATH "%EXE_DIR%\\templates\\sounds"
#define PRAGMA_PATH "%EXE_DIR%\\templates\\images"
#define PRAGMA_PATH "%EXE_DIR%\\templates\\models"
#define MAIN_BAG_ID 1
#define ACTIV_WPN_SLOT_ID 0
#define SNIPERGUN 0
#define SHOTGUN 1
#define MACHINEGUN 2
SOUND *sndReload = "reload.wav";
ENTITY *active_weapon = NULL;
function slot_was_clicked ( int occurrence, int bag_id, int slot_id, int placed_item_id, int removed_item_id )
{
if ( ( occurrence == INV_ITEM_REMOVED ) || ( occurrence == INV_ITEM_SWAPPED ) )
{
if (bag_id == MAIN_BAG_ID)
{
if (slot_id == ACTIV_WPN_SLOT_ID)
{
ent_remove ( active_weapon );
active_weapon = NULL;
}
}
}
if ( ( occurrence == INV_ITEM_PLACED ) || ( occurrence == INV_ITEM_SWAPPED ) )
{
if (bag_id == MAIN_BAG_ID)
{
if (slot_id == ACTIV_WPN_SLOT_ID)
{
snd_play ( sndReload, 100, 0 );
switch ( placed_item_id )
{
case SNIPERGUN: active_weapon = ent_create ( "snipergun.mdl", nullvector, NULL ); break;
case SHOTGUN: active_weapon = ent_create ( "shotgun.mdl", nullvector, NULL ); break;
case MACHINEGUN: active_weapon = ent_create ( "machinegun.mdl", nullvector, NULL ); break;
}
}
}
}
}
function main()
{
mouse_mode = 4;
inv_init();
wait(1);
level_load ( "" );
camera->x = -150;
Item *gun1 = inv_create_item ( SNIPERGUN, 1, "icon2.pcx", "icon2.pcx" );
Item *gun2 = inv_create_item ( SHOTGUN, 1, "icon3.pcx", "icon3.pcx" );
Item *gun3 = inv_create_item ( MACHINEGUN, 1, "icon4.pcx", "icon4.pcx" );
Bag *bag = inv_create_bag ( MAIN_BAG_ID,"bluebar.pcx");
inv_add_slot_to_bag ( bag, ACTIV_WPN_SLOT_ID, 1, "flash2.tga", 0, 0 );
inv_add_slot_to_bag(bag,1,0,"flash2.tga",0,120);
inv_add_slot_to_bag(bag,2,0,"flash2.tga",0,180);
inv_add_slot_to_bag(bag,3,0,"flash2.tga",0,240);
set_on_click_callback ( "slot_was_clicked" );
inv_insert_item_into_bag ( bag, gun1 );
inv_insert_item_into_bag ( bag, gun2 );
inv_insert_item_into_bag ( bag, gun3 );
inv_open_bag ( bag, 0, 0 );
while ( !key_esc )
{
if ( active_weapon != NULL )
active_weapon->pan += 5*time_step;
wait(1);
}
sys_exit ( NULL );
}