Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Construed on Sun 19/02/2012 19:35:28

Title: Designing random battle system [SOLVED]
Post by: Construed on Sun 19/02/2012 19:35:28
Fuck a struct!
Title: Re: Designing random battle system
Post by: Atelier on Sun 19/02/2012 20:52:14
Personally, I would put the entire code in Room 101.
Title: Re: Designing random battle system
Post by: Construed on Sun 19/02/2012 20:56:56
Well, alot of it can go in the room, but the whole part about followchar has to go in diffrent random woods rooms throughout the game, see what happens is the player is walking in some random woods, then a monster appears out of the edge of the screen and starts chasing him, if it comes into contact with him then it will switch to the battle room. im guessing each monster will need a seperate battle room.
Title: Re: Designing random battle system
Post by: Construed on Sun 19/02/2012 21:05:40
Basically im trying to create the somewhat simplistic QFG1 battle system, so if anyone is familiar with that it would be quite helpful, otherwise what i've come up with above is pretty close to what i'll need.

Title: Re: Designing random battle system
Post by: Construed on Mon 20/02/2012 20:51:05
Can anyone please help me look at this code here and spruce it up a bit.
My life is getting pretty busy and i would like to get this game done.
Title: Re: Designing random battle system
Post by: Ryan Timothy B on Mon 20/02/2012 21:11:23
First off here's my suggestions, if you want someone to look at your code make it look better. Indent properly and actually encapsulate it in the [code][/code] brackets.

I personally don't want to spend 2 seconds looking at this code, it looks a big mess of diarrhea typed with lazy fingers. AGS helps you indent properly, why would you remove it? It's purpose is to speed up the reading of the code.
Title: Re: Designing random battle system
Post by: Construed on Mon 20/02/2012 21:22:27
Sorry man, is that any better?
I'm terrible at formatting.
I'm not even sure if the code works or not because I'm still trying to figure out a basic template of my battle system is going to be before I even put the mess in my engine.
I dont want to put a bunch of code thats not going to work then when i go to remove it have remnants all over the place confusing things, you know?
If anyone can help me get this code in better shape it would be greatly appreciated.

