Jump to content

can ai give to player character?


Recommended Posts

Do you want the game AI to take over the player character?

 

That is possible with this:

Game.SetPlayerAIDriven()

More info:

 

https://www.creationkit.com/fallout4/index.php?title=SetPlayerAIDriven_-_Game

thanks for reply,

anyway i have test it using key trigger

this is the script :

 

Scriptname HotKeyScript extends Quest

Event OnInit()

RegisterForKey(161) ;R-Shift

RegisterForKey(163) ;R-Ctrl

RegisterForKey(165) ;R-Alt

endEvent

 

Event OnKeyDown(Int KeyCode)

If KeyCode == 161

Game.GivePlayerCaps(100)

Endif

If KeyCode == 163

Game.SetPlayerAIDriven()

endif

If KeyCode == 165

Game.SetPlayerAIDriven(false)

endif

endEvent

 

and the player still do nothing?, even in combat,

any clue or guide or missing step?,

anyway the give 100 caps is working normal

Link to comment
Share on other sites

SetPlayerAIDriven() won't give you anything, it just tells Game, that your player character should from now on adhere to AI packages. Before you'll be able to force player do somkething, you need to take control from him. For that you must create an InputEnableLayer on which DisablePlayerControls() would be called. This should be created in something... persistent, such as Quest Script. Thus it should look something like this:

Scriptname HotKeyScript extends Quest

InputEnableLayer Property ielLayer01 auto Hidden

Event OnQuestInit()
    RegisterForKey(161)
    RegisterForKey(163)
    RegisterForKey(165)
endEvent

Event OnKeyDown(Int KeyCode)
    If KeyCode == 161
        Game.GivePlayerCaps(100)
    endif

    If KeyCode == 163
        DisableControls()
    endif

    If KeyCode == 165
        EnableControls()
    endif
endEvent

Function DisableControls()
    ielLayer01 = InputEnableLayer.Create()
    ielLayer01.DisablePlayerControls(true, true, true, true, true, true, true, true, true, true, true)
    Game.SetPlayerAIDriven()
endfunction

Function EnableControls()
    ielLayer01.EnablePlayerControls()
    ielLayer01.Delete()
    ielLayer01 = NONE   
    Game.SetPlayerAIDriven(false)
endfunction

And if you want player to run some packages, participate in a scene - well, now you can use him. Don't forget to call EvaluatePackage() on player when scene starts, just to make sure he instantly starts running that.

 

 

 

 

Link to comment
Share on other sites

SetPlayerAIDriven() won't give you anything, it just tells Game, that your player character should from now on adhere to AI packages. Before you'll be able to force player do somkething, you need to take control from him. For that you must create an InputEnableLayer on which DisablePlayerControls() would be called. This should be created in something... persistent, such as Quest Script. Thus it should look something like this:

Scriptname HotKeyScript extends Quest

InputEnableLayer Property ielLayer01 auto Hidden

Event OnQuestInit()
    RegisterForKey(161)
    RegisterForKey(163)
    RegisterForKey(165)
endEvent

Event OnKeyDown(Int KeyCode)
    If KeyCode == 161
        Game.GivePlayerCaps(100)
    endif

    If KeyCode == 163
        DisableControls()
    endif

    If KeyCode == 165
        EnableControls()
    endif
endEvent

Function DisableControls()
    ielLayer01 = InputEnableLayer.Create()
    ielLayer01.DisablePlayerControls(true, true, true, true, true, true, true, true, true, true, true)
    Game.SetPlayerAIDriven()
endfunction

Function EnableControls()
    ielLayer01.EnablePlayerControls()
    ielLayer01.Delete()
    ielLayer01 = NONE   
    Game.SetPlayerAIDriven(false)
endfunction

And if you want player to run some packages, participate in a scene - well, now you can use him. Don't forget to call EvaluatePackage() on player when scene starts, just to make sure he instantly starts running that.

hi, thanks a lot for reply,

in simple way,

if player in combat mode,

the player control will taken by AI,

then the player will do auto combat until all enemies died,

now have i try your script, and it do nothing,

maybe because i not put the packages before it,

any clue or links where i put "combat packages" into player?

once again thanks for reply.

Link to comment
Share on other sites

 

hi, thanks a lot for reply,

in simple way,

if player in combat mode,

the player control will taken by AI,

then the player will do auto combat until all enemies died,

now have i try your script, and it do nothing,

maybe because i not put the packages before it,

any clue or links where i put "combat packages" into player?

once again thanks for reply.

 

 

Yes. Turning off user inputs isn't going to cause the character to do anything.

 

You do need to apply Packages to let the game know what you want them to do (just like any other NPC). There are multiple ways to do that. And unfortunately, all of them are cumbersome to work with (lots of setup, difficult to determine why they fail when they do, many ways for one Package to conflict with another). Probably the most reliable method is to use a Quest with a Scene that applies the Package you want to a Reference Alias (having fun yet?). You will need to ensure that the Quest is running, populate the Reference Alias and then start the Scene after SetPlayerAIDriven to True.

 

Another possibility that might be amusing if it works (haven't tested) is this:

Game.SetPlayerAIDriven()
PlayerRef.StartFrenzyAttack()

https://www.creationkit.com/fallout4/index.php?title=StartFrenzyAttack_-_Actor

 

Or, you can make more targeted calls that might work with player in AI control:

PlayerRef.StartCombat(AnEnemyActor)

https://www.creationkit.com/fallout4/index.php?title=StartCombat_-_Actor

Link to comment
Share on other sites

 

Another possibility that might be amusing if it works (haven't tested) is this:
Game.SetPlayerAIDriven()
PlayerRef.StartFrenzyAttack()

https://www.creationkit.com/fallout4/index.php?title=StartFrenzyAttack_-_Actor

 

Or, you can make more targeted calls that might work with player in AI control:

PlayerRef.StartCombat(AnEnemyActor)

https://www.creationkit.com/fallout4/index.php?title=StartCombat_-_Actor

 

hi, thanks for reply,

i have test the frenzy formula,

and it not work,

i will do some research about it today

Link to comment
Share on other sites

In my opinion, the easiest and the most reliable way to force fight is to add NPCs to faction which is "Enemy" to PlayerFaction. Add with a script, 'f course.
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...