Getting started
by Nicholas Helton · in Technical Issues · 05/20/2007 (12:04 am) · 1 replies
Im just getting started with Torque and we are working off of the FPS beginnings. I wanted to start small to learn how to start using Torque and decided to work on an experience point system. I added an experience point variable and a function to award exp to the player in the player script file. Then I wanted to call this function when the enemy was killed. Can someone help me to do this cuz I have tried a couple things and cant get it to work yet.
About the author
Torque Owner Caleb
Default Studio Name
For your AIs, create your own damage code so you can find who damaged your bot:
function AIPlayer::giveDamage(%this, %player, %amount) { //%this is the AI, %player is the player who hurt the AI, //and %amount is the damage amount if (%this.getState() !$= "Dead") { //Only apply damage if the AI is alive %this.applyDamage(%amount); } //Its possible that the previous block of code killed the AI, so lets see if (%this.getState() $= "Dead") %player.awardPoint(); //Where "awardPoint" is the name of your function that gives skill points }As an example for implementing this with a projectile, put this in your projectiles "onCollision" function:if (%col.getClassName() $= "AIPlayer" && %col.getState() !$= "Dead") %col.giveDamage(%obj, 10);Now, I believe there is the functions, "damage", and "onDeath" in the starter.fps folder that could be used, but I am not sure how you would use them.I hope this helps in some way.