[edit]
need both Syntax and structual help and also extending of the functions  :'( :'(
This is purely conceptual code..
Title: Re: Designing random battle system
Post by: Snarky on Mon 20/02/2012 23:21:37
I don't see any particular reason to help you, but I'll offer a few suggestions anyway:

-Tackle one part of the problem at a time. First develop just the combat mechanic without all the random encounter stuff.
-I probably wouldn't have separate characters for each monster, and certainly not separate code for each. Just use one or two characters (as many as there will ever be on screen at the same time) and switch out their views depending on the monster type.
-RPG combat is heavily stats-driven. This is where all the strategy and skill comes in, so you can't half-ass this part if you want the combat to be any fun. Almost no values should be hard-coded in the battle code, it should all be based on the stats of the hero (e.g. hit points, constitution, attack strength, dodge ability, defense strength, ...), the weapon (e.g. attack damage, likelihood of hit, ...), the monster (as for hero) and the armor (e.g. damage absorption). Figure out which stats you want to base your combat around, and then define structs for all of these (hero, weapon, monster, armor) that include the necessary data.
-Differences between monster behaviors should also be mainly defined by stats (different speed/reaction speed, aggressive/defensive bias, tendency to flee, etc.). Your goal, and initial approach, should be to only write one single chunk of combat code that works for ALL the monsters, with the only difference being their stats.
-Figure out what you want to do about magic up front, since it's probably going to involve a whole additional bunch of stats.
-You probably also want stats for different types of attacks. This would involve things like how long it takes to prepare, how effective different defenses are against it, and individual damage values for each type of attack.

Remember that each monster has a set of class stats, individual stats (which perhaps vary slightly, randomly, from the class stats), and current stat values (e.g. remaining hit points, current morale).

Then the combat is just running a loop over and over again, waiting for something to happen. Each round you see if the player has initiated an action, and if so you work out the outcome; if not, you update the current state of the different values depending on the current situation (e.g. you may adjust the chance of an attack depending on the hero's current fighting stance), check if the monster does something (e.g. decides to attack, or run away) by testing a random value against the relevant stats, and work out the outcome the same way as if the player does something (actually, for a responsive combat system you might want to give the player a chance to react in real-time to the monster attack, so you might have to spread out its attack over a couple of rounds: start playing the attack animation, give the player a chance to react, and only then determine the outcome).

Working out the outcome basically means calculating in all the different stats and bonuses (e.g. for current stance - an attack might be particularly successful if it comes at the right time), usually with a random component, and seeing whether the attack succeeds, and if so, how much damage it causes. (Though some magic spells might have other effects) Then you play the corresponding animation, display the value changes, and go back to the combat loop.

-Oh, and it's better not to link the player actions directly to particular keys. Particularly in a QFG-type system, where there's also a mouse-control option, but even in general players might want to redefine the button mapping. Just define the set of available actions and check for them each loop, and then have a separate piece of code to map inputs to player actions. (This approach also allows you to define combos, though it's a bit more work.)
Title: Re: Designing random battle system
Post by: Construed on Tue 21/02/2012 05:18:15
Hey, I appreciate the advice greatly.
It is indeed sound advice, of which i will probably use in my more advanced project I'm working on.
However for this particular game QFG1 I don't want to vary to far from the original combat system, which is probably the most simplistic of battle systems in existence.

To sum it up.

When walking in the wilderness there is a random chance that a monster may appear on the screen.
That monster will be using follow char to follow you, on collision you are transfered to another room in which the monster then appears with a completely different, bigger version of the sprite with various animations depicting the arms,head,etc..
on pressing the up arrow you have a random chance of stabbing the monster which has only 2 variables. Hit which is modified by dexterity and secondly the amount of damage which is modified by strength, then there is the back arrow which makes you use a shield to block which is modified by parry "I might not even add that". then there's right and left arrows which are dodging which are also modified by parry.
each monster species has a specified amount of life which is only changed per totally different species. That pretty much sums it up.
Title: Re: Designing random battle system
Post by: Khris on Tue 21/02/2012 10:54:58
What exactly do you need? What you describe still needs the approach Snarky described.
So are you just waiting for someone else to code this?
Title: Re: Designing random battle system
Post by: Construed on Tue 21/02/2012 17:45:13
Not completely, I need someone to help me brush up the code above.
Its pretty much what i need, just cant figure out the exact syntax of all the functions etc..i was hoping to do sort of an improv thing here until i complete it but it looks like people around here aren't into that sort of thing, even when I'm making a free game out of my own pocket for the community to enjoy which i really have no reason at this point to continue making.

Solved:
Answer, Don't expect help from people around here.
Even when you are trying to make them something to enjoy.
Title: Re: Designing random battle system [SOLVED]
Post by: Snarky on Tue 21/02/2012 20:21:22
See, this is why I wasn't too keen on helping you: You consistently act like a dick whenever people don't fall in with your every demand. Interact with GRY -> get abuse. Not a great incentive.

The code you posted was IMO pretty far away from what you needed, though I could see what you were going for. Like Khris says, the outline I gave is probably still applicable to this slightly simpler case (though there are actually only a couple of the things I mentioned that won't apply, like multiple different attacks and random variation in the stats between instances of the same monster). That should give you the sense that it's quite a lot of work to implement, and not something anyone is likely to just do for you.

Now you're talking about (and blaming us for!) abandoning the (ridiculously over-ambitious) project you were bragging about a few weeks ago just because no one has volunteered to make a combat system for you within a couple of days of your request. And we're the ungrateful ones! Oy vey!
Title: Re: Designing random battle system [SOLVED]
Post by: Khris on Tue 21/02/2012 21:11:57
To give you an idea of the required workload, what you're asking from us is to turn

this: (http://thumbs.dreamstime.com/thumblarge_611/13077300200RZ1xJ.jpg)  into this: (http://www.dietsch.com/vermsol/busot2/villa.jpg)

Does it really seem weird to you that we aren't falling over ourselves to help you?

99% of the people here are also making a free game for the rest of us to enjoy, do you see them asking for this kind of favor all the time?
Title: Re: Designing random battle system [SOLVED]
Post by: Construed on Tue 21/02/2012 22:54:17
You act like im asking you to handcode machine language or something, all i asked for was a little syntax correction etc.I've spent hundreds of hours of my life, insanely working dilligently day and night millions of cups of coffee packs of cigarettes and pain pills to fuel my developmental fury and its too hard for someone to take 3 minutes and give me a little syntax correction or a few little suggestions here and there.I REBUILT QFG1 from the ground up excluding the battle system in under a few weeks and don't even read my game in production post telling people all the services i offer to people who help me including free adless webspace,html,xml,php,css,mysql databases,flash,java,javascript ajax 2d/3d graphic design etc etc etc...
Honestly i give up on the forums.
There are alot of good people here in various sections, but this place is far too stressful for me with the abundant amount of cynical views.
Title: Re: Designing random battle system [SOLVED]
Post by: Khris on Tue 21/02/2012 23:32:53
Wow, you're back at lashing out and editing your posts, turning your back on the forums.
Can we skip to a few hours from now when you're sorry for everything again?

What we've been trying to get through to you was that the code you posted isn't "a little syntax correction" away from what you want to achieve. The code you had in your opening post was pretty much useless.
Even if it hadn't been, it would still only be about 5% of what's actually needed.

You act paranoid, as if we helped everybody else but rejected you because it's you. That's not what's happening. Other people have made ridiculous demands like this before you, and they got the same answer.

If you're willing to build free webpages in return for AGS coding, post in the Recruit A Team thread. Get a coder or learn how to do it yourself.
In this forum, we usually help with specific problems; we don't build entire engine frameworks.
Title: Re: Designing random battle system [SOLVED]
Post by: Construed on Tue 21/02/2012 23:43:49
I'm only taking the time to reply to this because i somewhat like you as a person. I'm just doing it myself.
I thought the forum would be willing to work in the spirit of teamwork and maby everyone chip in a little here and there but apparently that's not how we roll.
Instead we can all be overburdned on our projects and almost never get anything done.
But i have some things alot of people don't have and one of those things is sheer determination.after only a few short hours i'm about halfway done with the system.
I cant help but lash out when i help everyone around here but when the shoes on the other foot i get nothing.
I guess people people get tired of getting fucked over by helping people and recieving nothing in return so i cant really blame you for it, I'll just become like you and we can keep this cycle of unhelpfulness going forever.
Sounds great to me.
Title: Re: Designing random battle system [SOLVED]
Post by: Khris on Wed 22/02/2012 02:09:31
QuoteI thought the forum would be willing to work in the spirit of teamwork and maby everyone chip in a little here and there but apparently that's not how we roll.
This isn't collecting beer money, this is coding a battle engine. If you can't accept that one does not simply chip in a little here and there, well, don't.

Since you apparently weren't looking for technical help but wanted to open a coding club, why did you post here and not in the Recruit A Team thread? (rhetorical question)

QuoteI cant help but lash out when i help everyone around here but when the shoes on the other foot i get nothing. I guess people people get tired of getting fucked over by helping people and recieving nothing in return so i cant really blame you for it, I'll just become like you and we can keep this cycle of unhelpfulness going forever.
You are delusional. This is so far removed from what's actually happening I'm wondering if you believe this yourself. I don't see you help everyone around here. Are you talking about your webspace offer?
Also, we still helped you with other problems despite your psychotic outbreaks. And name one forum member besides yourself who is tired of getting fucked over by helping others and receiving nothing in return.
But spouting these delusions isn't enough, no, you have to again accuse me of being unhelpful, directly contradicting what you said in other people's help threads.

Seriously, what the fuck is wrong with you?
Title: Re: Designing random battle system [SOLVED]
Post by: Construed on Wed 22/02/2012 02:52:58
You can squeeze the lemon any way you want.
your sitting on a pile of infinate knowledge and cant so much ad pop a seed out for me.
I'm a man of free knowledge.
Ask and you shall recieve, However you are not.
I'm not delusional, just stating the obvious and perhaps yes i've gone the wrong way about it, I'm not looking to recruit a team i'm not looking for anything at all now.
I was looking for a bunch of people i tried to consider friends to take 10 seconds of their time to give me better functions and methods of which i could improve upon my battle system.
but apparently friends are few and far here in the ags forums.
and yes, you and others did help me despite my past fuckups which made me consider highly of you which is the only reason I'm even still hanging around this dump.

[edit]
Besides the artists here.
They are very nice people.

PS snarky. I copied your advice to a text document.
Although its not exactley what i wanted i do appreciate it.
Title: Re: Designing random battle system [SOLVED]
Post by: WHAM on Wed 22/02/2012 20:49:21
Dude, Grim...

LOOK at the bloody forums! Look at threads by other people! Khris is almost always here, almost always responding and giving HELPFUL-GODDAMN-ADVICE! It's not always the advice you expect, but it's always advice that will make you a better programmer and a better AGS developer if you just take the bloody time to listen to him and do what he says, and don't freak the fuck out as soon as new changes breaks old code or something!

Quote from: GrimReapYou on Wed 22/02/2012 02:52:58
I was looking for a bunch of people i tried to consider friends to take 10 seconds of their time to give me better functions and methods of which i could improve upon my battle system.

Dude, do you have any IDEA what you are talking about here. I've spent five minutes writing this post, making sure it adds up and doesn't sound like absolute raving madness (well, okay, it sort of still does). Khris has probably spent hours writing up posts and responses to YOU, not to mention everyone else, and you complain how people don't give you TEN SECONDS!? What planet are you living on!?

Stop whining, learn to take advice, swallow your pride and become a better programmer. If you can't do that, just go somewhere else!
Title: Re: Designing random battle system [SOLVED]
Post by: Construed on Wed 22/02/2012 21:06:20
Quote from: GrimReapYou on Sun 19/02/2012 19:35:28
Fuck a struct!
Is kinda what pisses me off about you.
I could go trolling through your old threads and quote every time you talked about [edit] edited out rude comments out of respect [/edit], But I'm better than that, I dont count up peoples imperfections and ridicule them over them.
Title: Re: Designing random battle system [SOLVED]
Post by: discordance on Thu 23/02/2012 05:36:13
LET ME CHIP IN

I HAVE CREATED A FUNCTION TO HELP YOU WITH YOUR BATTLE SYSTEM


function addHp(int amount)
{
  playerHp += amount;
  if (playerHp > playerMaxHp) playerHp = playerMaxHp;
}


GODSPEED BROTHER AND BEST OF LUCK WITH YOUR BATTLE SYSTEM
Title: Re: Designing random battle system [SOLVED]
Post by: WHAM on Thu 23/02/2012 07:32:55

function decreaseHP(int amount)
{
playerHp -= amount;
if (playerHp < 0)
{
playerHp = 0;
Display("GAME OVER - YOU ARE TEH DED");
QuitGame(0);
}
}


Well, I thought I could chip in too, here's a function I created to help you. I took over 20 seconds to make it, though, so it better fits the style of your code.
Title: Re: Designing random battle system [SOLVED]
Post by: Construed on Thu 23/02/2012 07:51:17
The entire battle system is gone, as well as 3 weeks worth of edits.
Game.agf crashed. Guess i should have backed up more often  :=
Title: Re: Designing random battle system [SOLVED]
Post by: Shane 'ProgZmax' Stevens on Thu 23/02/2012 08:18:27
Just because an agf file crashes does not mean it's lost.  CJ, for example, has been known to recover agf's for people when he's around and has free time, so don't just throw your work away.  :'(
Title: Re: Designing random battle system [SOLVED]
Post by: Construed on Thu 23/02/2012 08:38:53
Yea, i tried everything including system restore to recover it.
I think i have 1 untampered copy, however it gives me this wall of death:


---------------------------
Adventure Game Studio
---------------------------
An error occurred whilst trying to load your game. The error was:



Unexpected end of file has occurred. The following elements are not closed: GUIButton, Controls, GUIMain, GUIs, Game, AGSEditorDocument. Line 3877, position 7.



If you cannot resolve the error, please post on the AGS Technical Forum for assistance.



Error details: System.Xml.XmlException: Unexpected end of file has occurred. The following elements are not closed: GUIButton, Controls, GUIMain, GUIs, Game, AGSEditorDocument. Line 3877, position 7.

  at System.Xml.XmlTextReaderImpl.Throw(Exception e)

  at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)

  at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String arg)

  at System.Xml.XmlTextReaderImpl.ThrowUnclosedElements()

  at System.Xml.XmlTextReaderImpl.ParseElementContent()

  at System.Xml.XmlTextReaderImpl.Read()

  at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)

  at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)

  at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)

  at System.Xml.XmlDocument.Load(XmlReader reader)

  at System.Xml.XmlDocument.Load(String filename)

  at AGS.Editor.AGSEditor.LoadGameFile(String fileName)

  at AGS.Editor.Tasks.LoadGameFromDisk(String gameToLoad, Boolean interactive)

  at AGS.Editor.InteractiveTasks.LoadGameFromDisk(String gameToLoad)
