Game Development Community

attaching a trigger in a particualr state.

by rennie moffat · in Torque Game Builder · 10/15/2009 (4:46 pm) · 4 replies

function PhantomClass::Attack(%this)
{
if(%this.getAnimationName() $= "Phantom_Berserk")
{
%this.schedule(250, "Attack");
%Attack = new t2dTrigger()
   {
      scenegraph = %this.scenegraph;
      class = "EnemyAttack";
   }


this code is obviously calling for an attack which is a new t2dTrigger. What I am wondering is...

1. This trigger exists when the enemy, who the tigger is attached to is in "bezerk mode". Bezerk mode is only active for a limited time then the enemy returns to a normal state and the trigger is gone. So my question is, how would I set this up to insure that it worked? Would I simply pull a trigger out from "create" place it off screen and name it's class and the rest is taken care of?

About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
10/15/2009 (4:59 pm)
ps.
the reason I ask is becasue my computer is acting kinda glitchy with TGB, so I have shut her down for the day and am just doing theory, but also the

%Attack = new t2dTrigger

has phased me a bit since I didnt think you could call a "new" trigger like you can a behavior.

Thanks
#2
10/15/2009 (6:32 pm)
I think you need to look at what a t2dTrigger is. I don't see how it would work in this way.
#3
10/15/2009 (6:59 pm)
hmm, well I understand fully what a trigger is and it's purpose, but I guess more presicely, and if I am correct, this can apply to any new object, but what I am getting at is, and maybe this is where I am worried because I physically have not been able to do it yet is, call something, that is new and have it work.


Imagine a fighting gmae where our hero had to punch in order to attack/defend himself. So when I press btnA punchAnimation is triggered, at the same time, from what I gather, I will need to attach a trigger to my player's hand/fist, and set that trigger to deal damage to any enemy in contact with it.

So my question, wondering is, if I do this, the thing that gets me, is..
a. the trigger, will have to be new and appear only when btnA is pressed
b. the trigger must appear only over the fist.

So how do I insure that the trigger appears and in the right place.
#4
10/15/2009 (10:29 pm)
this is actually part of the same script different function,

what I am wondering is the very first line of code, why would the programmer set %this.space = false?
I would expect an "if false" but not = false, why would this type of technique be used?


Also I dont understand this sequence. why would he declare if spellable, then essentially, I think say the same thing "if spell ==1" then inside that say, if thats the case, this spellABle is false? Is this common easy scripting or is this guy doing something funky?
if(%this.owner.spellAble)
{
if($Spell == 1)
{
%this.owner.spellAble = false;




(this code is used as a hero's weapon, it is triggered by the space bar. My only guess as to why is that so a player can not just hold the space bar down, but unsure)

function MovementControlsBehavior::CastSpell(%this)
{
%this.space = false;
if(%this.owner.spellAble)
{
if($Spell == 1)
{
%this.owner.spellAble = false;
%this.castSpell1();
%this.castTrigger1();
%this.schedule(1500, "spellAbleOn"); //the timer to cast the next spell
%this.owner.playAnimation(Player_Cast);
}}}