Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
Joined: Nov 2017
S
Simzzz Offline OP
stranger
OP Offline
stranger
S
Joined: Nov 2017
Can anyone tell me where or how the 'Proc' functions are defined? For instance "Proc_HomesteadTeleportAfterMirror"

I searched all the scripts and it only appears in a single script where it's being called.

Are these 'proc' functions hardcoded into the engine? I'm a bit confused about how they work...

Joined: Nov 2017
S
Simzzz Offline OP
stranger
OP Offline
stranger
S
Joined: Nov 2017
nevermind. I think I figured it out (maybe)

Looks like it defines the function here:

PROC
Proc_HomesteadTeleportAfterMirror((CHARACTERGUID)_Player,(ITEMGUID)_Mirror,(TRIGGERGUID)_Trigger)
AND
_Trigger!=NULL_00000000-0000-0000-0000-000000000000
THEN
TeleportTo(_Player,_Trigger,"",0);

PROC
Proc_HomesteadTeleportAfterMirror((CHARACTERGUID)_Player,(ITEMGUID)_Mirror,(TRIGGERGUID)_Trigger)
AND
_Trigger==NULL_00000000-0000-0000-0000-000000000000
THEN
TeleportTo(_Player,_Mirror,"",0);


So I'm assuming (what appears to be casting in other languages) is defining the parameters.

So it might look more like this in other languages:
Proc_HomesteadTeleportAfterMirror(CHARACTERGUID _Player,ITEMGUID _Mirror,TRIGGERGUID _Trigger){

If(_Trigger == null){
TeleportTo(_Player,_Mirror,"",0);
}else{
TeleportTo(_Player,_Trigger,"",0);
}

}



Then it gets called here:
IF
CharacterCreationFinished(_Player)
AND
DB_Illusionist(_Player,_Mirror)
AND
GetVarObject(_Mirror,"PlayerPositionAfterCreation",_Trigger)
THEN
NOT DB_Illusionist(_Player,_Mirror);
Proc_HomesteadTeleportAfterMirror(_Player,_Mirror,(TRIGGERGUID)_Trigger);




Assuming I'm interpreting this correctly... Correct me if I'm wrong please

Last edited by Simzzz; 19/11/17 01:47 PM.
Joined: Oct 2017
Location: NH, USA
R
apprentice
Offline
apprentice
R
Joined: Oct 2017
Location: NH, USA
So far, so good. In your code scripts, they utilize 'AND' withing the PROC definition to, in other languages, overload the same PROC, as you have found out. The same thing applies for queries.


Projects: Tomb of Horrors: Tomb of Horrors
Joined: Dec 2013
old hand
Offline
old hand
Joined: Dec 2013
More precisely the logic would be written as follows:

Code
If(_Trigger != null){
  TeleportTo(_Player,_Trigger,"",0);
}

if (_Trigger == null){
  TeleportTo(_Player,_Mirror,"",0);
}


Now I know that the results would ultimately be the same between the two ways of writing it, but I think it's important to write it out the way that Osiris actually executes so that you don't get caught with some subtle problems in the future. You had two things a little off that could be highlighted.

First, your condition was reversed. The check for non-null occurs first and the check for null occurs second.

Secondly, the second PROC frame is not an "else". Both frames are going to get executed every time. Osiris will not skip the second frame of an identically named PROC just because the first check succeeded. It just so happens in this case that both PROC frames cannot be true at the same time, but that may not be the case in other procedures. In fact, Larian makes pretty frequent use of identically named PROCs where they expect both to execute but stagger them for different reasons related to timing or acting on some output from the previous frame.



DOS2 Mods: Happily Emmie After and The Noisy Crypt

Steam Workshop
Nexus Mods
Joined: Nov 2017
S
Simzzz Offline OP
stranger
OP Offline
stranger
S
Joined: Nov 2017
Originally Posted by Windemere
More precisely the logic would be written as follows:

Code
If(_Trigger != null){
  TeleportTo(_Player,_Trigger,"",0);
}

if (_Trigger == null){
  TeleportTo(_Player,_Mirror,"",0);
}


Now I know that the results would ultimately be the same between the two ways of writing it, but I think it's important to write it out the way that Osiris actually executes so that you don't get caught with some subtle problems in the future. You had two things a little off that could be highlighted.

First, your condition was reversed. The check for non-null occurs first and the check for null occurs second.



Thanks for the clarification, but I was just quickly explaining that I understood it was a declaration. I wasn't really trying to be precise with the code.

Originally Posted by Windemere

Secondly, the second PROC frame is not an "else". Both frames are going to get executed every time. Osiris will not skip the second frame of an identically named PROC just because the first check succeeded. It just so happens in this case that both PROC frames cannot be true at the same time, but that may not be the case in other procedures. In fact, Larian makes pretty frequent use of identically named PROCs where they expect both to execute but stagger them for different reasons related to timing or acting on some output from the previous frame.


That is very interesting. I thought it would act more like an overloaded method, than executing both. That is very useful information. Thanks


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