Questions
by Very Interactive Person · in Torque Game Engine · 02/04/2003 (7:00 am) · 5 replies
Question 1:
How dificult would it be to make a hurt trigger? I have some triggers already in my game.... those were done by a programmer who is no longer around, so now I have to do things myself.
So, lets say I have this in trigger.cs:
How would I do all this?
Question 2:
I have a vehicle and I want to add a load variable to it. Is this possible trough scripts, or do I have to change the engine code and add a new property to the vehcile class?
Also, when entering a certain trigger I want this variable to slowely increase until it reached a maximum limit (so its slowely loading its cargo). I also want another trigger to unload the vehicle.
Now I heard that triggers don't respond to vehicles.... is this still the case? Am I even approaching this problem the right way? Any toughts?
How dificult would it be to make a hurt trigger? I have some triggers already in my game.... those were done by a programmer who is no longer around, so now I have to do things myself.
So, lets say I have this in trigger.cs:
datablock TriggerData(Hurt)
{
tickPeriodMS = 100;
};
function Hurt::onEnterTrigger( %this, %trigger, %obj
)
{
echo("do damage");
}
function Hurt::onLeaveTrigger(%this, %trigger, %obj)
{
echo("stop doing damage");
}Now, everybody must remember for example half-life. You walk trough a fire and you are hurt. There's also a little icon on the screen that tells you what type of damage it is (burn, crush, freeze,...). So, in the onEnterTrigger function there should be a check wether its a player or not (right?) and then do damage to that player.... and show th right icon on the screen. So the trigger needs another parameter called "damagetype" or something.... can I just add that to the datablock? like damageType="Burn"; ?How would I do all this?
Question 2:
I have a vehicle and I want to add a load variable to it. Is this possible trough scripts, or do I have to change the engine code and add a new property to the vehcile class?
Also, when entering a certain trigger I want this variable to slowely increase until it reached a maximum limit (so its slowely loading its cargo). I also want another trigger to unload the vehicle.
Now I heard that triggers don't respond to vehicles.... is this still the case? Am I even approaching this problem the right way? Any toughts?
#2
2)Doing something over time :: Not hard, use schedules. When the truck enters the trigger, start a repeating schedule that adds a little bit a few times per second. When it leaves, cancel the schedule.
hope that helps.
02/04/2003 (10:50 pm)
1) Extra stuff in datablocks :: Sure, just glom it right on! Then pass the DamageType as an argument of the damage function. If the thing getting damage needs to repsond differently to different damage types, then handle that in the objects. See the script function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType) .2)Doing something over time :: Not hard, use schedules. When the truck enters the trigger, start a repeating schedule that adds a little bit a few times per second. When it leaves, cancel the schedule.
hope that helps.
#3
02/06/2003 (6:27 am)
Thanks, I'm sure I'll have more questions sooner or later, but this helps me in the right direction.
#4
Could someone post the code for a healing trigger for example. I think that would be very easy to do (so if the player is inside the trigger his health recharges slowely).... some example code will probably make me understand the whole thing a lot better.
02/09/2003 (8:25 am)
Hmm... still not fully understanding it all...Could someone post the code for a healing trigger for example. I think that would be very easy to do (so if the player is inside the trigger his health recharges slowely).... some example code will probably make me understand the whole thing a lot better.
#5
why don't you choose a more specific title (I don't even know why I've read this... :P)
but anyways, here is an example of a "random reward trigger"...
hope it helps a bit...
02/09/2003 (9:36 am)
Man, this must be the 5469th thread named "Question", "Questions", "I got a question", "TGE question", etc. ... :Pwhy don't you choose a more specific title (I don't even know why I've read this... :P)
but anyways, here is an example of a "random reward trigger"...
hope it helps a bit...
datablock TriggerData(RewardTrigger)
{
tickPeriodMS = 500;
};
function RewardTrigger::onEnterTrigger(%data, %obj, %colObj)
{
%checkname = %obj.getName();
%client = %colObj.getControllingClient();
%category = %obj.category;
//echo ("Client:" SPC %client SPC "Category:" SPC %category SPC "Name:" SPC %checkname SPC ": Entered RewardTrigger Trigger");
%rand = getRandom(5);
switch$(%rand)
{
case 0:
%client.player.incInventory(RifleAmmo,20);
CommandToClient(%client,'bottomprint',"RifleAmmo(20) has been awarded!",10,10);
case 1:
%client.player.incInventory(HealthKit,1);
CommandToClient(%client,'bottomprint',"1 HealthKit has been awarded!",10,10);
case 2:
%client.player.incInventory(Crossbow,1);
%client.player.incInventory(CrossbowAmmo,20);
CommandToClient(%client,'bottomprint',"1 Crossbow and 20 CrossbowAmmo have been awarded!",10,10);
case 3:
%client.player.incInventory(Rifle,1);
%client.player.incInventory(RifleAmmo,20);
CommandToClient(%client,'bottomprint',"1 Rifle and 20 RifleAmmo have been awarded!",10,10);
default:
%client.player.incInventory(RifleAmmo,20);
CommandToClient(%client,'bottomprint',"RifleAmmo(20) has been awarded!",10,10);
}
}
function RewardTrigger::onLeaveTrigger(%data, %obj, %colObj)
{
}
function RewardTrigger::onTickTrigger(%data, %obj)
{
}
Torque Owner Very Interactive Person