AGS: Can I Make an RPG with AGS?

Started by TerranRich, Mon 03/05/2004 05:56:47

Previous topic - Next topic

Akumayo

Thanks, I hadn't realized, still living in old v6  :P
"Power is not a means - it is an end."

A�rendyll (formerly Yurina)

Thanks! I appreciate your help!
Yuna: Give me a Y!
Rikku: Give me an R!
Paine: Give me a break...
~Final Fantasy X-2

I've been

Akumayo

"Power is not a means - it is an end."

mwahahaha

I can somehow see this as becoming quite arduous, but possible nonetheless.  Say, wouldn't real-time combat also work... somehow?

Anyway, I think I'll leave massive coding projects to other people, I'm fine with the standard stuff.

Akumayo

Yes... Real time would work, but it would work off of characters acting as projectiles and collision detection that would have to be modified for further leniency (as right now, AGS's collision detection is a little off-balance when it comes to projectiles).  I was considering making a real time combat system... maybe I should act on my ideas...
"Power is not a means - it is an end."

Akumayo

After seeing that Hammerite was having difficulty with random battles, I thought I'd pitch in with a simple random battle script that is hotspot based.  This script assumes that you have already coded a battle system.

Create a hotspot that you want the player to find enemies on.  Under the "While player stands on hotspot" script, place:

Code: ags

int findenemyornot = Random(399);
if (findenemyornot == 0) {
  int whichenemy = Random(9);
  if (whichenemy >= 0 && whichenemy <= 3) {
    //code for fighting an enemy that appears 4/10 of the time
  }
  if (whichenemy >= 4 && whichenemy <= 8) {
    //code for fighting an enemy that appears 5/10 of the time
  }
  if (whichenemy == 9) {
    //code for fighting another different enemy that appears only 1/10 of the time
  }
}


This code says that about every 10 seconds, there will be a fight.  Three possible enemies will appear, one 1/2 of the time, one 2/5 of the time, and one 1/10 of the time.  The code should be modified to meet the standards of the area the player is in.

-Regards, Akumayo
"Power is not a means - it is an end."

A�rendyll (formerly Yurina)

Now, this is one useful code, Akumayo!

Have you ever made RPG's yourself with AGS? If so, do you have a link to it? (Sorry is offtopic, but that game can be some kind of example to me.  ;D)
Yuna: Give me a Y!
Rikku: Give me an R!
Paine: Give me a break...
~Final Fantasy X-2

I've been

Akumayo

I have started a few, but never finished, the best demo of one can be found here:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23809.0

It is pretty sloppy, and mostly abandoned by now, but you may find it useful for ideas.  It uses most of the code I've posted in this thread, plus a little more.
"Power is not a means - it is an end."

Hammerite

some1 should make a module or a plugin for this sort o' thing.
i used to be indeceisive but now im not so sure!

Akumayo

#129
This thread covered that, making a module/plugin would narrow down the capabilities.Ã,  An RPG is best made by hand, by practice, so that every one is unique, and we don't come off looking like cloners.

EDIT:

Come to think about it, if you had the Advanced Randoms Module ( http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23175.msg285799#msg285799 ), you could shorten my earlier code by quite a lot:
Code: ags

int findenemyornot = Random(399);
if (findenemyornot == 0) {
  int whichenemy = RandomWeightedDice(1, 50, 2, 40, 3, 10, 0, 0);
  if (whichenemy == 1) {
    //script for fighting enemy that appears 50% of the time
  }
  if (whichenemy == 2) {
    //script for fighting enemy that appears 40% of the time
  }
  if (whichenemy == 3) {
    //script for fighting enemy that appears 10% of the time
  }
}


This code would make an enemy appear about every 10 seconds, have three enemies, one that appears 50%, one 40%, and one 10%, but without the nastiness of finding out things like:
Code: ags

if (a >= b && b <= c)

etc.
"Power is not a means - it is an end."

Hammerite

HURRAH!! THANKS!
One more question and I can get started...
how do I make it so if I press the 'x' key when standing next to an NPC, I start a conversation?
i used to be indeceisive but now im not so sure!

Akumayo

Assuming you want to be about 20 pixels from the NPC:
Code: ags

if ((player.x <= (cNpc.x + 20) || player.x >= (cNpc.x - 20)) && (player.y <= (cNpc.y + 20) || player.y >= (cNpc.y - 20))) {  //if the player is around 20 pixels from the cNpc
  if (IsKeyPressed(88)==1) { //if they pressed 'x'
    cNpc.RunInteraction(eModeTalk);
  }
}


You'd have to repeat that code for each NPC you wanted the player to talk with, replacing the "cNpc" value with the names of your npc's of course.  As for the first if statement, you'll have to try it out, because I'm pretty sure it will work, but not positive.  So give that code a whirl, and tell me if it works okay.  Oh, and you might find this useful also (I made it out since the manual doesn't give exacts on key presses):

Code: ags

IsKeyPressed(x) where x =
65=A
66=B
67=C
68=D
69=E
70=F
71=G
72=H
73=I
74=J
75=K
76=L
77=M
78=N
79=O
80=P
81=Q
82=R
83=S
84=T
85=U
86=V
87=W
88=X
89=Y
90=Z


-Regards, Akumayo
"Power is not a means - it is an end."

Ashen

I think the manual is quite exact: ASCII Codes.
It's nice to have the letters broken down like that, but - although it's not mentioned - letters, numbers and space can be refered to without using the exact code - just surround them with apostrophes (') e.g.:
Code: ags

if (IsKeyPressed('X') == 1) {

NOTE: As it says in the manual, all letters must be uppercase. Although you can use lowercase letters in strings e.g. with StrSetCharAt() (they're 97 - 122), all keypresses are handled as uppercase - 'x' wouldn't work. And, obviously, things like backspace, Ctrl-Q, return and so on can't be used this way.


Akumayo, I'm not sure if it'll work properly with those OR operators (||), I think they all need to be &&. At least, that's the way I've always done it, and it works - feel free to ignore me if ORs work as well.

To make it simpler than checking every possible characters, you could use a while loop, e.g. (off the top of my head, and totally untested):
Code: ags

//on_key_press
if (keycode == 'X') {
  int who;
  while (who < MAX_NUM_CHARACTERS) { // Set the number as needed, use a define, or GetGameParameter
    if (character[who].Room == player.Room) { // Make sure they're in the same room
      if ((player.x <= (character[who].x + 20) && player.x >= (character[who].x - 20)) && (player.y <= (character[who].y + 20) && player.y >= (character[who].y - 20))) {
        //If character[who] is within 20 pixels of player, talk to them, and stop checking.
        character[who].RunInteraction(eModeTalkto);
        return;
      }
    who ++;
  }
}


You could possibly add a check to see it the character has a talkto interaction. And you might also want to check which way the player is facing, in case you have a situation where more than one character is near enough to the player to trigger the interaction. (NOTE: Currently, it'll only talk to the character with the lowest number - if character[4]
and character[7] are both there, 7 will be ignored - another good reason to add those checks.)
I know what you're thinking ... Don't think that.

Akumayo

Quote from: Ashen on Mon 02/01/2006 20:24:47
Code: ags

if (IsKeyPressed('X') == 1) {


Now... how... in the world... do you find out something like that?!  The manual clearly isn't exact enough.  :P .  ( -Logs away information in quote... -)

Anyway, I prefer mixing || and && together to create more complex (if only on my end) statements.  It's all about practice for me.  Anyway, I haven't tried the ||'s, but the statement seems logical to me.  As for your while function, it probably would work faster than mine, because even in mine, NPC's that were within 20 pixels of one another, would both be talked to, one at a time.  So I assumed Hammerite would move them apart.  Still... with some tweaking, your's would be more useful I think.  Oh well, I tried  :D

-Regards, Aelte Akumayo
"Power is not a means - it is an end."

scourge

Quote from: Ashen on Mon 02/01/2006 20:24:47

Code: ags

//on_key_press
if (keycode == 'X') {
Ã,  int who;
Ã,  while (who < MAX_NUM_CHARACTERS) { // Set the number as needed, use a define, or GetGameParameter
Ã,  Ã,  if (character[who].Room == player.Room) { // Make sure they're in the same room
Ã,  Ã,  Ã,  if ((player.x <= (character[who].x + 20) && player.x >= (character[who].x - 20)) && (player.y <= (character[who].y + 20) && player.y >= (character[who].y - 20))) {
Ã,  Ã,  Ã,  Ã,  //If character[who] is within 20 pixels of player, talk to them, and stop checking.
Ã,  Ã,  Ã,  Ã,  character[who].RunInteraction(eModeTalkto);
Ã,  Ã,  Ã,  Ã,  return;
Ã,  Ã,  Ã,  }
Ã,  Ã,  who ++;
Ã,  }
}


hey ashen, this looks very similar too what i use in Kludden. Except in place of the big ugly check i call a function:

Code: ags

function intersect(int px1, int py1, int px2, int py2, int cx1, int cy1, int cx2, cy2) {

Ã,  // check if player above npc
Ã,  if (py2 < cy1) return false;
Ã,  // check if player below npc
Ã,  if (py1 > cy2) return false;
Ã,  // check if player to left of npc
Ã,  if (px2 < cx1) return false;
Ã,  // check if player to right of npc
Ã,  if (px1 > cx2) return false;

Ã,  return true;

}


replace the big if with:
Code: ags

if (intersect(player.x-10, player.y-10,player.x+10,player.y+10,character[who].x-10,character[who].y-10,character[who].x+10,character[who].y+10)) 


It's slightly more efficient.

Khris

#135
Just found this thread again, here's my two cents of incredible efficent scripting ;)

Code: ags
if (Maths.Sqrt((player.x-cEnemy.X)^2+(player.y-cEnemy.Y)^2)<=20) {
Ã,  ...
}


This only replaces the distance-if, of course.

EDIT:
Damn, ^ can't be used like that, true. I've confused it with another language.
This simply calculates the absolute distance in pixels, so the area is circular, correct.

Ashen

#136
Positively Pythagorean!
Can you actually use the ^ operator like that, though? If so - or if you used Maths.RaiseToPower - that'd give you the advantage of a circular checking area (wouldn't it? my maths is a bit rusty), which would probably be more accurate than the square.

buloght:
Would it not be more efficient still to pass the character(s) and a distance, and have Intersect() work out px1, py1, etc ...?

Code: ags

if (Intersect(who, 20) == true) {
...
}


Code: ags

function Intersect(int chara, int distance) {
  int x1 = player.x - distance;
  int x2 = player.x + distance;
  int y1 = player.y - distance;
  int y2 = player.y + distance;
  if (character[chara].x < x1) return false;
  if (character[chara].x > x2) return false;
  if (character[chara].y < y1) return false;
  if (character[chara].y > y2) return false;
  return true;
}


I know I've missed a few parameters out, but frankly they confused me some.
I know what you're thinking ... Don't think that.

SSH

Quote from: khrismuc on Tue 17/01/2006 13:39:53
Code: ags
if (Maths.Sqrt((player.x-cEnemy.X)^2+(player.y-cEnemy.Y)^2)<=20) {
Ã,  ...
}


It would be more efficient to square the right-hand-side than to root the left hand side, especially where it is a constant.

Code: ags

if ((player.x-cEnemy.X)*(player.x-cEnemy.X)+(player.y-cEnemy.Y)*(player.y-cEnemy.Y) <= 400) {

12

scourge

Quote from: Ashen on Tue 17/01/2006 14:07:28
buloght:
Would it not be more efficient still to pass the character(s) and a distance,

Yes it would  :) and a lot cleaner!

A�rendyll (formerly Yurina)

#139
How do I do equipable items?

I have a few things I want to do:
- clothes, which can't be removed, only replaced
- talisman, weapon and shields which can be completely removed

I also don't know anything about skills...

How can I do skilltypes, of which you can choose 3 of 5?

Well, I've been thinking about the tutorial thingy, and I think there shouldn't be a tutorial about how to make the battle system, like you guys said.

I think this is what a good (and of course simple) RPG tutorial needs:
- More about how to get globalInts to work. Like, how can I get a globalInt done which says which monster I'm fighting for?
- How to deal damage to the party and enemies and get it on screen?
- How to get skills, skillcatagories, classes (in case this is optional), and abilities done.
- How to handle experience.
- How to handle a turn-based RPG with different rooms for battle and general exploring and how to use walkable areas (for example) for real-time RPG's.
- How to make GUI's which are used in battle. (Simple examples, of course, which can be expanded)

Simply said this would be a tutorial for the people (with only a tiny bit of experience) who want to make RPG's. This would be just a tutorial that gives a basic idea about how to get an RPG done. It's like making a template which you can expand with more advanced stuff. I'm convinced there will be RPG's which will look quite the same because they're basic, but there always are people which want to expand their basic system with some unique features.

I'd do this tutorial myself if I was more experienced with scripting, but I hardly get how I can get globalInts, strings, variables, etc. done all by myself, so I can't do it...

Don't get me wrong, I love this thread and I think you guys are right about having standart RPG's, but it's a lot of work to find what you search for in here.

Anyways, it's just an idea... I won't force anyone to make this.  :P

~Yurina
Yuna: Give me a Y!
Rikku: Give me an R!
Paine: Give me a break...
~Final Fantasy X-2

I've been

SMF spam blocked by CleanTalk