Author Topic: So has a kyr system been created?  (Read 2945 times)

So has a kyr system been created?
« on: 20 Feb 2018, 16:55 »
Hello, I'm new here and to AGS but I did read rules and threads about what made me come here. I'm looking to find if someone has created a template or plug in or anything, something similar to Kyrandia's GUI of single pointer and inventory of up to 10 items (or more items if scrolling is allowed then that too). I did come across threads asking for that but in 2003-2005, I saw this thread but I am not sure if they are after the same kind. I just don't like the LucasArts system with right-click and texts that show you who you can interact with, I want to leave this to the player which is why I liked Kyrandia's system more.

I am asking because versions have changed and it is not clear if doable. Some threads mentioned you can drop objects if you do limit / room, which is fine, anything close to Kyr style. I read you can randomize things in a room, that's something I also will need but for another time.

Please let me know if there is a template or anything that can be used.

More useful links for this:
Script Manual
Day Night transition
Swapping BGs
Disabling Animated Background While wanting to use diff BG each game run
Calculate distance
Inventory Limit
Main Menu Start

P.S Disable room fade in/out from Settings - Visual - Default Transition When Changing Rooms to Instant.
day/night as done by me
Add spoiler tag for Hidden:
Code: Adventure Game Studio
  1. bool nightFall;
  2. int durationDayNight[2];
  3. float lightTransparency;
  4. float durationDay;
  5. float durationNight;
  6.  
  7. //somewhere in starting funct
  8.   if (season == 0 || season == 2) { durationDayNight[0] = 72000; durationDayNight[1] = 46080; } else { durationDayNight[0] = 52560; durationDayNight[1] = 65520; }
  9.  
  10. function repeatedly_execute_always() {
  11.  
  12.     //Day-Night system
  13.     if (FloatToInt(durationDay, eRoundNearest) < durationDayNight[0] && nightFall == false )
  14.     {
  15.       durationDay++;  
  16.       gNightOverlay.Visible = false;
  17.       lightTransparency = 100.00;
  18.     }
  19.    
  20.     //Calculated if 40 is 1 minute, 1200 is 30 mins for summer day light
  21.     if (FloatToInt(durationDay, eRoundNearest) == durationDayNight[0])
  22.     {
  23.       gNightOverlay.Visible = true;
  24.      
  25.       //0.01 is around 3 mins of transition to full darkness
  26.       lightTransparency = lightTransparency - 0.01;
  27.  
  28.       if (lightTransparency > 25.0) { gNightOverlay.Transparency = FloatToInt(lightTransparency, eRoundNearest); }
  29.     }
  30.    
  31.     if (gNightOverlay.Transparency == 26)
  32.     {
  33.       durationDay = 0.0;
  34.       durationNight++;
  35.       nightFall = true;
  36.     }
  37.    
  38.     //summer day light is 13 hours, transition 1.3 hours twice, night is 8.4 hrs, the same percentage of 72000 for night is 46080
  39.     //fall day is 9.5 hours, or 52560, again twice 1.3 transition time, night is  11.9 hrs so 65520 for night
  40.     if (FloatToInt(durationNight, eRoundNearest) == durationDayNight[1])
  41.     {
  42.       lightTransparency = lightTransparency + 0.01;
  43.       if (lightTransparency < 100.0) { gNightOverlay.Transparency = FloatToInt(lightTransparency, eRoundNearest); }
  44.     }
  45.  
  46.     if (gNightOverlay.Transparency == 100 && nightFall == true)
  47.     {
  48.       durationDay++;
  49.       durationNight = 0.0;
  50.       nightFall = false;
  51.     }
  52.   } //this bracket is from the if player room <= 300
  53. }
  54.  
« Last Edit: 01 Jun 2018, 23:27 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #1 on: 20 Feb 2018, 17:28 »
Some threads mentioned you can drop objects if you do limit / room, which is fine, anything close to Kyr style.

I've never seen such template around, but one thing I can say is that in AGS it would be much easier to use Characters for droppable/randomized items on ground, because -
1. Characters are unlimited, while objects are limited 40 per room (and you may have to use these not only for items)
2. Same characters can be moved into any room, and objects are restricted to room they are created in (so you'd have to create objects for dropped items in every room).

Other than that, I believe such system would not be too hard to script.
« Last Edit: 20 Feb 2018, 17:58 by Crimson Wizard »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: So has a kyr system been created?
« Reply #2 on: 20 Feb 2018, 17:34 »
As for the single-pointer UI, you can just use the left-click/right-click template and not use the right-click for anything.

Re: So has a kyr system been created?
« Reply #3 on: 20 Feb 2018, 19:53 »
Quote
As for the single-pointer UI, you can just use the left-click/right-click template and not use the right-click for anything.

Which one is that template? Oh this one

I've never seen such template around, but one thing I can say is that in AGS it would be much easier to use Characters for droppable/randomized items on ground, because -
1. Characters are unlimited, while objects are limited 40 per room (and you may have to use these not only for items)

Thanks, that's a good workaround that I could use, as long as it also allows putting these characters in an inventory.
« Last Edit: 24 Feb 2018, 17:22 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #4 on: 20 Feb 2018, 20:21 »
Thanks, that's a good workaround that I could use, as long as it also allows putting these characters in an inventory.

Characters cannot be put in inventory, but Objects cannot be put in the inventory either. In AGS inventory item is a separate entity that only exists in inventory, while room object, or character (or anything else) serve as item's representation in the room.
Common practice is to have an object in the room, which, when picked up, becomes invisible, while inventory item is added to inventory.
With character, you should probably move them to room -1, that's imaginary room which simply means that character is nowhere.
« Last Edit: 20 Feb 2018, 20:24 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #5 on: 26 Feb 2018, 17:21 »
Quote
Characters cannot be put in inventory, but Objects cannot be put in the inventory either. In AGS inventory item is a separate entity that only exists in inventory, while room object, or character (or anything else) serve as item's representation in the room.
Common practice is to have an object in the room, which, when picked up, becomes invisible, while inventory item is added to inventory.
With character, you should probably move them to room -1, that's imaginary room which simply means that character is nowhere.

Thanks, im making my first tries and a lot more. I have a question about objects, I read that they cannot be created from script, you have to place objects in the room.

What if I placed the max number of Environment objects I want to have and use script to decide if all will be visible and what position. Im trying to generate the rooms with different position of trees and other props for the different rooms but these objects once created should stay the same for those rooms, not change every time the character gets back to them (for the same run of the game).

The plan is, since I even use seasons, if season var is e.g 0 for summer, in the room show/hide (random number between 3 and 5 tree Objects) and position them (in random X,Y  point area). If season is e.g 1, change their sprite from their summer sprites to their e.g autumn sprites. I am using this on pre-placed objects since these cant be created from script. It already works for the ground (room background image) changed based on the random season var.

So the code questions are down to:
- How to scale the objects? (I want to add condition if it is in the upper part (maybe like between Y 0 and Y 200 in 1080p screen) and that is further from the character, I will add code to scale them down as if further)
- Set tint color/opacity again for Background reasons so we dont need a separate sprite for every single difference in distance
- How to change the sprite it uses from the folder if (conditions  are met) from sprite ID whichever to sprite ID whichever? For change of season based sprites.
- Based on where the objects trees etc are (again condition if too above or not) make them front/behind character
- How to hide or position Objects out of the room that will not be displayed)?
- How can I create an object/character that will be used for item and inventory at random room? (my guess would be have a global var that checks if a certain number is met, if yes, create at this room, else, do not create, if it already exists, do not create) - this one I might be able to do at my own but it seems I need to place the items at the rooms I want and hide them since I cant actually SPAWN them with script).

 
« Last Edit: 26 Feb 2018, 17:32 by Imc7r »

dayowlron

  • been programming computers since 1981
    • I can help with AGS tutoring
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
Re: So has a kyr system been created?
« Reply #6 on: 26 Feb 2018, 18:09 »
I can answer of few of these:
Scaling objects? You can either create the actual size of the graphic and load it as a separate sprite or put it on its own walkable area and set scaling there. I believe if you do that you also have to change a setting in the object to tell it to "Use Scaling"
Changing the graphic? All you do is set the object's Graphic property to be the new sprite id.
Object in front or behind, just set it's Baseline to be higher on the screen to move it behind other objects, lower to put it in front.
Only way to position or hide objects if you are not in the room is set a variable that will be used to control the object and in the Load function for the room make the adjustments according to the value of that variable.
Creating object in another room you would have to use the idea just mentioned by setting a variable and referencing it in Room_Load.
Creating a Character in another room you can just tell that character to "ChangeRoom".
You are correct that you would have to have the objects in every room that it could be created in and just set its Visible property to be false if it is not supposed to be in that room.
Pro is the opposite of Con
This fact can clearly be seen,
If progress means to move forward
Then what does congress mean?  --Nipsey Russell

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #7 on: 26 Feb 2018, 18:22 »
So the code questions are down to:
First thing I want to say, is that some of these questions are easily answered by simply reading a manual, specifically sections dedicated to functions and properties of characters and objects.

- Set tint color/opacity again for Background reasons so we dont need a separate sprite for every single difference in distance
Object has Tint function and Transparency property. Also there is SetAmbientTint function for everything on screen.
Alternatively, you may use GUI with certain background color and adjusted Transparency property used as a graphical overlay.

- How to change the sprite it uses from the folder if (conditions  are met) from sprite ID whichever to sprite ID whichever? For change of season based sprites.
Object.Graphic property.

- Based on where the objects trees etc are (again condition if too above or not) make them front/behind character
This is done automatically in AGS. If automatic result does not match desired one, use Object.Baseline property.

- How to hide or position Objects out of the room that will not be displayed)?
Object.Visible property.

- How to scale the objects? (I want to add condition if it is in the upper part (maybe like between Y 0 and Y 200 in 1080p screen) and that is further from the character, I will add code to scale them down as if further)
This is suddenly not simple.
The usual method of scaling things in AGS is to set up scaling properties of a walkable area these things are put on. Alternatively (and if you cannot have them on walkable area), characters may have individual scaling (properties are called ManualScaling and Scaling).
In your case, you probably won't be able to use walkable area scaling for trees, because you won't want characters to be able to walk there. Well, you may try, and also set "Solid" property for these objects to block character, but idk if that will work well.
What I suddenly realized, I've never paid attention to this fact, Objects do not have individual scaling for some reason. Probably engine author forgot to add this.
The only remaining solution I know is to use something called DynamicSprites. It works like this: you declare a number of DynamicSprite variables in the room, clone existing sprites into them, resized up or down, then apply DynamicSprite's ID to Object.Graphic. This sounds a bit complicated, but not overly difficult in practice.


- How can I create an object/character that will be used for item and inventory at random room? (my guess would be have a global var that checks if a certain number is met, if yes, create at this room, else, do not create, if it already exists, do not create) - this one I might be able to do at my own but it seems I need to place the items at the rooms I want and hide them since I cant actually SPAWN them with script).

My suggestion is this:
* Create a large number of dummy characters in your game (their quantity depends on how many items you want to allow in one room, but you may always add more).
* Create a global array of Character* pointers in global script, fill this array with dummy characters at game start, and use it as a "entity pool" to get available dummy characters for representing items lying in the rooms.
* You would need to save information about what items are lying on ground. Probably you will need some kind of item ID and coordinates.
* Upon entering a room, scan through this information and set up dummy characters, assigning them the appropriate looks.
* You may do this in every room, of course, but that may become tideous and require lots of copies of similar code, which is very bad. Much better, IMO, is to code a universal script module that would handle this task independent of room. There is a special built-in function callback in AGS called on_event, which is called in events like eEventEnterRoomBeforeFadein and eEventLeaveRoom, you may use it to run this script.
« Last Edit: 26 Feb 2018, 18:25 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #8 on: 05 Mar 2018, 12:18 »
Thanks for the detailed explanation and answers from the above posters, I will now deal with this one by one.

The only remaining solution I know is to use something called DynamicSprites. It works like this: you declare a number of DynamicSprite variables in the room, clone existing sprites into them, resized up or down, then apply DynamicSprite's ID to Object.Graphic. This sounds a bit complicated, but not overly difficult in practice.

I read your post here about dynamic sprites and I also read in the manual that there are some functions for creating image and im not very sure if it has to be like in your post there.

What I did was created an object in the room, assigned a transparent image almost as big as the entire room, and this is where the images (dynamic sprites) would be drawn (trees and other props).

So how can I draw them in a way that they will remain so when the character reenters the room they will not change? Should it be in the global script ? It has to be generated once for every room for that game run and unless a new game is started they should remain as they are created once. Then I can probably change color, resize as I read that you can do this with the dynamic sprites drawn on object and changing baseline.

It's not clear how where the ID of the image i want to draw goes

Code: Adventure Game Studio
  1. // room script file
  2.  
  3. DynamicSprite * EnvironmentProps;
  4.  
  5. function Start() {
  6.      
  7.  
  8.  
  9.   EnvironmentProps = DynamicSprite.Create(Room.Width, Room.Height);
  10.   DrawingSurface * EnvironmentPropsSurface = EnvironmentProps.GetDrawingSurface();
  11.   EnvironmentPropsSurface.DrawImage (0, 0, 292);
  12.   EnvironmentPropsSurface.Release ();
  13.   ObjForDynamicSprite.Graphic = EnvironmentProps.Graphic; //arent Graphic supposed to be IDs of sprites?
  14.  
  15. }
