Can You Do Combat in AGS?

Started by EnnarGames, Fri 29/04/2022 02:26:24

Previous topic - Next topic

EnnarGames

So something I’ve been interested in implementing into a point n click adventure game is some sort of combat system - perhaps turn based in some way? Or maybe even timing based - like a duel in a western… gotta click a button at a certain point or fast enough to kill your opponent.

I don’t think I’d necessarily want it to be real time - though it could be cool to have a system where you hold shift or something to draw your weapon, stop moving, and toggle the cursor to be a cross hair. Clicking on enemies fire. Similar to old Resident Evil combat. But something about real time takes me out of the point and click mindset and tempo.

Has anyone had experience in this? If so, are there examples and scripting you could point me to? It’s an idea I like but I’m having trouble expanding my mind and thinking outside the box enough to know how to begin doing that in AGS.

Any help would be greatly appreciated!
“Art is an object riddled with sharp edges that can cut you.  You can pound all those edges away and make it smooth and make it safe, but what you’re left with is just a shapeless blob.  It’s safe and it’s smooth, but it’s uninteresting.” Ron Gilbert

newwaveburritos

Yes, it's definitely possible.  I don't have any concrete examples but a turn based combat system could be done.  At the end of the day it's really just a big pile of variables but I suppose at the end of the day lots of coding is just big piles of variables.  If you're wanting beginning level stuff that's easier to understand you might think about the way RPGs handled combat in the 80s.  Like the original Final Fantasy style combat which is essentially just a menu system.  You could get something like working with just a few GUIs and a few variables.  Honestly, making the "rules" for combat may be trickier than the combat itself.  Sorry this isn't much help but I think starting with a simple system like an old RPG would be the way I would do it to get an idea of how the systems fit together as a start.  Just "attack," "defend," "run" or something like that.  Track HP of your player and enemy in a variable and manipulate that in script.   

Snarky

Certainly it can be done in AGS. AGS comes with a programming language that allows you to do just about anything, with the only limit being performance (usually only comes into play if you're trying to do something very heavy on the graphics side, e.g. full 3D) and some limitations about the kind of graphics/audio manipulations you can do and input you can collect (e.g. no multi-touch gestures). And of course the amount of work and skill it takes to implement. For example, several AGS Quest for Glory clones (QFG2VGA, Heroine's Quest, Quest for Infamy) have real-time RPG combat against a range of enemies, but those combat systems took months or even years to design, develop and debug.

For this case, the first thing is that you have to have a clear idea of what you want to make. Practically any kind of combat system is possible, but different systems will have to be built in different ways. A turn-based game of choosing your attacks and defenses will need completely different code than an arcade game where you have to try and hit an enemy that's running around the screen. Usually a good way to think about it is to divide it up into three parts:

-What are the rules? In other words, what does the "combat loop" look like, what are the possible outcomes, and what are the things that affect how the combat goes? (Also, if combat is repeatable, how does it vary between different encounters?)
-How is it controlled by the player? What sort of input does it use, and what kind of GUIs (if any) are needed to execute combat decisions?
-How will it be displayed? What sort of animations will play (or other feedback such as text prompts, audio clips, …), and at what points? It's particularly important to consider if there's a real-time component to any of it (where the player has to do something at a particular time as the animation plays, or the animation has to respond immediately to a player action).

Once you have these requirements defined, you can start to figure out how to build it. As newwaveburritos says, it's mostly about a big pile of variables. And with your first attempt, I would highly recommend keeping it simple. The more factors you add in, the more work it is to build and the more complicated the code becomes.

Crimson Wizard

Few years ago I've been answering a similar question. Although the combat system the person was asking about could be different, but the reply was mostly about the approach to coding, so I'd allow myself to citate that old post again: https://www.adventuregamestudio.co.uk/forums/index.php?topic=55643.msg636578340#msg636578340

Quote
Coding is not only about knowing the programming language, but first of all about writing algorithms and structuring your program.
Complex algorithms are usually broken into smaller parts, to make it easier to understand and code.

My biggest advice to anyone who begins to learn programming and wants to make something complex, like fighting in this topic:
First, write down what you'd like to have "on paper". At this stage there's no need to go into much details, just rough outline. What objects would you like to have on screen, how these objects act, how player is supposed to act.
Second, try to break the whole scene down to smaller tasks, and learn to make these one by one, separately. After you did, you will be able to combine complex scene out of those pieces.

For example, you want to have QFG-like combat. This involves a picture of a player that swings sword (or does other stuff) by player's command and picture of enemy that does actions by AI command. Essentially this means that there is some visual character that receives commands from a source. Source can be either player or AI script.

Try following: make a simplier scene (perhaps in a test game), where you have a character on screen, that runs animations when player presses a button. Learn how to test when action ends, so that player could not run new actions before that.

Then make another scene where same character is controlled by a script. Learn how to make it launch same actions randomly, by a timer.
It may be important to learn how to "detach" animation script from AI script, to make them independent of each other. This way you will be able to connect same AI script to multiple characters.

