Shooting, Alien breed style.

Started by Cakeman, Wed 25/05/2005 01:58:27

Previous topic - Next topic

Cakeman

I'm making a game with an Alien breed kind of look (birds view). I'm using this script to make  EGO shoot:


//In the "function repeatedly_execute()" I put:

{
if (character[BULLET].walking == 0) character[BULLET].room = -1;
}

//And in the "function on_key_press(int keycode)" I put:

if (keycode==83 && (character[EGO].loop == 0) && (character[EGO].walking == 0) && (character[BULLET].room == -1))  {character[BULLET].room = character[EGO].room;character[BULLET].y=character[EGO].y-1;character[BULLET].x=character[EGO].x-1;
   MoveCharacterStraight(BULLET,character[BULLET].x,204);}
  if (keycode==83 && (character[EGO].loop == 1) && (character[EGO].walking == 0) && (character[BULLET].room == -1))  {character[BULLET].room = character[EGO].room;character[BULLET].y=character[EGO].y-1;character[BULLET].x=character[EGO].x-1;
   MoveCharacterStraight(BULLET,-4,character[BULLET].y);}
  if (keycode==83 && (character[EGO].loop == 2) && (character[EGO].walking == 0) && (character[BULLET].room == -1))  {character[BULLET].room = character[EGO].room;character[BULLET].y=character[EGO].y-1;character[BULLET].x=character[EGO].x-1;
   MoveCharacterStraight(BULLET,324,character[BULLET].y);}
  if (keycode==83 && (character[EGO].loop == 3) && (character[EGO].walking == 0) && (character[BULLET].room == -1))  {character[BULLET].room = character[EGO].room;character[BULLET].y=character[EGO].y-1;character[BULLET].x=character[EGO].x-1;
   MoveCharacterStraight(BULLET,character[BULLET].x,-4);}

This is clumsy but it works. The problem is getting other characters to die when hit by the BULLET. I managed to do this with "AreCharactersColliding", but only with a specific character:
  "AreCharactersColliding (BULLET, ENEMY1)"
How do I swap "ENEMY1" with other characters?

And my second problem is to make other characters shoot back att EGO. Is there an easy way of doing this?

Third. When hit, I want character ENEMY1 to show a blood-splat (view 8 )  before he dies:

// In "function repeatedly_execute()"
{
if (AreCharactersColliding(BULLET, ENEMY1)==1) {SetCharacterView (ENEMY1, 8 ) ;
character[BULLET].room = -1;
}
}
The blood (view 8 ) is showed for 0 seconds.
Is there a way to put a "wait" here without making it go over and over again?

Scorpiorus

Quote"AreCharactersColliding (BULLET, ENEMY1)"
How do I swap "ENEMY1" with other characters?
A straightforward solution would be to check for each enemy character:


repeatedly_execute:

if (AreCharactersColliding(BULLET, ENEMY1)) { <enemy1 dies> }
if (AreCharactersColliding(BULLET, ENEMY2)) { <enemy2 dies> }
if (AreCharactersColliding(BULLET, ENEMY3)) { <enemy3 dies> }


Another way is to set up a "while" loop, but that depends on how the enemy characters are arranged in the Character Editor.


QuoteAnd my second problem is to make other characters shoot back att EGO. Is there an easy way of doing this?
Well, the script is almost the same as for the player character except that they don't have to press a key. :)
You can make a use of the Random() function to decide when enemies shoot:

repeatedly_execute:

int rnd = Random(400);

if (rnd == 1) <enemy1 shoots>
if (rnd == 2) <enemy2 shoots>
if (rnd == 3) <enemy3 shoots>


QuoteThird. When hit, I want character ENEMY1 to show a blood-splat (viewÃ,  Ã, before he dies:
QuoteIs there a way to put a "wait" here without making it go over and over again?
The easiest solution would be to put a Wait() command just after SetCharacterView. That'll pause the script for a moment though:

if (AreCharactersColliding(BULLET, ENEMY1)==1) {
SetCharacterView (ENEMY1, 8 );
Wait(5);
SetCharacterView (ENEMY1, DEAD_VIEW_HERE);
character[BULLET].room = -1;
}

SMF spam blocked by CleanTalk