IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> m_iAmmoIndex in TF2WeaponsData_t
J@nek
post Jun 22 2009, 03:43 PM
Post #1


Member
**

Group: Members
Posts: 19
Joined: 18-May 09
Member No.: 1,541



Hi,

I'm trying to understand to what m_iAmmoIndex is refering to in the weapons data structure. Here is the structure:
typedef struct
{
int iSlot;
int iId;
const char *szWeaponName;
int m_iFlags;
float minPrimDist;
float maxPrimDist;
int m_iAmmoIndex;
int m_iPreference;
}TF2WeaponsData_t;

Of course, my first thought was that it was corresponding to AmmoIndex that we have in our mod meaning that if I have a specific ammo for each weapons, I should have a different index and normally 0 is not used.

What I don't understand is that for TF2 you did this table of indexes for weapons :
int m_TF2AmmoIndices[] =
{
0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,2,2,2,2,1,1,2,1,2,2,0,2,1,1,3
};

where we can see very often the same values and very often 0. Does it mean that all weapons referencing a value > 0 are referencing the same type of ammo and that for all weapons with 0 it is automatic ?

I'm interested by all explainations about that.

Thank you in advance.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Cheeseh
post Jun 22 2009, 08:16 PM
Post #2


Admin
*****

Group: Admin
Posts: 3,056
Joined: 11-September 03
From: uk
Member No.: 1



Every bot has an ammo array of the ammo it has. The array has about 3-4 elements, each of these elements relate to a weapon, the ammo for that weapon is stored in that array,
The ammo index is the array index where the Ammo for the particular weapon's ammo is stored

all this e.g.

CODE

index
0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3
0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1
----------------------------------------------------------------------
ammo index
0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,2,2,2,2,1,1,2,1,2,2,0,2,1,1,3


weapon 0 is TF2_WEAPON_BAT and the ammo index for that is 0, because it is melee there is no ammo, it is the same for all melee weapons that need no ammo

The minigun is 12 which has weapon index 1, so this contains a different position in the bots ammo array

don't know how to explain well.. but this stufff is better untouched for now anyway
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
J@nek
post Jun 23 2009, 09:30 AM
Post #3


Member
**

Group: Members
Posts: 19
Joined: 18-May 09
Member No.: 1,541



1) I understand your explaination which is what I initially thought but I still have things that I don't understand. My mod is using HL2DM weapons. In HL2DM, weapons are mainly using different types of ammo and then different repository: I can't use ammo of smg1 for ar2 so I assume I must have a specific ammoindex for each weapons except melee. Am I right ?

When looking at your explainations, I understand that all weapons refering to the same ammoindex are sharing the same ammo repository. Am I right ? It is weird as it is saying that "flametrower", "grenadelauncher" and "pistol" use the same ammo ??? I don't think so.

2) Also, I have an other question about weapons having primary AND secondary fire. How is it possible to specify both states ? I saw the WEAP_FL_SEC_ATTACK but don't know how to define 2 states for the same weapon :
{2, WEAPON_SMG1, "weapon_smg1", WEAP_FL_KILLPIPEBOMBS|WEAP_FL_PRIM_ATTACK,0,1000,4,3}
{2, WEAPON_SMG1, "weapon_smg1", WEAP_FL_EXPLOSIVE|WEAP_FL_SEC_ATTACK,0,500,?,3} <-- I don't think I can use same index and name

J.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Cheeseh
post Jun 23 2009, 11:29 AM
Post #4


Admin
*****

Group: Admin
Posts: 3,056
Joined: 11-September 03
From: uk
Member No.: 1



QUOTE(J@nek @ Jun 23 2009, 10:30 AM) *

1) I understand your explaination which is what I initially thought but I still have things that I don't understand. My mod is using HL2DM weapons. In HL2DM, weapons are mainly using different types of ammo and then different repository: I can't use ammo of smg1 for ar2 so I assume I must have a specific ammoindex for each weapons except melee. Am I right ?

When looking at your explainations, I understand that all weapons refering to the same ammoindex are sharing the same ammo repository. Am I right ? It is weird as it is saying that "flametrower", "grenadelauncher" and "pistol" use the same ammo ??? I don't think so.


