Author Topic: Tech Guns and Bows, part 2  (Read 986 times)

Offline Amneiger

  • Newbie
  • *
  • Posts: 20
    • View Profile
Tech Guns and Bows, part 2
« on: September 17, 2009, 03:37:27 PM »
After a few months of not really doing much of anything, I decided to try modding new types of weapons into GH1 again.

As per the last time I tried this, I added the following lines to ghpmacro.txt:

TechGun       <Gear 4 6 ?3>
Bow           <Gear 4 7 ?3>
PowerPack     <Gear 5 6 ?3>
Arrows        <Gear 5 7 ?3>

As you can see, GS_TechGun =6 and GS_Bow = 7.  I also added the names to the DefaultWeaponName array in ghweapon.pp.  After that I went through the rest of ghweapon.pp setting things like initial value, weapon cost, and weapon range checks.  Persumably this would be enough to establish that these are new weapon types, so I added some sample weapons (one TechGun and one Bow) to the ADV file and let it run.

It appears that for whatever reason, the game doesn't recognize the weapons as valid parts.  While it reaches InitWeapon with the new weapons, it isn't reaching WeaponName, WeaponBaseDamage, WeaponBaseMass, WeaponCheckRange, or WeaponCheckValue.  I've also confirmed that it isn't reaching BasicWeaponDesc from damage.pp either.  So the weapons are coming up with as Missile Launchers with 0.5 kg and 0 DP.  

Those functions are called from gearutil.pp, so I looked through there; I still couldn't find any clues about what I was doing something wrong, however.  I can only assume that I missed a step somewhere, didn't decalre the new weapon types someplace vital, and therefore game doesn't realize that the new weapon types are supposed to be weapons.  

Really, I'm lost here.  If anyone can give me any sort of advice, that would be great.

Offline Joseph Hewitt

  • Administrator
  • Hero Member
  • *****
  • Posts: 2552
    • View Profile
    • http://www.gearheadrpg.com
Tech Guns and Bows, part 2
« Reply #1 on: September 17, 2009, 04:45:20 PM »
Sorry I didn't reply to the last post. New weapon categories have to be hardcoded into the program (ghweapon.pp), otherwise the game won't know how to handle them.

Offline Amneiger

  • Newbie
  • *
  • Posts: 20
    • View Profile
Tech Guns and Bows, part 2
« Reply #2 on: September 17, 2009, 07:04:06 PM »
I did that already...I think?  I added GS_TechGun and GS_Bow to the constants in ghweapon.pp (as 6 and 7), added them to the DefaultWeaponName array, and added them to functions such as CheckWeaponRange.  I'm not sure what else I'm supposed to be doing.

Offline Amneiger

  • Newbie
  • *
  • Posts: 20
    • View Profile
Tech Guns and Bows, part 2
« Reply #3 on: September 19, 2009, 06:29:21 AM »
Would it be easier if I just sent you a copy of the modifications I've made to ghweapon.pp?  That might be clearer than trying to describe them without a reference.

Offline Joseph Hewitt

  • Administrator
  • Hero Member
  • *****
  • Posts: 2552
    • View Profile
    • http://www.gearheadrpg.com
Tech Guns and Bows, part 2
« Reply #4 on: September 19, 2009, 06:51:28 AM »
OK. Next, you need to modify CheckWeaponRange so that these new weapon types are legal, and make sure that it checks their stats correctly. Oh, and you may want to add default weapon stats to InitWeapon.

After that, you can program in the behavior of these new types. This may be a difficult task- GH is written in procedural rather than object oriented style, so the bits controlling how weapons work are scattered all over the place. I would recommend doing a grep for GS_Ballistic; this should tell you which bits of the code have to do with ballistic weapons, and you can modify the behavior of those bits to correctly deal with these new types.

What new rules do these weapons have which couldn't be covered by simply making them ballistic weapons with a name change?

Offline Amneiger

  • Newbie
  • *
  • Posts: 20
    • View Profile
Tech Guns and Bows, part 2
« Reply #5 on: September 19, 2009, 08:33:34 AM »
Okay, I've done a search for GS_Ballistic and added things as needed.  That got me to InitWeapon, CheckWeaponRange, IsLegalWeaponSub, IsLegalWeaponInv, CheckAmmoRange, and WeaponValue.

The general idea behind the changes was that I wanted to change weapon skills so that they would be matched to weapon type instead of weapon DC.  

Bows are pretty much the same as ballistic weapons and won't really require changes.

Tech Guns are a bit more complicated.  What I wanted was a kind of battery-powered energy weapon, as opposed to the current includes-the-generator BeamGuns.  Ideally, the displayed magazine size would be determined by the magazine instead of the weapon, and the final weapon DC would be determined by the weapon DC instead of the ammo DC.  This was something that I'd first noticed in GH2 0.541, when I looked at the FS Vaken assault rifle.  NotGoodAmmo already checks that weapon and ammo S values match, so once I've gotten the weapons done I'll change that to accept Tech Gun / Power Packs with differing DCs.

Side note: The new ammunition doesn't seem to be working either; I'm assuming that this is for the same reason the weapons aren't working.

Offline Amneiger

  • Newbie
  • *
  • Posts: 20
    • View Profile
Tech Guns and Bows, part 2
« Reply #6 on: September 21, 2009, 08:41:10 AM »
That's pretty much as far as my own notes went in terms of what changes I had to make.  Is there anything else I need to do?