Game Development Community

question on Projectile and ProximityMine .H and .CPP files

by Pierre DragoFire Hay · in Torque 3D Professional · 03/19/2013 (9:47 pm) · 19 replies

Hi all, I'm trying to update how T3D handles weapons and their ammo. As I see if there are only the Projectile.H/.CPP and ProximityMine.H/.CPP files that are hard coded in the engine and Weapon.CS in Art folder and the individual weapon.cs files in the Weapons folder of the project.

Has anyone played around with these core files to set more defined weapon and ammo setups and features?

I did something simular with Operation Flashpoint and Armed Assault many many years ago, and now having the time, been thinking of porting my work into T3D to improve the weapon system. I just need to get my head around how its been done and how to add my coding in.

Here's an examples of what I had configured and had working correctly, which magazines and weapons linked to (I've cut a large amount out and left a few key things inplace), these are based on real-world weapons, and only a small amount;

Bullets:
	class Default
	class BulletSingle:Default
	class BulletBurst:BulletSingle
	class BulletFullAuto:BulletBurst
        class 7_62NATO_FMJ:BulletSingle // 7.62mm NATO FMJ
	class 7_62NATO_JHP:7_62NATO_FMJ // 7.62mm NATO JHP
	class 7_62NATO_AP:7_62NATO_FMJ // 7.62mm NATO AP
	class 7_62NATORL_FMJ:7_62NATO_FMJ // 7.62mm NATO reduced load FMJ
	class 7_62NATORL_JHP:7_62NATORL_FMJ // 7.62mm NATO reduced load JHP
	class 7_62NATORL_AP:7_62NATORL_FMJ // 7.62mm NATO reduced load AP
	class 4_7_FMJ:7_62NATO_FMJ // 4.7mm Caseless FMJ
	class 4_7_JHP:4_7_FMJ // 4.7mm Caseless JHP
	class 4_7_AP:4_7_FMJ // 4.7mm Caseless AP
	class 300M_FMJ:7_62NATO_FMJ // 300 Winchester Magnum FMJ
	class 300M_JHP:300M_FMJ // 300 Winchester Magnum JHP
	class 300M_AP:300M_FMJ // 300 Winchester Magnum AP
	class 7_62x39_FMJ:7_62NATO_FMJ // 7.62mm x 39mm FMJ
	class 7_62x39_JHP:7_62x39_FMJ // 7.62mm x 39mm JHP
	class 7_62x39_AP:7_62x39_FMJ // 7.62mm x 39mm AP
	class 7_62x54_FMJ:7_62NATO_FMJ // 7.62mm x 54mm FMJ
	class 7_62x54_JHP:7_62x54_FMJ // 7.62mm x 54mm JHP
	class 7_62x54_AP:7_62x54_FMJ // 7.62mm x 54mm AP
	class 5_45x39_5_FMJ:7_62NATO_FMJ // 5.45mm x 39.5mm FMJ
	class 5_45x39_5_JHP:5_45x39_5_FMJ // 5.45mm x 39.5mm JHP
	class 5_45x39_5_AP:5_45x39_5_FMJ // 5.45mm x 39.5mm AP
	class 5_56NATO_FMJ:7_62NATO_FMJ // 5.56mm NATO FMJ
	class 5_56NATO_JHP:5_56NATO_FMJ // 5.56mm NATO JHP
	class 5_56NATO_AP:5_56NATO_FMJ // 5.56mm NATO AP
	class 12_7x107_FMJ:7_62NATO_FMJ // 12.7mm x 107mm FMJ
	class 12_7x107_JHP:12_7x107_FMJ // 12.7mm x 107mm JHP
	class 12_7x107_AP:12_7x107_FMJ // 12.7mm x 107mm AP
	class 50_FMJ:7_62NATO_FMJ // 0.50 Browning FMJ
	class 50_JHP:50_FMJ // 0.50 Browning JHP
	class 50_AP:50_FMJ // 0.50 Browning AP
	class 14_5x115_AP:7_62NATO_FMJ //BS41 14.5mm x 115mm AP
	class 14_5x115_API-T:14_5x115_AP//BZT 14.5mm x 115mm API-T
	class 14_5x115_IncAP:14_5x115_AP//ZP 14.5mm x 115mm Inc. AP-T
	class 9_PAR_FMJ:7_62NATO_FMJ // 9mm Parabellum FMJ
	class 9_PAR_JHP:9_PAR_FMJ // 9mm Parabellum JHP
	class 9_PAR_AP:9_PAR_FMJ // 9mm Parabellum AP
	class 45ACP_FMJ:7_62NATO_FMJ // 45ACP FMJ
	class 45ACP_JHP:45ACP_FMJ // 45ACP JHP
	class 45ACP_AP:45ACP_FMJ // 45ACP AP
	class 32ACP_FMJ:7_62NATO_FMJ // 32ACP FMJ
	class 32ACP_JHP:32ACP_FMJ // 32ACP JHP
	class 32ACP_AP:32ACP_FMJ // 32ACP AP
	class 7_62x25_FMJ:7_62NATO_FMJ // 7.62mm x 25mm FMJ
	class 7_62x25_JHP:7_62x25_FMJ // 7.62mm x 25mm JHP
	class 7_62x25_AP:7_62x25_FMJ // 7.62mm x 25mm AP
	class 9x18_FMJ:7_62NATO_FMJ // 9mm x 18mm FMJ
	class 9x18_JHP:9x18_FMJ // 9mm x 18mm JHP
	class 9x18_AP:9x18_FMJ // 9mm x 18mm AP
	class 5_45x18_FMJ:7_62NATO_FMJ // 5.45mm x 18mm FMJ
	class 5_45x18_JHP:5_45x18_FMJ // 5.45mm x 18mm JHP
	class 5_45x18_AP:5_45x18_FMJ // 5.45mm x 18mm AP
	class ExplosiveBullet:BulletSingle
	class 25mm_API-T:ExplosiveBullet //M791 25mm API-T cannon round
	class 25mm_HEI-T:25mm_AP //M792 25mm HEI-T cannon round
	class 30mm_HEI-T:25mm_AP //30mm HEI-T cannon round
	class 30mm_API-T:25mm_AP //30mm API-T cannon round
