Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetPlayerProjectile causing NPCs/Creatures to be unable to use target spells until the game is restarted. #238

Open
HochmeisterRowan opened this issue Dec 21, 2024 · 6 comments

Comments

@HochmeisterRowan
Copy link

HochmeisterRowan commented Dec 21, 2024

When used 3 times in row, NPCs and Creatures become unable to use target based spells until the game is closed and reopened.

Tested as part of a loop for possessing multiple projectiles and doing single spell casts (both cases casting flare(s) from an activator), the script below is for the latter.

On-touch and On-self spells are unaffected.
Below is the script used for testing.

Edit: Forgot to mention, using xOBSE 22.11 (also tested using 21.5.7, since that is what was originally installed). No mods installed except the .esp used for testing.
It consists of the script below, an "onself" spell for triggering the effect, an interior cell and 3 activators.

SCN PTESTcastfunction

ref Spellref
ref Casterref
ref Targetref
ref CasterSourceref
ref PTestProjectileRef
	
Begin ScriptEffectStart

    ;Reference to spell caster
    set Spellref to GetSelf

    ;Reference to spell activator
    set Casterref to PTestCaster01

    ;Reference to caster target
    set Targetref to PTestTarget01

    ;Reference to spell caster origin object
    set CasterSourceref to PTestSource01
    
    Casterref.MoveTo Spellref 0,-15,95
    Targetref.MoveTo Spellref 0,-35,95
    
    Casterref.Cast StandardFireDamageTarget1Novice Targetref
    
    Casterref.MoveTo CasterSourceref 5,5,5
    Targetref.MoveTo CasterSourceref -5,-5,0
	
    ;Test Set projectile Ownership

    Set PTestProjectileRef to (GetFirstRef 34 1)

    ;Null check
    if PTestProjectileRef
        if (PTestProjectileRef.GetProjectileType == 1) && (PTestProjectileRef.GetProjectileSource == PTestCaster01)
            PTestProjectileRef.SetPlayerProjectile
        endif
    endif
	
End
@llde
Copy link
Owner

llde commented Dec 23, 2024

Could you make an esp with reproducible test case ?
The spell cast is triggered by script or by combat AI?

@HochmeisterRowan
Copy link
Author

HochmeisterRowan commented Dec 24, 2024

I've got an esp prepared, I'll attach it in a .zip
Test_Projectile_Ownership.zip

The target spells that stop working should be triggered by combat ai.
As it stands, using "setplayerprotectile" 3 times causes the bug. The count persists when loading an earlier save.
For example: Using the above script once -> loading prior save -> use the script again -> load earlier save -> use script a third time -> combat ai can no longer use target based spells.
So far I've only found closing and reopening the game clears the problem.

Edit: if you're referring to the script above, then that is triggered using a custom script effect spell, on-self, cast manually.
The spell has the editor ID "PTestProjOwn" in the esp.

@llde
Copy link
Owner

llde commented Dec 25, 2024

Wait, do this involve ALL target spells? Or just the ones involved in that projectile type?

@HochmeisterRowan
Copy link
Author

It goes for all target spells that combat ai tries to use.
Outside of Vindasel is a good spot to test since you get Daedra and generic conjurers spawning there.

@llde
Copy link
Owner

llde commented Dec 28, 2024

Hi @HochmeisterRowan, I'm checking what the game is doing with caster and projectiles, as nothing seems visibly wrong within the code of the function itself. Code is quite interwined, and decoding it is not straightforward at all.
To better understanding what's going wrong I'0d like you to do some tests:

  1. Check by moving the SetPlayerProjectile inside a quest script in GameMode
  2. Check by using SetProjectileSource with another NPC (different from player and the caster)
  3. If the projectile is still available after impact, try to switch back to the original caster.
  4. Check whetever there are differences in different projectile types (ball,fog,bolt)

@HochmeisterRowan
Copy link
Author

Hi @llde

I have (hopefully) done the tests as you've asked.

1-Issue still occurs when running SetPlayerProtectile inside GameMode in a quest script.

2-Using SetProjectileSource with another NPC (in this case, Amusei and Prior Maborei's paint horse), the issue does not occur.
Using SetProjectileSource with the player ref, the issue does occur.

3-Switching back to the original caster after impact made no difference, issue still occured.

4- I found 1 difference with ball and fog vs bolt.
For ball and fog projectiles, you need to set the projectile source as the player 3 times to cause the problem.
But, for bolt type projectiles, you need to change the projectile source to the player 6 times to recreate the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants