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

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