Game Development Community

CTF problem

by Aaron Heal · in Torque 3D Professional · 09/10/2009 (9:06 am) · 2 replies

I have this problem with the CTF resource buried deep within the forums. I have manged to import all the code in but when I enter the trigger it does nothing. The main problem is I know what needs to be changed I just figure out what to change it to. Here is my code:

function CapFlagTrigger::onEnterTrigger(%this, %trigger, %obj)
{
//Parent::onEnterTrigger(%this, %trigger, %obj);<- I commented this bit out because it wouldn't let me get past this part

error("ENTERING A CapFLAG TRIGGER");

if (%obj.client.team.teamId $= %trigger.team)
{
error("This is your team");
error("you have " @ %obj.getInvItem(%trigger.invcheckitem, "amount") @ //<- I am sure this is a prob
"Flags");

if (%obj.getInventory(%trigger.invcheckitem, "amount") > 0) //<-This too
{
error("You Scored");

$Game::TeamFlagCaptures[%obj.client.team.teamId]++;

messageAll('MsgObjective', '\c2Team %1 captured a Flag1! %2 points!',
%obj.client.team,$Game::PointsForCapture);
$Game::TeamScores[%obj.client.team.teamId] += $Game::PointsForCapture;

%obj.setInventory(%trigger.invcheckitem,0);//<- And this one

%obj.unmountImage($flagslot);

error("Entering A CapFlag Trigger");

newflag(%trigger.invcheckitem,%trigger.respawnat);
}
}
}


If anyone could help me that would be great.

#1
09/10/2009 (12:40 pm)
The question is, which CTF resource? -- there were several of them. The problem areas (or potential problem areas) that you've marked could be because they rely on other methods that may not be a part of Torque any longer, or were part of another resource.

For the Parent::onEnterTrigger() callback to work you would have to have a defaultTrigger datablock for it to fall back on. Basically your new trigger does some things but it also calls for the 'parent' in order to perform some basic functionality shared by all triggers.
#2
09/10/2009 (8:10 pm)
I got the code and stuff from here http://www.garagegames.com/community/resources/view/2799