Crash? Please help.
by Matt "Mr. Pig" Razza · in Torque Game Engine · 12/18/2005 (12:33 pm) · 4 replies
Problem: When ever I throw a nade in the game I am currently developing the game crashes (when I only have the nade in inventory - no other weapons).
Detail:
This nade has been working for a while. I recently added a call to my removeWeapon function in my inventory system when the nade is thrown so that it would be unmounted and removed from inventory. After it is unmounted the inventory system would then scan for the next weapon the player is holding (looks through weapon slots - Knife is 1, Pistol is 2, Rifle is 3, Nade is 4, ect). If it finds a match it mounts the weapon and exits the loop. It then distroys the inventoryData for the Nade. Or it should...
I compiled the debug version of TGE 1.4 but I didn't see any difference running with that exe or anyother console data. (I don't know if there is any special command to run debug mode in that app). This is what happens - from my investigation into the script. You press fire, one nade is removed from inventort (0 are left). The fire function calls to removed the nade from inventory. It runs the removeWeapon function in my inventory system which checks if the weapon being removed is mounted (which it is). It then unmounts the weapon image and searchs for a new weapon to mount - if one is found, it mounts it and works correctly. If one is not found it crashes. I am not sure if it crashes inside our outside of the weapon scan loop. I am guessing inside being that I did not see an echo inside the console that I had directly following the loop.
Code:
Thanks!
Detail:
This nade has been working for a while. I recently added a call to my removeWeapon function in my inventory system when the nade is thrown so that it would be unmounted and removed from inventory. After it is unmounted the inventory system would then scan for the next weapon the player is holding (looks through weapon slots - Knife is 1, Pistol is 2, Rifle is 3, Nade is 4, ect). If it finds a match it mounts the weapon and exits the loop. It then distroys the inventoryData for the Nade. Or it should...
I compiled the debug version of TGE 1.4 but I didn't see any difference running with that exe or anyother console data. (I don't know if there is any special command to run debug mode in that app). This is what happens - from my investigation into the script. You press fire, one nade is removed from inventort (0 are left). The fire function calls to removed the nade from inventory. It runs the removeWeapon function in my inventory system which checks if the weapon being removed is mounted (which it is). It then unmounts the weapon image and searchs for a new weapon to mount - if one is found, it mounts it and works correctly. If one is not found it crashes. I am not sure if it crashes inside our outside of the weapon scan loop. I am guessing inside being that I did not see an echo inside the console that I had directly following the loop.
Code:
//If the weapon that's being removed is mounted
if (%this.weaponShape[%slot] == %this.getMountedImage(0).getName())
{
//Un-mount the weapon
%this.unMount(%weapon);
//Mount new weapon (if you have it)
[b]for (%x = %slot - 1; %x > 0; %x--)
{
if (%this.weaponSlot[%x]) //Do you have a weapon in that slot?
{
%this.useWeapon(%x); //Mout it
break; //Exit loop
}
}[/b]
}Thanks!
About the author
Torque Owner Paul /*Wedge*/ DElia