« Last Edit: 05 Mar 2018, 14:11 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #9 on: 05 Mar 2018, 14:59 »
Well, your code example is generally correct, but there are couple of things I need to mention.

First of all, if you have several "layers" of props at different distances, and characters or moving objects are allowed to move between these layers (i.e.: some trees are at background, and some are on foreground or in the middle of the room), then you cannot use only 1 dynamic sprite. You will have to use at least 1 dynamic sprite per layer. If trees are separated apart, then maybe even 1 dynamic sprite per tree, but that's rather a question of optimization.

So how can I draw them in a way that they will remain so when the character reenters the room they will not change? Should it be in the global script ? It has to be generated once for every room for that game run and unless a new game is started they should remain as they are created once.

If you declare DynamicSprite in the room script it will stay there forever, keeping the stuff you drawn upon it, just like all the room objects remain on the places you told them to be when you leave and return to the room.

This is good, but may cause problems as well if you have a lot of rooms with generated props like that. Because, obviously, all those images will be kept in computer memory. If this ever becomes an issue, you could just do following:
* recreate these "layers" every time in "room_Load" event.
* delete them in "room_Leave" event.

The latter approach may even be used to have limited number of rooms simulating larger number of areas. What I mean is that in theory you may even have only few rooms used to depict a large number of random locations, regenerated every time player enters it. This is how "random mazes" may be implemented in a game.
There could be complications with walkable areas, because different locations may require different paths, but that could be solved by creating a combination of areas and turning them on and off as room is generated on load.


It's not clear how where the ID of the image i want to draw goes
You did correct, Graphic property holds ID of image, both in Object class and DynamicSprite class. Object.Graphic is an id of an image this object should have, and DynamicSprite.Graphic is an ID this dynamic sprite was assigned.
« Last Edit: 05 Mar 2018, 15:12 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #10 on: 05 Mar 2018, 16:47 »
Well, a sprite never creates.

Code: Adventure Game Studio
  1. DynamicSprite * EnvProp1;
  2. DrawingSurface *EnvPropSurface1;
  3.  
  4.  
  5. function Start() {
  6.  
  7.   EnvProp1 = DynamicSprite.Create(Room.Width, Room.Height);
  8.   EnvPropSurface1 = Room.GetDrawingSurfaceForBackground();
  9.   EnvPropSurface1.DrawImage(0, 0, 19); //19 is the ID im trying to display
  10.   ObjForDynamicSprite.Graphic = EnvProp1.Graphic; //should it remain "Graphic" here? Otherwise error compiling
  11.   //EnvPropSurface1.Release();
  12.   //EnvProp1.Delete();
  13.  
  14. }

I don't see anything.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #11 on: 05 Mar 2018, 17:02 »
Is this literally the full contents of your room script? Function Start() won't be run automatically, it should be explicitly called from somewhere, or connected to a room event on the room properties panel.

EDIT: wait, I just realized you modified the code.
This was correct:
Code: Adventure Game Studio
  1. DrawingSurface * EnvironmentPropsSurface = EnvironmentProps.GetDrawingSurface();
  2.  
Now it changed to this, which is incorrect:
Code: Adventure Game Studio
  1. EnvPropSurface1 = Room.GetDrawingSurfaceForBackground();
  2.  

Instead of drawing on dynamic sprite, you are now drawing on room background? Or you were just experimenting?

Note, that you do not have to (and better not at all) keep DrawingSurface as a global variable. It is enough to create it for the time of drawing, and release as soon as you finished drawing. calling Release() for the DrawingSurface it is a rule of thumb, because it ensures that image actually gets updated (it may not update in some circumsances if you forget to release surface).
« Last Edit: 05 Mar 2018, 17:05 by Crimson Wizard »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: So has a kyr system been created?
« Reply #12 on: 05 Mar 2018, 17:02 »
You're drawing to EnvPropSurface1, but that's not connected to EnvProp1, the dynamic sprite you're assigning to the object.

Also, you need to release the drawing surface before displaying it.

Re: So has a kyr system been created?
« Reply #13 on: 05 Mar 2018, 17:25 »
The room script runs immediately when it is started by the character right? If so, I added a function to run it:

Quote
DrawingSurface * EnvironmentPropsSurface = EnvironmentProps.GetDrawingSurface();

I correct this, thanks now it's like that

Code: Adventure Game Studio
  1. // room script file
  2. DynamicSprite * EnvProp1;
  3.  
  4.  
  5. function Start() {
  6.  
  7.   EnvProp1 = DynamicSprite.Create(Room.Width, Room.Height);
  8.   DrawingSurface * EnvPropSurface1 = EnvProp1.GetDrawingSurface();
  9.   EnvPropSurface1.DrawImage(0, 0, 19);
  10.   ObjForDynamicSprite.Graphic = EnvProp1.Graphic;
  11.   EnvPropSurface1.Release();
  12.   //EnvProp1.Delete();
  13.    
  14. }
  15.  
  16. function startRoom() {
  17.      
  18.   Start();
  19.    
  20. }


As for this:

Quote
You're drawing to EnvPropSurface1, but that's not connected to EnvProp1, the dynamic sprite you're assigning to the object.

Umm sorry how can I do that? I added blindly this definition EnvPropSurface1 and the one for the dynamic sprite EnvProp1 and the name of my object in the  room with transparent image is named 'ObjForDynamicSprite'

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #14 on: 05 Mar 2018, 17:35 »
The room script runs immediately when it is started by the character right? If so, I added a function to run it:

No, sorry, it looks like you do not know the basics of how the room script works in AGS.
Have you tried doing some tutorials first?

The script function won't be run automatically if you just put it in the script. There are number of functions with predefined names, such as "game_start" or "on_key_press", these are run by the engine if found, but for room entering and leaving you must connect your functions to the events table. This is done in the room editor, there is a panel on the bottom-right by default, where you set up properties and events.
« Last Edit: 05 Mar 2018, 17:37 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #15 on: 05 Mar 2018, 17:53 »
Well I started with some video that is 101 but it didn't mention that and it was likely to have gaps of even basics ^.^. But now that you showed this, I clicked to on the lightning and before-fade-in function room_Load put my code there and the sprite appeared also the EnvProp1 = DynamicSprite.Create(Room.Width, Room.Height, true); to make my png really transparent, thanks! I will try to repeat this with other objects to place them at different areas.

Khris

    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
    • Khris worked on a game that was nominated for an AGS Award!
Re: So has a kyr system been created?
« Reply #16 on: 05 Mar 2018, 19:56 »
How to create event handler functions is described in part 3 of the tutorial: http://www.adventuregamestudio.co.uk/manual/acintro3.htm
The tutorial section of the manual is mandatory reading before posting here, to avoid wasting time.

I'm referring to this: http://www.adventuregamestudio.co.uk/forums/index.php?topic=14373.0
« Last Edit: 05 Mar 2018, 23:48 by Khris »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: So has a kyr system been created?
« Reply #17 on: 05 Mar 2018, 21:20 »
Well, it's a very useful read, anyway. ;)

Re: So has a kyr system been created?
« Reply #18 on: 10 Mar 2018, 17:04 »
Can anyone tell me if I can do the script replacing the object name withing ObjectIDForScript with a string variable? Yes I have read the things about these vars.

Code: Adventure Game Studio
  1. ObjForDynamicSprite0.Graphic = EnvProp[i].Graphic;

It is because I repeat this for several objects in a While loop and all objects are called ObjForDynamicSprite0, ObjForDynamicSprite1, ObjForDynamicSprite5, etc. So im trying to combine string (same name + i where i is the increasing increment) but since it is ObjectIDforScript.Graphic im not sure if it can be read, I do like this:


« Last Edit: 20 May 2018, 23:49 by Imc7r »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: So has a kyr system been created?
« Reply #19 on: 10 Mar 2018, 17:56 »
You can't do that. A variable name is just a label for the programmer: when the program is compiled the name is thrown away and you're just left with a particular memory location. Therefore you can't do any program logic on a variable name.

This sort of task is usually solved by using pointers and/or arrays. I can't give a more precise answer because I'm not sure exactly what you're trying to do.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #20 on: 10 Mar 2018, 18:04 »
Can anyone tell me if I can do the script replacing the object name withing ObjectIDForScript with a string variable? Yes I have read the things about these vars.
Strings are not the same as actual object references, so you cannot use them to get object's data. Normally, in other engine/language, you would probably do something like GetObjectByName(string), but AGS does not provide such ability.

Then, putting something like "EnvProp[1]" in a string won't make that string an actual command that could be executed. AGS script is only compiled at the editing time, it cannot run commands created like that at runtime.


It is because I repeat this for several objects in a While loop and all objects are called ObjForDynamicSprite0, ObjForDynamicSprite1, ObjForDynamicSprite5, etc. So im trying to combine string (same name + i where i is the increasing increment)

Ok, what you need is to use an object array. There is "all objects in room" array already, called simply "object" (it's a global variable), which you may use to iterate through all objects in the room. It is refilled each time you change rooms.
So, for example, if you know that in your generated rooms you are using objects with IDs from 5 to 15, then you could make a loop:
Code: Adventure Game Studio
  1. int i = 5;
  2. while (i <= 15)
  3. {
  4.     Display(object[i].Name); // displays every object's name in a sequence
  5.     i++;
  6. }
  7.  

If you cannot do that for any reason, for example these objects are not sequential, or you want to have more generic program, like having generation script sepearated in a module (which may be reused in various rooms) you could create a separate array to store pointers to objects you need.
Crude example:
Code: Adventure Game Studio
  1. Object *ObjsForDynamicSprite[MAX_TREE_OBJECTS];
  2.  

You fill this array in the beginning of a room with actual room objects
Code: Adventure Game Studio
  1. function room_Load()
  2. {
  3.     // explicit assignment
  4.     ObjsForDynamicSprite[0] = ObjForDynamicSprite0;
  5.     ObjsForDynamicSprite[1] = ObjForDynamicSprite1;
  6.     // or, if these objects come in sequence
  7.     int i = 5;
  8.     while (i <= 15)
  9.     {
  10.        ObjsForDynamicSprite[i] = object[i]; // Note that this is not object copying, only pointer (reference) is being saved
  11.        i++;
  12.     }
  13. }
  14.  

Then you just use ObjsForDynamicSprite array during generation and other adjustments.



PS. Latest versions of AGS also support "for" loops (this is not mentioned in the online material, because its outdated, but you may find it in the offline manual which comes with AGS editor):
Code: Adventure Game Studio
  1. for (int i = 5; i <= 15; i++)
  2. {
  3.     // do something
  4. }
  5.  
« Last Edit: 10 Mar 2018, 18:09 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #21 on: 10 Mar 2018, 19:09 »
^ Excellent explanations, these are the ones I was looking for, thanks. I might be able to do fine with the global var for objects, yes I was looking for conversion of reference to string but you explained it's absent and what I can use instead. I will be on with these and find my way with them. I saw 'for' worked but was unsure if it is implemented which you confirmed.

Re: So has a kyr system been created?
« Reply #22 on: 11 Mar 2018, 17:14 »
Code: Adventure Game Studio
  1. for (int i = 0; i<=1; i++) {
  2.  
  3. propY[i] = Random(1080); //int var
  4. propScaleX[i] = FloatToInt((propY[i] / 385) * 600, eRoundNearest); //int var
  5. }
  6.  

I have this weird thing, I want to convert the float to integer after doing some calculation but it tells me Error (line 62): Type mismatch: cannot convert 'int' to 'float'
isnt this what FloatToInt is about to convert, to make it an integer eventually?

I even tried putting all the decimal calculation in a float var and ends same error when I use FloatToInt
Code: Adventure Game Studio
  1. scaleReal = FloatToInt((propY[i] / 385) * 600, eRoundNearest); //float var

or
Code: Adventure Game Studio
  1. scaleReal = propY[i] / 385) * 600;
  2. propScaleX[i] = FloatToInt(scaleReal, eRoundNearest);

« Last Edit: 11 Mar 2018, 17:23 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #23 on: 11 Mar 2018, 17:35 »
Which of your variables are ints and which are floats?
AGS is very inconvenient in terms of conversions between types. You need to make sure types match in every single operation and every constant determine correct type.
For example, if you have "float f" and want to divide it by 100, you must write 100 as "100.0", explicitly telling that it's a float.
« Last Edit: 11 Mar 2018, 17:37 by Crimson Wizard »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: So has a kyr system been created?
« Reply #24 on: 11 Mar 2018, 19:22 »
if you have "float f" and want to divide it by 100, you must write 100 as "100.0", explicitly telling that it's a float.

This is definitely the issue.

Re: So has a kyr system been created?
« Reply #25 on: 12 Mar 2018, 15:22 »
^ yes indeed that was the issue, it doesnt want to do float = (int * 2.00)/0.0344 even though mathematically the result would be a float , had to be float = IntToFloat(my int var)) * 2.00/0.3456

Ok Im working on the system but I've some inaccuracies. So for a 1920x1080 room screen I wanted to make the whole displaying trees at random location using Dynamic Sprites so that:

- the lower the image displayed on the screen, the bigger they look, the more on the top of the screen, the smaller the scale. What im really missing is the ability to get sprite width and height. The logic of my code is like that:

set Int var for Position X (random number between 0-1920), set int var for position Y (random number between 0-1080). This is because I have no other way to track their location that I want to make the scaling depend on. So based on the code I have so far:
« Last Edit: 20 May 2018, 23:50 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #26 on: 12 Mar 2018, 15:39 »
What im really missing is the ability to get sprite width and height

For static sprites:
Game.SpriteWidth[sprite_number] - returns width for sprite by its ID
Game.SpriteHeight[sprite_number] - returns height for sprite by its ID

For dynamic sprites: DynamicSprite.Width, Height.

Re: So has a kyr system been created?
« Reply #27 on: 12 Mar 2018, 18:33 »
^ Thanks this was handy and I found a relation between the sprite height and Y position to make the images larger at the bottom.

Code: Adventure Game Studio
  1.     propScaleReal[i] = (IntToFloat(propY[i])* IntToFloat(Game.SpriteHeight[prop[i]]))/376.71; //propY is int to determine the random Y across the screen, prop[] is the ID of the sprite
  2.     propScale[i] = FloatToInt(propScaleReal[i], eRoundNearest);

However, the images still appear either squished (as if only X was decreased), small and not big at the bottom of the screen. I assign to Objects that are 1920x1080 alpha channel images with X 0 and Y 1080 to cover the whole screen.

Code: Adventure Game Studio
  1.     EnvProp[i] = DynamicSprite.Create(Room.Width, Room.Height,  true);
  2.     EnvPropSurface[i] = EnvProp[i].GetDrawingSurface();
  3.     EnvPropSurface[i].DrawImage( propX[i], propY[i], prop[i]);
  4.     EnvProp[i].Resize(propScale[i], propScale[i]);
  5.     object[i].Graphic = EnvProp[i].Graphic;
  6.     EnvPropSurface[i].Release();  
  7.     //EnvProp0.Delete();

Is this code giving them different scale because it is a Room.Width/Height sheet? Or maybe my EnvProp.Resize(propScale[], propScale[]); needs to be made differently to scale the sprites properly?

(A side question, is there a way in the Editor to select between objects placed in the room the way you can see characters? The item tree of all elemnts does not show them and if you place the objects on top of one another you cannot select between them when they cover the whole room)
« Last Edit: 12 Mar 2018, 18:37 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #28 on: 12 Mar 2018, 19:14 »
However, the images still appear either squished (as if only X was decreased), small and not big at the bottom of the screen. I assign to Objects that are 1920x1080 alpha channel images with X 0 and Y 1080 to cover the whole screen.

I do not have time to investigate right now, but one thing to check out that comes to mind: the coordinates you are passing to DrawImage are top-left coordinates of an image, which is different from how objects are normally placed in pseudo-3d, where bottom line defines their visual position.
Depending on perspective rules you are emulating, "closer" objects, which are also larger, may need their top-left coordinate also be closer to the top of the screen, and hence use smaller Y (closer to 0) when you draw them.

Hope my explanation makes sense...

Since the meaning of "propY" is probably the position of the tree trunk where it touches ground, perhaps try to introduce new variable called "propHeight" and when drawing a prop, do something like DrawImage( x, propY - propHeight );


(A side question, is there a way in the Editor to select between objects placed in the room the way you can see characters? The item tree of all elemnts does not show them and if you place the objects on top of one another you cannot select between them when they cover the whole room)

Using the list on the properties pane.
Alternatively you may try the new experimental version of an Editor which has a "navigation bar" in the room editor: http://www.adventuregamestudio.co.uk/forums/index.php?topic=55829.0


EDIT: Oh, I just realized, you are making objects all room large. Another solution is to make smalls object with dummy gfx, and arrange them only to make it convenient to select them. Then in "room load" event you set correct gfx and positions.
« Last Edit: 13 Mar 2018, 01:35 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #29 on: 15 Mar 2018, 20:47 »
Code: Adventure Game Studio
  1. EnvProp[i].Resize(propScale[i] + EnvProp[i].Width, propScale[i] + EnvProp[i].Height);
adding the original width and height made the squished images look correct actually and it was about making the trees appear larger than the char, now it's proper aspect ratio of each image and acceptable sizes of trees. Scaling arent exactly always shrunk at the top screen but it doesn't matter much. I use for object Baseline propY*(-1) so I made it work so that lower screen objects would appear in front of ones at the top.


The white underlines things that need fixing.

1) In one of them, the stone probably has Baseline value lower than the tree (and btw the Y position of dynamic sprites or drawn images are taken from the top of the image, not the bottom). In such case Im trying to make it so
Code: Adventure Game Studio
  1. if ((Game.SpriteHeight[prop[i]] < 100)
&& (only the stones have such small height - this is the condition im missing - if 2/3 or top of the tree image is at the Y of the stone, then Set Baseline to e.g 1 or whichever higher value to hide BEHIND the tree crown - or even delete remove or hide the image since whats t he point of having it if hidden by the tree crown.

There is no (if something is in area of the screen). In my case using the propY as initially set position for every dynamic sprite, I can compare if it is around the propY of another sprite. But I want like
Code: Adventure Game Studio
  1. (if propY[i - currently taken integer] + (2/3 of Game.SpriteHeight[prop[i - 1]] or 2/3 of Game.SpriteHeight[prop[i + 1]]
etc) then set the baseline.

2) I see the BlockingHeight/Width property of objects but how can I detect the location of the trunk bottom or stone when the whole dynamic sprite is probably the whole screen while the stone or trunk area I want to block is part of it?
3) The stone in front of his face, perhaps the char.Baseline needs to be updated in a repeated event in the global script ?
« Last Edit: 16 Mar 2018, 18:36 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #30 on: 15 Mar 2018, 22:08 »
Unfortunately image does not load up for me, it sais "image is no longer available".
Without being able to see the screenshot I cannot really understand everything you are refering to, nor the purpose of those formulas.

and btw the Y position of dynamic sprites or drawn images are taken from the top of the image, not the bottom
All Ys in AGS are taken from the top. When you call DrawImage the Y coordinate is an offset from the top of destination surface, and when you set Object.Y the Y coordinate is also offset from the top of the room.

But the alignment of the item around that coordinate may be different: when you are drawing, the X,Y are coordinates to which the top-left corner of the copied image will be aligned, but when you are placing an object, X,Y are coordinates to which the bottom-left of the object will be aligned.
Afaik this difference is there because drawing usually assumes flat surface, while objects placing in room traditionally relate to pseduo-3d space, where the bottom lines of sprites define position (hence - baseline property).

2) I see the BlockingHeight/Width property of objects but how can I detect the location of the trunk bottom or stone when the whole dynamic sprite is probably the whole screen while the stone or trunk area I want to block is part of it?

If possible (number of objects is not too large) I'd rather suggest to have 1 sprite per object or very close set of objects.
As mentioned above, the objects are placed aligned to their bottom. Their "Height" is actually going upwards from Object.Y. This means that if you cut the dynamic sprite at tree's baseline, then you will be able to have Object's Y at where tree trunk's should be. This will make it easier to set up blocking width and height. (You probably won't need to set BlockingHeight to full height of a tree, just a little to simulate tree's depth).

Alternatively, you will have to code your own walking restrictions, if not whole pathfinding, which I won't recommend to do without serious reason.

3) The stone in front of his face, perhaps the char.Baseline needs to be updated in a repeated event in the global script ?
By default char.Baseline is updated automatically, synchronized with character's Y. That is unless custom Baseline value was set.
« Last Edit: 15 Mar 2018, 22:14 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #31 on: 16 Mar 2018, 18:35 »
Quote
Unfortunately image does not load up for me, it sais "image is no longer available".


Hopefully working now.

Quote
Alternatively, you will have to code your own walking restrictions, if not whole pathfinding, which I won't recommend to do without serious reason.

I would not do this, yes. Coded blocking can provide some weird blocking but I need to block the bottom of trees, so the char cant step over.

Quote
If possible (number of objects is not too large) I'd rather suggest to have 1 sprite per object or very close set of objects.

Yes im using only 8 objects that use all that randomize code per room and each object is using one dynamic sprite. Each object is whole screen transparent image and the dynamic sprites uses room.width and height, so they do not get shrunk or cut off, currently whole images display so it's fine.

I fixed part of 1) By adding a
Code: Adventure Game Studio
  1. if (Game.SpriteHeight[prop[i]] < 100){ object[i].Baseline = myChar.Baseline + 1; }
It tells the stones with that low height of sprite to always appear behind the char cause they are on the ground, else appear in front of his face when he walks through them. My question was if I have a tree crown (upper part of the tree) and a stone generated in front of the tree crown to use a condition 'If the stone is within the tree image, put it behind the tree) - same as appearing in front of the face but this code my set it behind any tree anyway, so that's fine.

But this where 3) comes in and yes his baseline is automatically updated though this is still seen, unless I need to base Baselines on other things not this code? So far it is the higher the object placed on the screen, the more behind it will appear. All bottom images appear in front of all and that's working but he still walks behind some upper images.
Code: Adventure Game Studio
  1.     object[i].Baseline = -1 * propY[i]; //propY[i] is the random generated Y position of the drawn dynamic sprite



and 2) is 
Quote
This means that if you cut the dynamic sprite at tree's baseline, then you will be able to have Object's Y at where tree trunk's should be.

So if my image bottom is |___###___| where |___ and ___| are the alpha channel and ### is the trunk of a tree, im trying to make the unwalkable (it's OK if I have to calculate myself how many pixels of the beginning of the image, yes I will just block a small height above the tree say the bottom where it reaches the ground). Knowing that I calculate Y of object upward is good though it's more about how to detect the drawn part at the bottom of the image, should I just hard code for each image type how many pixels away?, like say |___# for each image is the distance.  )

« Last Edit: 16 Mar 2018, 18:40 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #32 on: 16 Mar 2018, 18:57 »
Alright, sorry, but the issue I am having with this is that your formulas are way too confusing. I had a very hard time trying to understand the need for them.
In theory this all should be very simple to do, without need for weird conditions like "if (Game.SpriteHeight[prop[ i ]] < 100){ object[ i ].Baseline = myChar.Baseline + 1; }". Complex code like that is almost always a hint that logic is wrong.


EDIT: Erm... sorry, I just understood what you meant by doing that thing to stone. It's just that I was thinking about one problem, so I got confused by that.
Normally, for flat objects you can just set Baseline = 1, this way they will always be drawn behind characters.
But since you have stones and trees combined, that could be more complicated. In either case I don't recommend rely on character coordinates, because you may have more than 1 character in the room.


Now, your picture clearly indicates that you are setting wrong baselines for you tree objects.

Quote
So far it is the higher the object placed on the screen, the more behind it will appear. All bottom images appear in front of all and that's working but he still walks behind some upper images.
This could mean that relation between generated objects' baselines may be correct, but in absolute room coordinates their baselines are wrong.

NOTE: to reply to comment about character's face and feet on the image. Whole character has the same baseline, its parts are not separate layers, so character is all behind the tree, so to say.


I'd suggest to focus on a single problem - object's baseline - and solve it first.
As I mentioned previously, normally you'd need to calculate the position of a tree trunk in the room and set that as a baseline.

Quote
object.Baseline = -1 * propY; //propY is the random generated Y position of the drawn dynamic sprite
Alright, but where in the room is this "propY"? Is it the Y coordinate you pass to DrawImage? If so, that's wrong, because that's a coordinate of a top of an image, while for the baseline you'd need coordinate of a bottom of an image in the room.
« Last Edit: 16 Mar 2018, 19:37 by Crimson Wizard »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #33 on: 16 Mar 2018, 19:11 »
Ok, so I decided to make a small chart to help explaining what I mean. It displays a generic case, where you have an object in the room, and a picture (of tree) drawn on that object in random position:



The circles indicate the anchor position of X,Y the image has inside object's DynamicSprite, and X,Y the object has inside the room.

The red line is where tree's bottom is, and that is what you need to have as object's baseline. The baseline is a Y coordinate in room coordinate system.


The generic formula to calculate this baseline:

Code: Adventure Game Studio
  1. int baseline = object.Y - dynamicSpriteHeight + drawnImageY + drawnImageHeight;
  2. //
  3. // where:
  4. // object.Y -- object's coordinate inside the room;
  5. // dynamicSpriteHeight - the height of dynamic sprite you assign to an object;
  6. // drawnImageY - the coordinate you draw tree sprite on object's dynamic sprite (this is coordinate in local dynamic sprite's coords!);
  7. // drawnImageHeight - the height of that tree sprite.
  8.  

To elaborate:
object.Y - dynamicSpriteHeight == this is object's top coordinate in the room.
above + drawnImageY == this is tree's top coordinate in the room.
above + drawnImageHeight == this is tree's bottom coordinate in the room.
« Last Edit: 16 Mar 2018, 19:18 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #34 on: 16 Mar 2018, 21:30 »
^ Ahh thanks! I got that the Dynamic sprs start increasing Y value from top to bottom while Object's coord system does that from below upward without the drawing above but it confirmed what I was thinking. I would not have got what was to be subtracted and added if it wasn't for you doing that. Now here is how my baseline code looks I just set it all without a baseline specific variable:

Code: Adventure Game Studio
  1.     object[i].Baseline = object[i].Y - Room.Height + propY[i] + Game.SpriteHeight[prop[i]];
Since it is all under (for each..i in 0...7 I use the [i)]. Room Height since  I do set the Dynamic sprite vars to room width and height.
Code: Adventure Game Studio
  1. EnvProp[i] = DynamicSprite.Create(Room.Width, Room.Height,  true);

It works as I tested few times because he was able to walk in front of the same tree when too below and when he goes up he appears behind the same tree. As I said, it was the formula that I needed and you provided that thanks for it.

This solves the 1) and 3) as he walks behind and in front of the same trees correctly.

The issue 2) was about detecting not just the baseline which you are doing with the formula object.Y - dynamicSpriteHeight + drawnImageY + drawnImageHeight; but detecting the area within image. Using the baseline you have the height location of the bottom of the image. What should the width be? The difficulty comes to me since I did in my code:
Code: Adventure Game Studio
  1.     EnvProp[i].Resize(propScale[i] + EnvProp[i].Width, propScale[i] + EnvProp[i].Height);
which gives me the scalings I wanted but this may affect the values for finding that particular area. It could be a rough estimation of part of the image width but has to be. This is needed in the future as well, since I could base interaction, dialogs and others based on locating the drawn pixels so to say (meaning the part that is not transparent and bottom). Rocks are smaller images and should be entirely blocked.



Now please take your time as I am OK if it is looked another time, sorry if you feel too engaged with my part, I appreciate it, im trying to do on my own where I can but this system is the more complex, as the rest I have to do might be more standard interactions and things I look from existing stuff.
« Last Edit: 16 Mar 2018, 21:38 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #35 on: 16 Mar 2018, 21:48 »
^ Ahh thanks! I got that the Dynamic sprs start increasing Y value from top to bottom while Object's coord system does that from below upward without the drawing above but it confirmed what I was thinking.

I have to make a correction: object's coord system does not increase Y from below upward. In AGS all coordinate systems go from top to bottom.
It's just that objects put their image above its "origin" coordinate, aligning image's bottom to that origin. So, if you have object at room's (X,Y), the object sprite's top-left corner is at room's (X, Y - sprite height).

In other words, the direction of Y axis is still towards the bottom, but you may think that in the room the object's image is shifted by (-height) pixels.
« Last Edit: 16 Mar 2018, 21:52 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #36 on: 20 Apr 2018, 20:05 »
Hi, what about detecting part if the image for blocking height/width like I posted above with the image, considering the transparent object ius the whole screen and I need a particular part blocked,  how can I calculate that?

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #37 on: 20 Apr 2018, 20:30 »
Hi, what about detecting part if the image for blocking height/width like I posted above with the image, considering the transparent object ius the whole screen and I need a particular part blocked,  how can I calculate that?

The problem really is not only how to calculate it, but how to apply. Because you cannot define a blocking rectangle with all 4 points, only width and height, and blocking area will start always at object's (X,Y), so it cannot be covering whole room.

This is why I kept suggesting making smaller dynamic sprites, exactly enough to draw an object. That should not be too hard to do, you know original sprite size, and necessary scaling.

If you still insist on having very large dynamic sprites, you will have to draw an object aligned to its left-bottom corner, which corresponds to object's origin.
« Last Edit: 20 Apr 2018, 20:57 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #38 on: 20 Apr 2018, 23:22 »

This is why I kept suggesting making smaller dynamic sprites, exactly enough to draw an object. That should not be too hard to do, you know original sprite size, and necessary scaling.

If you still insist on having very large dynamic sprites, you will have to draw an object aligned to its left-bottom corner, which corresponds to object's origin.

I see but it will kind of mess the scalings and all stuff that are somewhat acceptable to the way I wanted, so I will have to keep the dynamic sprites as they are.  Even if I was to use smaller sprites, a trees trunk would always be part of the image so.. Speaking of your last sentence, i dont understand it. I dont mind specifying the different width and height for each of the dynamic sprite since they use several different sprites, so I can do if sprite is e.g rock, set blocking width to 20 and height, if sprite is rock 2, set them to 25, etc. I will play around to see, or do you mean making new objects on top of the ones with dynamic sprites (like new small box objects just to cover the same as the parts I want blocked)?

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #39 on: 21 Apr 2018, 00:24 »
Even if I was to use smaller sprites, a trees trunk would always be part of the image so..

Ohhh right, I did not realize that, sorry, this means you probably cannot do this with same object anyway.

or do you mean making new objects on top of the ones with dynamic sprites (like new small box objects just to cover the same as the parts I want blocked)?

No, but now when you said this, I am beginning to think that's the only way, except for scripting custom blocking/pathfinding.

Re: So has a kyr system been created?
« Reply #40 on: 21 Apr 2018, 23:17 »
Quote
No, but now when you said this, I am beginning to think that's the only way, except for scripting custom blocking/pathfinding.

Oh im not opposing the idea I was just asking, I already started using that way. So in addition to the 8 objects I added some 90x90 pixels another 8 objects that will be used for blocking only. For now I made them red squares so it is visible where they block. I partially made it work but the boxes are so out of position for the trees. Im not sure what formula to use to cover the bottom of the trees simply (the middle of the bottom of each image whether resized or not, I have the baseline but it didnt help much), here is what each means in my code
« Last Edit: 27 Apr 2018, 23:22 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #41 on: 23 Apr 2018, 16:33 »
I will be frank, the code that I see on your pic is pretty weird.

You first draw the tree sprite onto room-sized surface in original size, then resize the surface... I think that means that not only width and height of the tree will be changed, but its X and Y will also change (final tree image may get shifted away from the position you wanted).
Also, I cannot make any sense out of adding propScale to the surface's sizes. If that's really is a scale factor, then it's wrong, so that's probably not the scale factor, but the final tree size?? or not....

By the way, the Baseline calculation is also wrong. You are using original coordinates propY and Game.SpriteHeight to calculate its position, but they are no longer applicable to the final resized image. You should be multiplying these values by the image scale factor (see below).

If you look for the DrawImage article in the manual, you will see that it has optional width and height parameters. They let you resize an image when you are drawing it.
So the resizing code could probably look like this:
Code: Adventure Game Studio
  1. int scale ... // assuming you calculated scale somehow
  2. int orig_width = Game.SpriteWidth[prop[i]];
  3. int orig_height = Game.SpriteHeight[prop[i]];
  4. int final_width = orig_width * scale;
  5. int final_height = orig_height * scale;
  6. EnvPropSurface[i] = EnvProp[i].GetDrawingSurface();
  7. EnvPropSurface[i].DrawImage(propX[i], propY[i], prop[i], 0, final_width, final_height);
  8. EnvPropSurface[i].Release();
  9.  
In such case there is no need to resize large dynamic sprite, and also prop coordinates stay the same.




Alright, that said, if we still stick to your formulas, then to calculate the "block" object position you need to know following:
1) The size and position of Blocking area relative to the original sprite's size. This you have to define yourself, because only you know it, and you draw these sprites.
Let's call these OrigBlockX, OrigBlockY, OrigBlockWidth and OrigBlockHeight.
2) The size and position of Blocking area relative to the resized sprite. For these you need to multiply previous values by the same factor you are using to resize the sprite.

Since you are resizing whole final image, then every coordinate has to be resized as well:
Code: Adventure Game Studio
  1. // The scale factor is a relation between final size of large dynamic sprite and its original size
  2. // (normally I'd suggest to use Room.Width and Room.Height here instead of literal numbers)
  3. float ScaleX = IntToFloat(propScale[i] + EnvProp[i].Width) / 1920.0;
  4. float ScaleY = IntToFloat(propScale[i] + EnvProp[i].Height) / 1080.0;
  5. ScaledBlockX = FloatToInt(IntToFloat(OrigBlockX * ScaleX));
  6. ScaledBlockY = FloatToInt(IntToFloat(OrigBlockY * ScaleY));
  7. ScaledBlockWidth = FloatToInt(IntToFloat(OrigBlockWidth * ScaleX));
  8. ScaledBlockHeight = FloatToInt(IntToFloat(OrigBlockHeight * ScaleY));
  9.  
Again, these coordinates are positions of the blocking area related to the resized sprite's local coordinates. This is not final.

How to find the position of the blocking rectangle in the room:
Code: Adventure Game Studio
  1. // This is where your resized tree is actually positioned in the room
  2. int RealPropX = object[i].X + FloatToInt(IntToFloat(propX[i] * ScaleX));
  3. int RealPropY = object[i].Y + FloatToInt(IntToFloat(propY[i] * ScaleY));
  4. // So, and the blocking object rectangle will be
  5. int BlockRoomX = RealPropX + ScaledBlockX;
  6. int BlockRoomY = RealPropY + ScaledBlockY;
  7. int BlockRoomWidth = ScaledBlockWidth;
  8. int BlockRoomHeight = ScaledBlockHeight;
  9.  

EDIT: Realized a bit later, but we may actually skip ScaledBlockWidth/Height part and do following:
Code: Adventure Game Studio
  1. float ScaleX = IntToFloat(propScale[i] + EnvProp[i].Width) / 1920.0;
  2. float ScaleY = IntToFloat(propScale[i] + EnvProp[i].Height) / 1080.0;
  3.  
  4. int BlockRoomX = object[i].X + FloatToInt(IntToFloat((propX[i] + OrigBlockX) * ScaleX));
  5. int BlockRoomY = object[i].Y + FloatToInt(IntToFloat((propY[i] + OrigBlockY) * ScaleY));
  6. int BlockRoomWidth = FloatToInt(IntToFloat(OrigBlockWidth * ScaleX));
  7. int BlockRoomHeight = FloatToInt(IntToFloat(OrigBlockHeight * ScaleY));
  8.  
That should give identical results.


NOTE: the actual Baseline formula is also:
Code: Adventure Game Studio
  1. int RealPropY = object[i].Y + FloatToInt(IntToFloat(propY[i] * ScaleY));
  2. int RealPropHeight = FloatToInt(IntToFloat(Game.SpriteHeight(prop[i]) * ScaleY));
  3. object[i].Baseline = object[i].Y - Room.Height + RealPropY + RealPropHeight);
  4.  


Now, I have to admit that I did not test all this, but only figured in my head. So I cannot 100% guarantee that's correct. I'd need to have actual test game on my computer to experiment with.
In any case, I strongly advise to clarify the resizing code you are using. Especially since you say yourself that you do not know the reason behind some formula. Because as you progress further this situation will only worsen...
« Last Edit: 24 Apr 2018, 03:15 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #42 on: 25 Apr 2018, 01:36 »
That's a lot of posting I appreciate the time on it! Yes the code is messy and you are correct about resizing, I thought I may have to multiply by the same scaling factor, I was about to test the displacement if image is resized, this may also be the reason why things appear way off. Im going to work on improving that code because some things are made bad I agree. But let me explain why some things are as you see them, I had  to do a lot of math, it was like as if I was trying to find a distance or make ratios between positions to make things scale up/down based on where they are located Y-wise.

The reason why I added a "Scaling Factor" was exactly because I wanted to make the objects, the lower they are on the Y axis, the bigger they are , on the very top they had to be scaled down to serve as a distant background.

I MISSED the SCALE parameters of Draw Image, you are right, then I can use just those instead of separate vars, I completely omit these not seeing they exist! (thanks). And then I dont need an extra scaling it can be all happening within the Draw image line.

You said prop coordinates stayed the same if I used the Draw Image Width Height scaling, then this is the first thing I just corrected. Here is the improved code:

Code: Adventure Game Studio
  1. function room_Load()
  2. {
  3.   SetBackgroundFrame(season);
  4.  
  5.   if (Game.DoOnceOnly("3"))
  6.   {
  7.     exitEast = true;
  8.     exitNorth = true;
  9.     exitSouth = false;
  10.     exitWest = false;
  11.  
  12. //code to decide Props ID randomized then
  13.  
  14.    
  15.     for (int i = 0; i<=7; i++)
  16.     {
  17.       propX[i] = Random(System.ViewportWidth);
  18.       propY[i] = Random(FloatToInt(IntToFloat(System.ViewportHeight) * 0.37, eRoundNearest));
  19.       propScale[i] = IntToFloat(propY[i]) / 100.0;
  20.       if (propScale[i] < 1.20) { propScale[i] = 1.20; }
  21.       object[i].Baseline = object[i].Y - Room.Height + propY[i] + FloatToInt(IntToFloat(Game.SpriteHeight[prop[i]]) * propScale[i], eRoundNearest);
  22.      
  23.       EnvProp[i] = DynamicSprite.Create(Room.Width, Room.Height,  true);
  24.       EnvPropSurface[i] = EnvProp[i].GetDrawingSurface();
  25.       EnvPropSurface[i].DrawImage( propX[i], propY[i], prop[i], 0, FloatToInt((IntToFloat(Game.SpriteWidth[prop[i]]) * propScale[i]), eRoundNearest), FloatToInt((IntToFloat(Game.SpriteHeight[prop[i]]) * propScale[i]), eRoundNearest));
  26.      
  27.       propTint[i] = 50.0 - (IntToFloat(object[i].Baseline) / 3.148) * 0.0462;
  28.      
  29.       if (prop[i] == 9 || prop[i] == 10 || prop[i] == 12 || prop[i] == 13 || prop[i] == 16 || prop[i] == 17 || prop[i] == 19 || prop[i] == 20 || prop[i] == 23 || prop[i] == 24 || prop[i] == 26 || prop[i] == 27)
  30.       { EnvProp[i].Tint(1, 1, 1, FloatToInt(propTint[i]), 0); }
  31.      
  32.       object[i + 8].SetPosition(propX[i] + FloatToInt((IntToFloat(Game.SpriteWidth[prop[i]]) *  propScale[i] / 2.00) - (IntToFloat(Game.SpriteWidth[29]) / 2.00), eRoundNearest),  object[i].Baseline);
  33.      
  34.       if (prop[i] == 13 || prop[i] == 20)
  35.       { object[i + 8].SetPosition(propX[i] + FloatToInt((IntToFloat(Game.SpriteWidth[prop[i]]) *  propScale[i] / 2.00) - (IntToFloat(Game.SpriteWidth[29]) / 2.00), eRoundNearest) + FloatToInt(50.0 * propScale[i], eRoundNearest),  object[i].Baseline); }
  36.       else if (prop[i] == 27)
  37.       { object[i + 8].SetPosition(propX[i] + FloatToInt((IntToFloat(Game.SpriteWidth[prop[i]]) *  propScale[i] / 2.00) - (IntToFloat(Game.SpriteWidth[29]) / 2.00), eRoundNearest) + FloatToInt(80.0 * propScale[i], eRoundNearest),  object[i].Baseline); }      
  38.      
  39.       object[i + 8].BlockingWidth = FloatToInt(IntToFloat(Game.SpriteWidth[29]) * propScale[i], eRoundNearest);
  40.       object[i + 8].BlockingHeight = FloatToInt(IntToFloat(Game.SpriteHeight[29]) * propScale[i], eRoundNearest);
  41.       object[i + 8].Solid = true;
  42.    
  43.       object[i].Graphic = EnvProp[i].Graphic;
  44.       EnvPropSurface[i].Release();  
  45.       //EnvProp[i].Delete();
  46.     }
  47.   }
  48. }
  49.  
   


