2019-06-20 11:22:44 +00:00
|
|
|
#include "common.h"
|
2020-04-17 13:31:11 +00:00
|
|
|
|
2019-06-21 18:16:51 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include "FileMgr.h"
|
2019-06-20 11:22:44 +00:00
|
|
|
#include "WeaponInfo.h"
|
2020-03-28 14:47:52 +00:00
|
|
|
#include "AnimManager.h"
|
2019-06-21 18:16:51 +00:00
|
|
|
#include "AnimBlendAssociation.h"
|
2020-03-28 14:47:52 +00:00
|
|
|
#include "Weapon.h"
|
2020-05-15 14:30:25 +00:00
|
|
|
#include "ModelInfo.h"
|
|
|
|
#include "ModelIndices.h"
|
|
|
|
|
2020-08-27 16:52:43 +00:00
|
|
|
uint16 CWeaponInfo::ms_aReloadSampleTime[WEAPONTYPE_TOTALWEAPONS] =
|
|
|
|
{
|
|
|
|
0, // UNARMED
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0, // GRENADE
|
|
|
|
0, // DETONATEGRENADE
|
|
|
|
0, // TEARGAS
|
|
|
|
0, // MOLOTOV
|
|
|
|
0, // ROCKET
|
|
|
|
250, // COLT45
|
|
|
|
250, // PYTHON
|
|
|
|
650, // SHOTGUN
|
|
|
|
650, // SPAS12 SHOTGUN
|
|
|
|
650, // STUBBY SHOTGUN
|
|
|
|
400, // TEC9
|
|
|
|
400, // UZIhec
|
|
|
|
400, // SILENCED_INGRAM
|
|
|
|
400, // MP5
|
|
|
|
300, // M16
|
|
|
|
300, // AK47
|
|
|
|
423, // SNIPERRIFLE
|
|
|
|
423, // LASERSCOPE
|
|
|
|
400, // ROCKETLAUNCHER
|
|
|
|
0, // FLAMETHROWER
|
|
|
|
0, // M60
|
|
|
|
0, // MINIGUN
|
|
|
|
0, // DETONATOR
|
|
|
|
0, // HELICANNON
|
|
|
|
0 // CAMERA
|
|
|
|
};
|
|
|
|
|
2020-05-15 14:30:25 +00:00
|
|
|
// Yeah...
|
2020-08-27 16:52:43 +00:00
|
|
|
int32 CWeaponInfo::ms_aMaxAmmoForWeapon[WEAPONTYPE_TOTALWEAPONS] =
|
|
|
|
{
|
2020-05-19 14:39:19 +00:00
|
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
2020-05-23 13:53:20 +00:00
|
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1
|
2020-05-15 14:30:25 +00:00
|
|
|
};
|
2019-06-20 11:22:44 +00:00
|
|
|
|
2021-01-23 22:13:40 +00:00
|
|
|
CWeaponInfo aWeaponInfo[WEAPONTYPE_TOTALWEAPONS];
|
2020-08-27 16:52:43 +00:00
|
|
|
char CWeaponInfo::ms_aWeaponNames[WEAPONTYPE_TOTALWEAPONS][32] =
|
|
|
|
{
|
2019-06-21 18:16:51 +00:00
|
|
|
"Unarmed",
|
2020-05-19 14:39:19 +00:00
|
|
|
"BrassKnuckle",
|
|
|
|
"ScrewDriver",
|
|
|
|
"GolfClub",
|
|
|
|
"NightStick",
|
|
|
|
"Knife",
|
2019-06-21 18:16:51 +00:00
|
|
|
"BaseballBat",
|
2020-05-19 14:39:19 +00:00
|
|
|
"Hammer",
|
|
|
|
"Cleaver",
|
|
|
|
"Machete",
|
|
|
|
"Katana",
|
|
|
|
"Chainsaw",
|
2020-05-17 17:36:48 +00:00
|
|
|
"Grenade",
|
|
|
|
"DetonateGrenade",
|
2020-05-23 13:53:20 +00:00
|
|
|
"TearGas",
|
2020-05-17 17:36:48 +00:00
|
|
|
"Molotov",
|
|
|
|
"Rocket",
|
2019-06-21 18:16:51 +00:00
|
|
|
"Colt45",
|
2020-05-23 13:53:20 +00:00
|
|
|
"Python",
|
2020-05-17 17:36:48 +00:00
|
|
|
"Shotgun",
|
2020-05-23 13:53:20 +00:00
|
|
|
"Spas12Shotgun",
|
|
|
|
"StubbyShotgun",
|
2020-05-15 14:30:25 +00:00
|
|
|
"Tec9",
|
2019-06-21 18:16:51 +00:00
|
|
|
"Uzi",
|
2020-05-15 14:30:25 +00:00
|
|
|
"SilencedIngram",
|
|
|
|
"Mp5",
|
2020-05-23 13:53:20 +00:00
|
|
|
"m4",
|
|
|
|
"Ruger",
|
2019-06-21 18:16:51 +00:00
|
|
|
"SniperRifle",
|
2020-05-23 13:53:20 +00:00
|
|
|
"LaserScope",
|
2019-06-21 18:16:51 +00:00
|
|
|
"RocketLauncher",
|
|
|
|
"FlameThrower",
|
2020-05-23 13:53:20 +00:00
|
|
|
"M60",
|
|
|
|
"Minigun",
|
2019-06-21 18:16:51 +00:00
|
|
|
"Detonator",
|
2020-05-15 14:30:25 +00:00
|
|
|
"HeliCannon",
|
2020-05-23 13:53:20 +00:00
|
|
|
"Camera",
|
2019-06-21 18:16:51 +00:00
|
|
|
};
|
2019-06-20 11:22:44 +00:00
|
|
|
|
|
|
|
CWeaponInfo*
|
2020-05-24 15:27:12 +00:00
|
|
|
CWeaponInfo::GetWeaponInfo(eWeaponType weaponType)
|
|
|
|
{
|
2021-01-23 22:13:40 +00:00
|
|
|
return &aWeaponInfo[weaponType];
|
2019-06-20 11:22:44 +00:00
|
|
|
}
|
|
|
|
|
2019-06-21 18:16:51 +00:00
|
|
|
void
|
|
|
|
CWeaponInfo::Initialise(void)
|
|
|
|
{
|
|
|
|
debug("Initialising CWeaponInfo...\n");
|
2019-07-04 20:31:21 +00:00
|
|
|
for (int i = 0; i < WEAPONTYPE_TOTALWEAPONS; i++) {
|
2021-01-23 22:13:40 +00:00
|
|
|
aWeaponInfo[i].m_eWeaponFire = WEAPON_FIRE_INSTANT_HIT;
|
|
|
|
aWeaponInfo[i].m_fRange = 0.0f;
|
|
|
|
aWeaponInfo[i].m_nFiringRate = 0;
|
|
|
|
aWeaponInfo[i].m_nReload = 0;
|
|
|
|
aWeaponInfo[i].m_nAmountofAmmunition = 0;
|
|
|
|
aWeaponInfo[i].m_nDamage = 0;
|
|
|
|
aWeaponInfo[i].m_fSpeed = 0.0f;
|
|
|
|
aWeaponInfo[i].m_fRadius = 0.0f;
|
|
|
|
aWeaponInfo[i].m_fLifespan = 0.0f;
|
|
|
|
aWeaponInfo[i].m_fSpread = 0.0f;
|
|
|
|
aWeaponInfo[i].m_vecFireOffset = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
aWeaponInfo[i].m_AnimToPlay = ASSOCGRP_UNARMED;
|
|
|
|
aWeaponInfo[i].m_fAnimLoopStart = 0.0f;
|
|
|
|
aWeaponInfo[i].m_fAnimLoopEnd = 0.0f;
|
|
|
|
aWeaponInfo[i].m_fAnimFrameFire = 0.0f;
|
|
|
|
aWeaponInfo[i].m_fAnim2LoopStart = 0.0f;
|
|
|
|
aWeaponInfo[i].m_fAnim2LoopEnd = 0.0f;
|
|
|
|
aWeaponInfo[i].m_fAnim2FrameFire = 0.0f;
|
|
|
|
aWeaponInfo[i].m_fAnimBreakout = 0.0f;
|
|
|
|
aWeaponInfo[i].m_Flags = WEAPONFLAG_USE_GRAVITY | WEAPONFLAG_SLOWS_DOWN | WEAPONFLAG_RAND_SPEED | WEAPONFLAG_EXPANDS | WEAPONFLAG_EXPLODES;
|
|
|
|
aWeaponInfo[i].m_nWeaponSlot = WEAPONSLOT_UNARMED;
|
2019-06-21 18:16:51 +00:00
|
|
|
}
|
|
|
|
debug("Loading weapon data...\n");
|
|
|
|
LoadWeaponData();
|
|
|
|
debug("CWeaponInfo ready\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CWeaponInfo::LoadWeaponData(void)
|
|
|
|
{
|
|
|
|
float spread, speed, lifeSpan, radius;
|
|
|
|
float range, fireOffsetX, fireOffsetY, fireOffsetZ;
|
2020-05-15 14:30:25 +00:00
|
|
|
float anim2LoopStart, anim2LoopEnd, delayBetweenAnim2AndFire, animBreakout;
|
|
|
|
float delayBetweenAnimAndFire, animLoopStart, animLoopEnd;
|
2019-06-21 18:16:51 +00:00
|
|
|
int flags, ammoAmount, damage, reload, weaponType;
|
2020-05-15 14:30:25 +00:00
|
|
|
int firingRate, modelId, modelId2, weaponSlot;
|
2019-06-21 18:16:51 +00:00
|
|
|
char line[256], weaponName[32], fireType[32];
|
2020-05-15 14:30:25 +00:00
|
|
|
char animToPlay[32];
|
2019-06-21 18:16:51 +00:00
|
|
|
|
2020-07-22 11:56:28 +00:00
|
|
|
size_t bp, buflen;
|
2019-06-21 18:16:51 +00:00
|
|
|
int lp, linelen;
|
|
|
|
|
|
|
|
CFileMgr::SetDir("DATA");
|
|
|
|
buflen = CFileMgr::LoadFile("WEAPON.DAT", work_buff, sizeof(work_buff), "r");
|
|
|
|
|
|
|
|
for (bp = 0; bp < buflen; ) {
|
|
|
|
// read file line by line
|
|
|
|
for (linelen = 0; work_buff[bp] != '\n' && bp < buflen; bp++) {
|
|
|
|
line[linelen++] = work_buff[bp];
|
|
|
|
}
|
|
|
|
bp++;
|
|
|
|
line[linelen] = '\0';
|
|
|
|
|
|
|
|
// skip white space
|
2020-12-28 00:25:26 +00:00
|
|
|
for (lp = 0; line[lp] <= ' ' && line[lp] != '\0'; lp++);
|
2019-06-21 18:16:51 +00:00
|
|
|
|
2020-12-28 00:25:26 +00:00
|
|
|
if (line[lp] == '\0' || line[lp] == '#')
|
2019-06-21 18:16:51 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
spread = 0.0f;
|
|
|
|
flags = 0;
|
|
|
|
speed = 0.0f;
|
|
|
|
ammoAmount = 0;
|
|
|
|
lifeSpan = 0.0f;
|
|
|
|
radius = 0.0f;
|
|
|
|
range = 0.0f;
|
|
|
|
damage = 0;
|
|
|
|
reload = 0;
|
|
|
|
firingRate = 0;
|
|
|
|
fireOffsetX = 0.0f;
|
|
|
|
weaponName[0] = '\0';
|
|
|
|
fireType[0] = '\0';
|
|
|
|
fireOffsetY = 0.0f;
|
|
|
|
fireOffsetZ = 0.0f;
|
|
|
|
sscanf(
|
|
|
|
&line[lp],
|
2020-05-15 14:30:25 +00:00
|
|
|
"%s %s %f %d %d %d %d %f %f %f %f %f %f %f %s %f %f %f %f %f %f %f %d %d %x %d",
|
2020-05-11 23:24:57 +00:00
|
|
|
weaponName,
|
|
|
|
fireType,
|
2019-06-21 18:16:51 +00:00
|
|
|
&range,
|
|
|
|
&firingRate,
|
|
|
|
&reload,
|
|
|
|
&ammoAmount,
|
|
|
|
&damage,
|
|
|
|
&speed,
|
|
|
|
&radius,
|
|
|
|
&lifeSpan,
|
|
|
|
&spread,
|
|
|
|
&fireOffsetX,
|
|
|
|
&fireOffsetY,
|
|
|
|
&fireOffsetZ,
|
2020-05-11 23:24:57 +00:00
|
|
|
animToPlay,
|
2019-06-21 18:16:51 +00:00
|
|
|
&animLoopStart,
|
|
|
|
&animLoopEnd,
|
|
|
|
&delayBetweenAnimAndFire,
|
2020-05-15 14:30:25 +00:00
|
|
|
&anim2LoopStart,
|
|
|
|
&anim2LoopEnd,
|
2019-06-21 18:16:51 +00:00
|
|
|
&delayBetweenAnim2AndFire,
|
2020-05-15 14:30:25 +00:00
|
|
|
&animBreakout,
|
2019-06-21 18:16:51 +00:00
|
|
|
&modelId,
|
2020-05-15 14:30:25 +00:00
|
|
|
&modelId2,
|
|
|
|
&flags,
|
|
|
|
&weaponSlot);
|
2019-06-21 18:16:51 +00:00
|
|
|
|
|
|
|
if (strncmp(weaponName, "ENDWEAPONDATA", 13) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
weaponType = FindWeaponType(weaponName);
|
|
|
|
|
|
|
|
CVector vecFireOffset(fireOffsetX, fireOffsetY, fireOffsetZ);
|
|
|
|
|
2021-01-23 22:13:40 +00:00
|
|
|
aWeaponInfo[weaponType].m_eWeaponFire = FindWeaponFireType(fireType);
|
|
|
|
aWeaponInfo[weaponType].m_fRange = range;
|
|
|
|
aWeaponInfo[weaponType].m_nFiringRate = firingRate;
|
|
|
|
aWeaponInfo[weaponType].m_nReload = reload;
|
|
|
|
aWeaponInfo[weaponType].m_nAmountofAmmunition = ammoAmount;
|
|
|
|
aWeaponInfo[weaponType].m_nDamage = damage;
|
|
|
|
aWeaponInfo[weaponType].m_fSpeed = speed;
|
|
|
|
aWeaponInfo[weaponType].m_fRadius = radius;
|
|
|
|
aWeaponInfo[weaponType].m_fLifespan = lifeSpan;
|
|
|
|
aWeaponInfo[weaponType].m_fSpread = spread;
|
|
|
|
aWeaponInfo[weaponType].m_vecFireOffset = vecFireOffset;
|
|
|
|
aWeaponInfo[weaponType].m_fAnimLoopStart = animLoopStart / 30.0f;
|
|
|
|
aWeaponInfo[weaponType].m_fAnimLoopEnd = animLoopEnd / 30.0f;
|
|
|
|
aWeaponInfo[weaponType].m_fAnim2LoopStart = anim2LoopStart / 30.0f;
|
|
|
|
aWeaponInfo[weaponType].m_fAnim2LoopEnd = anim2LoopEnd / 30.0f;
|
|
|
|
aWeaponInfo[weaponType].m_fAnimFrameFire = delayBetweenAnimAndFire / 30.0f;
|
|
|
|
aWeaponInfo[weaponType].m_fAnim2FrameFire = delayBetweenAnim2AndFire / 30.0f;
|
|
|
|
aWeaponInfo[weaponType].m_fAnimBreakout = animBreakout / 30.0f;
|
|
|
|
aWeaponInfo[weaponType].m_nModelId = modelId;
|
|
|
|
aWeaponInfo[weaponType].m_nModel2Id = modelId2;
|
|
|
|
aWeaponInfo[weaponType].m_Flags = flags;
|
|
|
|
aWeaponInfo[weaponType].m_nWeaponSlot = weaponSlot;
|
2020-05-15 14:30:25 +00:00
|
|
|
|
2020-05-23 13:53:20 +00:00
|
|
|
if (animLoopEnd < 98.0f && weaponType != WEAPONTYPE_FLAMETHROWER && !CWeapon::IsShotgun(weaponType))
|
2021-01-23 22:13:40 +00:00
|
|
|
aWeaponInfo[weaponType].m_nFiringRate = ((aWeaponInfo[weaponType].m_fAnimLoopEnd - aWeaponInfo[weaponType].m_fAnimLoopStart) * 900.0f);
|
2020-05-15 14:30:25 +00:00
|
|
|
|
|
|
|
if (weaponType == WEAPONTYPE_DETONATOR || weaponType == WEAPONTYPE_HELICANNON)
|
|
|
|
modelId = -1;
|
|
|
|
else if (weaponType == WEAPONTYPE_DETONATOR_GRENADE)
|
|
|
|
modelId = MI_BOMB;
|
|
|
|
|
|
|
|
if (modelId != -1)
|
|
|
|
((CWeaponModelInfo*)CModelInfo::GetModelInfo(modelId))->SetWeaponInfo(weaponType);
|
|
|
|
|
|
|
|
for (int i = 0; i < NUM_ANIM_ASSOC_GROUPS; i++) {
|
|
|
|
if (!strcmp(animToPlay, CAnimManager::GetAnimGroupName((AssocGroupId)i))) {
|
2021-01-23 22:13:40 +00:00
|
|
|
aWeaponInfo[weaponType].m_AnimToPlay = (AssocGroupId)i;
|
2020-05-15 14:30:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-06-21 18:16:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
eWeaponType
|
|
|
|
CWeaponInfo::FindWeaponType(char *name)
|
|
|
|
{
|
2019-07-04 20:31:21 +00:00
|
|
|
for (int i = 0; i < WEAPONTYPE_TOTALWEAPONS; i++) {
|
2019-06-21 18:16:51 +00:00
|
|
|
if (strcmp(ms_aWeaponNames[i], name) == 0) {
|
|
|
|
return static_cast<eWeaponType>(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return WEAPONTYPE_UNARMED;
|
|
|
|
}
|
|
|
|
|
|
|
|
eWeaponFire
|
|
|
|
CWeaponInfo::FindWeaponFireType(char *name)
|
|
|
|
{
|
|
|
|
if (strcmp(name, "MELEE") == 0) return WEAPON_FIRE_MELEE;
|
|
|
|
if (strcmp(name, "INSTANT_HIT") == 0) return WEAPON_FIRE_INSTANT_HIT;
|
|
|
|
if (strcmp(name, "PROJECTILE") == 0) return WEAPON_FIRE_PROJECTILE;
|
|
|
|
if (strcmp(name, "AREA_EFFECT") == 0) return WEAPON_FIRE_AREA_EFFECT;
|
2020-05-23 13:53:20 +00:00
|
|
|
if (strcmp(name, "CAMERA") == 0) return WEAPON_FIRE_CAMERA;
|
2019-06-21 18:16:51 +00:00
|
|
|
Error("Unknown weapon fire type, WeaponInfo.cpp");
|
|
|
|
return WEAPON_FIRE_INSTANT_HIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CWeaponInfo::Shutdown(void)
|
|
|
|
{
|
|
|
|
debug("Shutting down CWeaponInfo...\n");
|
|
|
|
debug("CWeaponInfo shut down\n");
|
2020-05-11 23:24:57 +00:00
|
|
|
}
|