Shells:
	class Shell:Default
	class Shell73:Shell
	class 73_HEAT:Shell //Russain 73mm Shell HEAT
	class 105_HEAT:73_HEAT //M456 105mm Shell HEAT
	class 105_APFSDS:105_HEAT //M774 105mm Shell APFSDS-T
	class 105_HEP:105_HEAT //M393 105mm Shell HEP
	class 105_APDS:105_HEAT //M392A2 105mm Shell APDS
	class 115_HEAT:105_HEAT //BK-4M 115mm Shell HEAT
	class 115_APFSDS:115_HEAT //BM-6 115mm Shell APFSDS-T
	class 115_HE:115_HEAT //OF-18 115mm Shell HE
	class 120_HEAT:105_HEAT //M830 120mm Shell HEAT-T
	class 120_APFSDS:120_HEAT //M829 120mm Shell APFSDS-T
	class 120_HESH:120_HEAT //L31 105mm Shell HESH-T
	class 120_APDS-HE:120_HEAT //L15 105mm Shell APDS-T
	class 125_HEAT:120_HEAT //BK-14M 125mm Shell HEAT-T
	class 125_HE:120_HEAT //OF-19 125mm Shell HE
	class 125_APFSDS:120_HEAT //BM-9 125mm Shell APFSDS-T
	class Shell105:Shell73
	class Shell120:Shell105
	class Shell125:Shell120
	class Heat:Shell
	class Heat73:Heat
	class Heat105:Heat73
	class Heat120:Heat105
	class Heat125:Heat120