EDIT: After changing some things into this, it works! Thanks for some suggestions I based it on these ideas you posted but also entirely remade some formulas myself. The squares are always centered in the bottom center of the image. Now that I got them where I wanted I could use Solid but I would still need to increase blocking based on the scaled image, so I will use Blocking W/H. I tested it and im not sure of Blocking Height/Width worked without Solid, as Char still went thru, I had to enable Solid too. Oh the manual says it needs Solid to work so yes, done with this Random system ! (Next I will work one one Day/Night ez cycle just some dark transparent screen, new post if I come across such confusing system but I think I did the HARDEST of my game, since it is so uncommon to do such a system). Thanks for the help with all that, I will give credit for all the help.
« Last Edit: 01 Jun 2018, 18:11 by Imc7r »

Re: So has a kyr system been created?
« Reply #43 on: 27 Apr 2018, 23:37 »
With the above a large milestone was made.  Im not planning to make other complex things other than the other things I mentioned in my first posts, all less complex and more common. I may be having some smaller questions mostly related to unexplained problems that make no sense to not work, and I should be able to do the rest on my own. Here is one:

Prob 1) - Solved
I cannot understand why my character refuses to Change Room on the Right. In the starting room 1 I set the function for 'Walks off left edge' and 'right edge' and it changes to room 2 that is on the left. So this works, but then when he appears at Room 2 (If he left room 1 [x_______| on the left there I set his X to e.g 1900 (out of room width 1920) to be there |_______x| in room 2 . So. he walks at the Right edge of Room 2 and nothing happens. I tried in Room 1 to go Right and also nothing happens, even though I set the function for Right edge. In room 2 (created from template of Room 1 with all objects already set), I removed block code or anything in case it was blocking but he still doesnt change room e.g back to room 1 on the Right. Im using the Single Cursor template but it has code related to mouse click, I use arrows for walking so it is not the reason I think, since it works at least on the Left screen.

In the 'Edges' of the room BottomEdgeY (default 198), TopEdgeY (default 40), LeftEdgeX (0) and RightEdgeX (317) not sure if I had to change them for 1920x1080. Bingo. This was the culprit. I had to modify to my HD edges like 1910 for Right X.

Prob 2) - Solved
I noticed that in order to preserve the system of randomly placed objects so as to be the same, I need to have it at 'First time enter the room' event. Though, the items are then created after you see the screen so they pop up suddenly which makes them unrealistic, I would prefer to hide the generation of objects like 'Before Fade In' but this one won't preserve the initially created Dynamic Sprites and will recreate new ones & new positions when returning to the room. This would be better for elegance, even though they are popping up like that just once. I tried adding a Fade to hide the sudden appearance of objects but it seems First Time Enter still waits for the Before Fade In event. Splitting the code by generating the variable values at First Time and drawing image in Before Fade In also didnt work because First Time Enter may be running after Before/After Fade In.

EDIT: thanks for the below~ it works
AND I noticed, if I want to start at random room, even though I had to set an existing room for Char's starting room, I can use this   MyChar.ChangeRoom(Random(1) + 1); in function game_start() event in Global Script.
« Last Edit: 30 Apr 2018, 01:18 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #44 on: 28 Apr 2018, 16:14 »
Prob 2) - Unsolved
I noticed that in order to preserve the system of randomly placed objects so as to be the same, I need to have it at 'First time enter the room' event. Though, the items are then created after you see the screen so they pop up suddenly which makes them unrealistic, I would prefer to hide the generation of objects like 'Before Fade In' but this one won't preserve the initially created Dynamic Sprites and will recreate new ones when returning to the room. This would be better for elegance, even though they are popping up like that just once. I tried adding a Fade to hide the sudden appearance of objects but it seems First Time Enter still waits for the Before Fade In event.


Start generation from "Before fade-in", but call generation function under this condition:
Code: Adventure Game Studio
  1. if (Game.DoOnceOnly("RoomNGenerated"))
  2.     GenerateRoom();
  3.  

"RoomNGenerated" should be a unique ID for each room.

Alternatively you may use some boolean variable per room for the same purpose.
« Last Edit: 28 Apr 2018, 16:15 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #45 on: 18 May 2018, 20:51 »
I'm trying some UI changes to fit the Kyr style and I read some related threads but I can still mess up some things.

1. SOLVED Is there a way to make the UI menu pop up when Mouse moves at the bottom of the screen? One thing I like over the old styles is the ability to hide the menu when not called but it would be better at the bottom. I noticed gIconbar has the option to Pop Up from top only so my guess is the same does not work from Bottom?

----What I did was set the Visibility to Normal, Initially Off, then

