Game Development Community

Question about weapon script

by Logan Strunk · in Torque Game Engine · 03/22/2006 (4:00 pm) · 2 replies

I'm trying to adapt the CrossBow script to act more like an automatic rifle than a Crossbow.

I've been playing around with it most of the day, and can't seem to figure out alot.

1.) How do I change the amount of ammo that is added to your players cache, every time you pick up a ammo clip? I thought I might have found it, but it didn't seem to work.

2.) How do I get rid of the explosions that the arrows cause when they hit something? I didn't want to go just editing major parts of the script out, when I assume there must be somwhere in there to turn off the explosion effect off at just one line. I just can't find it.


3.) How do Increase the ROF?

Starting on line 896
// Play the relead animation, and transition into
stateName[4] = "Reload";
stateTransitionOnNoAmmo[4] = "NoAmmo";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 0.1;
stateAllowImageChange[4] = false;
stateSequence[4] = "Reload";
stateEjectShell[4] = true;
stateSound[4] = CrossbowReloadSound;

I found this, and when I changed the timeout vaule to .1 instead of (I think it was) .6, that seemed to work, is that the proper way to go about this?


I'm sorry if these seem like really newbie questions. I'm still trying to lean the ropes on this thing, and I expermimented all day with the weapons. I wish a more "normal" example of a rifle would have been included rather than the cross bow.

I also have a rather dumb question about the scripting. I just want to make sure I'm understanding this properly.

Lets take this datablock for example:
function CrossbowProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
// Apply damage to the object all shape base objects
if (%col.getType() & $TypeMasks::ShapeBaseObjectType)
%col.damage(%obj,%pos,%this.directDamage,"CrossbowBolt");

// Radius damage is a support scripts defined in radiusDamage.cs
// Push the contact point away from the contact surface slightly
// along the contact normal to derive the explosion center. -dbs
radiusDamage(%obj, %pos, %this.damageRadius, %this.radiusDamage, "Radius", %this.areaImpulse);
}

Now, is the C code, in the actual engine, using this for additional data? So for example, there is a weapon function in the engine, and when the projectile hits something, it looks at this section of the script to see if there is anything additional it needs to do, in addition to what its already doing in the engine? I know thats a little bit simplistic of a way of trying to explain what I'm thinking, but is that somewhat how this works?

I've worked with some Python before, and am not bad a C programming, but the way this scripting language is set up is a little foreign to me.


Thank you, anyone that helps me out with this.

#1
03/22/2006 (6:05 pm)
Hey Logan,

1) Within the datablock ItemData(CrossbowAmmo) section look for this line & change accordingly.
maxInventory = 20;

This also references back to player.cs within the datablock PlayerData(PlayerBody) section.
maxInv[CrossbowAmmo] = 50;

2) Look in the datablock ProjectileData(CrossbowProjectile) section & comment out...
explosion           = CrossbowExplosion;

3) Yes, you're on the right track. You'd also want to look at the state directly above.
stateName[3]                     = "Fire";
   stateTransitionOnTimeout[3]      = "Reload";
   stateTimeoutValue[3]             = 0.2;[b]//look here[/b]
   stateFire[3]                     = true;
   stateRecoil[3]                   = LightRecoil;
   stateAllowImageChange[3]         = false;
   stateSequence[3]                 = "Fire";
   stateScript[3]                   = "onFire";
   stateSound[3]                    = CrossbowFireSound;

   // Play the relead animation, and transition into
   stateName[4]                     = "Reload";
   stateTransitionOnNoAmmo[4]       = "NoAmmo";
   stateTransitionOnTimeout[4]      = "Ready";
   stateTimeoutValue[4]             = 0.8;[b]//and here[/b]
   stateAllowImageChange[4]         = false;
   stateSequence[4]                 = "Reload";
   stateEjectShell[4]               = true;
   stateSound[4]                    = CrossbowReloadSound;
#2
03/22/2006 (6:57 pm)
Wow, thank you so much. I wasn't expecting that quick and good of a response.