---------------------------
OK  
---------------------------





and might have been irreversably damaged in the restore....
and i cant even open it to see if the sprites rooms and views are there...
See what happened is my pc had a memory leak and when i want to load a room it said the room didn't exist, then i tried to save the game and it threw me a fatal error. so I'm guessing half of certain things got saved, random bits of info because of the memory leak or whatever and now all the information is scattered and missing pieces.
Kinda hard to explain, but i think you'll know what i mean.
Title: Re: Designing random battle system [SOLVED]
Post by: steptoe on Thu 23/02/2012 10:21:57
Understanding your frustrations GrimReapYou I can only add that at times you have to eat humble pie and take notice of certain people on here that I have great praise for.

I myself have been shot down a few times and have the scars too prove it, but in the end it makes you stronger and better.

You say you won't recruit a team to help, bad move. If you want it done ask in the right place.

Would you build a house on your own? No, you would recruit a team. Good move.

Comments by Khris are well founded and I have always found him compliant in most cases and helpful as a fellow scripter as well as giving out the odd bollocking.

Lashing out in temper all the time will deter anyone from helping you.

So, take heart, rethink, get back in check and start again. This may well bring you success.

;)



Title: Re: Designing random battle system [SOLVED]
Post by: Construed on Fri 24/02/2012 02:21:04
Yea, perhaps I'm sometimes too harsh and hasty with my words and actions.
I guess thats what Bi-polar, ADHD , hyperactive and explosive disorder do.
I spent many years not believing that i have mental illnesses but i guess the proof is in the pudding.
Its not so much myself that i feel sorry for as the people who are subjected to me.
Title: Re: Designing random battle system [SOLVED]
Post by: Construed on Fri 24/02/2012 05:21:44
Recent good news though is, my wife had an old copy of my source and I've found im able to manually retrieve most of the scripts just have to redo the views  :=
Title: Re: Designing random battle system [SOLVED]
Post by: steptoe on Fri 24/02/2012 06:48:47
That's great news.

Go at it with a different view of getting it done properly and I hope you succeed.

End of story I think...

;)
Title: Re: Designing random battle system [SOLVED]
Post by: Construed on Fri 24/02/2012 07:07:54
Thanks, and also thanks to all the people of the forums,
I probley should have been banned long ago  :o