Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
#645584 02/05/18 12:16 AM
Joined: Dec 2016
Location: United States
member
OP Offline
member
Joined: Dec 2016
Location: United States
Hi everyone, I'm a bit of a loss with this problem and am hoping someone can offer a solution.

Consider this:

I have a button that needs to be used (via player click) very frequently. It has simple scripting that sends an item event to Osiris. Osiris catches the event and plays an effect on the button. That's it.

The problem is that the button throws its event after a delay of anywhere from zero to ~1.5 seconds when it isn't placed within the center of the most populated area of the map. Clearly this is strange, as one would assume that a very remote area would offer the best performance--since almost all objects are culled.

Now, even in this special spot, the button is still delayed if I have my camera angled such that many objects/light probes are visible, but I can understand this. What I cannot understand is why the button is so severely delayed when placed in a very remote location with nearly no objects or light probes.


Here's the itemScript:
Code
INIT
ITEM:__Me
EXTERN STRING:%AMER_Button_Event = null  //This is defined as "TESTTEST"

EVENTS

EVENT Button_Use
VARS
CHARACTER:_Char
ON
	OnUseItem(_Char,__Me)
ACTIONS
	CharacterItemEvent(_Char, __Me, %AMER_Button_Event)


...And the Osiris catch:
Code
IF
CharacterItemEvent(_Char, _Item, "TESTTEST")
THEN
PlayEffect(_Item, "AMER_RS3_FX_ButtonPress");

Super simple.


I can't leave the button in the center of my map, so I've tried everything I can think of to have it perform, as well as it does there, at another point in the map--Region triggers, Cull triggers, low-impact atmospheres, surrounding the button with terrain cliffs and random doodads--to no avail.

Any suggestions would be greatly appreciated.


Edit: I should note that there is no such lag in-editor. Only in-game.

Last edited by Ameranth; 02/05/18 04:45 AM.
Joined: May 2017
enthusiast
Offline
enthusiast
Joined: May 2017
The fact that you're getting lag from that is pretty strange indeed. Have you tried using the "CharacterUsedItem" events directly in Osiris? Did those lag as well?

Code
CharacterUsedItem((CHARACTERGUID)_Character, (ITEMGUID)_Item)
CharacterUsedItemTemplate((CHARACTERGUID)_Character, (STRING)_Template, (ITEMGUID)_Item)

Joined: Oct 2008
A
ALF Offline
journeyman
Offline
journeyman
A
Joined: Oct 2008
You get the delay, because the game code asks Osiris if it can use the button or not.

React to the CanUseItem event and call RequestProcessed with a 1 as the last parameter to indicate you allow the use.

You'll have similar delays for the other requests like this:

Code
event CanMoveItem((CHARACTERGUID)_Character, (ITEMGUID)_Item, (INTEGER)_RequestID) (3,0,809,1)
event CanPickupItem((CHARACTERGUID)_Character, (ITEMGUID)_Item, (INTEGER)_RequestID) (3,0,810,1)
event CanUseItem((CHARACTERGUID)_Character, (ITEMGUID)_Item, (INTEGER)_RequestID) (3,0,811,1)
event CanLockpickItem((CHARACTERGUID)_Character, (ITEMGUID)_Item, (INTEGER)_RequestID) (3,0,812,1)
event CanCombineItem((CHARACTERGUID)_Character, (ITEMGUID)_ItemA, (ITEMGUID)_ItemB, (ITEMGUID)_ItemC, (ITEMGUID)_ItemD, (ITEMGUID)_ItemE, (INTEGER)_RequestID) (3,0,813,1)


EDIT: rereading your post, this might be something else. I would still verify that you're calling RequestProcessed. (check your Osiris log)

Does the button have an owner and is the crime system blocking the use?

Last edited by ALF; 02/05/18 02:12 PM.
Joined: Dec 2016
Location: United States
member
OP Offline
member
Joined: Dec 2016
Location: United States
Thanks for the replies!

- Because CharacterUsedItem events are handled before StoryEvents I had also thought to try using those instead, but there is sadly no change in delay.

- The request is indeed being processed. As you are suggesting, there would always be a ~1 second delay if it were due to missing a RequestProcessed, but the delay is not consistent at all, and Osiris always reports the request as processed.

- The crime system is not involved at all aside from the obligatory Processing of the ItemCanUse request.


Another interesting point is that, when "spam-clicking" the button in a place where it has a large delay, such as with the camera angled toward many objects/light probes, it will not fire at all until the clicking stops--at which point it will fire once. This leads me to believe some sort of buffering is occurring but it is not being handled quick enough. But again, the concern is why this same system strain is present with nearly no objects being drawn.

Last edited by Ameranth; 03/05/18 04:39 AM.
Joined: Nov 2017
L
member
Offline
member
L
Joined: Nov 2017
How certain are you that the delay is before the
CharacterItemEvent(_Char, _Item, "TESTTEST")
comes in and not between
PlayEffect(_Item, "AMER_RS3_FX_ButtonPress")
and the effect actually being played?

Joined: Dec 2016
Location: United States
member
OP Offline
member
Joined: Dec 2016
Location: United States
Hi Ilya! Thanks for the reply smile

I am fairly certain for a couple of reasons, as if it were the case that it was merely a delay between the effect call and the effect actually playing:
- There would be one effect played for each click of the object, yet this is not the case. As I mentioned earlier, in the worst of circumstances, I can click on the button however many times I wish and the effect will only play one time--after I have stopped clicking.
- osirislog only records one handling of the event "TESTTEST" for each effect I see, though I have clicked on the object many more times.

Joined: Nov 2017
L
member
Offline
member
L
Joined: Nov 2017
Well that's funny.
It's kind of a long shot, but could you post a chunk of Osiris log where you click the thing several times?

Maybe two, one with lag and one without?

Joined: Dec 2016
Location: United States
member
OP Offline
member
Joined: Dec 2016
Location: United States
Here is a log with delay (In this test my button is near many objects, and the camera is turned in a direction that draws many of them): Pastebin

It actually revealed one very interesting point--that there are many more CanUseItem events being handled than CharacterItemEvents. In fact, many CanUseItem handlings are not followed by any "UsedItem" events whatsoever. I gathered that these were all of my clicks that were "missed" so I tested with a PROC hook out of _CRIME_CrimeTriggers' ProcProcessUseOfItem(); right after the RequestProcessed() call.

The result was that the button did play the effect more regularly, but clicks were still missed. Also, in-game, the button was still delayed (and many clicks missed), even in areas with almost no objects nearby. This suggests that "missed" clicks are not firing a CanUseItem event at all.


Here is a log with almost no delay (In this test my button is near many objects, but the camera is turned in a direction that does not draw many of them): Pastebin

In this case, it seems that every CanUseItem event is followed by the family of "UsedItem" events, as well as the CharacterItemEvent.

Last edited by Ameranth; 04/05/18 01:10 AM.
Joined: Oct 2008
A
ALF Offline
journeyman
Offline
journeyman
A
Joined: Oct 2008
Can you send your mod with some repro steps to supportdos2@larian.com ? It looks like the item is still considered as "in use" when the requests are being processed.

Joined: Dec 2016
Location: United States
member
OP Offline
member
Joined: Dec 2016
Location: United States
I was hoping to show my work to you all soon, but it seems this problem has called for an early edition :P

Anyway, I have sent a condensed version (because the full mod is very large) that demonstrates the problem; I hope you can find a solution!


Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5