View Single Post
Old 21-10-17, 20:24   #482
matrix54
Member
 
matrix54's Avatar
 
Joined: May 2007
Posts: 20,453
Default

Hey all.

Since this is going to take a whiiiile, I thought I'd share a WIP version of the tutorial I'm making for y'all. Is has the important bits in it for having multiple weapons (more than 6) in a project, but it needs pictures, more text, and some sample objects to get everyone going. I'm posting it because I'm a little winded from writing all of this and I wanted to share, so enjoy.

-------------------------

** Stress-Free Package At The Bottom Of The Page**
**If You Can Little For Learning And Just Want Guns!**


This is an advanced tutorial, and assume the user knows how to script, look for/create script entries in the NGLE and use WadMerger. Things will be explained when needed.

To start, let's create a list of required and suggested tools:

Required:
-TRNG (Next Gen Level Editor & NGCenter)
-WadMerger
-Additional desired weapons & animations

Suggested:
-Flep

Here, we have a list of the weapons that we have available to us:

Code:
-Pistols
-Uzis
-Revolver
-Revolver+Lasersight
-Shotgun
-Crossbow
-Crossbow+Lasersight
-Grenade Gun
Let's add in a list of missing weapons from the classic games that we're going to add to the game.

Code:
-Pistols
-Uzis
-Revolver
-Revolver+Lasersight
-Shotgun
-MP5
-Crossbow
-Grappling Gun
-Grenade Gun
-Rocket Launcher
Now, a list of ammunition types available to us, and their properties when paired with specific weapons:

Code:
-Pistol Ammo (Hitscan)
-Uzi Ammo (Hitscan)
-Revolver Ammo (Hitscan)
-Shotgun Normal Ammo (1-6 Hitscans, Narrow)
-Shotgun Wideshot Ammo (1-6 Hitscans, Wide)
-Crossbow Normal Ammo (Weightless Projectile)
-Crossbow Poison Ammo (Weightless Projectile, Poisons Living Things)
-Crossbow Explosive Ammo (Weightless Projectile, Explosive Target Upon Death)
-Grenade Gun Normal Ammo (Weighted Projectile, Explosive Target Upon Death)
-Grenade Gun Super Ammo (Weighted Projectile, Clusters, Explosive Target Upon Death)
-Grenade Gun Flash Ammo (Weighted Projectile, Blinds Humans)
This ammo will then be converted to the following:

Code:
-Pistol Ammo
-Uzi Ammo
-Revolver Ammo
-[Unused]
-Shotgun Ammo
-Crossbow Ammo
-Grapple Gun Ammo
-Rockets
-Grenade Gun Ammo 
-[Unused]
-MP5 Ammo
To add in these additional weapons, we'll be modifying out animation slots. The MP5 (or M16 if you prefer, it will work the same) will used the shotgun slot. The Grappling Gun and Rocket Launcher will use the Crossbow slot. Sadly, this only works for weapons that can be placed on Lara's back (though there are work around for other weapons).

Let's be clear absolutely clear about the new weapon changes we're going to make:

All Weapons:
Code:
-To mask our modified data, we will hide all available ammo types available in the inventory.
-This will require an ammo counter in game.
Shotgun:
Code:
-The Shotgun will use only one ammo type: Wideshot.
MP5:
Code:
-The MP5 will use modified version of the shotgun and its Normal Ammo.
-The MP5 will require grenade gun flash ammo, and deplete grenade gun flash ammo when used. It can also use uzi ammo, if desired (since the two are submachine guns).
-The shotgun's normal ammo will be set to either 1 or 0 if the desire ammo is present. This will cause the shotgun to fire one bullet at a time.
-It is possible to have the MP5 fire ammo from a global variable if desired, but it will not carry forward after using ResetHub.
-The MP5 can fire from the hip while running, or from the shoulder while standing still.
Crossbow:
Code:
-The crossbow will only use on ammo type.
-The crossbow can also be a harpoon gun if desired.
-The crossbow will not use a lasersight.
Grappling Gun:
Code:
-The Grapple Gun will used a modified version of Crossbow Poison Ammo.
-The grapple gun will always use a lasersight.
-The grapple gun does not require a grapple point to fire.
-The grapple gun can differentiate between what is and is not a grapple point to launch a rope.
-The grapple require a special grapple point object to launch a rope.
-The crossbow bolt will be changed respectively.
Rocket Launcher:
Code:
-The Rocket Launcher will use a modified version of crossbow explosive ammo.
-The Rocket Launcher will not use a lasersight.
-The crossbow bolt will be changed respectively.
But how? How is this all possible!? Variables!

