[Need Help] - Managing Energy
by Nicolai Dutka · in Torque 3D Beginner · 05/05/2010 (1:00 pm) · 3 replies
In a project I am working on, we're using the built-in 'energy' that powers the default jetpack, to power our spell system. Spells are cast using the energy and immediately after casting, the energy starts recharging. This is all good and fine, but the energy is recharging too fast for game balance.
Where would I find the code that is controlling the energy recharge rate so I can make it recharge at about half-speed?
Where would I find the code that is controlling the energy recharge rate so I can make it recharge at about half-speed?
#2
The datablock sets the rate, the onAdd for the class gets the 'recharge' going. Similar method(s) can apply for all shapebase objects.
05/05/2010 (3:39 pm)
Check out the player datablock (Full Template), you'll find something similar to this:rechargeRate = 0.256;Then in game/scripts/server/player.cs in function Armor::onAdd() you'll find this:
// Default dynamic armor stats %obj.setRechargeRate(%this.rechargeRate); %obj.setRepairRate(0);
The datablock sets the rate, the onAdd for the class gets the 'recharge' going. Similar method(s) can apply for all shapebase objects.
#3
For some reason, I didn't think to look for a 'setRechargeRate' or anything else with the term 'recharge'... I was looking for anything related to 'energy'.
05/05/2010 (4:42 pm)
Beautiful, exactly what I was looking for!For some reason, I didn't think to look for a 'setRechargeRate' or anything else with the term 'recharge'... I was looking for anything related to 'energy'.
Associate Chris Robertson
The recharge rate is added to the object's current energy level each tick, up to the maxEnergy level set in the ShapeBaseData datablock.