Missiles:
	class AT3:Default
	class LAW:AT3
	class RPG:LAW
	class CarlGustav:AT3
	class AT4:CarlGustav
	class AA:CarlGustav
	class 9K32:AA	
	class AT-4:AT3 //Russain Spigot AT-4		
	class AT-5:AT3 //Russian Spandrel AT-5
	class BGM-71D:AT3 //USA TOW2
	class BGM-71A:BGM-71D //USA Basic TOW
	class Hellfire:AT3
	class HellfireApach:Hellfire
	class AT6:Hellfire
	class Maverick:Hellfire
	class Ch29T:Maverick
	class AGM_65AB: Hellfire // Air Force Maverick models A,B 
	class AGM_65D: AGM_65 // Air Force Maverick model D
	class AGM_65E: AGM_65 // Marine Corp Maverick model E
	class AGM_65GF: AGM_65 // Air Force Maverick model G & NAVY model F
	class AGM_45A: AGM_65 // Shrike model A
	class AGM_84: Hellfire // AirLaunched Harpoon
	class AIM_7: AA // Sparrow
	class AIM_9H: AA // Sidewinder
	class AIM_9LM: AIM_9H // Sidewinder models L & M
	class AIM_54: AA // Phoenix
	class AIM_120: AA // AMRAAM Slammer 
	class AIM_132: AA // ASRAAM 
	class FIM_922: AA // Stinger  
Rockets:
	class AT3:Default
	class Hellfire:AT3
	class Zuni:Hellfire
	class Rocket57:Zuni
	class Zuni_5: Hellfire // 5inch rocket
	class Hydra_2_75: Zuni // 2_75inch rocket
Bombs:
	class MK_81: Default // 250lb GP BOMB
	class MK_82: MK_81 // 500lb GP BOMB
	class MK_83: MK_81 // 1000lb GP BOMB
	class MK_84: MK_81 // 2000lb GP BOMB
	class GBU_12D: MK_82 // 500lb Laser Guided BOMB
	class GBU_16B: MK_83 // 1000lb Laser Guided BOMB
	class GBU_10E: MK_84 // 2000lb Laser Guided BOMB GBU-24E & B use this
	class LaserGuidedBomb:Default
	class MK77 : LaserGuidedBomb
	class MK77Burner : SmokeShell

Example of a few of the bombs and missiles modeled.

homepages.maxnet.co.nz/ajp_hay/images/weapons.jpg
Here's examples of the magazine setup, I've left a few with with extra details to show how it worked and the possiblities.

