Game Development Community

ditch the ammo, just use energy

by Dr. John Nobody · in Torque Game Engine · 06/03/2003 (11:26 pm) · 3 replies

Hey all, as the title suggests I'd like to switch from collecting ammo and using an inventory system to just having a weapon which draws straight from the characters energy. Would it be possible to just replace this line from
rifle::onfire which decrements to inventory "%obj.decInventory(%this.ammo,0);" to something that decrements the players energy? thanks for any help you can offer.

#1
06/04/2003 (1:05 am)
If I'm not mistaken you can just remove:
ammo = AmmoType;
in the ShapeBaseImageData datablock and add the lines
usesEnergy = true; //Tells the weapon to use energy
MinEnergy = 50; //Minimal energy required to fire the weapon.

However there's also an line
stateEnergyDrain[3] = 10; //from the laser beam tut.
That needs to be added to your firing state.

Ofcourse you could just like you said replace the ammo decreasing function in weapon::onfire() and use the following functions,
%player.getEnergyLevel(%amount);
%player.setEnergyLevel(%amount);

However I think, wether or not the weapon is allowed to fire depends on the datablock specifics shown above.
#2
06/04/2003 (1:16 am)
thanks sebastiaan, I'm gonna go try this out!
#3
01/19/2004 (4:04 pm)
This works perfectly for me. Thank you so much. This is great for a spell system.

I just added these lines to the ShapeBaseImageData datablock for the spell(weapon) I created:

usesEnergy = true;
MinEnergy = 15;
stateEnergyDrain[3] = 15;

Change the numbers for different power of spells, and it's great.