real-time battles?

Started by Destroyer, Wed 05/11/2003 06:01:47

Previous topic - Next topic

Destroyer

Are real-time battles possible with AGS? If so, how? Or am I better off with a turn-based battle system?

Another question. I'm trying to make my game mainly be played with the keyboard. I notice that when I'm moving my char. with the arrow keys, occasionally he will do some kind of "double step"? I guess you would call it.

Also, do I use regions for doors and objects? I'm trying to make it so the space bar will be the "action button".

Hope someone could help. Thanks.


Hope I'm in the right forum....

CB..

#1
this is probably not what you are after but im interested in the same subject..
and slowly learning how to give the NPC's some sort of AI behavuior and sensors

this code uses a random movement script to move the NPC (in this case a gaurd) and at the same time moves his line of sight  to simulate him looking around (really just using another character tied to the NPC's movements)


 // script for room: Repeatedly execute
if (IsTimerExpired(1)==1)
{int ran=Random(1);
if (ran==0) MoveCharacter(GD,character[GD].x,character[GD].y-70);
else MoveCharacter(GD,character[GD].x,character[GD].y+70);
SetTimer(1,200);
}    
if (IsTimerExpired(2)==1)
{character[SIGHT].x=character[GD].x + 42;
character[SIGHT].y=character[GD].y - 2;
SetTimer(2,200);
}    
if (IsTimerExpired(3)==1)
{if (AreCharactersColliding(EGO,SIGHT)==1){
PlaySound (3);}
SetTimer(3,40);
}  




then if the player walks into the gaurds line of sight (ie they collide)
in this case the gaurd shouts "alert"
which is PlaySound (3)

using the timers set in as the room loads (thanks Timosity for that!)

this keeps both the guard and his line of sight constantly moving and acting independantly from the player

if yu can set up a health score system for each NPC and use the
(AreCharactersColliding(EGO,SIGHT)==1)
to trigger a random reduction in health for the NPCS in question

perhaps like this instead of my playsound

if (AreCharactersColliding(EGO,SIGHT)==1){
int ran=Random(2);
if (ran==0) GiveScore(-10);
else if (ran==1) GiveScore(-0);
else GiveScore(-5);

then yu can have a dynamic extremely unpredictable battle system that has a life of it's own independant from the player characters actions..

but im afriad im still a begginner and havent figured out how to assign a seperate health/score for each NPC ..but the idea is there..

Alynn

I'm still kinda new to this myself but couldn't you give each character an HP property?

deltamatrix

Its possible.

I think I have an AGS demo on-line which has a combat system. Do you wanna see it? See if its what you want?
BAD WOLF - TORCHWOOD - MR SAXON - THE BEES ARE DISAPPEARING - PANDORICA - RIVER SONG

CB..

#4
i wouldn't mind see-ing the battle system yu created delta if yu want to post some xtracts from the scripting here that would be great food for thought..


for the Hp health system i keep reading this from erica's tutorial

If you have characters to follow the player and every one of them has: int skill and int damage (note: you can`t have strings in structs, sorry) you can do this:



struct Character

{

int skill;

int damage;

};



Then:



Character char1, char2, char3;



Then:



char1.skill = 3;

char1.damage = 0;



char2.skill = 5;

char2.damage = 0;



char3.skill = 1;

char3.damage = 50;



- - - - - - - - - - - - - - - - -



That`s all. It`s very simple and very easy. If you didn't have structs you'd probably have to do some stupid thing like this:

int char1skill, char2skill, char1damage, char2damage;

Which obviously is hard to do and gives you a lot of problems when scripting. Not to mention adding a 4th character will be very annoying.



/////////

tho i havent had the courage to try and implement it yet..

im still pottering around trying to use the distance between NPC's as a trigger for combat..

i found this here on the forums a while ago (sorry can't remeber who posted it)

if ((character[GD].x<120) || (character[GD].y<120))


which i think refers to an action triggered if the NPC gets within 120 pixels of the player character..which is very interesting tho i can't get it to work i must admit..
if i can get it to work (or if anyone can clear it up for me)
then yu could use it in a dynamic batle script ..

ie

if NPC1 gets within 120 pixels of NPC2 then he will shoot  an arrow at  NPC1
with an appropiate reduction in the NPC's heath..(will have to use a timer or similar system to prevent constant attacking and allow for the transition from one weapon to another)
if NPC1 gets within 80 pixels of NPC2 then he will throw a spear at NPC1
with a different reduction in NPC1's health
and if is colliding then he will use a sword..etc...
using a randomised script for the reduction in health on each occasion..and a whole lot of NPC's on each side ; with this script and random movements ,and or instructions to chase the other NPC's if they are within his line of sight ,then a very entertaining and dynamic battle would ensue..the out come of which would be unpredictable and most likely different each time it was run..

then perhaps looking at ways to give the player some tactical control over his NPC's
ways of altering the health etc by equiping them with items and so on
but im just pottering around at the moment and havent really spent a lot of time on it..

it doesnt sound too far fetched tho (and im sure it's allready been done at some point)
but it's giving me something to mess around with
the main jist being the desire to give the NPC's some individual life of their own
summat like that anyway

Isegrim

Quote from: CB.. on Wed 05/11/2003 16:26:23

if ((character[GD].x<120) || (character[GD].y<120))


which i think refers to an action triggered if the NPC gets within 120 pixels of the player character..which is very interesting tho i can't get it to work i must admit..
if i can get it to work (or if anyone can clear it up for me)
then yu could use it in a dynamic batle script ..


That's checking against absolute coordinates... you should check against the other character's coordinates like:

"if ((character[GD].x-character[GUARD].x<120) || (character[GD].y-character[GUARD].x<120))"

I'd also say that for an advanced battle scene maybe the finite state plugin might be quite useful (maybe in changing the opponent's tactics at different health levels or so...)
This post was generated automatically and therefore bears no signature.

CB..

many thanks ! will take a look at the plug in allso

Scorpiorus

The one I had created as an tech article for AGS-ezine:
template [100kb]
doc [10kb]

just in case it helps

~Cheers

Destroyer

Thanks you guys, it's helping.

I've been using FollowCharacter for the enemies. I'm attempting to use a certain keycode that is pressed to aim your weapon. Holding it down will keep the weapon up, letting go will put it away. While the keycode is pressed, I want to be able to press another key to fire, but only when you're aiming. Is this possible?  Or am I better off with not having to hold the aim button down to fire?

deltamatrix

function monsterdying() {
 if (GetGlobalInt(23) < 0 && IsGUIOn(5) ==1) {
   SetMusicRepeat(0);
   if (monster == 8) SetCharacterBaseline(HUNT, 2);
   if (monster == 15) SetCharacterBaseline(PAR, 2);
   PlayMusic(6);
   SetLabelText(9, 1, "0");
   SetCharacterView(monster, GetCharacterProperty(monster, "Deathview"));
   if (character[EGO].room == 41) SetGlobalInt(28, 3);
   dead ++;
   GUIOn(1);
   if (stress >= 30 + GetGlobalInt(20) && dead == 1) {
      Wait(40);
      Display("Geez. All these battles have blown your mind! You are all stressed out!");
      stress = 999999;
      mightbuffer = GetGlobalInt(4);
      agilbuffer = GetGlobalInt(6);
      SetLabelColor(3, 26, 14);
      SetLabelText(3, 26, "Stressed!");
      SetTimer(6, 720);
   }
   character[HUNT].y = character[HUNT].y + 20;
   GUIOff(5) && GUIOff(7) && GUIOff(9) && GUIOff(10);
   running = 0;
   a = 0;
   chased = -1;
   chicken = 0;
   if (IsGUIOn(7) == 0) {
      SetCharacterSpeed(EGO, 5);
      SetCharacterView(EGO, 10);
      AnimateCharacterEx(EGO, 0, 2, 0, 1, 1);
      ReleaseCharacterView(EGO);
      SetCursorMode(0);
   }
 }
}

This is one of the many functions in my combat engine. It probably won't mean without the rest of the code but there a LOT of it. Not just combat, theres food, thrist, day/night etc.

I can only really offer a link to the demo file.
Unfortunately due to circumstances I may never complete the actual game but most of the engine is there.
BAD WOLF - TORCHWOOD - MR SAXON - THE BEES ARE DISAPPEARING - PANDORICA - RIVER SONG

CB..

#10
Isegrim; many thanks after a major bit of head scratching i sussed the problem with the script for guageing the distance from the NPC for triggering events..
the problem with the script was that if the player was to the left of the NPC then he continued to trigger the event no matter how far away he was..(the script didnt take into acount the possibility of a minus x screen location for the player(the NPC in question is randomly moving)

finally after some trail and error

if ((character[EGO].x-character[GD].x<80 && character[EGO].x-character[GD].x>-80)){
GiveScore(-1);}


which translated into if the player is within an area that is both less than 80 pixels (to the right) and greater(meaning less in real terms) than -80 pixels (to the left) from the character then the event is triggered

need to combine this with the same sequence for the y co-ords to finish the job off..

but it works..many thanks again for getting me on the scent!!
and many thanks to evryone else allso, interesting stuff all this!!  am slowly learning

UP-DATE;yup it works..bit clunky but works

if player is within 80 pixels North, South, East and West of the NPC event is triggered

if ((character[EGO].x-character[GD].x<80 && character[EGO].x-character[GD].x>-80 && character[EGO].y-character[GD].y<80 && character[EGO].y-character[GD].y>-80)){
GiveScore(-1);}


this would be great for populating a forest with invisable enemys (view set to transparent) randomly moving around as the player group walks thru it..if the enemy moves within 80 pixels of the player (or other group member) then set enemys view to non transparent and start the battle would certainly ad tension and replayability to scenarios..and gawd knows what else
maybe unlimited regions as this seems to create regions for triggering events ?
begginer stuff i know but it's part of the fun of AGS to slowly create a system from what little yu do know (with evry-ones help of course) for me anyhow

SMF spam blocked by CleanTalk