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

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 »