Third-person shooter

Started by avalanche_5874, Thu 20/04/2006 22:14:12

Previous topic - Next topic

avalanche_5874

I am currently working on a 24 adventure game based on the hit television show starring Kiefer Sutherland. I can make most of the game work, like collecting evidence, thus thwarting the terrorist's plans, but there must also be a shooting element of the game. I don't want a first person shooter. I want to be able to click on an enemy with a gun from the inventory list to shoot him and kill him. But I also want the enemy to be able to shoot me also. How would I go about doing this? Any help would be appreciated.

Colxfile

#1
At its most basic level, to shoot the terrorist in the manner you describe would only need the shooting stuff (Animate Jack firing gun, Animate terrorist falling down dead etc) into the interaction editor when you use the gun inventory object on the terrorist character. If this is the case, then player.ActiveInventory will be required.
Code: ags

// Global Script File

int is_enemy_alive = 1;

some_global_function_a(){

Ã,  Ã, if (player.ActiveInventory == iGun) {
Ã,  Ã,  Ã,  // Do stuff
Ã,  Ã,  Ã,  // Shoot enemy
Ã,  Ã,  Ã,  is_enemy_alive = 0;
Ã,  Ã, }
}

Assuming iGun is the Script-o-name of the gun in question. Also, that int [is_enemy_alive] is a variable you'll see in a moment.

As for the terrorist shooting the character, again, I can give a simple idea. If you simply have a confrontation and you had a split second or two to fire before you got killed, then you can use timers.

After the confrontation sequence has happened, you'd call SetTimer(timer number, how long it lasts). Also, in that room script, you'd have the IsTimerExpired function in the repeatedly_execute block. When the timer expired, the enemy would shoot. So:
Code: ags

function the_confrontation() {
Ã,  Ã, ...
Ã,  Ã, ...
Ã,  Ã, ...
Ã,  Ã, SetTimer(x, time)
}

function repeatedly_execute() {

Ã,  Ã, if (IsTimerExpired(x) == 1 && is_enemy_alive == 1) {
Ã,  Ã,  Ã,  // Do stuff
Ã,  Ã,  Ã,  // Shoot player
Ã,  Ã,  Ã,  ...
Ã,  Ã,  Ã,  ...
Ã,  Ã,  Ã,  // Death
Ã,  Ã,  Ã,  // Cancel next season
Ã,  Ã, }


The [is_enemy_alive] condition would be required to stop the enemy shooting you after you've killed him. You change that in the function when you manage to kill him. Needless to say, you'd need to set up a variable of that name and make sure that it starts off with a value of 1.*

But this idea is very simlistic and would most likely be used for a one-shot kill on either side. If you had more in mind a shooting-gallery-type section, or basically something other than what I have descibed that would be more complex (But perfectly do-able). I'm sure someone else will have such an idea in mind :)

EDIT: * Yeah, if the variable is declared in the global script, but needed in the room script, then you'll need to import it in the script header, and export it from the global script. See the manual for more.
Always carry a UV marker pen with you. When you go to a shop or a friend's house, if you see something you like, put your name and postcode on it. If it gets stolen and subsequently recovered, the police will get in touch with you so that they can 'return' it.

SSH

#2
You must also add in the following code:

Code: ags

function repeatedly_execute() {
  int random_bad_guy=5+Rand(5); // Choose from some random bad guys
  character[random_bad_guy].ChangeRoom(cKim.Room); // Make him go wherever Kim is
}


  ;)
12

Saberteeth

hmm, this too:

Code: ags

//this is at the top of the global script

int bullets = 15;

//put this in the interact character(the character should be a bad guy)