Weapon variable are stored in the weapon's save game memory, and they each use code bits, which are essentially true or false statements. All weapons have the following 8 flags:

Code:
-1: In the inventory.
-2: Flashlight is used [Unused].
-4: Lasersight is used (Crossbow).
-8: Ammo 1 is used (Shotgun, Crossbow, Grenade Gun).
-16: Ammo 2 is used (Shotgun, Crossbow, Grenade Gun).
-32: Ammo 3 is used (Crossbow, Grenade Gun).
-64: Ammo 4 is used (Grenade Gun)[Unused].
-128: Ammo 5 is used (Grenade Gun)[Unused].
With these flags, you can instantly switch back and forth between different ammo types once triggered. As you can see, there are also a few [Unused] flags available for each weapon. These are incredibly important, as well as powerful. These variables will also persist from level to level for the entire game so you can even use them for non weapon related variables!

This is what the final version of our flags will resemble for each of our weapons:

Shotgun:
Code:
-1: In the inventory.
-2: [Unused].
-4: [Unused].
-8: This is an MP5.
-16: This is a shotgun.
-32: [Unused].
-64: The MP5 mesh has been swapped.
-128: [Unused].
Crossbow:
Code:
-1: In the inventory.
-2: [Unused].
-4: Lasersight is used.
-8: This is a crossbow.
-16: This is a grappling gun.
-32: This is a rocket launcher.
-64: The grappling meshes has been swapped.
-128: The rocket meshes has been swapped.
Step 1. Animations
For this to work, we must add additional weapons to our weapon slots. Each of these animations from the classic guns must be properly connected with state IDs of that slot and transitions to each animation, beyond the starting animation for each sub set.

First, you must diagnose which weapons you want to have what properties. Since the MP5 is a hitscan weapon, we attach those animations to the shotgun. The grappling gun is a projectile weapon that doesn't explode, so we'll make that a crossbow. The Rocket Launcher is a weightless projectile that explodes, so we'll attach the animations to the crossbow as well. If you're taking animations from TR1-5, you must change the state-ID's and the next animations.

Here are a list of state IDs for the weapons:

Shotgun:
Code:
0: Transition - Equipped > Firing
1: Transition - Unequipped > Equipped
2: Firing
3: Transition - Equipped > Unequipped
4: Transition - Firing > Equipped
Crossbow:
Code:
0: Transition - Equipped > Firing
1: Transition - Unequipped > Equipped
2: Firing
3: Transition - Equipped > Unequipped
7: Transition - Firing > Equipped
Grenade Gun:
Code:
0: Transition - Equipped > Firing
1: Transition - Unequipped > Equipped
2: Firing
3: Transition - Equipped > Unequipped
4: Transition - Firing > Equipped
5: Reloading
Note: For each weapon animation that has State-ID 3 (the unequip animation) , you'll be required to use Animation Command 0-Die and you'll be required to set the Next Frame to the last frame of the animation.

You'll also be required to set up a few flip effects for the animations...

Step 2. Scripting

First, we need to give our weapons new properties. These properties give our weapons new characteristics to make them behave more what they're supposed to (like removing damage from grapple ammo, manipulating projectile speed, etc.).

Code:
Customize=			CUST_AMMO, SHOTGUN_AMMO1_ITEM, IGNORE, 5, IGNORE, 0, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE
Customize=			CUST_AMMO, SHOTGUN_AMMO2_ITEM, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE

