Breaking Health
by Richard Preziosi · in Torque Game Engine · 05/01/2008 (10:03 pm) · 3 replies
Has anyone been able to make this work, I posted before about integrating it with another resource, but I wanted to just focus on this since I didn't get any feedback on the integration post.
Here is the resource I am attempting to use:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9774
If there is an easier or better way, any help would be appreciated.
Here is the resource I am attempting to use:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9774
If there is an easier or better way, any help would be appreciated.
#2
05/12/2008 (4:37 pm)
I thought about that as well, but would I be able to affect that dynamically?
#3
As far as damage is concerned, you could just tag each new Player object with a script damage multiplier variable. It's even easier to change and damage is processed entirely at the server-side script level. Just leave the datablock's maxDamage at 100 (or whatever), and it basically will represent a damage percentage.
After you spawn the Player in script, just do something like: %player.dmgMult = 0.1 (for 1,000 HP)..
When damage is applied in the damage() function, multiply the damage by %player.dmgMult.
Whenever you want to change the HP of the object, just change that variable in script.
This isn't the most elegant solution, but it is the one that requires the smallest change to make work quickly, and I can't really think of any drawbacks. You'll probably also want to multiply any healing applied to the object by this value, otherwise a player with 10,000 HP and one with 10 HP both get the same % restored HP from a healing item.
Again, energy can be done in a similar way, but because it processes on the client as well, you'll want to actually add a variable to the Player class (or Vehicle, or whatever) and sync this during the network updates.
All that said, the resource you linked actually looks like it should work, I'm just personally not a fan of alterations to the code with statements like "do a global replace of.." as I tend to be really compulsive about making it easy to port my code to new versions of Torque. What specific issue did you have with the resource?
05/14/2008 (2:05 pm)
You can dynamically alter any value that is in the instantiated object, ie any variable actually found on the Player object itself and not the PlayerData datablock.As far as damage is concerned, you could just tag each new Player object with a script damage multiplier variable. It's even easier to change and damage is processed entirely at the server-side script level. Just leave the datablock's maxDamage at 100 (or whatever), and it basically will represent a damage percentage.
After you spawn the Player in script, just do something like: %player.dmgMult = 0.1 (for 1,000 HP)..
When damage is applied in the damage() function, multiply the damage by %player.dmgMult.
Whenever you want to change the HP of the object, just change that variable in script.
This isn't the most elegant solution, but it is the one that requires the smallest change to make work quickly, and I can't really think of any drawbacks. You'll probably also want to multiply any healing applied to the object by this value, otherwise a player with 10,000 HP and one with 10 HP both get the same % restored HP from a healing item.
Again, energy can be done in a similar way, but because it processes on the client as well, you'll want to actually add a variable to the Player class (or Vehicle, or whatever) and sync this during the network updates.
All that said, the resource you linked actually looks like it should work, I'm just personally not a fan of alterations to the code with statements like "do a global replace of.." as I tend to be really compulsive about making it easy to port my code to new versions of Torque. What specific issue did you have with the resource?
Torque Owner Henry Todd
Atomic Walrus
Technically I added an RPG-style stat/inventory system to the class, but the effect is the same -- some easily-modified value in the object modifies the application of damage. A simple example would be having an F32 damageMult in the class (don't really need to sync this to clients since damage is effectively always a server-side script event) which you multiply against any applied damage everytime the object's damage method gets called in script. In other words, if you want this particular object to have 10x the HP, use 0.1, which will cause it to take 10% of the damage it normally would, and results in exactly the same thing.
Energy may require a net-synced solution (ie add a var to the class and send it in the updates) since its use occurs on both the client and server during run/jump events, as does its regen.