[HELP] w2beh variables, and "thePlayer.SetBehaviorVariable" usage

+
Hello,
While looking for a way to enhance my next playthrough of the witcher 2 I found this mod: https://www.nexusmods.com/witcher2/mods/724?tab=description

However, it has a couple of problems:
1- horizontal and vertical positioning of the camera does not work while playing with a controller
2- the camera is fixed, I would like for it to automatically change, for example, while in combat

EDIT:
Well, turns out that mod is just some functions taken from another bigger mod, Rise of the Sword. Using that mod's camera_graph.w2beh makes the transition between right and left shoulder smooth insead of skipping frome one to the other.
And it solves the second problem by having a different, automatic, combat camera.

It still does not allow X and Z changes while using a controller, how could that be achieved?
 
Last edited:
So, it looks like I have solved the problem of the X and Z axis not working with the controller!!

It is done via editing the w2beh file, which is somewhat of a nightmare, the bug (rather, missing functionality) was hidden two levels deep inside a node...

Now, I would like to use the sprinting function from Rise of the Sword, and possibly fix it (Because as it is now you can't stop geralt once you start sprinting), can anyone help?

EDIT:
Also, does anyone know how to add variables? presumably to a graph, because this mod defines at least two new variables related to the camera (they are not available when editing the vanilla w2beh, so I assume they are inside the modded one)

I have found a redkit manual that has a single mention of the word "variable" under the section "Facts DB", I have no idea where that is, if it even exists, but anyway the mod does not include any db files, so I don't think that is there.
 
Last edited:
I understand that I am years late to the party, but as long as this is not breaking any rules I think I will post updates, maybe it will be some sort of log of this project.

First, the author of the Rise of The Sword mod did an incredible job, literally, how did he manage all of this without documentation is beyond my understanding (as is the mod itself lol)

Now, for the sprint "bug", I might post videos later of the behaviour to better illustrate it.

I think this is an interesting block of code (I selected javascript as it seems to have a similar syntax):
JavaScript:
    timer function ExperiencedGeralt_Sprinting( timeDelta : float )
    {
        if ( theGame.GetGameInputValue('GI_Sprint') > 0.5f ) // Sprint Key
        {
            ExperiencedGeralt_SprintingAction();
        }
    }
    function ExperiencedGeralt_SprintingAction()
    {
        if ( thePlayer.ExperiencedGeralt_IsSprinting )
            return;

        if ( theGame.GetGameInputValue('GI_AxisLeftY') < 0.5f
          || theGame.GetGameInputValue('GI_UseItem') > 0.5f
          || theGame.GetGameInputValue('GI_UseAbility') > 0.5f
          || theGame.GetGameInputValue('GI_Hotkey05') > 0.5f
          || theGame.GetGameInputValue('GI_Hotkey06') > 0.5f
          || theGame.GetGameInputValue('GI_Hotkey07') > 0.5f
          || theGame.GetGameInputValue('GI_Hotkey08') > 0.5f
          || theGame.GetGameInputValue('GI_Hotkey09') > 0.5f
          || thePlayer.ExperiencedGeralt_IsDodgeing )
            return;

        if ( theGame.IsBlackscreen()
          || thePlayer.ExperiencedGeralt_InSceneCheck()
          || !theHud.CanShowMainMenu()
          || !thePlayer.IsManualControl()
          || !parent.isMovable
          || parent.ExperiencedGeralt_BlockingHitDisallowDodge
          || !thePlayer.CanPlayHitAnim( HitParams() )
          || thePlayer.IsOverweight() )
            return;

        if ( !thePlayer.isNotGeralt || thePlayer.IsAssasinReplacer() )
        {
            PlayerCombatSprint(PCH_Sprint);
        }
    }

If I understand this correctly (I doubt it) when receiving, for example, GI_Hotkey06, geralt shoudl stop sprinting. It does not work.
Or is the function just to start the sprint?

There are two cases for sprinting, while not in combat (case A) and in combat (case B)

Case A:
You can turn (control geralt direction)
Only way I found to stop the sprint is by using the keybind added by mod to make geralt raise his fists (for throwing punches)

Case B:
If you enter the sprinting state while having fists raised you can turn, if you do it with a sword equipped you cannot
Either way the only way to stop is by dodgeing, pressing the spacebar.

It looks like the sprinting is only interrupted by things added or modified by the mod?

I don't know, I understand very little at this point, but I think I'll keep digging. Any help is still welcome.
 
Last edited:
So, I have solved most of the problems I had.

I have a new question now: how do I change a variable in a Behavior Tree?

For example, the camera mod adds the variable "camera_axis_X" to "camera_graph.w2beh", I can set it via script with:

theCamera.SetBehaviorVariable( 'camera_axis_X' , float );

Then I personally added a new variable to "combat_geralt.w2beh" and "exploration.w2beh" which I can set using:

thePlayer.SetBehaviorVariable( 'SprintCombatSpeed' , float );
thePlayer.SetBehaviorVariable( 'SprintExploreSpeed' , float );


this method however does not work for a new variable I added to door.w2beh, how do I point to it?
I tried using "thePlayer", but it does not seem to work...
 
Last edited:
Top Bottom