Code: Adventure Game Studio
  1. function repeatedly_execute_always() {
  2.  
  3.   if (player.Room <= 300)
  4.   {  
  5.     if (gIconbar.Visible == false && mouse.y >= FloatToInt(IntToFloat(System.ViewportHeight) * 0.98, eRoundNearest) &&
  6.     ( mouse.x >= FloatToInt(IntToFloat(System.ViewportWidth) * 0.01, eRoundNearest) || mouse.x >= FloatToInt(IntToFloat(System.ViewportWidth) * 0.99, eRoundNearest)))
  7.     {
  8.       gIconbar.Visible = true;
  9.     }
  10.     else if (mouse.y < FloatToInt(IntToFloat(System.ViewportHeight) * 0.81, eRoundNearest))
  11.     {
  12.       gIconbar.Visible = false;
  13.     }
  14.  

------------------------

2. SOLVED
I will also do like Kyrandia when mouse is say 10 pixels from some edge (but not corner that will be used for showing the UI) the pointer icon changes and a click means walk to that end automatically, to change screen. I have the code to change room when the char reaches just need to command him, but that might be the same as my main question switching modes as a single cursor w left click? (EDIT - so far may be like how i did the above code)

Trying to change arrow  at the edge of each direction and if it is not where you can change screen show the red X that you cannot exit that way. I declare these bools in each room script (because where you can go varies from room to room):

Code: Adventure Game Studio
  1. import bool itemIsSelected;
  2.  
  3. //to change cursor at each edge including the X cursor
  4. function room_RepExec()
  5. {
  6.   if (itemIsSelected == false)
  7.   {
  8.     if (mouse.x <= FloatToInt(IntToFloat(System.ViewportWidth) * 0.005, eRoundNearest))
  9.     {
  10.       if (exitEast == true)
  11.       {
  12.         mouse.ChangeModeGraphic(Mouse.Mode, 6);
  13.       }
  14.       else if (exitEast == false)
  15.       {
  16.         mouse.ChangeModeGraphic(Mouse.Mode, 37);
  17.       }
  18.     }
  19.     else if (mouse.x >= FloatToInt(IntToFloat(System.ViewportWidth) * 0.97, eRoundNearest))
  20.     {
  21.       if (exitWest == true)
  22.       {
  23.         mouse.ChangeModeGraphic(Mouse.Mode, 7);
  24.       }
  25.       else if (exitWest == false)
  26.       {
  27.         mouse.ChangeModeGraphic(Mouse.Mode, 37);
  28.       }
  29.     }
  30.     else if (mouse.y <= FloatToInt(IntToFloat(System.ViewportHeight) * 0.009, eRoundNearest))
  31.     {
  32.       if (exitNorth == true)
  33.       {
  34.         mouse.ChangeModeGraphic(Mouse.Mode, 4);
  35.       }
  36.       else if (exitNorth == false)
  37.       {
  38.         mouse.ChangeModeGraphic(Mouse.Mode, 37);
  39.       }
  40.     }
  41.     else if (mouse.y >= FloatToInt(IntToFloat(System.ViewportHeight) * 0.94, eRoundNearest))
  42.     {
  43.       if (exitSouth == true)
  44.       {
  45.         mouse.ChangeModeGraphic(Mouse.Mode, 1);
  46.       }
  47.       else if (exitSouth == false)
  48.       {
  49.         mouse.ChangeModeGraphic(Mouse.Mode, 37);
  50.       }
  51.     }
  52.     else
  53.     {
  54.         mouse.ChangeModeGraphic(Mouse.Mode, 2061);
  55.     }    
  56.   }
  57. }
  58.  


3. SOLVED
The biggest thing is how do I make the cursor do specific actions as one? I created a custom Mouse Cursor and added in global script on startup to disabled Look, Inventory, Talk To, Pickup.  So by default it should do the same as walk but when clicking on hotspots and things, should it be coded things to happen when the mouse is at certain region? How does it change the mode, do I still need to switch to modes ? Im not sure

Inventory window will be deleted as it will be part of the main panel but how it will detect items placed in the main panel and how to place them will deal later.
« Last Edit: 29 May 2018, 01:38 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #46 on: 20 May 2018, 16:09 »
3. UNSOLVED
The biggest thing is how do I make the cursor do specific actions as one? I created a custom Mouse Cursor and added in global script on startup to disabled Look, Inventory, Talk To, Pickup.  So by default it should do the same as walk but when clicking on hotspots and things, should it be coded things to happen when the mouse is at certain region? How does it change the mode, do I still need to switch to modes ? Im not sure

I see you have posted the script example below your question, that kind of script might actually for work for you. You just have to modify it for you particular needs.

Just in case, some clarification.
Mouse Modes are made for convenience when using Sierra-like cursor mechanics, when each cursor type has its action. Then you may just script
Code: Adventure Game Studio
  1. if (button == eMouseLeft)
  2.     Room.ProcessClick(mouse.x, mouse.y, mouse.Mode);
  3.  
Which means "refer to this cursor's mode to trigger corresponding interaction".
Notice, that you still tell engine what to do, there is no automatic action here on mouse click. And if you want custom behavior, you simply change ProcessClick parameters to something else.

For example, in the Khris's script you posted above, the "mode" parameter sent to ProcessClick is determined not by mouse mode (since it stays the same), but by other conditions, such as mouse button or kind of location you click on.

You may devise your own rules, for instance, change the interaction depending on type of object:
Code: Adventure Game Studio
  1. int mode = eModeInteract;
  2. int lt = GetLocationType(mouse.x, mouse.y);
  3. if (lt == eLocationCharacter)
  4.     mode = eModeSpeak;
  5. Room.ProcessClick(mouse.x, mouse.y, mode);
  6.  

Or make use of Custom Properties to know which action to run on the hotspot, but then you will have to get actual object using GetAtScreenXY
Code: Adventure Game Studio
  1. Character *ch = Character.GetAtScreenXY(mouse.x, mouse.y);
  2. Object *obj = Object.GetAtScreenXY(mouse.x, mouse.y);
  3.  
  4. int mode = eModeWalk;
  5. if (ch != null)
  6.     mode = ch.GetProperty("DefaultAction");
  7. else if (obj != null)
  8.     mode = obj.GetProperty("DefaultAction");
  9. Room.ProcessClick(mouse.x, mouse.y, mode);
  10.  



Another ability that you have is RunInteraction function (it is applicable to most game classes, such as Characters, Objects etc). The difference between ProcessClick and RunInteraction is that ProcessClick first finds out what actual object will receive the event, and then calls RunInteraction for it. Calling RunInteraction yourself gives you precise control over which object will that be.
You may even do multiple RunInteraction calls for different objects or with different interaction modes sequentially.
« Last Edit: 20 May 2018, 16:17 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #47 on: 20 May 2018, 20:27 »
In solution 1 and 2 I shared the code, I built my bottom pop-up gIconbar menu and cursor change at edges, as well as Walk player to edges, also cursor change to X cursor if you can't go there and play sound, for now I dont hear sounds even when imported but this will be dealt at later point. Since the game cannot detect 'Current cursor image used' when it is set in the rooms and what edge the cursor will be changes from room to room, since some rooms you go 4 ways others only 2 or 3 etc. Then I put the edgeCursor integer to be updated as a var when cursor icon changes, so it all goes under the

if edgeCursor == 0 which is when the cursor is within the game and not any edge cursor do: all the different things you can do with left-click.
Thx for the explanation I will play around with these.
« Last Edit: 20 May 2018, 20:39 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #48 on: 20 May 2018, 20:41 »
Since the game cannot detect 'Current cursor image used' when it is set in the rooms and what edge the cursor will be changes from room to room, since some rooms you go 4 ways others only 2 or 3 etc. Then I put the edgeCursor integer to be updated as a var when cursor icon changes

You could use Mouse.ChangeModeGraphic, then it will tell you which graphic is that with Mouse.GetModeGraphic. Also then you won't have to have multiple cursor modes for this, only different sprites.

Aside from that, I strongly recommend using System.ViewportWidth and System.ViewportHeight when you refer to the size of the screen, and Room.Width and Room.Height when you refer to the size of the room, instead of putting literal coordinates in the general scripts. The latter is more important, because you may happen to have scrolling rooms later at some point, then your scripts will work incorrectly.
« Last Edit: 20 May 2018, 20:44 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #49 on: 21 May 2018, 00:50 »
You could use Mouse.ChangeModeGraphic, then it will tell you which graphic is that with Mouse.GetModeGraphic. Also then you won't have to have multiple cursor modes for this, only different sprites.

Aside from that, I strongly recommend using System.ViewportWidth and System.ViewportHeight when you refer to the size of the screen, and Room.Width and Room.Height when you refer to the size of the room, instead of putting literal coordinates in the general scripts. The latter is more important, because you may happen to have scrolling rooms later at some point, then your scripts will work incorrectly.

Ah, I was using UseModeGraphic and I checked it was always returning the default icon with Mouse.GetModeGraphic that's why I used other variables but now I made it all work with ChangeModeGraph. I deleted the other cursors, now it works the same. I started using SystemViewports and updated all my code where I use e.g 1900 of 1920 which is 98% to be e.g 0.98 * system.. width, even updated here in the posts. Thanks, I dont think I would use other types of rooms but it could come in handy if I resized things.

Well there are things not clearly posted in the Khris code like he posts ProcessClick but that requires e.g Room.ProcessClick. And Im also not sure if im doing those right as nothing happens. So far I do:

function game_start() {
  mouse.DisableMode(eModeLookat);
  mouse.DisableMode(eModeInteract);
  mouse.DisableMode(eModeTalkto);
  mouse.DisableMode(eModeUseinv);
  mouse.DisableMode(eModePickup);
  mouse.DisableMode(eModeWait);
  mouse.EnableMode(eModeKyrCursor);
  mouse.Mode = 8;

and then at
function on_mouse_click(MouseButton) - any mouse button will do the same, I will not restrict button.

if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) { Room.ProcessClick(mouse.x, mouse.y, eModeWalkto); }
^ that doesnt work, I just tried to see from Khris code (unless it doesnt work because my objects cover the whole screen only the dynamic images are part of it) I dont mind using other way or detecting only if there is hotspots/chars. For random trees unless I assign a hotspot or something, clicking on them should be walkable as if there is nothing even though they are part of whole screen object.

I think I get it though, the simplest is, if I do (if there is object hot spot character whatevr do ..... stuff)

ELSE
  else { player.Walk(mouse.x,  mouse.y); }
« Last Edit: 21 May 2018, 01:02 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #50 on: 21 May 2018, 01:05 »
  mouse.Mode = 8;
You could also do "mouse.Mode = eModeKyrCursor;"

if (GetLocationType(mouse.x, mouse.y) == eLocationNothing) { Room.ProcessClick(mouse.x, mouse.y, eModeWalkto); }
^ that doesnt work, I just tried to see from Khris code (unless it doesnt work because my objects cover the whole screen only the dynamic images are part of it) I dont mind using other way or detecting only if there is hotspots/chars. For random trees unless I assign a hotspot or something, clicking on them should be walkable as if there is nothing even though they are part of whole screen object.

Oh right, you have that big object, or objects that cover all screen... this is also another reason to have small objects per each tree only roughly the size of tree.

Anyway, first thing to check is that you have "Pixel-perfect click detection" enabled in General Settings (Visual category).
Other thing to test out is set these large objects Clickable property to false.
I do not remember right away whether GetLocation acknowledges these settings, probably it should.
On the other hand this may be something else wrong with the script.

Re: So has a kyr system been created?
« Reply #51 on: 22 May 2018, 23:24 »
Oh right, you have that big object, or objects that cover all screen... this is also another reason to have small objects per each tree only roughly the size of tree.

Yes but if you think about it, even if a tree object/dynamic sprite took 1/8 of the screen width, every time there was a tree you would not be able to use things at its base even if there was transparent areas. So making those uninteractable while other things are placed too works fine for me. That works already to click on chars on top of these large objects:

Code: Adventure Game Studio
  1.     else if (GetLocationType(mouse.x, mouse.y) == eLocationCharacter)
  2.     {
  3.       Room.ProcessClick(mouse.x,  mouse.y,  eModeTalkto);

I set the character  talk, even used right click for general look at, so im on the page of Inventory. Few questions: I remember from page 1 that I was better off using characters as inventory that when clicked you get the item cursor as if picked, character hides (in room -1) or disappears etc. My question is, I noticed there are Custom values but if I can't differentiate different types of chars, it will be of no use to me. I want to assign text property Item to all chars that will be items but not to others. If I couldn't use Custom Value I would just IF every single char that is item or vice-versa but I see more use in Custom value if it could distinguish same type e.g between chars.
« Last Edit: 22 May 2018, 23:31 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #52 on: 22 May 2018, 23:35 »
My question is, I noticed there are Custom values but if I can't differentiate different types of chars, it will be of no use for me. I want to assign text property Item to all chars that will be items but not to others, so t hat I have a condition if (value is Item) ---do this, instead of IF every single character that is item or not so as to have a different outcome if it is a character or "item character". E.g if character - talk if not, - the pick up item stuff.

These are not really "attribute" kind of properties, but "variable" kind, in other words property will be attached to all of them, but its value may be different.

In other words, you create property "Item" for everyone, but then set values "Yes" or "No" for particular characters.

For your case a custom property of type boolean could be enough, but who knows maybe you will need more character types. So you may even make property "CharacterType", and set value "Item" to ones who are items. Then condition would be:
Code: Adventure Game Studio
  1. if (ch.GetTextProperty("CharacterType") == "Item")
  2.  
« Last Edit: 22 May 2018, 23:38 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #53 on: 23 May 2018, 01:35 »
Oh I was new to this, so I can use a common name like CharType and just change/compare the value of the types I want to distinguish. Can I set the value of each character from the Editor or only with script? If I can manually add the 'Item' value to such characters but I think I can only edit the default value that applies to all from the Editor.

I made a nice way to mimic Kyrandia inventory like that, tomorrow i'll only make the items show up in the inventory window:

I will just try when I click on the visible inventory panel, item to get placed there.

« Last Edit: 23 May 2018, 23:31 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #54 on: 23 May 2018, 01:46 »
Oh I was new to this, so I can use a common name like CharType and just change/compare the value of the types I want to distinguish. Can I set the value of each character from the Editor or only with script? If I can manually add the 'Item' value to such characters but I think I can only edit the default value that applies to all from the Editor.

Default/starting values are set in the editor, but may be changed in script using SetProperty/SetTextProperty.

Re: So has a kyr system been created?
« Reply #55 on: 23 May 2018, 15:01 »
^ Yes but you cannot set the default value to be different for different chars (e.g char 1 has default value text "hero", char2 has default "item", char3 "item" too), they all would start with what you typed as value, so I have to use script to change the value of each item that pops up in the world. That's fine.

I have this more 'how to build the code for this' I actually am weak on using (something) * (something) in script, barely made one thing work.
I want to have say if (at the mouse click event and gIconBar.visible == true, it now contains the InventoryWindow) to show:

(if Mouse.x and Mouse.Y triggered by the mouse click event are within the InvWindow) then check if (slot 1 in the inventory is NOT busy, place an item, else at slot 2, else, at slot 3). The slots are just part of the gIconbar image, the Invwindow is a rectangle area,  and I  read some manual stuff dont know how 'cells' are used in an inventory box and what prevents from placing an item on top of another. I could not find any info for this.
« Last Edit: 23 May 2018, 15:33 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #56 on: 23 May 2018, 15:22 »
^ Yes but you cannot set the default value to be different for different chars (e.g char 1 has default value text "hero", char2 has default "item", char3 "item" too), they all would start with what you typed as value, so I have to use script to change the value of each item that pops up in the world. That's fine.

No you can, that's the point of the system, because originally you could not change values in script at all.
Simply find "Properties" property in particular character's pane, click on (...) and change starting value there.

I was perhaps not clear enough, when saying "Default/starting value" I meant they are different values, not same.

"Default value" is the one set when you edit Properties Schema. This is the value that will be assigned to all characters until you change it later.
"Starting value" is per-character value that you set for particular character in its properties.



I have this more 'how to build the code for this' I actually am weak on using (something) * (something) in script, barely made one thing work.
I want to have say if (at the mouse click event and gIconBar.visible == true, it now contains the InventoryWindow) to show:

(if Mouse.x and Mouse.Y triggered by the mouse click event are within the InvWindow) then check if (slot 1 in the inventory is NOT busy, place an item, else at slot 2, else, at slot 3). The slots are just part of the gIconbar image, the Invwindow is a rectangle area,  and I  read some manual stuff dont know how 'cells' are used in an inventory box and what prevents from placing an item on top of another. I could not find any info for this.

I need to clarify this, are you using builtin InventoryWindow, or trying to script your own? In builtin one you cannot choose at which exactly slot to place an item, it does not have such functionality. It simply displays the items from Character's inventory in some order (don't remember which one, probably in the order you found them).
From your description (slot 1 in the inventory is NOT busy, place an item, else at slot 2, else, at slot 3) this behavior may be achieved by simply using builtin InventoryWindow and giving item to character using Character.AddInventory. InventoryWindow will do the rest on its own.
« Last Edit: 23 May 2018, 15:44 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #57 on: 23 May 2018, 21:13 »
Oh I didn't see the field before 'Edit schema' has almost invisible field that doesn't say it is starting value but it works now thanks.

And I can try with the default Inventory scripts, I do use custom type tho  but what LucasArts and the AGS defaults do is when character clicks on item in the world, it immediately appears in the inventory. I want like in Kyrandia you have to navigate your cursor (already set to the item icon) to the inventory window before the 'create inventory' kind of scripts. As for how it positions, I will see later cause my inventory image has different places to put items on would have been better if I could choose where but for now let's have it drop at the inventory.

I'm trying to get the correct mouse check, it is not GUI, I tried GUIControl * inventoryArea, my InventoryWindow is part of gIconbar, dunno if I have to still enable inventory
« Last Edit: 27 May 2018, 17:45 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #58 on: 23 May 2018, 21:26 »
And I can try with the default Inventory but what it does is when character clicks on item in the world, it immediately appears in the inventory. I want like in Kyrandia you have to navigate your cursor (already set to the item icon) to the inventory window before the 'create inventory' kind of scripts.

Oh, I see now.

Hmm. Well, then it should probably be done in following way:
1) On left-clicking a "item" on ground you hide the character, and remember the corresponding InventoryItem* in some variable, let's say "PickedUpItem". Also switch mouse.Mode to eModeUseInv, or simply change mouse graphic to the item's sprite (depends on how you handle modes).
Note, you cannot use Character.ActiveInventory property, because it's restricted to only items that is already in inventory.
So now, the item is not yet in inventory (and not displayed in InventoryWindow), but it is stored in a variable and displayed on cursor.


2) On left-clicking on InventoryWindow you check whether item variable "PickedUpItem" holds a valid pointer. If it does, then you call player.AddInventory(PickedUpItem), reset "PickedUpItem" to null, reset cursor graphic.

Detecting that left click was made over inventory window is done like this:
Code: Adventure Game Studio
  1. function on_mouse_click(MouseButton button)
  2. {
  3.    if (button == eMouseLeftInv)
  4.    {
  5.        // put into inventory
  6.    }
  7. }
  8.  


PS.
Code: Adventure Game Studio
  1. inventoryArea = GUIControl.GetAtScreenXY(mouse.x, mouse.y); //well this seems to be wrong here already display shows nothing
  2. Display("%s", inventoryArea);
  3.  
  4. if (inventoryArea == InventoryWindow)
  5. {
  6.     player.Say("You got it");
  7. }
  8.  