Customize=			CUST_AMMO, GRENADE_GUN_AMMO1_ITEM, IGNORE, IGNORE, 2, IGNORE, IGNORE, IGNORE, IGNORE, 256, IGNORE, IGNORE, IGNORE
Customize=			CUST_AMMO, GRENADE_GUN_AMMO2_ITEM, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE
Customize=			CUST_AMMO, GRENADE_GUN_AMMO3_ITEM, IGNORE, IGNORE, 60, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE

Customize=			CUST_AMMO, CROSSBOW_AMMO1_ITEM, IGNORE, 5, 3, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE
Customize=			CUST_AMMO, CROSSBOW_AMMO2_ITEM, IGNORE, 0, 1, 100, IGNORE, IGNORE, 0, IGNORE, IGNORE, IGNORE, IGNORE
Customize=			CUST_AMMO, CROSSBOW_AMMO3_ITEM, IGNORE, 100, 1, 1, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE
Then we create flip effects for our weapons. These flip effects will enable the shotgun, and crossbow (and grenade gun if you desire) to equip new weapons when the weapons default draw animation plays.

Shotgun to MP5:
Code:
TriggerGroup=		20, >
$2000, 244, $1BFF,	> Copy Shotgun from Save Game Memory to Current Value
$2000, 272, $42,	> Current Value to Local Byte Alpha 3
$8000, 255, $32C,	> If Bit 3 is Set...
$2000, 272, $FF,	> Fake Item Weapon Index to Current Value
$2000, 245, $2FF,	> Current Value to Selected Item Memory
1+$5000, 32, $60F	; Play animation 6
Crossbow to Rocket Launcher:
Code:
TriggerGroup=		30, >
$2000, 244, $1BFF,	> Copy Shotgun from Save Game Memory to Current Value
$2000, 272, $42,	> Current Value to Local Byte Alpha 3
$8000, 255, $32C,	> If Bit 3 is Set...
$2000, 272, $FF,	> Fake Item Weapon Index to Current Value
$2000, 245, $2FF,	> Current Value to Selected Item Memory
1+$5000, 32, $60F	; Play animation 6

Since the grappling gun from TRC shares the same animations as the crossbow, we don't need to do any fancy magic tricks. Outside of the draw animations, some weapons require select properties.

The MP5 isn't supposed to fire different ways depending on how Lara's moving...

Code:
;MP5 - Aiming Fire
TriggerGroup=		23, >
$8000, 11, $5,		> If Lara is Stopping...
$2000, 272, $FF,	> Fake Item Weapon Index to Current Value
$2000, 245, $2FF,	> Current Value to Selected Item Memory
1+$5000, 32, $B0F	; Play animation 11 + FOUND ITEM INDEX

;MP5 - Force Hip Fire While Aiming
TriggerGroup=		24, >
$8000, 11, $105,	> If Lara is NOT Stopping...
$2000, 272, $FF,	> Fake Item Weapon Index to Current Value
$2000, 245, $2FF,	> Current Value to Selected Item Memory
1+$5000, 32, $C0F	; Play animation 12 + FOUND ITEM INDEX

;MP5 - Force Aim Fire While Hip Firing
TriggerGroup=		25, >
$8000, 11, $5,		> Lara is Stopping...
$2000, 272, $FF,	> Fake Item Weapon Index to Current Value
$2000, 245, $2FF,	> Current Value to Selected Item Memory
1+$5000, 32, $90F	; Play animation 9 + FOUND ITEM INDEX
Step 3. Animation II

Now, we attached the scripts to our animations with SetPosition commands. For our weapons default draw animation, we attach these to our animations:

Code:
-24321 | 372 | 20
The 20 is bolded due to the change in flip effect numbers from project to project. You can change the draw flip effect numbers to whatever you prefer, so the number in your animation should be changed to that. Here, for this weapon we use 20. For Another, we'd use 30, the 40 (or whatever).

to be continued...

Last edited by matrix54; 22-10-17 at 13:56.
matrix54 is offline   Reply With Quote