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 - Gepard

#21
Well a single place consist of multiple "rooms". These are not actual rooms, just levels, that are set using integer whenever player enters a room. So I just decide which level is the Enemy1 going to be in and when player fights it and win, the entString for that place will have "enemy1" appended to it. And I define the enemy when the place is opened. I use function for that.
#22
Thank you all for help. I'm trying to implement as much as possible to the system I already have. You guys are a great help! Much appreciated!
#23
Thank you, everyone, for your ideas.

In my game I have many places, that player can explore. While exploring, he can encounter three kinds of puzzles, enemies or items. For each place I have a String assigned and this String changes everytime a player solves a puzzle, defeats an enemy or finds an item. So for example if he enters a place where there is an enemy and the String does not contain the word "enemy1", a fight will start. If he defeats the enemy, than word "enemy1" will be added to that place's String (the same can be done with loot, I just append "chest1" and puzzles, I just add "relicpuzzle"). Not every place has the same type of puzzles, numbers of enemies, items etc. Also it is very easy to reset the place from the start and make all the puzzles, items and enemies alive again, I just set the String to "". I will definitely use the Game.DoOnceOnly feature, and will also look at structs as I haven't use them so far.

Edit: Also, I only have one room in the game (not counting the main menu).
Edit2: I searched the forums and the internet, but I couldn't find any tutorial on structs in AGS. I tried to declare them in my game, but with no luck. Can anyone tell me if there is a complex tutorial for beginners on how to use them. How and where to declare them, how to get and set their values? Thank you.
#24
I'm sorry, I don't understand. I have a String defined in Global variables. Now I want it to change when player click on a GUI button. But when he clicks the button, it can always be different String that changes, depending on "where" the player is right now. How do I do this? I mean, what to put under button click code and what in the function?
#25
Hello,

I have various dungeons that player can explore and find loot in them. For example, he ventures deep into the dungeon, opens a door and finds a treasure chest. When he clicks the treasure chest an inventory window shows up with a single item, that was added to the inventory when he opened the door or clicked on the chest. I have this code for this:

Code: ags
if (eventPlace1.IndexOf("gold")==-1) {
place1.AddInventory(iGold);
eventPlace1 = eventPlace1.Append ("gold");
}


This is to ensure the item will only be added once. And it is working, but the problem is, my script is getting pretty heavy. I was thinking if I could use a function that would fit these lines into one. I don't know if you can make a function that would refer to a String already in the game like you do with characters or inventory items. I tried but the game said "Invalid use of pointer".

Thanks for any help.
#26
Bloody hell. That did it! At least for now it seems like it works. Thank you Cassiebsg and everyone else. Sorry for being such a drama queen. I'll be more calm and give more detail in my next topics if there are any. Thanks for the varning Snarky. Will have to bear that in mind.
#27


A, B, C, D - places (characters) - not solid
player character is behind place A and is the only one moving around - solid
What I've noticed so far in this placement. Player starts at A, can travel to B and C no problem and back as well. Can travel to D, but only from A. If he tries to go from B or C to D, code skips the move player command. Also skips move player when travelling from D to B or C. When I move D to Y:80 like so:



