Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Red_Armadillo on Fri 21/11/2003 07:23:34

Title: Fighting Style
Post by: Red_Armadillo on Fri 21/11/2003 07:23:34
How would I put in a fighting move when you click on an enemy?
Title: Re:Fighting Style
Post by: After on Fri 21/11/2003 07:54:23
AGS Help*>Text script functions>Character functions.
AnimateCharacter will likely suit.

*Use program menubar or just open the .chm file.

The character interaction editor is prolly the easiest way to trigger it.
Under the appropriate interaction, have something like,
MoveCharacter(EGO,character[ENEMY].x,character[ENEMY].y);
while(character[EGO].walking){Wait(1);}
if(AreCharactersColliding(EGO,ENEMY)){AnimateCharacter(EGO,attackViewNum);}

That may not work as is (I haven't tried that sort of thing myself), and isn't very realistic, but it's something to fiddle with.
Title: Re:Fighting Style
Post by: Reno Caspain on Fri 21/11/2003 09:58:33
I don't remember the exact command for getting the coordinates, but here's the main idea: I'd get the cursor y-coordinate, and compare it to the y-coordinate of the character clicked. Then add the fighting move to the character interaction on whatever cursor mode you use for fighting.

For example:

if (cursor y-axis - clicked character y-axis) < 10
{
//low punch/kick here
}
elseif ((cursor y-axis - clicked character y-axis) > 20) && ((cursor y-axis - clicked character y-axis) < 40)
{
//middle punch/kick here
}
elseif (cursor y-axis - clicked character y-axis) < 10
{
//high punch/kick here
}
Title: Re:Fighting Style
Post by: scotch on Fri 21/11/2003 13:29:35
mouse.x and mouse.y give the x and y coords of the mouse

character[charid].x and character[charid].y give the x and y coords of a character.
Title: Re:Fighting Style
Post by: Red_Armadillo on Sat 22/11/2003 03:21:58
So... I would make a string of character moves enter in the above code and set the y and x coordinates? Then to kill the character what code would I use?
Title: Re:Fighting Style
Post by: After on Sat 22/11/2003 03:47:36
character[ENEMY].room=-1;
Title: Re:Fighting Style
Post by: Red_Armadillo on Sat 22/11/2003 18:21:22
Thanks After, one final question, how would i make it so when they see me they shoot?
Title: Re:Fighting Style
Post by: Scummbuddy on Sun 23/11/2003 00:11:46
perhaps use a region, and if the main char is on a region, engage the shooting
Title: Re:Fighting Style
Post by: Red_Armadillo on Sun 23/11/2003 00:37:20
Okay, thanks.