Game Development Community

A simple turn based RPG damage function

by Snaggz · in Torque Game Engine · 04/30/2006 (8:49 am) · 6 replies

So basically i was trying to modify the CodeSampler.com tutorial on weapon dmg to my RPG dmg. So far i have a gui that comes up when you collide with an object. (its an ant) It has an attack button. I dont know what to call from the command of the button to get my damage function to run...

I have className = HP; in the datablock StaticShapeData(Ant) section also

function HP::Damage(%this, %object, %sourceObject, %damage)
{

echo( "Function HP::Damage has been called");
}

This is my function because i didnt want to get ahead of myself, and i just wanted to get it called.

function ShapeBase::damage(%this, %sourceObject, %damage)
{
// All damage applied by one object to another should go through this
// method. This function is provided to allow objects some chance of
// overriding or processing damage values and types. As opposed to
// having weapons call ShapeBase::applyDamage directly.
// Damage is redirected to the datablock, this is standard proceedure
// for many built in callbacks.
%this.getDataBlock().damage(%this, %sourceObject,%damage);
}

I also have this in server/shapebase.cs. I dont really understand why but it looks like it belongs there...

So my questions:
1:Should i make another function in somewhere to call my dmg function?
2:How should i call it from the command field in the GUI?
3:Are the arguments %this and %object values that you dont have to enter? it seems like they didnt put those 2 in when they called the funtion.

Could someone please help me or point me to a good resource? Im lost as hell here. I ordered the GG book but it hasnt come yet and im stuck =/

P.S. I see now that i forgot %object in the shapebase part, but it prolly wouldnt have helped because i was guessing commands to put in E.G. Damage(%client.player, 20); which crashed the game pretty quick lol.

#1
04/30/2006 (10:44 am)
%object.applydamage(%amount);

I believe that's all you need to actuall do the damage itself

The tricky part might be knowing what the object to damage will be.

Perhaps you could send that data to the GUI object, or use some Global Values.

I've got a fully function turnbased system, but i'm not using much of the default stats of the aiplayers.
I've got my my HP stat and what not. All i do is pay attention to that stat to determine if the object needs to be killed off.

My scripts for the battle system are pretty lengthy though. Here's some of my recent blogs.
www.garagegames.com/blogs/11127/10331
www.garagegames.com/blogs/11127/9485

Anyhow, why are you using Shapebase? is the Ant not an AIPlayer?
#2
04/30/2006 (12:57 pm)
My ant is in a StaticShapeDatat datablock under categories items or something. so its basically a static shape with my own script
#3
04/30/2006 (2:02 pm)
Yeah im trying to put the HP stat in one of the GUI windows at first. ill prolly take it out once the game progresses but i just want to watch it to make sure its changing when a player takes dmg. I tried putting in myAnt.applydamage(20); and I dont get any errors in the consil. Thanks for the help but then Im tried to:

echo( "My ant has been dmged by:" @ %damage );

in the function Armor::onDamage( %this, %obj, %damage) function. I didnt get the echo for some reason and i thought it might be because it was a static shape. So i copied all the ant data over to my ai bot and still no echo in the consil when i apply the damage.
#4
04/30/2006 (5:04 pm)
Nevermind i got it. thanks :) i just forgot to add the className = Armor; to the bot file.
#5
04/30/2006 (5:35 pm)
Your right though... the only problem is targeting my AI bot. I dont know how to name him when he spawns. Anyone know how to do that?
#6
04/30/2006 (5:49 pm)
Nevermind i figured that out too. :D