Next step: teach AI to react on opponent's actions. You do not have to have actual opponent for that. Implement "imaginary" opponent. For example, remember what opponent is doing (defending, attacking, etc) in a variable, put a text on screen telling that to make it easier for you, and let player change that imaginary action by key press. Make AI react to this variable: when you set it to "attack" - AI should defend, and vice versa (or other variants).

Fourth scene could be where two characters stand face to face. They may be even both controlled by AI. Make them fight with each other using techniques you learnt in previous three scenes.

After you succeed in this, move on to combat rules and GUI part, with health, winning and loosing conditions, and so forth.

AndreasBlack

#4
Quote from: hobbesboi on Fri 29/04/2022 02:26:24


Has anyone had experience in this? If so, are there examples and scripting you could point me to? It’s an idea I like but I’m having trouble expanding my mind and thinking outside the box enough to know how to begin doing that in AGS.

Any help would be greatly appreciated!


Like Snarky says, anything is possible within the AGS language most likely, it's just a matter of knowing how to do it or figure it out, and if you can't figure it out, it's not possible, for you!  (laugh) 
I've tried to recreate the classic beat em up "Streets of Rage 2" a little bit, even with my very limited basic scripting knowledge i managed to make a very basic AI that just walks towards you and hits, and if you wait for 2 seconds and walk towards or away from him he will hit you again, then i gave up, too much work for me  (laugh). Health bar i did with a GUI but it can probably be done with anything objects or probably drawn onto the screen with the synthax drawsurface, most likely. Been using AGS for i don't know almost 3years now? Anyways check this out.

The first thing you want to do is get this module by SSH called PPCollision Here: https://www.adventuregamestudio.co.uk/forums/index.php?topic=26307.msg636537995#msg636537995 It detects when objects or characters or both collides into eachother, really useful for this purpose you're asking for! I used it for my little beat em up test game.

I used basic AGS scripting like Walkable Areas for example for the enemy to attack me. if you don't know it's a sidescrolling beat em up game. I used "followcharacter". For the jump mechanism i used Crimsons Timers module and did if statements of the character.z, and i experimented a little with it until the jump feelt natural. Really a dumb way to do it, but it worked! Same for when the AI could walk towards you, or attack you, or when it's gonna wait for a second attack on you, etc. Timers..But it was a lot of code even tho it was "very basic" in concept for the skilled scripters on this forum, and they would most likely never ever do it, like i did it! (laugh) Bottom line is, if i can do something similar to a combat scene, you probably can do what you ask for too. It doesn't sound to advanced what you've described. Old Resident Evil games, sounds more like you talk about Virtua Cop tho in your description (Mouse as a crosshair, i don't remember the feda-renos using those  ;) ).

That would be easier to do then what i've just described for sure with the PPCollision module, since i guess you are in a fixed position sorta! And if they attack you all you need to do is do an if statement where you check the Y position and once their bullets or attacks crosses that line you lose health. Perhaps you could have use for this module aswell! You really should take a look at all modules available for AGS it unlocks more potential for combat.

Module mode7 0.3.0 by eri0o   


https://www.adventuregamestudio.co.uk/forums/index.php?topic=59854.0







Snarky

#5
As for ideas for how you could integrate shooting into a Western game if you're not happy with the Resident Evil model, here are a few options:

-A spaghetti-Western style duel, where you get a closeup of your opponents' eyes in one part of the screen, and have to fire just when he looks away (maybe at a distraction, which happens at random intervals) maybe while making sure your cross-hair doesn't drift away from him in another part of the screen. (You could also build puzzles around setting up the distractions in the first place.)

-A first-person-view shootout against a gang of bandits from behind cover. You have to stick your head out to look where they are hiding, which gives you a timer to duck back in hiding before they shoot you. In that time you have to locate them and fire. (Either directly at them or at some nearby feature in the environment that will take them out, e.g. a sign hanging over the head of one, or to scare a horse to kick at another.)

-An obstacle course where you have to move several characters from Point A to Point B while under fire. One character lays down covering fire while another character goes from one point of cover to another nearby. The player controls when the characters are shooting and at what, but don't have to deal with aiming. You can do it as a timing/rhythm-based challenge where they have to move at the right time based on the patterns of the enemies' attacks, or as a puzzle maze where you have to find the right path/order of movement that will let you take out the opponents, and maybe even pick up their guns to recover depleting ammo as you advance.

-Arcade-style escape on horseback while chased (moving left-to-right). You have to steer your horse to avoid or jump over environmental hazards (rocks, cacti, fences, holes; similar to those asteroid field rocket ship games), while turning around to shoot at pursuers behind you. While shooting you cannot steer, so you have to time it right.

There are of course many other ways you could do it, depending on how it fits into the story, what kind of mood you want to create and what kind of gameplay you want it to be. Should the focus be on sharpshooting or firing wildly? Should it be more puzzle-based, more strategy-based, more arcade-based, more precision-based, more QTE-based, etc.? Should it be tense, exciting, emotional, just fun, or what?

SMF spam blocked by CleanTalk