Breaking MaxHealth and Energy from the Databock
by Vince Gee · 03/17/2006 (6:59 pm) · 33 comments
Ok,
Step one, in shapebase.h add
right after
Then,
Do a global search and replace for mDataBlock->MaxDamage and replace it w/ mMaxDamage
Then go to ShapeBase.cc
After
and at the end add
Thats it, basically the step we were missing all along was updating the masks, now that the masks are updated when ever you change the hp, things update correctly....
BTW, "WE" means dreamer and I... sorry dreamer...
Vince
Step one, in shapebase.h add
F32 mMaxDamage;
right after
class ShapeBase : public GameBase
{
typedef GameBase Parent;
friend class ShapeBaseConvex;
friend class ShapeBaseImageData;
friend void physicalZoneFind(SceneObject*, void *);
public:Then,
Do a global search and replace for mDataBlock->MaxDamage and replace it w/ mMaxDamage
Then go to ShapeBase.cc
After
ShapeBase::ShapeBase()
{
mTypeMask |= ShapeBaseObjectType;addmMaxDamage = 100;
and at the end add
ConsoleMethod( ShapeBase, setMaxDamage, void, 3, 3, "(F32 Max Damage)")
{
if (object->isServerObject())
{
object->mMaxDamage = dAtof(argv[2]);
object->setMaskBits(object->DamageMask);
}
}Thats it, basically the step we were missing all along was updating the masks, now that the masks are updated when ever you change the hp, things update correctly....
BTW, "WE" means dreamer and I... sorry dreamer...
Vince
About the author
www.winterleafentertainment.com
#2
Vince
03/16/2006 (7:19 pm)
you would call it by saying %Player.SetMaxDamage(1000); and it would set that players max health to 1000.Vince
#3
03/18/2006 (9:42 am)
If you have different races, why wouldn't you just make subclassed player definitions with different stats? The only point of doing this is if you need to be dynamically changing the definition of maxHealth in gameplay. I can't see this working properly without the right netcode setup, though I can only assume the DamageMask is making it work to some extent, I'd have to check what that forces to update.
#4
RPGs that have items that add to health could use this, even FPS games that have items you can pickup that raise your max health could use it.
Also if your subclassed player datablocks only change something like max health, then your creating needless data thats just adding to your server and client datablock load/transfer time.
03/19/2006 (5:04 pm)
It would work quite reliably. Only the server actually needs to know the correct maxDamage anyways. the datablock value isn't even transmitted normally. RPGs that have items that add to health could use this, even FPS games that have items you can pickup that raise your max health could use it.
Also if your subclassed player datablocks only change something like max health, then your creating needless data thats just adding to your server and client datablock load/transfer time.
#5
This is what we were doing in the old Advanced MMORPG tutorial series, that way you have a Max Health and a Max Mana or energy which could be set.
03/20/2006 (12:41 pm)
Just a heads up if you were wanting to do this in an RPG environment, you may also want to change the max energy values in much the same way.This is what we were doing in the old Advanced MMORPG tutorial series, that way you have a Max Health and a Max Mana or energy which could be set.
#6
03/20/2006 (4:27 pm)
@dreamer: have the advanced mmorpg tuts been updated to 1.4??
#8
03/21/2006 (11:35 am)
Paul, the reason behind is so that EACH player would have unique hitpoints. changing the datablock changes EVERYONES properties.
#9
03/21/2006 (8:03 pm)
@dreamer: is the SVN thing the only way to access the tuts or is there a ... simpler way.. hehe
#10
But...
SVN is for access to the code repository especially the enhancement kit, however there are and will be other things available.
The tutorials still exist as well, and I am going to repost some of those tonight with more coming in the future, however access to those is still completely free and will always be as such. They are just being bug fixed.
03/21/2006 (8:25 pm)
Ok seriously guys I'm not here to hijack this thread, so you should take the discussion of what's available on my site over there.But...
SVN is for access to the code repository especially the enhancement kit, however there are and will be other things available.
The tutorials still exist as well, and I am going to repost some of those tonight with more coming in the future, however access to those is still completely free and will always be as such. They are just being bug fixed.
#11
03/22/2006 (4:48 pm)
this code looks awful familiar.. like.. from the advanced tut. series perhaps? Vince.. is this all authentic code?
#13
03/22/2006 (10:11 pm)
yes
#14
Thats why I had said [qoute]Thats it, basically the step we were missing all along was updating the masks, now that the masks are updated when ever you change the hp, things update correctly....[/qoute]
03/26/2006 (8:05 am)
@Jon, Dreamer originally wrote it but he forgot the flag update, So I put this up w/ the flag update. AHH I for got to say who "We" were lol... Yes dreamer originally did the mod... Thats why I had said [qoute]Thats it, basically the step we were missing all along was updating the masks, now that the masks are updated when ever you change the hp, things update correctly....[/qoute]
#15
03/26/2006 (8:05 am)
I'll update the header :)
#16
03/26/2006 (9:27 am)
Also, if you don't do the damage mask flag... the server side melee resource WILL NOT work. It took me forever to figure out what was wrong... slapped my head pretty hard when I figured it out lol.
#17
I never meant for it to propegate to all clients when there was a change to max damage since the thing was only meant for a targeting GUI, but hey this is still some awesome work.
Anyways Vince still that was kewl of you to give me credit, drop me a line sometime I've got something you might enjoy using.
03/26/2006 (10:11 pm)
Hey Vince good catch man, I appreciate the cred for it.I never meant for it to propegate to all clients when there was a change to max damage since the thing was only meant for a targeting GUI, but hey this is still some awesome work.
Anyways Vince still that was kewl of you to give me credit, drop me a line sometime I've got something you might enjoy using.
#18
03/27/2006 (6:43 pm)
It's probably better to just set this in the gameconnection object belonging to the client instead of having every single instance of shapebase with a maxdamage value. When you add this to shapebase, all classes derived from shapebase inherit this, which means you are using more memory than you need to. At the very least it should be set in the Player object (unless you want trees to be doing 100 damage).
#19
Vince
03/28/2006 (2:55 pm)
Last time I looked it only included vehicles and player objects... Trees aren't derived off shapebase... I guess I could be wrong though.Vince
#20
Should be
I'll post more as I find them
04/16/2006 (11:48 pm)
Just quick fix to a typo you havemDataBlock->MaxDamage
Should be
mDataBlock->MaxDamage
I'll post more as I find them

Torque Owner Mr Meikel
I'm still a noob when it comes to editing the engine - could someone tell me where to expose this variable to the console for scripting purposes?