Magazines:
class FAL_20FMJ:Default
		ammo="7_62NATO_FMJ";
		count=20;
	class 7_62NATO_Belt_100FMJ:FAL_20FMJ
	class FAL_20JHP:FAL_20FMJ
	class 7_62NATO_Belt_100JHP:FAL_20JHP
	class FAL_20AP:FAL_20FMJ
	class 7_62NATO_Belt_100AP:FAL_20AP
	class BAR_20FMJ:FAL_20FMJ
	class BAR_10FMJ:BAR_20FMJ
	class BAR_20JHP:BAR_20FMJ
	class BAR_10JHP:BAR_20JHP
	class BAR_20AP:BAR_20FMJ
	class BAR_10AP:BAR_10FMJ
	class AR-15_30FMJ:Default
		ammo="5_56NATO_FMJ";
		count=30;
		initSpeed=730.3;
		reloadTime=0.07;
	class AR-15_40FMJ:AR-15_30FMJ
	class Mini-14_30FMJ:AR-15_30FMJ
	class Mini-14_20FMJ:Mini-14_30FMJ
	class Mini-14_10FMJ:Mini-14_30FMJ
	class Mini-14_40FMJ:Mini-14_30FMJ
	class SAW_200FMJ:AR-15_30FMJ
	class SAW_100FMJ:AR-15_30FMJ
	class AR-15_30JHP:AR-15_30FMJ
	class AR-15_40JHP:AR-15_30JHP
	class SAW_200JHP:AR-15_30JHP
	class SAW_100JHP:AR-15_30JHP
	class Mini-14_30JHP:AR-15_30JHP
	class Mini-14_20JHP:Mini-14_30JHP
	class Mini-14_10JHP:Mini-14_30JHP
	class Mini-14_40JHP:Mini-14_30JHP
	class AR-15_30AP:AR-15_30JHP
		ammo="5_56NATO_AP";
	class AR-15_40AP:AR-15_30AP
		count=40;
	class SAW_200AP:AR-15_30AP
		count=200;
	class SAW_100AP:AR-15_30AP
		count=100;
	class Mini-14_30AP:AR-15_30AP
		count=30;
	class Mini-14_20AP:Mini-14_30AP
		count=20;
	class Mini-14_10AP:Mini-14_30AP
		count=10;	
	class Mini-14_40AP:Mini-14_30AP
		count=40;
	class Shell73:Default
		ammo="Shell73";
		count=15;
		initSpeed=700;
		reloadTime=16.0;
	class Heat73:Shell73
		ammo="Heat73";
	class Shell105:Shell73
		ammo="Shell105";
		count=35;
	class Heat105:Shell105
		ammo="Heat105";
	class Shell120:Shell105
		ammo="Shell120";
		count=35;
	class Heat120:Shell120
		ammo="Heat120";
	class Shell125:Shell120		
	class Heat125:Shell125
	class XM214:MGun // USA XM214 Microgun 5.56mm NATO 6 Barrel gatling gun
		ammo="5_56NATO_AP";
		count=2000;
	class M134:MGun // USA M134 Minigun 7.62mm NATO 6 Barrel gatling gun
		ammo="7_62NATO_AP";
		count=1000;
	class GShG-7_62:MGun // Russia GShG-7.62 7.62x54mm 4 Barrel gatling gun
		ammo="7_62x54_AP";
		count=1000;
	class YakB-12_7:MGun //Russia YakB-12.7 12.7x108mm 4 Barrel gatling gun
		ammo="12_7x107_AP";
		count=1000;
	class MachineGun7_6:MGun
		ammo="Bullet7_6";
		count=500;
	class MachineGun7_6Manual:MachineGun7_6
	class M60:MachineGun7_6Manual		
		ammo="Bullet7_6W";
	class PK:MachineGun7_6Manual		
		ammo="Bullet7_6E";
	class MachineGun12_7:MachineGun7_6
		ammo="Bullet12_7";
		count=500;
	class Browning:MachineGun12_7
		ammo="Bullet12_7";
	class MachineGun30:MachineGun7_6
		ammo="Bullet30";
		count=500;
	class MachineGun30W:MachineGun30		
		ammo="Bullet30W";
	class MachineGun30E:MachineGun30
		ammo="Bullet30E";
	class MachineGun30A10:MachineGun30
		count=2000;
	class MachineGun30A10Burst:MachineGun30A10
		ammo="Bullet30A10";
	class ZsuCannon:MachineGun30		
		ammo="Bullet4x23";
		count=2000;
	class LAU61_7: LAU61_19 // single 7 rocketlauncher pod
	class LAU61_14: LAU61_19 // dual 7 rocketlauncher pods
	class LAU61_32: LAU61_19 // dual 19 rocketlauncher pods

