Developing a Battle System (discussion)
by Infinitum3D · in Torque Game Engine · 05/06/2009 (9:45 am) · 67 replies
I have TGE 1.5.2
The way I see it, there are three types of battles;
1. melee
2. ranged
3. magic
Torque has a basic 'ranged' battle system in effect.
I'm looking at player.cs and crossbow.cs first.
player.cs has datablock PlayerData(PlayerBody)
with the definition "maxDamage = 100;" which is commonly referred to as 'hit points'.
further down;
function Armor::onImpact applies damage %obj.damage()
and function Armor::damage applies damage
%obj.applyDamage(%damage);
and function Armor::onDamage does 3 things:
1.checks to see if player is dead
2.'flashes' the screen to show damage being done
3. plays an audio (pain) file
There are also the onEnterLiquid damage switch for Lava and finally the function Player::kill which looks like it assigns 10000 points damage to the player.
Crossbow.cs uses datablock ProjectileData(CrossbowProjectile)
which has the definitions
directDamage=20;
radiusDamage=20;
and further down
function CrossbowProjectile::onCollision()
which applies damage to ShapeBaseObjectTypes
So, what is my question?
Obviously this all applies to a 'ranged' battle system.
Would anyone care to comment on how they've adapted this to fit their game?
Are modifiers added through script, or are engine changes used? For example, if I wanted a more powerful (or less powerful) crossbow projectile, I could simple increase (or decrease) tthe directDamage variable.
But what I'm looking for is a discussion on various ways to modify this inherent battle system in TGE.
I know a 'melee' system resource exists (I've already added it), but for now, maybe we can just discuss 'ranged' modifications?
Any comments?
Tony
The way I see it, there are three types of battles;
1. melee
2. ranged
3. magic
Torque has a basic 'ranged' battle system in effect.
I'm looking at player.cs and crossbow.cs first.
player.cs has datablock PlayerData(PlayerBody)
with the definition "maxDamage = 100;" which is commonly referred to as 'hit points'.
further down;
function Armor::onImpact applies damage %obj.damage()
and function Armor::damage applies damage
%obj.applyDamage(%damage);
and function Armor::onDamage does 3 things:
1.checks to see if player is dead
2.'flashes' the screen to show damage being done
3. plays an audio (pain) file
There are also the onEnterLiquid damage switch for Lava and finally the function Player::kill which looks like it assigns 10000 points damage to the player.
Crossbow.cs uses datablock ProjectileData(CrossbowProjectile)
which has the definitions
directDamage=20;
radiusDamage=20;
and further down
function CrossbowProjectile::onCollision()
which applies damage to ShapeBaseObjectTypes
So, what is my question?
Obviously this all applies to a 'ranged' battle system.
Would anyone care to comment on how they've adapted this to fit their game?
Are modifiers added through script, or are engine changes used? For example, if I wanted a more powerful (or less powerful) crossbow projectile, I could simple increase (or decrease) tthe directDamage variable.
But what I'm looking for is a discussion on various ways to modify this inherent battle system in TGE.
I know a 'melee' system resource exists (I've already added it), but for now, maybe we can just discuss 'ranged' modifications?
Any comments?
Tony
#62
So the order of callBack is ALWAYS defined in the source?
So if I wanted to (not that I want to , but for example), I could go into the source and rearrange the order of this callBack.
Just to be clear: If there is ever any doubt to the order, I can go into the source and find it, right?
05/19/2009 (1:11 pm)
AHA!So the order of callBack is ALWAYS defined in the source?
Quote:
You can see, that you can use every name you want but the order is ALWAYS the same.
So the order of this callback is always:
1. ID of the Datablock
2. ID of the Object itself
3. Position
4. Rotation
5. Scale
So if I wanted to (not that I want to , but for example), I could go into the source and rearrange the order of this callBack.
Just to be clear: If there is ever any doubt to the order, I can go into the source and find it, right?
#63
05/19/2009 (1:27 pm)
Yes, that's true for callbacks that are called in the source. Sometimes you will define functions for your own use, not callbacks the engine recognises - in this case, you have to remember what arguments you use to do what, and put them in the right order.
#64
So there really is no easy way to know the order. Experience, I guess.
Time to start reading the source :)
Tony
05/19/2009 (1:55 pm)
Wow, thanks.So there really is no easy way to know the order. Experience, I guess.
Time to start reading the source :)
Tony
#65
Just an example I found of a way to "modify" a datablock.
EDIT: D@mn, Daniel did this way back in post #21. I need to pay more attention.
05/22/2009 (9:37 am)
function powerJump()
{
MessageAll("","Jump Boost On");
datablock PlayerData(PlayerBody : powerJump)
{
jumpForce = 8.3 * 900;
};
schedule(10000, 0, jumpBoostoff );
}
function jumpBoostoff()
{
MessageAll("","Jump Boost Off");
datablock PlayerData(PlayerBody : powerJump)
{
jumpForce = 8.3 * 90;
};
}
moveMap.bind( keyboard, lshift, powerJump );Just an example I found of a way to "modify" a datablock.
EDIT: D@mn, Daniel did this way back in post #21. I need to pay more attention.
#66
05/22/2009 (12:08 pm)
datablock PlayerData(PlayerBody : powerJump)
{
jumpForce = 8.3 * 900;
};Okay, so you're creating a new datablock called PlayerBody which inherits values from the powerJump datablock.
#67
2. Create the Datablock PlayerBody when PlayerBody already exists?
3. The modified value of jumpForce is not transmitted to the clients.
05/22/2009 (12:26 pm)
1. Function and Datablock have the same name?2. Create the Datablock PlayerBody when PlayerBody already exists?
3. The modified value of jumpForce is not transmitted to the clients.
Torque Owner Daniel Buckmaster
T3D Steering Committee
void ShapeBase::onCollision(ShapeBase* object,VectorF vec) { if (!isGhost()) { //Make two text arrays to put stuff in char buff1[256]; char buff2[32]; //Fill the first array with "x y z" of vector vec dSprintf(buff1,sizeof(buff1),"%g %g %g",vec.x, vec.y, vec.z); //Fill thesecond array with the vector's length dSprintf(buff2,sizeof(buff2),"%g",vec.len()); //Call the function onCollision with 5 arguments: // the datablock object's id // this object's id // the colliding object's id // buff1 (the vector vec) // buff2 (the vector's length) Con::executef(mDataBlock,5,"onCollision",scriptThis(),object->scriptThis(), buff1, buff2); } }Every time onCollision is called in the script, it is a result of this function (unless you call it yourself for some reason). The line with Con::executef actually performs the function. You can see that the arguments are passed in a certain order. This is the order they are put into the function, so this is the order you use them in, no matter what ou name the arguments in the script function definition.