Raised This Month: $51 Target: $400
 12% 

[Alien Swarm] Finding current equipped weapon name


Post New Thread Reply   
 
Thread Tools Display Modes
comp_noob
Senior Member
Join Date: Nov 2010
Old 11-30-2010 , 10:35   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #21

it's my pleasure to help you, as i'm not only helping myself, i will also be helping all the other alien swarm plugin producers out there will be reporting any bugs i find again soon.

EDIT: it's good, Swarm_GetMarine(client), Swarm_GetClientOfMarine(marine), Swarm_GetMarineResFromCommander(client) & Swarm_GetMarineResOfMarine(marine) are working as expected. will be testing out the other commands... by the way, what is the resouce entity index for? and also, is OnGameFrame working for alien swarm? =S i can't get it to work...
will continue the testing tmr, needa catch some sleep first...

Last edited by comp_noob; 11-30-2010 at 12:11.
comp_noob is offline
comp_noob
Senior Member
Join Date: Nov 2010
Old 11-30-2010 , 23:08   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #22

i created a list of weapon classname for alien swarm, might be useful for future plugins writers.. here it is, psychonic, if u can add it to the sourcemod wiki, it will be best..
PHP Code:
slot 0 1:
asw_weapon_rifle (98 rounds5 clips5 Frag Grenades) [22A3-1 Assault Rifle]
asw_weapon_prifle (98 rounds5 clips5 Stun Grenades) [22A7-Z Prototype Assault Rifle]
asw_weapon_autogun (250 rounds1 clip) [S23A SynTek Autogun]
asw_weapon_vindicator (14 rounds5 clips5 Incendiary Grenades) [M42 Vindicator]
asw_weapon_pistol (24 rounds10 clips) [M73 Twin Pistols]
asw_weapon_sentry (450 rounds) [IAF Advanced Sentry Gun]
asw_weapon_heal_grenade (8 rounds default) [Heal Beacon]
asw_weapon_ammo_satchel (3 rounds) [IAF Ammo Satchel]
asw_weapon_shotgun (4 rounds8 clips) [Model 25 Pump-action Shotgun]
asw_weapon_tesla_gun (20 rounds13 clips) [IAF Tesla Cannon]
asw_weapon_railgun (1 round72 clips) [Precision Rail Rifle]
asw_weapon_heal_gun (80 rounds) [IAF Medical Gun]
asw_weapon_pdw (80 rounds11 clips) [K80 Personal Defense Weapon]
asw_weapon_flamer (40 rounds5 clipsFire Extinguisher) [M868 Flamer Unit]
asw_weapon_sentry_freeze (800 rounds) [IAF Freeze Sentry Gun]
asw_weapon_minigun (250 rounds1 clipBarrel Spin-up) [IAF Minigun]
asw_weapon_sniper_rifle (12 rounds5 clipsEnhanced Target Imaging)[AVK-36 Marksman Rifle]
asw_weapon_sentry_flamer (800 rounds) [IAF Incendiary Sentry Gun]
asw_weapon_chainsaw (Infinite) [Chainsaw]
asw_weapon_sentry_cannon (25 rounds) [IAF High Velocity Sentry Cannon]
asw_weapon_grenade_launcher (6 rounds3 clips) [Grenade Launcher]

