Raised This Month: $32 Target: $400
 8% 

[FAQ]armoury_entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-02-2014 , 05:20   [FAQ]armoury_entity
Reply With Quote #1


I've seen a number of questions related to this topic, so I thought that such a FAQ is welcome.

What is an armoury_entity ? armoury_entity is the weapons that is spawned on the ground (like in fy_snow). This does not include the dropped weapons which are weaponboxes. If you pickup an armoury_entity and drop, it will be no longer an armoury_entity, but an weaponbox ent. An armoury_entity can hold more than one weapon.

Before you begin you need to know the armoury_entity indexs, this is what you will use.

Code:
enum
{
	ARM_MP5, //0
	ARM_TMP,
	ARM_P90,
	ARM_MAC10,
	ARM_AK47,
	ARM_SG552,
	ARM_M4A1,
	ARM_AUG,
	ARM_SCOUT,
	ARM_G3SG1,
	ARM_AWP,
	ARM_M3,
	ARM_XM1014,
	ARM_M249,
	ARM_FLASHBANG,
	ARM_HEGRENADE,
	ARM_KEVLAR,
	ARM_ASSAULT,
	ARM_SMOKEGRENADE //18
}
You can name them whatever you want, but I choosed ARM_WPNNAME. The first one is 0 and the last one is 18.

The models for armoury_entity:
Code:
"models/w_mp5.mdl",       
"models/w_tmp.mdl",        
"models/w_p90.mdl",    
"models/w_mac10.mdl",       
"models/w_ak47.mdl",       
"models/w_sg552.mdl",       
"models/w_m4a1.mdl",       
"models/w_aug.mdl",        
"models/w_scout.mdl",      
"models/w_g3sg1.mdl",      
"models/w_awp.mdl",         
"models/w_m3.mdl",          
"models/w_xm1014.mdl",    
"models/w_m249.mdl",        
"models/w_flashbang.mdl",   
"models/w_hegrenade.mdl",  
"models/w_kevlar.mdl",
"models/w_assault.mdl",     
"models/w_smokegrenade.mdl"
Note that you can't have armoury_entity with c4, knife, pistols, famas and galil.

Some offset that we will use:
Code:
const XO_CArmoury = 4 //diff windows/linux const m_iType = 34 // armoury_entity index( see above enum ) const m_iCount = 35// hold the number of weapons that the armoury_entity will have

Ok, let's begin:

1.Hook touch with an armoury_entity:
Code:
#include <hamsandwich> #include <cstrike> //Hook as pre RegisterHam(Ham_Touch, "armoury_entity", "CBaseEntity_Touch", false) public CBaseEntity_Touch( iTouched, iToucher ) {         //iTouched is the armoury_entity that is touched         //iToucher is the entity index that touch the armoury_entity. It is not 100% a player, you need to check it's classname or use engine's register_touch with allow you to specify the toucher class too.     new armouryIndex = cs_get_armoury_type(iTouched)         //If you need to block return HAM_SUPERCEDE         //If you need to block just for one weapon check if armouryIndex is what you want and supercede        //cs_get_armoury_type return CSW_ indexs and not the one from the above list. }

