Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - aussie

#1
Quote from: Snarky on Sun 22/10/2023 11:39:00What I don't quite understand is how, having sorted the speeds, you are then able to tell which unit corresponds to each element in the sorted array and should move first. Do you do a lookup to find which unit has the particular speed? That adds another layer of inefficiency, if so. And what if multiple units have the same speed? (Edit: Ah, I see that you edited your post right before I finished this, and in fact can not tell.)

Precisely my point. I only noticed after I tried your solution. I have a very nicely arranged array where I do not know which value goes with which character!

Quote from: Snarky on Sun 22/10/2023 11:39:00Also, one tip: It's a great benefit if you can use the same struct both for heroes and enemies, since that means you can, among other things, store them in a common array, which lets you easily do things like sort them or run through them one by one. And you wouldn't need separate .herospeed and .enemyspeed properties (and many other stat properties that are probably duplicated); instead you could just have one .speed property, and a single flag like bool isHero to tell them apart.

Yes. This is so true  :smiley:  :smiley:  :smiley:. I have fixed all my code so that I now have a single struct where I previously had three. It makes things so much more convenient. I think this is also going to help me with the sorting problem.

Quote from: eri0o on Sun 22/10/2023 12:10:55I really think you don't need to sort, just pick the unit with the maximum speed of a group and then remove it from the group - this should make it easier to add additional conditionals, like, maybe flying units goes first indifferent from speed.

Anyway, if your units all share a same index and you want to sort by speed and you have int sort working, a common trick is instead sorting "val= speed*256 + unit_index" and then later just filtering the index out by using "unit_index= val&0xFF".

Agreed. That should work provided I remember to "put the character back in" once each round of individual turns is complete. I also get what Snarky is saying.

I still have a bit of thinking to do to make things work exactly as I want, but you guys have placed me on the right track. I might revisit this post in the coming days if I need further advice. For the time being, thank you so much!!!
#2
I see. That seems to work! Thanks!

You guys are legends!

EDIT. Now I realise I may have done something stupid. I have a perfectly sorted array of speed values, but I believe the script no longer knows which speed belongs to which character!

Instead of an array, is it possible to start with a struct with the speed and the name of the character, then sort it following Snarky's procedure? Any easier workarounds?

Thanks again!
#3
Quote from: Khris on Sun 22/10/2023 10:09:02Try
Code: ags
  selectSortMax(turnorder, 8);

Thanks Khris. In that case I get the following error: Type mismatch: cannot convert 'int*' to 'int[]' :confused:
#4
Quote from: Snarky on Sat 21/10/2023 23:44:13In the general case, it's best to implement a performant search algorithm like quicksort or mergesort.

But if you're dealing with small arrays, on the order of maybe a dozen entries, you can use an inefficient but simple algorithm instead. I'll go with selectsort since it is pretty intuitive:


Thanks Snarky. I have tried your solution. It appears to work, except I somehow can't call the function to sort my array. Here is my code. It is all within the room script, as I do not expect to use the sorting function outside it.

The error I get is in the very last line. I may not be calling the function properly, but I think I have tried all combinations.

Code: ags

//First your function

void selectSortMax(int array[], int arraySize)

(...)

//then get the speed of all characters/enemies in battle

heroLBspeed = hero[heroLB].herospeed;
heroUBspeed = hero[heroUB].herospeed;
heroUFspeed = hero[heroUF].herospeed;
heroLFspeed = hero[heroLF].herospeed;
enemyLBspeed = enemy[enemyLB].enemyspeed;
enemyUBspeed = enemy[enemyUB].enemyspeed;
enemyUFspeed = enemy[enemyUF].enemyspeed;
enemyLFspeed = enemy[enemyLF].enemyspeed;

//put them all in an array

int turnorder[8];
turnorder[0] = heroLBspeed;
turnorder[1] = heroUBspeed;
turnorder[2] = heroUFspeed;
turnorder[3] = heroLFspeed;
turnorder[4] = enemyLBspeed;
turnorder[5] = enemyUBspeed;
turnorder[6] = enemyUFspeed;
turnorder[7] = enemyLFspeed;

//Then I call the function you defined

selectSortMax (turnorder[],8); ---- [This is the line that gives me the error]


Depending on what I pass into the last line I get different errors:

- Type mismatch: cannot convert 'int' to 'int[]'
- Array index not specified

Quote from: eri0o on Sun 22/10/2023 03:14:52I made a quick sort here: https://www.adventuregamestudio.co.uk/forums/advanced-technical-forum/solved-doing-quicksort-in-ags-problems-with-pointers-and-managed-types/msg636624313/#msg636624313

I think if the party/monster is sufficiently small, you can assign an unique add to them and then just put in a group, then you can find the maximum from the group and just remove one by one the ones that are playing their turn. Once none is available the round ends and then you start a new round.

Thanks a lot eri0o. :smiley: I have not tried your solution yet because it looks a little more complex and I have limited time today. I will do so as soon as I can then get back to you.
#5
Hi all! It's been years since I last posted here. It's great to see familiar nicks still around!  :grin:

Today I bring you an embarrasingly basic scripting question.

I am trying to set up the turns of a turn-based combat system. So far I have defined the characters' and enemies' attributes in structs in the header and main script. I can import and export these between the battle room and the main screen without problems. I can also have different enemy and hero parties depending on the battle I need to run, so I feel things are coming together nicely.

But here is where I run into trouble. Each character/enemy has a speed attribute (int) which should determine the order in which he is to act. Now I am trying to automate the turns and I feel I am getting stuck in one of the easy parts of the process. I have arranged the speed attributes in an array of int values and I need to have them in descending order. Any tips?

