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 - The Electrician

#1
Quote from: Khris on Fri 12/11/2010 04:42:45
Custom properties are still useful though, e.g. for storing a weapon's damage or a room exit's direction and the like.

You can still do this with a global array. Just index it with the inventory id (for, e.g., weapons), or room number (for exit direction).

I think you can do any custom properties this way. You can even group them in structs (maybe, I haven't tried) if you want to get fancy and organised.

I think if someone is at the level of using custom properies, they would be proficient enough in scripting to do this. That's why for me this has always been a non-issue, but I understand others like to work in different ways.
#2
I just stopped bothering with custom properties (which are read-only at run-time?) a long time ago. I just declare in GlobalScript a global array of whatevers with length the number of, e.g., characters, then access them by indexing via character.id.

I don't know if that makes sense or if I missed the issue. As a programmer, I find it easier to do most things with code, and just skip the IDE for most such tasks. Seems a useful workaround for me. Is it deficient in any way?
#3
I am not entirely sure that what Ryan proposed is a good idea. On one hand, you will notice that the very action of pressing a mouse button tends to move the mouse ever so slightly: so in fact you will have quasi-unpredicatable behaviour when you click again: did the mouse move or not? This could confuse the player, rather than teach them not to multiple-click. You could also check for proximity, say no more than 2 pixels away from the first click, if you really want to do this.

This leads me to another question: when are walkpaths calculated and recalculated? It seems that on a walk-to click the game engine constructs a list of waypoints, and the character moves in straight lines, checking off the waypoints one by one (the AddWaypoint() method suggests this is how its done). HOWEVER: as the character moves, the environment may change. Now I am not 100% certain as I can't test this right now, but it seems the following things happen:
1) If another character gets in the way (and both are blocking==true), then I guess the old path is dropped, and a new path is recalulated to the same previous destination and our first character keeps walking. (However, I sometimes get the impression that two blocking charactes walk through each other, but it's hard to tell).
2) I had a situation where a square room is all walkable, but has a thin walkable area
though its middle. If the player steps on certain stones (regions), an iron grid falls across the middle of the room, blocking passage between the two sides. At that point, I RemoveWalkableArea() the middle area, so that the grid becomes solid. However, if cEgo is at one end of the room and the player clicks (only once) to walk to the other end of the room, then, if while walking cEgo triggers the required region, the grid will drop but cEgo will still happily walk through the grid and to the other end of the room. [A workaround to this problem was not hard, but it got me thinking.]

So, in conclusion, should not the walk path be recalculated:
a) whenever a character OR object with blocking==true changes coordinates (moves),
b) whenever RemoveWalkableArea() or RestoreWalkableArea() is called?

I guess this can all be scripted as needed, though having it embedded in the engine would be nice. I appreciate that pathfinding can be computationally expensive (AGS uses A* on 3x3 squares, I think), but do you really want your characters to walk through stuff they shouldn't? I guess IRL we recalculate our paths all the time when walking down a crowded street [or don't, and then bump into people].

Thoughts?
#4
Thanks GarageGothic - ok, I get your point now and it was me that misunderstood. Yes, that might be a good solution too, particularly for my first example (the maze map). I guess I will find out what the char limit really is for long strings.
#5
Thanks GarageGothic, that's a very good (and quick!) reply.

I guess you got all my points, except one.
Quote from: GarageGothic on Sat 03/07/2010 03:56:09
Re: 2) You *can* use a linebreak within a line of script, but it will also mean a linebreak in the displayed text unless you remove it from the String before displaying.

I don't want a linebreak in the game output (using '[', if I remember correctly), but rather in the code editor, so I don't need to horizontally scroll through a very long text. Anyway, it seems there's a rather small char limit on constant strings, so the issue is irrelevant.

I like both your solutions, and will probably implement one of them when/if I finish the game.

To everyone: any other thoughts? I am curious if this an issue many people have? What other uses do you see for very long strings? Should AGS have internal text folders where you can dump huge pieces of text? (As an afterthought, perhaps I can just (mis)use the dialog editor for that. Thinking...)
#6
I've been using AGS for a few months now, and I can mostly make it jump how I tell it to (I have some programming background). However I am not sure how to properly handle very long constant (read-only) strings. Let me give you 2 instances of where I need to do this, though you might think of others:
a) I have a rather large maze-like area, all using one AGS room, where I use some dynamic drawing and turn walkable areas on and off, etc. to give the illusion of multiple rooms. So far so good: each virtual room needs to have several parameters set (location of doors and walls, connectivity with other rooms, misc objects, etc.) and these are described in one .txt file, each line describing one virtual room. The code then reads the lines into a string of arrays at the beginning of the game, and parses the information for a particular room during its load function.
b) The player finds a book which contains several pages of text. When the book is opened, its closeup appears, and the page's text is rendered in a funky font, with the possibility of flipping pages with the hand icon. The totality of the book's text is stored in one .txt, with separator symbols between pages.

In both situations, you need a very large block of text, which is not easy to place between quotes (the editor doesn't even wrap lines). Loading .txt's is fine, except should I finish the game and deliver it to the public, I don't want the user to look at, or mess with, these files. Copying the whole text into a string by hand is cumbersome for editing later on, particularly for editing my maze map.

To summarise, I have one of two problems:
i) The large strings are placed directly in the code, which makes them cumbersome to edit.
ii) They are placed in a .txt file, where the user has unfettered access to them.

So I want to hear how others have handled/would handle this.

This leads me to the following questions/ideas:
1) Can you import a .txt as a resource into AGS?
2) Can you write long strings in the AGS editor in a multiline fashion, or at least make the editor wrap lines?
3) In the end, I might just develop the game with the .txt's, and copy everything manually into strings at the very end, just before making it public. This is bad programming practice however, and ideally such large resources should be in some way separate, just like the .vox files are.
4) Alternatively, I might write a simple home-brewed encryption algorithm to change the text into something unreadable, with some checksum so that it cannot be easily messed with, and have the game read and decrypt the file. (After all, if someone is very ambitious, they might as well try to decompile the game code itself.) This feels a little overkill, though.

Discuss.
#7
Another solution is simply to check the position of the character when s/he enters the room. I do this when I have my character come out a door and make the closing door animate. It saves you the global variable.

In programming, it is generally bad practice to use global constants unless strictly necessary. It makes for messy code as you have more and more of them. General rule: keep variables as local as possible, or don't use any if they can be derived from other variables.
SMF spam blocked by CleanTalk