if (player.ActiveInventory==iGun) && (is_enemy_alive==1) {
ChangeCharacterView(KIM,2);
AnimateCharacter(KIM,1,3,0);Ã,  Ã,  //shoot
AnimateCharacter(BGUY,3,4,0);Ã,  Ã,  //falls down
ChangeCharacterView(KIM,1);
bullets --;


I didn't test this in the editor and so I don't know if everything is as it should be.

Kirota

#4
Where do I type in that text to make it work?

(Edit by strazer: Don't double-post, use the Modify button.)

Also can some one give me one whole code not 3 codes and I need them all in the right order and I need to know where to put them what editor where it is and where do I type that stuff?

Rui 'Trovatore' Pires

Don't take this the wrong way... but if you have to ask the stuff you're asking, you're not ready to script this project.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Kirota

i dont care i dont understand it and no one explains not even the tutorial and I dont want to understand it i want to the code and I want to know where exatly do I put it and how do I make it work plz thats all I want!!!!

Ubel

But Kirota, that's just a piece of an example code. You really DO need to understand it if you want it to work the way you want. And if you don't know how it works, you'd just need to get someone else to script it for you. That's just how it goes.

Kirota

#8
I don't like AGS and I don't like you.

Rui 'Trovatore' Pires

#9
Oh, I just noticed that "Kirota" isn't "avalanche".

I assume avalanche's problem got solved, then. But in that case, why did you jump in, Kirota? Your question makes it obvious that you're not ready for this kind of scripting yet - you were ready to paste the code Colxfile gave, it seems, but if you know what it is, you'll see that it's just an exmaple code, with no practical use whatsoever. Which Pablo had already stated.

If you really want to make a game, you'll have to start small, and work up from there. You'll have to understand how the editor works. Games don't magically make themselves, you have to put a lot of effort into it.

Also, there is zero need to be insultive. You had a right, as does everyone in these forums, to ask questions, to ask for help, and to get given said help. In this case, you didn't like the help you got (which was, basically, "rethink your strategy, start small"). Well, you had that right, and I suppose you still do, but after treating people like that I wonder who would be so eager to help you next time.

Anyway - if you're serious about putting all this into 1 lump of code and knowing where to put it, here it goes. Much good may it do you, maybe then you'll understand what we mean.

Put this on your global script, just after any declared variables you might have:

Code: ags
int is_enemy_alive = 1;
int bullets = 15;

some_global_function_a(){

Ã,  Ã, if (player.ActiveInventory == iGun) {
Ã,  Ã,  Ã,  // Do stuff
Ã,  Ã,  Ã,  // Shoot enemy
Ã,  Ã,  Ã,  is_enemy_alive = 0;
Ã,  Ã, }
}

function the_confrontation() {
Ã,  Ã, ...
Ã,  Ã, ...
Ã,  Ã, ...
Ã,  Ã, SetTimer(x, time)
}


Put this in repeatedly_execute:

Code: ags

int random_bad_guy=5+Rand(5); // Choose from some random bad guys
character[random_bad_guy].ChangeRoom(cKim.Room); // Make him go wherever Kim is

 if (IsTimerExpired(x) == 1 && is_enemy_alive == 1) {
Ã,  Ã,  Ã,  // Do stuff
Ã,  Ã,  Ã,  // Shoot player
Ã,  Ã,  Ã,  ...
Ã,  Ã,  Ã,  ...
Ã,  Ã,  Ã,  // Death
Ã,  Ã,  Ã,  // Cancel next season
Ã,  Ã, }


And put this in a bad guy's "Interact" interaction (oooh look, isn't this figure of speech called an oxymoron? Or am I showing my non-englishness?):

Code: ags

if (player.ActiveInventory==iGun) && (is_enemy_alive==1) {
ChangeCharacterView(KIM,2);
AnimateCharacter(KIM,1,3,0);Ã,  Ã,  //shoot
AnimateCharacter(BGUY,3,4,0);Ã,  Ã,  //falls down
ChangeCharacterView(KIM,1);
bullets --;


Have fun. Let us know how it works out. I for one am eagerly antecipating your response.

EDIT - Also, knowlessmen, be it know to thee that AGS be rubber and thou be glue. Thy thinly-veiled verbal attacks shalt not wound it; yea, verily it will stand when all is past, when we be but dust in the wind, and the great Onion Ring shall hold sway over all, threatened only by Chaos and the Tall Man, named Chzo.

Also, re-consider your definition of "life". If we haven't got a life already, then we're dead. What are you doing getting mad at dead people? They're wiser than thou - they've been through the whole works and know how it goes. They dead. And they grateful.

(weeee. off-topic randomness. too much ctrl-alt-del and chef brian for this character)
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

aventurero

Very good. I was looking for this, too, thanks!

Quote from: Colxfile// Death
// Cancel next season

You're killing me!  ;D
Code: ags
function iToxicWaste_Talk()
{
Display ("You eat the toxic waste. Obviously, you die.");
QuitGame (0);}

SMF spam blocked by CleanTalk