Thanks!

Edit: I have also run several searches in the forum but I cannot seem to find what I am after.
#6
I see. That makes plenty of sense.

Thankyou so much!!
#7
Hi all,
I have this function in my global script where I have defined an array containing the same variable (health) for a series of characters. It looks like this:

Code: ags

funtion character_health();
{
int health [10];
health [0]=100;
health [1]=80;
...
health [9]=50;
}


Much later, I have different function to check if a character is dead once it takes a hit during a battle. More or less like this:

Code: ags

funtion character_takes_hit();
{
(...)

int hit = 50;

if (health[0]>=hit) {health [0]=health[0]-50;}
else {//character dead code goes here}

}


The problem is I get an "undefined symbol 'health'" error. It looks like AGS cannot pass array index 0 into the second function. Is that so or am I doing anything wrong?

I've run a forum search and it looks like passing array indexes into functions used to be problematic. However, the earliest post I found regarding this topic is from 2010. I wonder whether it's been fixed.
#8
Thanks a lot to both of you. I have come up with a workaround, but I will definitely look into those solutions. They look better than mine.
#9
Hi all,
I have a Monkey Island dialog GUI (you know, the black box with a list of options down the bottom of the screen). I need to list like 10 or 12 options, but I don't want to make the box any bigger so it doesn't interfere with the characters in screen. Two silly questions:

1. Can you have scrolling dialog options? (like in MI's insult swordfights)
2. If so, which is the easiest way?

I've run a couple of forum searches, but the search function seems a bit sluggish today. It's not giving me any results.

Thanks in advance.

BTW, I'm running version 3.2.1
#10
Thanks Khris,

I have done the .rar thingy. Game size does drop significantly, from 45 to 20mb.

But I'm not sure if the proportion will be linear, and still, I could end up with a 75-100mb game... :-\
#11
Thanks kyodai,

How do you change images to 16 bit outside ags?

Also, I've run a search in the forum and most people say that the image format (jpg, pcx, png) does not matter much because AGS uses its own packing algorithm.

There is no music in the game yet, but I'll keep in mind your advice.
#12
Hi all, I have two basic questions:

1. I'm making an 800x600 res game. I'm using real pictures. After completing five rooms, the game is already up to 45mb. Since I'm planning quite a few more, I'm afraid the file size could really skyrocket.

How could I keep it down? Please note that lowering res won't do, and that I have already compressed sprite size and changed from 32 to 16 bit color (this doesn't seem to affect game size).

Just in case it turns out to be important: I started off with 1024x768 then switched to 800x600, then reduced all bgs and sprites.

2. What takes up the most space in a game? Am I on the right track changing sprites and resolutions?
#13
Critics' Lounge / Closeup portraits
Tue 01/11/2011 10:53:41
Hi,

I have made these three closeups based on some earlier sprites by buloght.

They kinda look allright when you zoom in, but they're not great at the screen resolution - which is the resolution of the game.



I just need some advice as to how to improve them. In particular, I want to develop a style that is both simple and effective (i.e. I'm trying to minimize shading and stuff like that because I'm not very good at it).

Paintovers are more than welcome.



#14
Quote from: LeKhris on Sun 30/10/2011 16:41:22
Just put this in game_start:

Code: ags
  game.show_single_dialog_option  = 1;


It's in the game variables section.

I think this solution works best. Thanks!
#15
I've done a search for this in the forums, but it's kinda difficult to word it correctly.

I have this conversation where there is one single dialog option left to say. The player character says it automatically, but I want the player to actually click on it before it is said. How do you do that?

The question is pretty basic. The fact is I've done it already in the game I'm working on, but I can't remember how.  :-\

Thanks very much.
#16
Quote from: Ghost on Sun 02/10/2011 00:02:25
Is there a reason for not using TTF, then? I got several that support "odd" characters, and would happily share.

I hadn't really thought about ttf fonts until I say pcj's post, really.

I guess I could use one of those. Trouble is, I already have like ten rooms already where I've implemented tonnes of messages with Spanish characters (I use @ to represent á, < for é, etc). Changing the font would imply going through all that again.

Look, don't worry too much about it. The normal font (not outlined) doesn't look that bad. I guess it'll have to do.

Thanks anyway. 



#17
Quote from: Ghost on Sat 01/10/2011 23:46:39
You could, of course, write a custom display function that uses non-outlines text and draws the same string NINE times, with offsets and a colour you set:

BLACK:
x-1, y0
x+1,y0
x-1,y-1
x+1,y-1
x+1,y+1
y-1,y-1
x0,y-1
x0,y+1

WHITE
x0,y0

That would give you an outline (due to the offsets), and then the string on top of it. I think AGS already DOES outlining that way internally.

[edit]
As I re-read this, it really sounds very much overboard- but might be worth a shot.

Alternatively:
Calin wrote a Spritefont module-
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=44359.0

I guess that could work. As you say, however, it's simply too much trouble. I'd rather look into other alternatives. Thanks anyway. :)

Quote from: pcj on Sat 01/10/2011 23:47:37
That's a bit over-compensating for what sounds like a simple problem.  Try a different font and see if that works?

I just tried to no avail. All SCI fonts seem to do this.  :-[

#18
When I set white to the TextColor property I get the top message.



I would like to get the bottom one, which I made with photoshop just to show what it should look like.

Maybe it has something to do with you using a TTF font?
#19
Nope. That doesn't work either. It's the first thing I tried.  :)

That changes the color of the outline, but the inside of the font remains transparent.

Other ideas?
#20
Nope. That didn't work.  :-\

It sounded like a good idea. Thanks anyway.

Any more takers?
SMF spam blocked by CleanTalk