No. The ammo index is just the array index of an array for the bot's current weapons it is holding, in TF2 all bots have at least 4 weapons, so there are 4 integers that relate to the ammo it has. This is in the m_iAmmo array [0,1,2,3] , 0 is typically the melee weapon (which for scout may be the bat), 1 may be the ammo for the weapon in slot 1 (for the scout may be the pistol), then 2 for slot 2 (shotgun for scout for e.g.), and so on, ... for the purposes of the bot I just link the weapon name, and weapon ID with the ammo slot, so they can quickly check how much ammo they have left.

With HL2DM I have no idea how the ammo is done, I never got to this stage. I'm guessing that's what you're trying to implement now. I'm guessing that :

m_iAmmo = CClassInterface::getAmmoList(m_pEdict);

may return a bigger array, but don't know what will be stored in it exactly.

QUOTE(J@nek @ Jun 23 2009, 10:30 AM) *

2) Also, I have an other question about weapons having primary AND secondary fire. How is it possible to specify both states ? I saw the WEAP_FL_SEC_ATTACK but don't know how to define 2 states for the same weapon :
{2, WEAPON_SMG1, "weapon_smg1", WEAP_FL_KILLPIPEBOMBS|WEAP_FL_PRIM_ATTACK,0,1000,4,3}
{2, WEAPON_SMG1, "weapon_smg1", WEAP_FL_EXPLOSIVE|WEAP_FL_SEC_ATTACK,0,500,?,3} <-- I don't think I can use same index and name

J.

like this:

{2, WEAPON_SMG1, "weapon_smg1", WEAP_FL_SEC_ATTACK|WEAP_FL_PRIM_ATTACK,0,1000,4,3}

This little guy is called ORing a bitmask,

WEAP_FL_SEC_ATTACK|WEAP_FL_PRIM_ATTACK

For example:
WEAP_FL_SEC_ATTACK = 1
WEAP_FL_PRIM_ATTACK = 2

in bit form this means
WEAP_FL_SEC_ATTACK = 01
WEAP_FL_PRIM_ATTACK = 10

You can see something happening here,

Possible Values:

Not Primary Attack Or Secondary Attack = 00 (0)
Primary Attack Only = 01 (1 or WEAP_FL_PRIM_ATTACK)
Secondary Attack Only = 10 (2 or WEAP_FL_SEC_ATTACK)
Both Attacks = 11 (3 or WEAP_FL_SEC_ATTACK|WEAP_FL_PRIM_ATTACK)

What this : WEAP_FL_SEC_ATTACK|WEAP_FL_PRIM_ATTACK: is doing is doing an OR

i.e.
01 OR 10 = 11

and,
11 = Both attacks
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
J@nek
post Jun 23 2009, 12:46 PM
Post #5


Member
**

Group: Members
Posts: 19
Joined: 18-May 09
Member No.: 1,541



1) I must investigate. Thank you for the information. Very usefull.

2) In fact, I know about the ORing but this way how can you make a weapon refering to 2 types of ammo. For example for smg1 primaryattack is firing bullets and secondary attack is launching smg1 grenade. With one line only one ammo can be refered.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Cheeseh
post Jun 23 2009, 03:34 PM
Post #6


Admin
*****

Group: Admin
Posts: 3,056
Joined: 11-September 03
From: uk
Member No.: 1



QUOTE(J@nek @ Jun 23 2009, 01:46 PM) *

2) In fact, I know about the ORing but this way how can you make a weapon refering to 2 types of ammo. For example for smg1 primaryattack is firing bullets and secondary attack is launching smg1 grenade. With one line only one ammo can be refered.

In that case you will need to make a seperate "ammoindex" for secondary ammo, this is how it was done in HL1 if I remember correctly, and it is probably the same with HL2.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
J@nek
post Jun 23 2009, 06:31 PM
Post #7


Member
**

Group: Members
Posts: 19
Joined: 18-May 09
Member No.: 1,541



QUOTE(Cheeseh @ Jun 23 2009, 05:34 PM) *

In that case you will need to make a seperate "ammoindex" for secondary ammo, this is how it was done in HL1 if I remember correctly, and it is probably the same with HL2.

Oh OK. Thank you very much for driving me to the current spirit of how the code is currently. Very usefull before adding my own codeline to not break it :-)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 09:30 AM