Not sure why the condition below does not work, but its lucky this Display did not crash the game, because "%s" expects String, and you pass a pointer to object there (EDIT: oh, it probably won't crash, but not display anything at all). The proper format for pointers is "%p".
« Last Edit: 23 May 2018, 21:39 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #59 on: 23 May 2018, 23:27 »
1. Unable to click item hidden behind Solved

See else if (itemIsSelected == true && gIconbar.Visible

2. Create item at inventory after clicking in the inv window Solved

See function on_event(EventType event, int guiType)
« Last Edit: 27 May 2018, 18:42 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #60 on: 23 May 2018, 23:48 »
The itemIsSelected == true is because it can be selected and then if no Inventory, the clicking on Ground leaves it on the ground (returns the character back to the player room and restores cursor).

You may do the same by testing "if (pickedItem != null)" which would mean that some item is selected. I am not sure if a separate boolean variable required.

I do not see if you clear pickedItem anywhere, it has to be set to null if you either put it back or add to inventory.

Alas, nothing happens, there, where I change the cursor I also change the pickedItem = iKey; but still does not show up in inventory. Anything wrong with my InventoryWindow on gIconbar? Its height is 88 and the item icon is 15.


Hm, I do not see anything else wrong with the shown script.
Could you try giving player anything upon some simple event (like a key press) and see if inventory window will display it?

Things to double check:
- InvWindow is actually linked to your player character (CharacterID property).
- InvWindow has valid ItemWidth and ItemHeight values.
- Inventory item itself actually has assigned sprite (Image property).



The itemIsSelected == true is because it can be selected and then if no Inventory, the clicking on Ground leaves it on the ground (returns the character back to the player room and restores cursor).
This made that problem though and it doesnt matter if my objects/ dynamic sprites are huge or not, since anyone can try to click on a dynamic sprite - if the item is dropped on some dynamic sprite it can be hidden behind and never to be picked up again (funny that's why Kyrandia used some bounce effect where the item bounces like a ball to a certain location and can't be put exactly where you click). One way is setting the Baseline which would be unrealistic like putting it on top of everything or transparency at least to show it is two objects overlapping.

But then I would need to detect not the objects since they cover large parts, but the Dynamic sprites or graphic.
I think you are already using formulas to get the actual tree graphic position in relation to room coordinates - when calculating Baseline and blocking object's position. You may use similar logic to find a bounding box around tree (not necessarily precise), and if player leaves item there, then make it move towards nearby free area. Not sure what's the best way of finding that free area though.

For starters you could simply cancel item drop in such case. Or define number of preset locations in the room, and choose closest one.
« Last Edit: 23 May 2018, 23:54 by Crimson Wizard »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #61 on: 23 May 2018, 23:55 »
Oh wait, I am stupid. eMouseLeftInv only works when you click on actual item in inventory, not on the inventory itself.

So, yes, you actually need to find out whether you clicked in the InvWindow.

First of all, find out if you have "Override build-in inventory click handling" in General Settings.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #62 on: 24 May 2018, 00:09 »
Alright, my apologies, this is one of the AGS quirks I forget all the time.

I am bit tired right now, so may as well miss something else, but apparently AGS does not send on_mouse_click events when player clicks on the GUI, at all. The only exception is when player clicks on actual item in inventory window (then it calls on_mouse_click with eMouseLeftInv).

So far the only way I found that works, is to track mouse button state in repeatedly_execute:
Code: Adventure Game Studio
  1. function repeatedly_execute()
  2. {
  3.     GUIControl *inv = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
  4.     if (gIconbar.Visible)
  5.     {
  6.         if (inv == InventoryWindow && mouse.IsButtonDown(eMouseLeft))
  7.         {
  8.             // do something
  9.         }
  10.     }
  11. }
  12.  

Note that this script example above is not perfect, because it will continiously trigger so long as you keep mouse button down. So probably it should be expanded, remembering mouse button state (was down or up) and perform actions only once, when it was just pressed down or released.


UPDATE:
Alright, another correction.
You may actually receive clicks to the GUI by adding OnClick event handler.
Problem is, that this event only fires when you click on GUI background, not on its controls. So it won't work right in your case.
And InvWindow control does not have a OnClick event on its own, sadly.
If you do not like the solution with catching clicks in repeatedly_execute, then only other solution I currently see is to script custom inventory drawing right on GUI background (using another dynamic sprite). Then you will be able to handle clicks using gIconbar's OnClick event.
Perhaps this is not worth it without other reasons.
« Last Edit: 24 May 2018, 00:26 by Crimson Wizard »

Khris

    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
    • Khris worked on a game that was nominated for an AGS Award!
Re: So has a kyr system been created?
« Reply #63 on: 24 May 2018, 11:21 »
I didn't read the last few posts so in case this doesn't apply, please ignore.

There's on_event / eEventMouseGUIUp/Down, which I've used in the past to handle arbitrary GUI clicks.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #64 on: 24 May 2018, 11:28 »
There's on_event / eEventMouseGUIUp/Down, which I've used in the past to handle arbitrary GUI clicks.

Yes, I can confirm, this detects click on InvWindow also! It even works if you click on inventory item.
Although, I do not see a way to know which mouse button was pressed/released without mouse.IsButtonDown.

Code: Adventure Game Studio
  1. function on_event(EventType event, int data)
  2. {
  3.     if (event == eEventGUIMouseDown && data == gIconbar.ID)
  4.     {
  5.         GUIControl *inv = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
  6.         if (inv == InventoryWindow && mouse.IsButtonDown(eMouseLeft) && !mouse.IsButtonDown(eMouseRight))
  7.         {
  8.             // do something
  9.         }
  10.     }
  11. }
  12.  

(Damn, all those different methods in AGS are confusing...)
« Last Edit: 24 May 2018, 12:12 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #65 on: 24 May 2018, 22:17 »
Yes override-inventory is True in General Settings. And yes I use itemIsSelected for other functions. I still use the code for how to drop the item on the ground as I have it here but Im ready to start a new function specially for clicking within the Inventory window.

I won't restrict the button you can click inventoryWindow on, so as long as Left works, any other working is even better. I will set pickedItem to null for when placed on the ground or in inventory. Yes the code works, the item is now created! Thanks for that code both Crimson Wizard and Khris!

Works:
Add spoiler tag for Hidden:
Code: Adventure Game Studio
  1. function on_event(EventType event, int guiType)
  2. {
  3.     if (event == eEventGUIMouseDown && guiType == gIconbar.ID && itemIsSelected == true)
  4.     {
  5.         GUIControl *inv = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
  6.         if (inv == InventoryWindow && mouse.IsButtonDown(eMouseLeft) || mouse.IsButtonDown(eMouseRight))
  7.         {
  8.           player.AddInventory(pickedItem);
  9.           itemIsSelected = false;
  10.           mouse.ChangeModeGraphic(Mouse.Mode, 2061);
  11.           pickedItem = null;
  12.         }
  13.     }
  14. }

Now for the other part, taking from inventory event and similar actions as dropping on ground. This below doesn't register the pick up, I suppose since Im not on the default Mode for picking up an item. I tried few other places but now i cant pick it up from the inventory xD , this event is for 'Other click on inv item' event of the item, im on my usual custom cursor mode.

Not working next posts

Quote
I think you are already using formulas to get the actual tree graphic position in relation to room coordinates - when calculating Baseline and blocking object's position. You may use similar logic to find a bounding box around tree (not necessarily precise), and if player leaves item there, then make it move towards nearby free area. Not sure what's the best way of finding that free area though.

Yes I will see, the problem is that when I used Collision comparison it didn't work even though I put it under For loop and checked with every object, it worked on one object but the rest didn't. I guess I will play on my own with it, I like the idea to put the item in front of all and 50 transparency, as it still shows 2 objects overlapping and not by making transparent the whole huge object like it's done on other games, just the item itself.
« Last Edit: 27 May 2018, 18:43 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #66 on: 24 May 2018, 22:34 »
Imc7r, you have a mistake in the code here:

Code: Adventure Game Studio
  1. if (inv == InventoryWindow && mouse.IsButtonDown(eMouseLeft) || mouse.IsButtonDown(eMouseRight))
  2.  

You need to put || operation in brackets, because && operation takes precedence:
Code: Adventure Game Studio
  1. if (inv == InventoryWindow && (mouse.IsButtonDown(eMouseLeft) || mouse.IsButtonDown(eMouseRight)))
  2.  




Now for the other part, taking from inventory event and similar actions as dropping on ground. This below doesn't register the pick up, I suppose since Im not on the default Mode for picking up an item. I tried few other places but now i cant pick it up from the inventory xD , this event is for 'Other click on inv item' event of the item, im on my usual custom cursor mode.

The best way to know is to put Display("IT WORKS") command there.

But I guess you do not have to use "Other click" event at all. In your on_mouse_click you may catch "eMouseLeftInv" because this definitely what it's meant for.
The currently clicked inventory item may be found using "game.inv_activated" variable. I think it returns item's numeric ID, so to get actual InventoryItem you do:
Code: Adventure Game Studio
  1. InventoryItem *clickedOnItem = inventory[game.inv_activated];
  2.  
Then you may call your function, passing the clicked item as parameter (so no need to do GetAtScreenXY again).

So in the end it may look something like this:
Code: Adventure Game Studio
  1. function on_mouse_click(MouseButton button)
  2. {
  3. <....>
  4.  
  5.     // clicking on item in inventory window
  6.     if (button == eMouseLeftInv)
  7.     {
  8.         if (pickedItem != null)
  9.         { // this means we have picked item from the ground
  10.             <...>
  11.         }
  12.         else if (player.ActiveInventory)
  13.         { // this means we have an item from inventory in the cursor (not sure if you are going to differentiate between these two cases)
  14.             <...>
  15.         }
  16.         else
  17.         { // cursor is just a pointer, so pick the item
  18.              InventoryItem *clickedOnItem = inventory[game.inv_activated];
  19.              itemPickedFromInventory(clickedOnItem);
  20.         }
  21.     }
  22.  
  23. <....>
  24. }
  25.  
« Last Edit: 24 May 2018, 22:37 by Crimson Wizard »

Re: So has a kyr system been created?
« Reply #67 on: 25 May 2018, 14:40 »
Hey thanks for the correction with the bracket. I manage the drop on ground elsehwere, it's good. I just needed the correct click detection in inventory, that does it for me as well:

SOLVED - Pick up and Drop Kyr style inventory - thanks for the below post explanation, updated script here to not paste the same over and over
Code: Adventure Game Studio
  1.   else if (button == eMouseLeftInv || button == eMouseRightInv)
  2.   {
  3.     pickedItem = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  4.     itemIsSelected = true;
  5.     mouse.ChangeModeGraphic(Mouse.Mode, pickedItem.Graphic);
  6.     player.LoseInventory(pickedItem);
  7.     Overlay * pickedItemString = Overlay.CreateTextual(FloatToInt(IntToFloat(System.ViewportWidth) * 0.0104, eRoundNearest), FloatToInt(IntToFloat(System.ViewportHeight) * 0.96, eRoundNearest),  200, Game.SpeechFont, 15, "%s picked.", charClicked.Name);
  8.     Wait(40);
  9.   }
  10.  

Just for a small q - is there a way to display text at any given moment without pausing the game and animations? Display text pauses it, I use player.Say that creates a small Wait cursor but it would have been nicer if there was a text that just shows up as notification while all else is running.

[WIP o working on Fixing...]
And for now I will be forced to remove my slots drawn at the inventory area, would have been good to limit inventory to 12 for my game and place them at specific slots, but eh, will deal w this another time.

The item is already re-created and the cycle works all over again. If I want to put the item at specific place in the world, this can be further expanded. Thanks for the help with this again, I will work on my drop-behind --tree prevention and will not bother you with other questions for some time.
« Last Edit: 28 May 2018, 00:01 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #68 on: 25 May 2018, 14:55 »
I think you may simplify your item picking code to the point when you no longer need switch, because you may get every value from the "item" pointer:
Code: Adventure Game Studio
  1. mouse.ChangeModeGraphic(Mouse.Mode, item.CursorGraphic); // or alternatively -- item.Graphic
  2. itemIsSelected = true;
  3. pickedItem = item;
  4. player.LoseInventory(item);
  5.  

Just for a small q - is there a way to display text at any given moment without pausing the game and animations? Display text pauses it, I use player.Say that creates a small Wait cursor but it would have been nicer if there was a text that just shows up as notification while all else is running.

Overlay.CreateTextual may work for that.
For more complex behavior you may create a GUI with label(s), show it up and remove by timer (see SetTimer).

Re: So has a kyr system been created?
« Reply #69 on: 27 May 2018, 18:40 »
Hey thanks for these, I updated or simplified some script but having some bugs,  I had to try with 2 items at least (or 2 item-characters at the same time on the ground).  imgI noticed how the SWITCH function (in the pick up) screwed things up cause it ran both cases even if I clicked only one of the two Item chars, it ran the action twice and  changed cursor twice. This was fixed when I use if / if else instead of switch with cases.

Bugs that happen: I already redid my inventory sprite to have circle slots next to each other, so that when you put e.g 82x82 images for inventory icon (respectively mouse cursor graphic when changed) they would fill each circle correctly, by changing the ItemWidth and ItemHeight in the InventoryWindow also to 82, so now items appear correctly. I guess, I can't expect if I used different size images for icons to be equidistant. Since I use the same for cursor and item sprite, I did all these images same 82x82 and hotspot 41.

A bit of a prob is that you have to click always right of existing item in the inventory to get the new item added, if you click on the first item slot it will attempt to add an inventory but will fail, and return to as if you never clicked the inventory, so always have to click way on the right:



I guess a main question would be: using custom properties for chars and items, can I replace "If pickedItem == ikey, set charClicked = Key, if pickedItem == iBracelet, set charVar = Bracelet' with something like set charClicked = "the char, whose Custom value is ..)? This is essential for custom values to have use, if you can replace the direct identification of an item or char with 'The one who has the Custom value of..'

At least I also made the custom GUI using a new background for it, set it Clickable = True, GUI in Room 301 and the buttons with associated script to run and other properties. Is there no way to have a Text paragraph in the GUI? Labels allow you to paste big text but not new paragraphs. I was meaning to add some text as a value directly, without using script.

Im posting my code and some elsewhere throughout this thread for my or anyone's info, since there were some who asked for kyr template in past years.


Code: Adventure Game Studio
  1. //Global Script
  2. bool itemIsSelected;
  3. int dialogIncrement[20];
  4. Character * charClicked;
  5. InventoryItem * pickedItem;
  6.  
  7. function on_mouse_click(MouseButton button)
  8. {
  9.   if (player.Room <= 300)
  10.   {
  11.     if (IsGamePaused() == 1) { }
  12.     else if (itemIsSelected == true && gIconbar.Visible == false && GetLocationType(mouse.x, mouse.y) != eLocationCharacter && GetLocationType(mouse.x, mouse.y) != eLocationHotspot && charClicked.GetTextProperty("Behavior") == "Item")
  13.     {
  14.         if (charClicked == cVioletBerry && season == 1) { charClicked.ChangeView(7); }
  15.         charClicked.ChangeRoom(player.Room);
  16.         charClicked.x = mouse.x;
  17.         charClicked.y = mouse.y;
  18.         itemIsSelected = false;
  19.         mouse.ChangeModeGraphic(Mouse.Mode, 2061);
  20.        
  21.         pickedItem = null;
  22.         if (gMap.Visible == true) { gMap.Visible = false; }
  23.         if (GetLocationType(mouse.x,mouse.y) == eLocationObject)
  24.         { charClicked.Baseline = 10010; charClicked.Transparency = 50;
  25.           Overlay * pickedItemString = Overlay.CreateTextual(charClicked.x, charClicked.y - 10,  600, Game.SpeechFont, 15, "%s", charClicked.Name); Wait(40);
  26.         }
  27.         else { for (int i = 0; i <= 7 && player.Room != 1; i++) { charClicked.Baseline = object[i].Baseline - 1; charClicked.Transparency = 0; } }
  28.     }
  29.    
  30.     else if (button == eMouseLeftInv || button == eMouseRightInv)
  31.     {
  32.       pickedItem = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  33.       charClicked = character[pickedItem.GetProperty("ItemCharID")];
  34.       itemIsSelected = true;
  35.       mouse.ChangeModeGraphic(Mouse.Mode, pickedItem.Graphic);
  36.       player.LoseInventory(pickedItem);
  37.       Overlay * pickedItemString = Overlay.CreateTextual(FloatToInt(IntToFloat(System.ViewportWidth) * 0.0104, eRoundNearest), FloatToInt(IntToFloat(System.ViewportHeight) * 0.96, eRoundNearest),  600, Game.SpeechFont, 15, "%s picked.", charClicked.Name);
  38.       Wait(40);
  39.     }
  40.    
  41.     else if (button == eMouseLeft)
  42.     {
  43.       if (Mouse.GetModeGraphic(Mouse.Mode) == 6)
  44.       {
  45.         player.Walk(0,  mouse.y);
  46.       }
  47.       else if (Mouse.GetModeGraphic(Mouse.Mode) == 7)
  48.       {
  49.         player.Walk(System.ViewportWidth,  mouse.y);
  50.       }
  51.       else if (Mouse.GetModeGraphic(Mouse.Mode) == 4)
  52.       {
  53.         player.Walk(mouse.x,  0);
  54.       }
  55.       else if (Mouse.GetModeGraphic(Mouse.Mode) == 1)
  56.       {
  57.         player.Walk(mouse.x,  System.ViewportHeight);
  58.       }
  59.       else if (Mouse.GetModeGraphic(Mouse.Mode) == 37)
  60.       {
  61.         aError.Play();
  62.       }
  63.       else if (GetLocationType(mouse.x, mouse.y) == eLocationCharacter)
  64.       {
  65.         charClicked = Character.GetAtScreenXY(mouse.x, mouse.y);
  66.        
  67.         if (charClicked.GetTextProperty("Behavior") != "Item")
  68.         {
  69.           if (pickedItem != null)
  70.           {
  71.             Room.ProcessClick(mouse.x,  mouse.y,  eModeInteract);
  72.           }
  73.           else
  74.           {
  75.             Room.ProcessClick(mouse.x,  mouse.y,  eModeTalkto);
  76.           }
  77.         }
  78.         else
  79.         {
  80.           Room.ProcessClick(mouse.x,  mouse.y,  eModePickup);
  81.         }
  82.       }
  83.       else if (GetLocationType(mouse.x, mouse.y) == eLocationHotspot)
  84.       {
  85.         Room.ProcessClick(mouse.x,  mouse.y,  eModeInteract);
  86.       }
  87.       else if (GetLocationType(mouse.x, mouse.y) == eLocationObject)
  88.       {
  89.         Object * obj = Object.GetAtScreenXY(mouse.x, mouse.y);
  90.         if (obj.GetTextProperty("Behavior") == "Item") { Room.ProcessClick(mouse.x,  mouse.y,  eModePickup); }
  91.       }      
  92.      
  93.       else { player.Walk(mouse.x,  mouse.y); }
  94.     }
  95.    
  96.     else if (button == eMouseRight)
  97.     {
  98.       if (GetLocationType(mouse.x, mouse.y) == eLocationCharacter)
  99.       {
  100.         Room.ProcessClick(mouse.x,  mouse.y,  eModeLookat);
  101.       }
  102.       else
  103.       {
  104.         dialogIncrement[0]++;
  105.         if (dialogIncrement[0] <= 1)
  106.         {
  107.           player.Say("Talk 1.");  
  108.         }
  109.         else if (dialogIncrement[0] == 2)
  110.         {
  111.           player.Say("Talk 2.");  
  112.         }
  113.         else
  114.         {
  115.           dialogIncrement[0] = 0;
  116.           player.Say("Talk 3.");
  117.         }
  118.       }
  119.     }
  120.   }
  121.   else { Room.ProcessClick(mouse.x,  mouse.y,  eModePointer); }
  122. }
  123.  
  124. function cItem_PickUp()
  125. {
  126.   if (charClicked.Room != -1) { charClicked.ChangeRoom(-1); }
  127.   itemIsSelected = true;
  128.   Overlay * pickedItemString = Overlay.CreateTextual(FloatToInt(IntToFloat(System.ViewportWidth) * 0.0104, eRoundNearest), FloatToInt(IntToFloat(System.ViewportHeight) * 0.96, eRoundNearest),  600, Game.SpeechFont, 15, "%s picked.", charClicked.Name);
  129.   pickedItem = inventory[charClicked.GetProperty("ItemCharID")];
  130.   if (pickedItem == iVioletBerry && season == 1) { if (charClicked == cVioletBerry) { mouse.ChangeModeGraphic(Mouse.Mode, 72); } } else { mouse.ChangeModeGraphic(Mouse.Mode, pickedItem.Graphic); }
  131.   Wait(40);
  132. }
  133.  
  134. function itemChar_Interact()
  135. {
  136.   if (charClicked == player)
  137.   {
  138.     if (Mouse.GetModeGraphic(Mouse.Mode) == 3) { charClicked.Say(""); }
  139.     else if (Mouse.GetModeGraphic(Mouse.Mode) == 75) { charClicked.Say(""); gMap.Visible = true; }
  140.     else if (Mouse.GetModeGraphic(Mouse.Mode) == 83) { charClicked.Say(""); }
  141.     else if (Mouse.GetModeGraphic(Mouse.Mode) == 70) { charClicked.Say("Yum! "); mouse.ChangeModeGraphic(Mouse.Mode, 2061); }
  142.     else if (Mouse.GetModeGraphic(Mouse.Mode) == 72) { charClicked.Say(""); mouse.ChangeModeGraphic(Mouse.Mode, 2061); }
  143.     else { charClicked.Say("");  }
  144.   }
  145.  
  146.   else if (charClicked == cNPC)
  147.   {
  148.     if (Mouse.GetModeGraphic(Mouse.Mode) == 3) { }
  149.  
  150.    
  151.     else if (Mouse.GetModeGraphic(Mouse.Mode) == 83) charClicked.Say("Some.");
  152.     else { charClicked.Say("Not it"); }
  153.   }
  154.  
  155.   if (pickedItem == iVioletBerry) { charClicked = null; itemIsSelected = false; pickedItem = null; }
  156.   else { charClicked = character[pickedItem.GetProperty("ItemCharID")]; }
  157.  
  158. }
  159.  
  160.  
« Last Edit: 05 Jun 2018, 00:51 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #70 on: 30 May 2018, 15:54 »
I guess a main question would be: using custom properties for chars and items, can I replace "If pickedItem == ikey, set charClicked = Key, if pickedItem == iBracelet, set charVar = Bracelet' with something like set charClicked = "the char, whose Custom value is ..)? This is essential for custom values to have use, if you can replace the direct identification of an item or char with 'The one who has the Custom value of..'

