Game Development Community

Delay player, with progress bar?

by Steve Howson · in Torque Game Engine · 09/08/2005 (10:28 am) · 8 replies

Hi all!
I just got Torque and I'm designing a small game to help me learn the SDK.

One function of my game is there's a particular weapon that the player will have to "build". What I want is for the player to be delayed (maybe play an animation) and show a progress bar that shows the time until the weapon is complete.

I don't want to pause everything, I want the player to be vulnerable to attacks during that time.

I'm a total noob to Torque so I have no idea how to go about this.

Any help would be appreciated!
Thanks!

Steve

#1
09/08/2005 (10:45 am)
You mean, like planting a bomb in counter strike?
i guess all you would have to do, is to cut of the player controls, like unbinding the mouse and the moveMap keys, althought i have no concrete code to do that. then all you would need to do is to create a progress bar, which you need to update using schedules. just write a function which calculates how far the progress would be, and call it lets say every 100 ms.
and after it reached 100%, rebind the mouse and keyboard controls again.

or maybe you could code a boolean into player.cc that disables player movement.

i hope that helps as a starting point ;-)
#2
09/08/2005 (10:56 am)
You talking like the buildables in FarCry?

Perhaps the bestway would be to have the buildable made with a few different poses, in an animated form each pose on a different frame. Those poses could be called at specific intervals. The player would need a specific tool ( might be able to use key card code as a base) to trigger the animation start and stop. Bind a gui to the build tool, have function calls that check which key frame the model is at, and update the gui accordingly.

It would be interesting to see something like that.
#3
09/08/2005 (10:56 am)
Thanks!
That is a great starting point, only thing is I don't want the player controls to be cut.. I want them to be able to abort the building by moving. :)

I think I have an idea of where to look now, thanks a lot!

Like I said I'm a total Torque noob, so if anyone else has more information please post it.
#4
09/08/2005 (11:07 am)
Add this to default.bind.cs

new ActionMap(idleMap);

idleMap.bind( keyboard, a, echo("cannot move while building!") );
idleMap.bind( keyboard, d, echo("cannot move while building!") );
idleMap.bind( keyboard, w, echo("cannot move while building!") );
idleMap.bind( keyboard, s, echo("cannot move while building!") );



then delete default.bind.cs.dso

go up one directory delete config.cs and config.cs.dso

fire up torque

then bring up the console with "~" and type in the command
idleMap.push();

now try and move and you'll notice you can't :)

type
idleMap.pop(); to re-enable moving
#5
09/08/2005 (11:09 am)
It's not so much building with tools, but something takes time to put together.

Like if you had a couple of items and needed to combine them.
It'd take time to combine them, but during that time you'd be vulnerable to other attacks. If you move to avoid the attack, you'd be aborting the build.

Hope that makes sense.
#6
09/08/2005 (11:13 am)
What I posted will disable movement on command... to find out when a player is moved you'll need to put something in these functions in default.bind.cs


function moveleft(%val)
{
   $mvLeftAction = %val * $movementSpeed;
}

function moveright(%val)
{
   $mvRightAction = %val * $movementSpeed;
}

function moveforward(%val)
{
   $mvForwardAction = %val * $movementSpeed;
}

function movebackward(%val)
{
   $mvBackwardAction = %val * $movementSpeed;
}

you can do some sort of check, like this

function moveleft(%val)
{
   if(Player.building)
   {
      ceaseBuilding();
   }

   $mvLeftAction = %val * $movementSpeed;
}

then it will trigger ceaseBuilding() if you set Player.building = true;
#7
09/08/2005 (11:43 am)
How about creating a trigger on the fly around the player and destroying it on a timer.
if the player leaves the trigger, then cancel what he was doing.

You could set up a scheduled event to increment the percentage completed... when it reaches 100, you're done. Destroy the trigger and create your built object.
#8
09/08/2005 (11:44 am)
Just to add, this way... if you get shot at and pushed outside of the trigger, it also cancels.