Some of the Weapons done to date, there's a larger amount not included;
class Default
	class Gun73:Default
		{
		scopeWeapon=2;
		scopeMagazine=0;
		displayName="$STR_DN_GUN";
		sound[]={"Weaponsgun73",10.0,1};
		reloadSound[]={"Weaponsreload",0.001,1};
		backgroundReload=1;
		ffMagnitude=1;
		ffFrequency=5;
		magazines[]={"Heat73","Shell73"};
		};
	class Gun105:Gun73
		magazines[]={"Heat105","Shell105"};
	class Gun120:Gun105
		magazines[]={"Heat120","Shell120"};
	class Gun125:Gun120
		magazines[]={"Heat125","Shell125"};
	class L1A1-F1:Riffle // Australia L1A1 - F1 7.62mm NATO Assault Rifle		
		magazines[]={"FAL_20FMJ","FAL_20JHP","FAL_20AP"};
		modes[]={"Safety","Single"};
	class FN_FAL:L1A1-F1 // Belgium FN FAL 7.62mm NATO Assault Rifle
		modes[]={"Safety","Single","Burst"};
	class L1A1:L1A1-F1 // UK L1A1 7.62mm NATO Assault Rifle
	class M14A1_SAW:L1A1-F1 // USA M14A1 7.62mm NATO SAW
		magazines[]={"BAR_20FMJ","BAR_20JHP","BAR_20AP","BAR_10FMJ","BAR_10JHP","BAR_10AP"};
		modes[]={"Safety","Single","Burst"};
	class M14:M14A1_SAW // USA M14 7.62mm NATO Semi-automatic rifle
		magazines[]={"BAR_20FMJ","BAR_20JHP","BAR_20AP","BAR_10FMJ","BAR_10JHP","BAR_10AP"};
		modes[]={"Safety","Single","Burst"};
	class M16A1:Riffle // USA M16A1 5.56mm NATO Assault Rifle	
		magazines[]={"AR-15_30FMJ","AR-15_30JHP","AR-15_30AP","AR-15_40FMJ","AR-15_40JHP","AR-15_40AP"};
		modes[]={"Safety","Single","FullAuto"};
	class M16A2:M16A1 // USA M16A2 5.56mm NATO Assault Rifle
	class M16A3:M16A1 // USA M16A3 5.56mm NATO Assault Rifle
		modes[]={"Safety","Single","FullAuto"};
	class M16A4:M16A1 // USA M16A4 5.56mm NATO Assault Rifle
	class AC556:M16A1 // USA Ruger AC556 5.56mm NATO Assault Rifle
		magazines[]={"Mini-14_10FMJ","Mini-14_10JHP","Mini-14_10AP","Mini-14_20FMJ","Mini-14_20JHP","Mini-14_20AP","Mini-14_30FMJ","Mini-14_30JHP","Mini-14_30AP","Mini-14_40FMJ","Mini-14_40JHP","Mini-14_40AP"};
	class CAR_15:M16A1 // USA Colt CAR 15 5.56mm NATO Assault Rifle
		modes[]={"Safety","Single","Burst"};
	class XM-177E1:CAR_15 // USA Colt XM-177E1 5.56mm NATO Assault Rifle
		modes[]={"Safety","Single","Burst"};
	class XM-177E2:XM-177E1 // USA Colt XM-177E2 5.56mm NATO Assault Rifle
		modes[]={"Safety","Single","Burst"};
	class Colt_M4:M16A1 // USA Colt M4 5.56mm NATO Carbine
		modes[]={"Single","Burst"};
	class Colt_M4A1:M16A1 // USA Colt M4A1 5.56mm NATO Carbine
		modes[]={"Single","Burst"};
	class M249_SAW:MGun // USA Minimi M249 SAW 5.56mm NATO Squad Automatic Weapon
		magazines[]={[]={"SAW_100FMJ_BOX,"SAW_100JHP_BOX","SAW_100AP_BOX","AR-15_30FMJ","AR-15_30JHP","AR-15_30AP","AR-15_40FMJ","AR-15_40JHP","AR-15_40AP","SAW_200FMJ_BOX,"SAW_200JHP_BOX","SAW_200AP_BOX"};
		modes[]={"Safety","Burst","FullAuto"};
	class M249_SAW_SPW:M249_SAW // USA Minimi M249 SAW SPW 5.56mm NATO Squad Automatic Weapon
		magazines[]={"SAW_100FMJ_BOX,"SAW_100JHP_BOX","SAW_100AP_BOX","SAW_200FMJ_BOX,"SAW_200JHP_BOX","SAW_200AP_BOX"};
	class XM207_SAW:M249_SAW // USA XM207 5.56mm NATO Squad Automatic Weapon
	class M60_GPMG:M249_SAW // USA M60 7.62mm NATO GPMG
		magazines[]={"7_62NATO_Belt_100FMJ","7_62NATO_Belt_100JHP","7_62NATO_Belt_100AP"};
		modes[]={"Safety","Burst","FullAuto"};
	class M60E3_GPMG:M60_GPMG // USA M60E3 7.62mm NATO GPMG
	class MG3_GPMG:M60_GPMG // Germany MG3 7.62mm NATO GPMG
		modes[]={"Safety","Burst","FullAuto"};
	class HK_21E_GPMG:M60_GPMG // Germany H&K 21E 7.62mm NATO GPMG
		modes[]={"Safety","Burst","FullAuto"};

	class LAU10_4: AT3Launcher // single 4 rocketlauncher pod
		ammo= Zuni_5;
		magazines[] = {"LAU10_4","LAU10_8"};
	class LAU10_8: LAU10_4 // dual 4 rocketlauncher pods
	class LAU61_19 : AT3Launcher // single 19 rocketlauncher pod 
		{
		ammo= Hydra_2_75;
		magazines[] = {"LAU61_19", "LAU61_7", "LAU61_14", "LAU61_32"};

Here's what the code looked like for a weapon (pay attention to line code "magazines[]", you'll notice the amount of magazine types it could mount, this is based off real-world information) and "modes[]:
class M249_SAW:MGun // USA Minimi M249 SAW 5.56mm NATO Squad Automatic Weapon
		{
		nameSound="mgun";
		reloadTime=0.25;
		soundContinuous=1;
		reloadSound[]={"",1,1};
		flash="gunfire";
		flashSize=0.5;
		optics=0;
		scopeWeapon=2;
		scopeMagazine=2;
		valueWeapon=0;
		valueMagazine=1;
		model="";
		modelOptics="";
		opticsZoomMin=0.35;
		opticsZoomMax=0.35;
		displayName="M249_SAW";
		displayNameMagazine="M16A1";
		shortNameMagazine="M16A1";
		sound[]={"WeaponsM60mgun",3.1622779,1};
		drySound[]={"weaponsM16dry",0.01,1};
		magazines[]={[]={"SAW_100FMJ_BOX,"SAW_100JHP_BOX","SAW_100AP_BOX","AR-15_30FMJ","AR-15_30JHP","AR-15_30AP","AR-15_40FMJ","AR-15_40JHP","AR-15_40AP","SAW_200FMJ_BOX,"SAW_200JHP_BOX","SAW_200AP_BOX"};
		modes[]={"Safety","Burst","FullAuto"};

As you can see trying to run all this from script maybe an issue. Ideally I think running the ammo types and magazines and the key base weapons would keep the over head low, and allow for new weapons and magazines to be added later without issues.

Ideally I would like to setup something like the following weapon core structure:
class default
      class Thrown:default
      class rocket:default
      class shell:default
      class bullet:default
      class place: default
      class explosive:default

As you can see this would cover the basic weapon types and have ref coding available to use.


Look forward to any input.



#1
03/20/2013 (7:33 am)
What improvements do you want to make? This is a very vague question that cannot be answered with specifics without knowing more about what you intend.

But basically, all weapon behavior is datablock managed. Neither projectile.cpp nor proximity.cpp hardcodes any of the projectile or mine behaviors that you see in the game. All interface with the player's inventory is handled in script.
#2
03/20/2013 (7:34 am)
weapon and ammo setup are handled in script. Look in the art/datablocks and art/datablocks/weapons folders. Also, look at the weapons and inventory scripts in scripts/server.
#3
03/20/2013 (11:27 am)
Yes I know that weapons and ammo are handled within art/datablocks and art/datablocks as script files, but as we all know the more scripts running the more processing power is required.

What I want to do is hard code the primary weapon types (@6) and ammo types (@10) to reduces this processing over head and to have referance classes that new weapons and ammo can be child of.

Part of this is I also plan to add a true kinetic damage system and other different forms of damage (heat, radiation, concussion, etc...) to the engine.

I'll add some more detail to the main post later today to provide information.
#4
03/20/2013 (12:39 pm)
Then you can probably just inherit the object types and port the relevant scripts to C++. Just want to point out that the current system was sufficiently fast for Tribes and Tribes 2 - both of which allowed a large number of players over pretty slow connections on fairly limited hardware. Premature optimisation is the root of all evil....

Also, datablocks don't "run," they load. They're mainly data used by the engine to initialize objects. The callbacks fire actual running script, but as long as you don't try to calculate a hyperspace jump to Aldebaran in one you shouldn't really have much of a performance hit (treat them like critical sections - do the minimum needed and get out).
#5
03/20/2013 (12:56 pm)
Weapon "types", ammo "types", damage "types" all can easily be adjusted within the datablocks and scripts. As Richard mentioned, this type of interaction will have little effect on overall overhead given it's past performance, and is actually what the engine and networking implementation is designed for.

But for sure it is possible to hardcode all of these little things into C++ with the subsequent loss of flexibility that the current system gives you.
#6
03/20/2013 (1:12 pm)
Now, if you really want to see some scripts that will bog you down check out these. To use them, create a new project, download the scripts and then copy the scripts directly over the game folder of the new project - all of them. Then run it.

You can place "barracks" using the buttons in the lower right, you can spawn units from them by left-clicking them. You can drop enemy units from the camera location by pressing the 'b' key. Dump a ton of units out there and watch the framerate plummet! These scripts are constantly running so the units can think - you can decrease or increase the time between think cycles and you can set distance parameters so that units farther from the camera think less often (and outside of a certain range based on priority stop thinking all together).

This is a really solid case for porting script to source, but I've created a prototype and from it I know the limitations and bottlenecks. Until you get some metrics to show that firing a rifle takes forever I'd have to guess that time spent optimising it would be better spent working on other things.
#7
03/20/2013 (1:38 pm)
Pierre - most of the scripts don't 'run', as Richard mentioned - they just handle callbacks, responding to a single function call before terminating.

I like the idea of redesigning weapons and ammunition, though I think Projectiles are pretty much as fundamental as they can get. All that scripts do for a Projectile is set properties like speed and damage, and provide a collision callback that actually does damage. And I think having damage done through scripts is a good idea in general. Hardcoding damage might work once you've got your core gameplay down and completely solid, but I don't think it's appropriate for a game engine to hardcode.

Providing different weapon 'types' is a matter of tweaking the weapon image's state machine, as far as I'm aware. There are also default onFire scripts that tend to be pretty much the same for most weapons - that's a good candidate for simplification/internalisation.
#8
03/20/2013 (3:08 pm)
Richard - yes know what you mean about weapon configuration in games, theres a fine line to it, if not a fine art. What I did in OFP/ARMA took ages to do, and luckly I have all that information still. Yes there will be tweaking to bring it into T3D. But if it can be done, the addition of laser targeting, IR tracking, and things addition could be added to the core engine it would add some freedom for others to use it and make their own scripts to modify it to thier needs.

Daniel - yes the script callbacks work nicely, but if I can enhance the core engine to have different damage types and affects it would be benifical to all in the long run.
E.g.
Grenade explosion not limited to direct hit damage and indirect damage, but also concussion damage, heat damage, kinetic pushback plus audio and visual damage. And developers can modify these with scripts for armour, shields, character abilities.

#9
03/20/2013 (3:44 pm)
Quote:But if it can be done, the addition of laser targeting, IR tracking, and things addition could be added to the core engine it would add some freedom for others to use it and make their own scripts to modify it to thier needs.
Definitely! That sounds like a great idea. There have been resources in the past for simple heat-seeking and so on, but we never really settled on anything canonical. At the moment, damage types are all implemented in script, but I'd support adding features to the engine if necessary!

The classes you listed in your post, though, are definitely what should be done in script. If I'm not wrong in thinking that these classes differ only in terms of their static information (muzzle vel - though I guess it's dependent on the gun as well - damage, etc.), that's exactly what datablocks were designed for.

Stuff like specifying modes in a datablock is more complex, but I think it's still an issue for scripts. Because the firing modes are implemented in a weapon's state machine, allowing or disallowing them is probably also a script-side problem. Same with accepted magazines - though that depends on whether your inventory system is in script or code.

I've always thought that radius damage in Torque could use some work. At the moment, the method of computing coverage is very, very simple.
#10
03/20/2013 (3:54 pm)
Daniel - yes most of the weapons, ammo and magazines ref. back for a core set of defaults (rough concept added to header post), and only make key changes for that weapon.
eg. magazine/s used, scope, fire modes, model paths, sounds, and other things like these.

Which would could be done in the datablock.

Things like common ammo (say 5.56 NATO rounds) being removed from one weapons magazine (M249 SAW) into another (M16A1) could even be scripted, based on how many rounds left in the magazine and time to load each into other weapon magazine.
#11
03/20/2013 (4:07 pm)
Quote:
As you can see trying to run all this from script maybe an issue. Ideally I think running the ammo types and magazines and the key base weapons would keep the over head low, and allow for new weapons and magazines to be added later without issues.
I'm not seeing much that can't be handled by the system as it stands. All of your weapon class initialization looks exactly like a datablock (which is exactly what datablocks are for). Honestly, I think that you'd save time by just using the system to do as much of the work as possible and seeing how it goes - and of course extending the engine for things like laser sighting. GarageGames released their weapon packs and I can tell you from experience that having 10 or 15 weapon types in game did not in any way affect game speed, network traffic, frame rates, weapon responsiveness or, really anything at all - except perhaps fun factor....
#12
03/20/2013 (4:33 pm)
Richard - I know what you mean, what I'd like to know is has anyone been able to find the limit on weapons/magazines before the game does start to suffer? And yes most can be done in datablocks, I hope you see where I'm trying to go with this idea.

I ask about the limit as what I'm working on has to start with currently in design @30 torpedoes, 8 torpedo launcher/magazines, @24 gun/cannon type weapons (with options of being fixed mounted or turreted) for 60+ vehicles, with some having upto 6 turrents, 2 torpedoe launchers and 4 fix mounted guns/cannons, plus counter-measures.
Not including personal weapons and magazines.

#13
03/20/2013 (5:07 pm)
So far as I'm aware of no one has reported a performance issue related to having any number of weapons or ammunition types available. All issues relate to having more than 30 players in a single game - and I believe that was fixed when the mission area bug at post #4 was fixed.

The only time a weapon incurs an overhead it is on a callback - and those are rare. The script to fire the weapon takes the ammo type, creates a projectile and sends it on its way, then decrements inventory - probably less than 15ms even in script. Unless your ammunition has a huge creation time due to some large preparation script (can't even imagine a good example case) there really shouldn't be a problem.

And there is no difference between personal weapons and mounted weapons - they're just weapons (though I suppose the AI Turret is a weird hybrid AI Player/Weapon thing).
#14
03/20/2013 (5:11 pm)
Thanks Richard, I'll have a look through things and decide how to tackle this idea.

I still think the idea of having a core default group of weapons a good idea, but agree that nothing needs to be added to the core, other than laser/IR/sonar/etc...-targeting/guidance, decoy system, update damage system (as talked about above)
#15
03/20/2013 (5:33 pm)
I really want to jump into this thread in more with more detail but I'm so swamped right now I can't respond with the detail it deserves. Anyway, I can assure you the best route for this is to use the system as is. I started my career in the sim industry. I actually worked for the US distributor of VBS1 and we were using Torque to build a sim tool to compete against VBS2.
#16
03/20/2013 (6:24 pm)
Scott - interesting fact that about VBS using Torque, never heard that from a few mates that were contracting on those projects, might have to hit them up about that.

SO with you knowing how the VBS system weapon/ammo coding worked you'd have a rough Idea where I'm heading.

Look forward to your response when you get the time! ;) (know what it's like)
#17
03/20/2013 (7:10 pm)
Oh no, VBS is OpFlash/Arma. What we used Torque for, which unfortunately never got past the RnD phase due to other reasons, was to build a competitor tool like it.
#18
03/20/2013 (7:35 pm)
Scott - yes know VSB was based on OFP, before whole Codemasters thing happened.

And ARMA was the new version of OFP, when BIS stepped away from Codemasters. ARMA added a few enhancements from community ADDONs and ideas, and better engine. It continued on up to the latest version of VSB2 and alpha release of ARMA3.

Anyhow back to topic, I want to include things like Marcus L's (MixedGraphics) MX weapon mod's and the guided projectile idea to what I'm planning, alone with my own ideas.
#19
03/24/2013 (12:50 pm)
Well this week, I plan to look into how the Projectile and ProximityMine .H and .CPP file interact with weapon.cs files. Hopefully something will come of it, at least I hope to have a better understanding of the interaction.