2.Create an armoury entity:
Code:
enum {     ARM_MP5, //0     ARM_TMP,     ARM_P90,     ARM_MAC10,     ARM_AK47,     ARM_SG552,     ARM_M4A1,     ARM_AUG,     ARM_SCOUT,     ARM_G3SG1,     ARM_AWP,     ARM_M3,     ARM_XM1014,     ARM_M249,     ARM_FLASHBANG,     ARM_HEGRENADE,     ARM_KEVLAR,     ARM_ASSAULT,     ARM_SMOKEGRENADE //18 } stock CreateArmouryEntity( itemType, itemCount, Float: fOrigin[ ] ) {     new armouryEnt = create_entity("armoury_entity")     if(!armouryEnt)     {         return -1     }         if(itemType < ARM_MP5 || itemType > ARM_SMOKEGRENADE)     {         return -1     }         set_pev(armouryEnt, pev_origin, fOrigin)     set_pdata_int(armouryEnt, m_iType, itemType, XO_CArmoury)     set_pdata_int(armouryEnt, m_iCount, itemCount, XO_CArmoury)     dllfunc(DLLFunc_Spawn, armouryEnt)     return armouryEnt }
itemType is the index from the above enum( ARM_ )
itemCount is the number of the weapons that the armoury entity will hold.
fOrigin is the origin where the armoury_entity will be spawned.
The stock above will return -1 on failure/ the armoury index otherwise.

3.Remove all armoury_entity from the map:
Code:
new armouryEnt = -1 while((armouryEnt = find_ent_by_class(armouryEnt, "armoury_entity")) {     remove_entity(armouryEnt) }

I'm waiting for suggestion and comments.

Please check this post: https://forums.alliedmods.net/showpo...8&postcount=10 in order to find out how armoury entities are hidden when they contain 0 weapons and how they are restored.
__________________

Last edited by HamletEagle; 07-26-2015 at 03:25.
HamletEagle is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 11-02-2014 , 07:13   Re: [FAQ]armoury_entity
Reply With Quote #2

Good tutorial. Though AFAIK you don't need to use the models enum. Using this should be enough:

PHP Code:
    //cs_set_armoury_type(armouryEnt, itemType)
    
ExecuteHamB(Ham_SpawnarmouryEnt
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.

Last edited by bibu; 11-02-2014 at 07:13.
bibu is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-02-2014 , 07:20   Re: [FAQ]armoury_entity
Reply With Quote #3

It seems that you are right, game sets the model on it's own. But I'll let the model list, in case someone wants to know.
__________________

Last edited by HamletEagle; 11-02-2014 at 07:22.
HamletEagle is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-02-2014 , 07:45   Re: [FAQ]armoury_entity
Reply With Quote #4

I thought defines were existing for armoury_entity, but I guess it's defined only in cstrike module. It would be probably welcomed to define that in amxconst.inc as well.
__________________

Last edited by Arkshine; 11-02-2014 at 07:45.
Arkshine is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 11-03-2014 , 06:04   Re: [FAQ]armoury_entity
Reply With Quote #5

You shouldn't set origin with set_pev.
Is there a way to set ammo for weapon inside that ent? Or, what happens when setting more than one count? Also, how to set other weapons in armoury entity? I'm not sure, but if I remember correctly, via valve hammer editor you could set weapon, then count, then set other weapon and it's count (I could be wrong, did mapping long time ago, will check later).
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-03-2014 , 10:42   Re: [FAQ]armoury_entity
Reply With Quote #6

No, it's perfectly fine with set_pev. EngFunc_SetOrigins is usefull for linking the entity with the world, I don't think this is needed now, so we can reduce the code that is called internally.

I don't think you can change the default ammo directly, like an offset, will check that.
__________________
HamletEagle is offline
Aydeev
Junior Member
Join Date: Oct 2014
Old 01-12-2015 , 18:39   Re: [FAQ]armoury_entity
Reply With Quote #7

Quote:
Originally Posted by HamletEagle View Post


3.Remove all armoury_entity from the map:

Code:
      new armouryEnt = -1 while((armouryEnt = find_ent_by_class(armouryEnt, "armoury_entity")) { &nbsp;&nbsp;&nbsp;&nbsp;remove_entity(armouryEnt) }
Why does this remove the entities for the remainder of the map? Since picked up weapons respawn each round I would have thought removing them would make them reappear again next round.

I want to remove all armoury_entity entities for round 1 only since we play a map that only gives the Terror team AKs and that gives them an unfair advantage in the first round

Last edited by Aydeev; 01-12-2015 at 18:41.
Aydeev is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 01-15-2015 , 20:34   Re: [FAQ]armoury_entity
Reply With Quote #8

Quote:
Originally Posted by Aydeev View Post
Why does this remove the entities for the remainder of the map? Since picked up weapons respawn each round I would have thought removing them would make them reappear again next round.

I want to remove all armoury_entity entities for round 1 only since we play a map that only gives the Terror team AKs and that gives them an unfair advantage in the first round
PHP Code:
new armouryEnt = -1
while((armouryEnt find_ent_by_class(armouryEnt"armoury_entity"))
{
    
set_pdata_int(armouryEntm_iCount0XO_CArmoury);
    
set_pev(armouryEntpev_effectspev(armouryEntpev_effects) | EF_NODRAW);

__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 01-15-2015 , 20:50   Re: [FAQ]armoury_entity
Reply With Quote #9

Quote:
Originally Posted by meTaLiCroSS View Post
PHP Code:
new armouryEnt = -1
while((armouryEnt find_ent_by_class(armouryEnt"armoury_entity"))
{
    
set_pdata_int(armouryEntm_iCount0XO_CArmoury);
    
set_pev(armouryEntpev_effectspev(armouryEntpev_effects) | EF_NODRAW);

So remove_entity/remove_entity_by_name will prevent them from spawning again in the rounds after entirely?
RateX is offline
Aydeev
Junior Member
Join Date: Oct 2014
Old 01-19-2015 , 13:12   Re: [FAQ]armoury_entity
Reply With Quote #10

Quote:
Originally Posted by meTaLiCroSS View Post
PHP Code:
new armouryEnt = -1
while((armouryEnt find_ent_by_class(armouryEnt"armoury_entity"))
{
    
set_pdata_int(armouryEntm_iCount0XO_CArmoury);
    
set_pev(armouryEntpev_effectspev(armouryEntpev_effects) | EF_NODRAW);

Thank you!
Aydeev is offline
Reply


Thread Tools
Display Modes

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 16:10.


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