A, B, C, D are not solid, the character can be solid or not (doesn't seem to matter), everything works fine, but I cannot have D on the map where I want it.

This is the walkable area:

#28
I apologize, I know I can sound a bit chaotic, and I always keep in mind, that when there is something wrong, it is not the AGS, but me who made the mistake. OK, so let me clarify. I use characters as locations, because I want a lot of locations and in AGS there is unlimited number of characters but not hotspots, objects or something else I could use. Also I have each character's properties defined neatly in the Custom properties section. One of those properties is a text property TravelChoice, lets say character A has a TravelChoice "B C". This is to limit player character to a certain location he can travel to. When he clicks the B location, the string Destination is set to B. Than TravelChoice of current char (current place) A is compared to the Destination. If TravelChoice has the destination in it, than player can travel there. As I've mentioned earlier, I have a lot of locations planned, and they will all be in one room, so I don't think there would be enough regions. I really appreciate your help guys, I'm just a bit frustrated because of how much work I've already put into the game.

So, I've solved the issue with getting the character's text property, now just the previous one remains. I will try to post another image explaining it.
#30
Yes, the target character itself can move just fine. I found out another thing though. The character that is causing the problem is placed almost at the top of the screen (Y: 45), but if I move it a bit more to the south, it seems to work just fine. And it is not just that character. If I replace it with another one, that is "up north", than it will cause the same trouble. This is so weird. I mean, how or why does the game decides to just skip one line of command? Can you at least tell me if this is a bug or not?

Edit: Yes, the editor or the game must be broken. I have just changed a location of one character on a map and even the code that worked before is now refusing to run. Like getting a character text property. Did this happaned to anyone before? What can I do to save my game? A lot of work went into it. I'd hate to lose it :(
#31
Khris, strange thing is that whether the characters are solid or not, it seems to have no impact on the result. It always gets the same result. 3 places work just fine. The fourth doesnt. Anyway, did what you asked, and got the same result. My problem now is that with that fourth place, the Move command gets ignored.
#32
Doesn't work. It must be a bug of some sort. I tried everything. Putting all kinds of commands before and after it. All execute no problem. This one: "player.Move (WhichOne.x, WhichOne.y, eBlock, eWalkableAreas);" just gets ignored. Even if you put two of those. Nothing happens. The Move command just gets ignored. This is so frustraging :undecided:
#33
I already tried that. Works fine that way. I have no idea what is going on with the engine.
#34
This is a total mystery to me now. There are total of four places in the game. When I make the character solid, it the code works with only one of them. When I make it not solid, it works with the remaining three, but not the one. I have also noticed that the code runs OK but for some reason it decides not to execute the line that moves the character. I even put Display message before and after it. Both work, but not the line that should move the player.
#35
OK, just when I thought it was going to work fine, the game just went haywire. I mean, one moment, you can travel to a certain place and the next you just cannot. It is like the game decides itself it will run a certain part of the code or not.

Code: ags
function OpenPlace () {
Character *WhichOne = Character.GetAtScreenXY (mouse.x, mouse.y);
  if ((player.x != WhichOne.x || player.y != WhichOne.y)) {
    if (TravelTo.IndexOf("%s" Destination)>=0) {
      TravelTo = String.Format ("%s", WhichOne.GetTextProperty("TravelChoice"));
      player.Move (WhichOne.x, WhichOne.y, eBlock, eWalkableAreas);
    }
    else Display ("This location is too far");
  }
  if (player.IsCollidingWithChar(WhichOne)==1) {
    // rest of the code is here
    }
  }
}


Sometimes the whole code runs perfectly, sometimes, the game decides to skip the part when the character moves, the one starting with "if (TravelTo.IndexOf..." I have no idea, what is going on... :f (

And btw. each character that I click on has a TravelTo Text Property. For example: "prison oldchapel" and when I click on some character on a map, it sets the Destination String to its name. For example I am in Port and the port has Text Property "TravelTo" set to "prison oldchapel". When I click the Old Chapel character, it sets the Destination to oldchapel, than the code should check, whether TravelTo of Port has the "oldchapel" in it (WHICH IT DOES!!!) and if it does, moves the character towards the character that I clicked. But the code just refuses to run. Why?
#36
Thank you both very much. Btw. I have solved it in a different way. I made the characters solid and instead of checking if they are on the same X and Y, I put the IsCollidingWith function. Thank you for your help anyway.
#37
Hello, I have s simple problem with character movement. I have this code in a function:

Code: ags
Character *WhichOne = Character.GetAtScreenXY (mouse.x, mouse.y);
if (((player.x < WhichOne.x)||(player.x > WhichOne.x))||((player.y < WhichOne.y)||(player.y > WhichOne.y))) {
    if (TravelTo.IndexOf("%s" Destination)>=0) {
      player.Move (WhichOne.x, WhichOne.y, eBlock, eWalkableAreas);
      TravelTo = String.Format ("%s", WhichOne.GetTextProperty("TravelChoice"));
    }
    else Display ("This location is too far");
  }
  if ((player.x == WhichOne.x)&&(player.y == WhichOne.y)) {


This second part of the code that should run when players x and y is the same as WhichOnes doesnt run. It was running fine when set to eAnywhere before. But when I decided to move the character only on walkable areas, what happens now is that the character moves to the WhichOne x and y, but not exactly to its x and y. It is always a bit off (255, 111 vs 262, 106). And yes, there is enough walkable area around. Interestingly enough, one location works fine, but three more just do not. Any suggestions?

Thank you!
#38
Right. Thank you!
#39
OK, so I've simply declared a String in my game start global like so:

Code: ags
function game_start() 
{
  String Active;
  export Active; 
}


and than in header like so:

Code: ags
import String Active;


It gives me the: "Local variable cannot have the same name as an import" error. These are literally the only occurences of the "Active" String as this is a brand new game and only have few lines of code. Can anyone help?

Thanks!
#40
I feel so stupid. Thank you again! It's been a long time since I've used AGS. Thank you!
SMF spam blocked by CleanTalk