georgeto / gothic3sdk

An inofficial SDK for Gothic 3.
Other
28 stars 6 forks source link

AI questions #5

Closed warxander closed 1 year ago

warxander commented 1 year ago

Hi,

Is it possible to alter existing NPCs behavior or create custom AI companions for example?

If you know - could you please give a short briefing about how AI works and its most important API. (I saw comments in ge_scriptprocessingunit.h, but it seems to be incomplete for me, I didn't figure out how it works in general)

Also, if I want to sync players in multiplayer - is it even possible to do it with entities without ScriptRoutine property?

georgeto commented 1 year ago

Is it possible to alter existing NPCs behavior or create custom AI companions for example?

Yes, it is possible.

If you know - could you please give a short briefing about how AI works and its most important API. (I saw comments in ge_scriptprocessingunit.h, but it seems to be incomplete for me, I didn't figure out how it works in general)

Unfortunately I never came write more documentation for this. There would be many things to explain here, starting with how an NPC decides what he wants to do. How he then selects an interaction object and goes to it. How the interactions are scripted (this is what the comments in ge_scriptprocessingunit.h are aiming for). Do you have a specific goal in mind?

Also, if I want to sync players in multiplayer - is it even possible to do it with entities without ScriptRoutine property?

Mhm, I am wondering to what kind of entities you are referring here. Because all NPCs also have the gCScriptRoutine_PS property set. Moving entities like projectiles? Probably even easier than synchronising NPCs, since there is a lot of randomness involved in their routines.

warxander commented 1 year ago

Do you have a specific goal in mind?

Yes, I'm trying to replicate NPCs for multiplayer mod.

I tried to use both approaches.

NPCs are always trying to do their own tasks when I tried to override them through AIFullStop/SetTask. While StartPlayAnim stops working after removing gCScriptRoutine_PS property.

I also noticed than if you spawn two or more PC_Hero entities - they all will be controled by localhost. Looks like it's hardcoded or I need to disable/modify property - do you know something about it?

warxander commented 1 year ago

Ping, I would appreciate for any bit of information.

georgeto commented 1 year ago

NPCs are always trying to do their own tasks when I tried to override them through AIFullStop/SetTask.

Yeah, the reason for this is that the selection of an activity / interaction point is partly dependent on randomness and what other NPCs do. Thus syncing at this layer is likely to be quite difficult.

While StartPlayAnim stops working after removing gCScriptRoutine_PS property.

I can't say anything about it of the top of my head, after a cursory look into Entity::StartPlayAni I don't see the immediate connection to gCScriptRoutine_PS.

I also noticed than if you spawn two or more PC_Hero entities - they all will be controled by localhost. Looks like it's hardcoded or I need to disable/modify property - do you know something about it?

I haven't checked, but I expect that this is coupled to the property set gCCharacterControl_PS. Remove that from your second PC_Hero and the movements should no longer be controlled by your input.

warxander commented 1 year ago

Yeah, I tried to remove gCCharacterControl_PS - my game crashed.

Anyway, thanks a lot, I will keep researching, my project is here - https://github.com/gorn-se/gorn - any contributions are welcome ;)