You may assign character's numeric ID in the item's custom property, then you could do something like:
Code: Adventure Game Studio
  1. Character *charForItem = character[item.GetProperty("LinkedCharacter")];
  2.  
The "character" is a global array of all characters in game, so its safe to use anytime.

Similarily you may do counter link using character's properties
Code: Adventure Game Studio
  1. InventoryItem *itemFromCharacter = inventory[ch.GetProperty("LinkedItem")];
  2.  

Re: So has a kyr system been created?
« Reply #71 on: 02 Jun 2018, 23:51 »
Thats what I was looking for, thanks. I was still not good at using such ways of identifying objects. The one thing that doesn't work well is a Hotspot in particular room doesnt fire the event function even though I made a hotspot rectangle on the room and set the event for Interaction and I have in my mouse click if (GetLocationType(mouse.x, mouse.y) == eLocationHotspot) to do Room.ProcessClick(mouse.x,  mouse.y,  eModeInteract); and that's the kind of event that uses the function and still nothing happens. However, as I would use placed objects as well, I can fire it upon the objects that will act as items.

I still have to see how to use more than 1 character of the same type if I wanted to drop 'several same type items' on the ground. With a single item per type it is a single character that appears, I can't duplicate chars it seems.
Also when you click on the inventory to create a 2nd item of the same type, the item is not created, you still remain with the first one. And the code for creating inventory item when at specific cursor graphic is here.
« Last Edit: 03 Jun 2018, 23:18 by Imc7r »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: So has a kyr system been created?
« Reply #72 on: 04 Jun 2018, 10:08 »

I was still not good at using such ways of identifying objects. The one thing that doesn't work well is a Hotspot in particular room doesnt fire the event function even though I made a hotspot rectangle on the room and set the event for Interaction and I have in my mouse click if (GetLocationType(mouse.x, mouse.y) == eLocationHotspot) to do Room.ProcessClick(mouse.x,  mouse.y,  eModeInteract); and that's the kind of event that uses the function and still nothing happens.
I've seen there was a code before, but you removed it for some reason. First of all it is necessary to find out what exactly does not work, is it detection or triggering event function, or code inside function. That may be found by placing "Display" calls everywhere and see which is not get called.

I still have to see how to use more than 1 character of the same type if I wanted to drop 'several same type items' on the ground. With a single item per type it is a single character that appears, I can't duplicate chars it seems.
Since AGS cannot create characters at runtime, only way is to precreate more characters for particular item.
On another hand, if you want to have no limit of number of items of same kind on the ground in the room, then you will have to use "character pool" same way you are using "object pool" for decorations. In other words, not 1 particular character per each type of inventory, but simply a huge number of characters, which you fill into global array, take out as you need an item on ground, and put back as item is removed or you leave the room. Of course this way you would have to save item locations in variables too.
This is where SetProperty come handy, if you follow the character-item linking method mentioned above, you may change character's role on fly.


Also when you click on the inventory to create a 2nd item of the same type, the item is not created, you still remain with the first one.

Make sure you have "Display multiple icons for multiple items" enabled in General Settings.

Re: So has a kyr system been created?
« Reply #73 on: 05 Jun 2018, 01:06 »
^ ah it fails at the event run even but it's OK if the place is buggy I used a workaround where the object has the Item property and he interacts with it instead of the hotspot. I put all my updated related code at the bottom of this post.

Quote
Since AGS cannot create characters at runtime, only way is to precreate more characters for particular item.
On another hand, if you want to have no limit of number of items of same kind on the ground in the room, then you will have to use "character pool" same way you are using "object pool" for decorations. In other words, not 1 particular character per each type of inventory, but simply a huge number of characters, which you fill into global array, take out as you need an item on ground, and put back as item is removed or you leave the room. Of course this way you would have to save item locations in variables too.
This is where SetProperty come handy, if you follow the character-item linking method mentioned above, you may change character's role on fly.

Ah so I will have to use multi chars for same items. Probably I will not have more than 10 or less items of same type. So that's what I thought, even better than making 5 of each possible multiple objects, using same 5 Dummy chars with changed View (to whatever items are to be on the ground) and changing value with Set property and assigning them to whichever items would have to pop as chars on the ground. I think I can handle that myself just need to see a lot of inaccuracies that will occur.

Quote
Make sure you have "Display multiple icons for multiple items" enabled in General Settings

This was the case indeed, thanks