Slot 2:
asw_weapon_medkit (1 round) [IAF Personal Healing Kit]
asw_weapon_welder (Infinite) [Hand Welder]
asw_weapon_flares (15 rounds) [SM75 Comabt Flares]
asw_weapon_laser_mines (12 rounds) [ML30 Laser Trip Mine]
asw_weapon_normal_armor (Infinite) [I3a Tactical Heavy Armor]
asw_weapon_buff_grenade (5 rounds) [X33 Damage Amplifier]
asw_weapon_hornet_barrage (3 rounds) [Hornet Barrage]
asw_weapon_freeze_grenades (5 rounds) [Freeze Grenade]
asw_weapon_stim (3 rounds) [Adrenaline]
asw_weapon_tesla_trap (3 rounds) [IAF Tesla Sentry Coil]
asw_weapon_electrified_armor (Infinite3 Electric Charges) [v45 Electric Charged Armor]
asw_weapon_mines (5 rounds) [M478 Proximity Incendiary Mine]
asw_weapon_flashlight (Infinite) [Flashlight Attachment]
asw_weapon_fist (Infinite) [IAF Power Fist Attachment]
asw_weapon_grenades (5 rounds) [Hand Grenades]
asw_weapon_night_vision (Rechargable) [MNV34 Nightvision Goggles]
asw_weapon_smart_bomb (1 round) [MTD6 Smart Bomb
next i will be finding out the names of the 3rd equipped slot items as well... but psychonic, do you know the netprop that controls the number of clips a weapon has? i found out that m_iClip1 controls the current amount of ammo, m_iClip2 controls the amount of secondary ammo.. but i didn't seem to be able to find out what controls the number of clips ... and something else, the game keeps logging m_iClip1 changed when i tried changing the ammo... like this:
PHP Code:

Entity 29 
(class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed.
Entity 29 (class 'asw_weapon_prifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed
is there anyway to stop the game from logging these?

EDIT2: error 1: when i tried to add Swarm_GetMarineWeaponSlot(marine, weaponslot),
PHP Code:
// C:\Program Files (x86)\Steam\steamapps\common\alien swarm\swarm\addons\sourcemod\scripting\include\swarmtools.inc(90) : error 017: undefined symbol "weaponOffset"
//
// 1 Error. 
EDIT3: ok, i found out what's causing the error, u missed out a s from the name, it should be "weaponsOffset" instead... after i changed that from the swarmtools.inc, everything is good again..
and, i wan to ask something else, is there an event player_disconnect that we can use? because by using OnClientDisconnect, it is called on every map change, but i want a script to be activated only when a client really disconnected and not just disconnected because of mapchange..

Last edited by comp_noob; 12-01-2010 at 03:11.
comp_noob is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-01-2010 , 07:49   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #23

Quote:
Originally Posted by comp_noob View Post
by the way, what is the resouce entity index for?
It is used to manage the players' marines and share data with the client. Every marine has a marine resource and this is what the plugin uses to lookup the marine/commander relations.

Quote:
Originally Posted by comp_noob View Post
and also, is OnGameFrame working for alien swarm? =S i can't get it to work...
It should be working. Been a while since I messed with AS, but if it hibernates between games like l4d does, no frames are processed during hibernation.
psychonic is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-01-2010 , 07:54   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #24

Quote:
Originally Posted by comp_noob View Post
psychonic, if u can add it to the sourcemod wiki, it will be best..
The nice thing about the wiki is that anyone can edit it ;) You can log in with your forum account.
Quote:
Originally Posted by comp_noob View Post
but psychonic, do you know the netprop that controls the number of clips a weapon has?
Player's ammo amount of that type divided by weapon clip size(?)

Quote:
Originally Posted by comp_noob View Post
the game keeps logging m_iClip1 changed when i tried changing the ammo...
is there anyway to stop the game from logging these?
What code are you using to change it?

Quote:
Originally Posted by comp_noob View Post
EDIT2: error 1: when i tried to add Swarm_GetMarineWeaponSlot(marine, weaponslot),
PHP Code:
// C:\Program Files (x86)\Steam\steamapps\common\alien swarm\swarm\addons\sourcemod\scripting\include\swarmtools.inc(90) : error 017: undefined symbol "weaponOffset"
//
// 1 Error. 
EDIT3: ok, i found out what's causing the error, u missed out a s from the name, it should be "weaponsOffset" instead... after i changed that from the swarmtools.inc, everything is good again..
Thanks, I'll fix that when I'm able to post an update later today.

Quote:
Originally Posted by comp_noob View Post
and, i wan to ask something else, is there an event player_disconnect that we can use? because by using OnClientDisconnect, it is called on every map change, but i want a script to be activated only when a client really disconnected and not just disconnected because of mapchange..
That is normal. When a mapchange happens (in any Source game), clients are disconnected and told to reconnect. Hooking the "player_disconnect" event should let you know when players are actually choosing to disconnect.
psychonic is offline
comp_noob
Senior Member
Join Date: Nov 2010
Old 12-01-2010 , 08:08   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #25

Quote:
Originally Posted by psychonic View Post
It should be working. Been a while since I messed with AS, but if it hibernates between games like l4d does, no frames are processed during hibernation.
well, i was trying to make a plugin that enables infinite ammo for the marines... but it doesn't work when i'm using OnGameFrame() to edit... here's my current infinite ammo script:
PHP Code:
public Action:OnPlayerRunCmd(i_Client, &i_Buttons, &i_ImpulseFloat:f_Velocity[3], Float:f_Angles[3], &i_Weapon)
{
    if (
IAMMOPLAYER[i_Client])
    {
        if (
i_Buttons IN_ATTACK)
        {
            
decl marineidweaponentidclippriclipsec;
            
marineid Swarm_GetMarine(i_Client);
            
weaponentid GetEntPropEnt(marineidProp_Send"m_hActiveWeapon");
            if (
weaponentid != -1)
            {
                
clippri GetEntProp(weaponentidProp_Send"m_iClip1");
                
clipsec GetEntProp(weaponentidProp_Send"m_iClip2");
                if (
clippri != -&& clippri 250)
                {
                    
SetEntProp(weaponentidProp_Send"m_iClip1"250);
                }
                if (
clipsec != -&& clipsec 2)
                {
                    
SetEntProp(weaponentidProp_Send"m_iClip2"10);
                }
            }
        }
    }

but, the game keeps logging the changes, making my whole console full of the logs... like this:
PHP Code:
Entity 29 (class 'asw_weapon_rifle'reported ENTITY_CHANGE_NONE but 'm_iClip1' changed
ok, i realised that when i changed to OnGameFrame(), it still produces a log of the entity prop change.... anyway to remove that annoying log though? anyways, all the functions in the swarmtools.inc and swarmtools.smx are working, fully working! good job

Last edited by comp_noob; 12-01-2010 at 10:24.
comp_noob is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-02-2010 , 08:00   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #26

Quote:
Originally Posted by comp_noob View Post
anyway to remove that annoying log though?
With SetEntProp, the entity is not marked as changed.

Try this:
Code:
// Globals new clip1offset, clip2offset; // in OnPluginStart // lookup the offsets of the clip vars from CBaseCombatWeapon, a class all of the weapons inherit from clip1offset = FindSendPropInfo("CBaseCombatWeapon", "m_iClip1"); clip2offset = FindSendPropInfo("CBaseCombatWeapon", "m_iClip2"); // to set clip // SetEntData(entity, offset, any:value, size=4, bool:changeState=false); // we'll use size=1 since 8 bits==1 bytes //  -Member: m_iClip1 (offset 1272) (type integer) (bits 8) //  -Member: m_iClip2 (offset 1276) (type integer) (bits 8) SetEntData(weapon, clip1offset, amount, 1, true); SetEntData(weapon, clip2offset, amount, 1, true);
psychonic is offline
comp_noob
Senior Member
Join Date: Nov 2010
Old 12-02-2010 , 09:09   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #27

Quote:
Originally Posted by psychonic View Post
With SetEntProp, the entity is not marked as changed.

Try this:
Code:
// Globals new clip1offset, clip2offset;

// in OnPluginStart // lookup the offsets of the clip vars from CBaseCombatWeapon, a class all of the weapons inherit from clip1offset = FindSendPropInfo("CBaseCombatWeapon", "m_iClip1");
clip2offset = FindSendPropInfo("CBaseCombatWeapon", "m_iClip2");

// to set clip // SetEntData(entity, offset, any:value, size=4, bool:changeState=false); // we'll use size=1 since 8 bits==1 bytes // -Member: m_iClip1 (offset 1272) (type integer) (bits // -Member: m_iClip2 (offset 1276) (type integer) (bits SetEntData(weapon, clip1offset, amount, 1, true);
SetEntData(weapon, clip2offset, amount, 1, true);

ok, will try it later.. but anyway, on one of your post, u said that you know of a way to make a menu like panel or something, are you able to redo it? because alien swarm is missing the vgui for doing both menus and panels, and without them it's hard to do some stuff... like weapon spawner and such...

EDIT: wow, you really hit the spot! using setentdata really stops the logs! cool~

EDIT 2: another problem again -.- why is ongameframe active event when the game has not started and is in the preparations screen? this happens when i complete a mission and goes on to the next... i understand that all the commands can be entered when in the preparations screen, but, ongameframe is trying to set the clips even when there are no marines created yet, resulting in heavy lag and lots of errors spewing in the console, like these:
PHP Code:

L 12
/02/2010 23:23:44: [SMDisplaying call stack trace for plugin "ready.smx":
L 12/02/2010 23:23:44: [SM]   [0]  Line 602ready.sp::OnGameFrame()
L 12/02/2010 23:23:44: [SMNative "GetEntDataEnt2" reportedEntity -(-1is invalid
L 12
/02/2010 23:23:44: [SMDisplaying call stack trace for plugin "swarmtools.smx":
L 12/02/2010 23:23:44: [SM]   [0]  Line 78swarmtools.sp::GetMarine()
L 12/02/2010 23:23:44: [SMNative "Swarm_GetMarine" reportedError encountered while processing a dynamic native 
is there any way to prevent ongameframe from processing when the game in preparations stage and no marines are spawned yet?

Last edited by comp_noob; 12-02-2010 at 10:26.
comp_noob is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-02-2010 , 12:05   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #28

Quote:
Originally Posted by comp_noob View Post
ok, will try it later.. but anyway, on one of your post, u said that you know of a way to make a menu like panel or something, are you able to redo it? because alien swarm is missing the vgui for doing both menus and panels, and without them it's hard to do some stuff... like weapon spawner and such...
You'll probably just have to get by with commands for now. I don't currently have time to work on it.

Quote:
Originally Posted by comp_noob View Post
EDIT 2: another problem again -.- why is ongameframe active event when the game has not started and is in the preparations screen? this happens when i complete a mission and goes on to the next... i understand that all the commands can be entered when in the preparations screen, but, ongameframe is trying to set the clips even when there are no marines created yet, resulting in heavy lag and lots of errors spewing in the console, like these:
PHP Code:

L 12
/02/2010 23:23:44: [SMDisplaying call stack trace for plugin "ready.smx":
L 12/02/2010 23:23:44: [SM]   [0]  Line 602ready.sp::OnGameFrame()
L 12/02/2010 23:23:44: [SMNative "GetEntDataEnt2" reportedEntity -(-1is invalid
L 12
/02/2010 23:23:44: [SMDisplaying call stack trace for plugin "swarmtools.smx":
L 12/02/2010 23:23:44: [SM]   [0]  Line 78swarmtools.sp::GetMarine()
L 12/02/2010 23:23:44: [SMNative "Swarm_GetMarine" reportedError encountered while processing a dynamic native 
is there any way to prevent ongameframe from processing when the game in preparations stage and no marines are spawned yet?
There may be some event you can hook for marines existing and being destroyed; I haven't looked much at the events yet.

Regardless, you should be checking that the return of Swarm_GetMarine isn't -1. Per the docs, "Marine entity index or -1 for none or not found".

On a side note, I have posted the SwarmTools plugin in the New Plugins section and also added even more natives to give marine versions of client-only functions in sdktools, such as slap, slay, eye angles, equip weapon, drop weapon. I also added functions for triggering and curing infestation.
psychonic is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 12-02-2010 , 17:43   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #29

Quote:
Originally Posted by psychonic View Post
With SetEntProp, the entity is not marked as changed.

Try this:
Code:
// Globals new clip1offset, clip2offset; // in OnPluginStart // lookup the offsets of the clip vars from CBaseCombatWeapon, a class all of the weapons inherit from clip1offset = FindSendPropInfo("CBaseCombatWeapon", "m_iClip1"); clip2offset = FindSendPropInfo("CBaseCombatWeapon", "m_iClip2"); // to set clip // SetEntData(entity, offset, any:value, size=4, bool:changeState=false); // we'll use size=1 since 8 bits==1 bytes //  -Member: m_iClip1 (offset 1272) (type integer) (bits 8) //  -Member: m_iClip2 (offset 1276) (type integer) (bits 8) SetEntData(weapon, clip1offset, amount, 1, true); SetEntData(weapon, clip2offset, amount, 1, true);
Code:
// Globals new clip1offset, clip2offset; // in OnPluginStart // lookup the offsets of the clip vars from CBaseCombatWeapon, a class all of the weapons inherit from clip1offset = FindSendPropInfo("CBaseCombatWeapon", "m_iClip1"); clip2offset = FindSendPropInfo("CBaseCombatWeapon", "m_iClip2"); // to set clip // SetEntProp provides extra safety, using it is good. SetEntProp(weapon, Prop_Send, "m_iClip1", amount); ChangeEdictState(weapon, clip1offset); SetEntProp(weapon, Prop_Send, "m_iClip2", amount); ChangeEdictState(weapon, clip2offset);
SetEntProp provides extra safety, still using it is good.
Still needs the manual lookups in advance though, in order to avoid resending the entire edict across the network.
__________________
asherkin is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-02-2010 , 20:22   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #30

Quote:
Originally Posted by asherkin View Post
Still needs the manual lookups in advance though, in order to avoid resending the entire edict across the network.
That's why I just used SetEntData. It saves two native calls (per clip, 4 total per frame in this case) and also saves from SM having to lookup the offset again (direct or from cache).
psychonic is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:17.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode