Jump to content

How to prevent saber staff NPCs from using fast style?


Go to solution Solved by RebornKyle,

Recommended Posts

Posted

I've noticed this bug has been unsolved from various forums I've looked at. It seems to only happen when the player wields the same weapon type too. Tried to fix it without diving into the code, through npc and sab files, but that doesn't work, so I'm 99% sure its a hardcode issue.

The problem with that is the references are too vast and complex for all the different saber styles, especially ones with restrictions like the dual and staff, to sift through.

Does anyone have experience in solving this issue, or know where to start looking at least?

Droidy365 likes this
  • RebornKyle changed the title to How to prevent saber staff NPCs from using fast style?
Posted

What exactly is the bug? Do NPCs sometimes turn off one blade to use fast style, or do they use fast style with both blades extended?

Posted
18 hours ago, mrwonko said:

What exactly is the bug? Do NPCs sometimes turn off one blade to use fast style, or do they use fast style with both blades extended?

Basically when you as the player wield a saber staff, other NPCs who wield saber staffs will start out using the expected stance, but then for whatever reason changes to fast style, with both blades extended. This effect lasts until they die, I think.

I also think that dual wielding (2 separate single blades) is affected by this, same method as above but just with dual wielding stance instead, they'll start using fast stance with both blades active. I don't use that stance much though so I can only say I've seen it, not that I regularly encounter it.

From the 4 forums I saw on the topic, it might affect OpenJK users. I myself use JAEnhanced, so I can confirm that it does happen with at least one OpenJK mod.

No idea why this happens, because it only occurs when the player is also using those styles. Single lightsaber users would not encounter this bug, the NPC correctly uses all available styles to it when this happens.

So to sum, staff players will encounter bugged staff NPCs, dual players may encounter bugged dual NPCs, single players unaffected.

Posted

There's a hardcode in the game code that sets the NPC's style to fast whenever they take damage.

It's primarily seen with modded assets since the function that handles saber style logic has a few hard code cases with the base npcs. I don't have the code in front of me right now since I'm currently at work, but this was a problem with Galactic Legacy before it was corrected.

Droidy365 likes this
Posted
7 hours ago, Linken said:

There's a hardcode in the game code that sets the NPC's style to fast whenever they take damage.

It's primarily seen with modded assets since the function that handles saber style logic has a few hard code cases with the base npcs. I don't have the code in front of me right now since I'm currently at work, but this was a problem with Galactic Legacy before it was corrected.

I see, thank you Linken. Do you remember where the problem was in the hardcode? Or did you have to write new code to correct it? Perfectly fine for doing either, but as we all know the code is old and a spaghetti filled mess, any place to start is a great one. BTW, kudos for fixing so much with your mod too, its very impressive how well it plays, and how well everything is integrated all together, from the JAO mod inside to the new missions recently created.

Posted
On 8/28/2024 at 11:03 PM, RebornKyle said:

I see, thank you Linken. Do you remember where the problem was in the hardcode? Or did you have to write new code to correct it? Perfectly fine for doing either, but as we all know the code is old and a spaghetti filled mess, any place to start is a great one. BTW, kudos for fixing so much with your mod too, its very impressive how well it plays, and how well everything is integrated all together, from the JAO mod inside to the new missions recently created.

I think it's here on line 5336, of course it's been FOREVER since I did this.

I can't for the life of me remember if doing Q_irand(SS_FAST, SS_TAVION) fixed it, even for dual/staff wielders, but it's a good place to start, probably even in the function itself.

image.png.5b002aa2fd385cc7c2d0599a16000efc.png

Posted
20 hours ago, Linken said:

I think it's here on line 5336, of course it's been FOREVER since I did this.

I can't for the life of me remember if doing Q_irand(SS_FAST, SS_TAVION) fixed it, even for dual/staff wielders, but it's a good place to start, probably even in the function itself.

image.png.5b002aa2fd385cc7c2d0599a16000efc.png

Unfortunately the replacement didn't seem to do it. I replaced the SS_FAST flag with the Q_irand(SS_FAST, SS_TAVION), results were the same. When I have more time I'll look a little further at the function call itself

Posted

I looked further at the function, the first set of statements set the styles of specific NPC types, that's understandable, but unlikely to be the cause, as both allies and enemies are affected by this, and the code only affects single style NPC types like the cultists or certain ranks. The rest of it I'm not too sure about, it seems like edge cases in case of switching past the enumerated types of styles, and a final block for debugging. That part could be the issue, but I don't see an easy fix for that in this file. I'm afraid I don't know where to go further.

 

Droidy365 likes this
Posted

I twiddled my thumbs for way too long before I realized I can just look at the code for SWGL on GitHub and see what the differences between mine and @Linken's are. I think I've effectively ruled out the function changes for Jedi_AdjustSaberAnimLevel. Doing combinations of, and also just changing them all to SWGL version, yielded the same results no matter what. I'll keep looking further and compare the two files later, to see if something else may be the key.

  • 2 weeks later...
Posted

Ok so, I tested it extensively in-game as I had no luck with figuring out a solution (yet). Here are my findings:

  • Single saber NPC's ARE AFFECTED. I figured this out by spawning in alora (from hoth3, not taspir2) who only has one saber style, medium, but who is not hardcoded like the cultists to follow one particular or multiple saber styles, while I used a single saber. She went to fast style! However she did correctly go back to medium every time, even when I only used a set medium style back at her. So its temporary with single sabers, but it still does happen.
  • The only NPC immune to this effect is tavion_scepter. Hers is a great indicator as to the problem, as her scepter is not a saber, but a different weapon itself. Thus the problem may lie exclusively with the way the saber weapon is handled.
  • There does not seem to be a clear way as to what actually triggers this. I thought that damage alone might be the cause, but I hovered above NPCs that were engaging me, and I did not damage them in any way once spawned nor could they attack me. After a random amount of time, they started using fast style.
  • Damage DOES however produce immediate results, much faster than waiting for the NPC to switch. Not sure then if its damage itself or some code being used with the damage that other properties of saber combat use as well.
  • Staggering them with force push or gently brushing them with saber (not attacking), also triggers it pretty consistently.
  • Switching your style with either dual or staff (fast with dual, medium with staff) can cause the NPC to switch BACK to the appropriate style they should be using. So it seems like the NPC is reading what style we're using and incorrectly switching, when they shouldn't ever have that option to.  They will switch back to the buggy fast style if your style matches again however.
  • It is exclusively based on what style the player is using that affects the NPC. The saber type itself does not matter. For instance, I glitched my player to have the staff style while using a single saber. When using the staff stance, the NPC became bugged. When switching to any other style, the NPC switched back to staff style.

To go over the specifics of the behavior the NPC exhibits while bugged:

  • Their movement, attacks, saber lock anims, recoveries, taunts, and pretty much everything exhibit the behavior of what should be an NPC using a single saber with fast style.
  • The ONLY thing not affected, is their neutral stance with sabers out while not moving at all. They display the correct stance every time.

With all of this in mind, I'm hoping someone can figure out where the issue may lie without me having to dig, but in the meantime I'll continue to do so when I can.🙂

Posted

Apparently it affects the game even with nothing but the base assets. I stored a backup in an entirely different location, deleted all of Jedi Academy files, then uninstalled it, re-downloaded it, and booted it up only to encounter the same glitch when doing it again. I've now put my backup back in.

Unless I'm doing a clean install wrong here, or that somehow the hardware I'm using isn't up to snuff to run JA (lol), then something seems to be wrong with the steam version itself. I cannot recall this bug ever appearing when I had it on disc many years ago as a youngin, and I loved using the staff style too. RIP my brain and any hope of figuring this out on my own.

Posted

@Linken I went digging through the commits you've made to SWGL, and found two relevant ones to my problem. One was the aforementioned AI_Jedi fixes. The other file that both commits touched on was NPC_reactions. These lines were the new ones added by you and your team:

 

if (self->client->ps.saberStylesKnown & (1 << SS_FAST))
{
  self->client->ps.saberAnimLevel = SS_FAST;//next attack must be a quick attack
}
if (self->client->ps.saber[0].type == SABER_STAFF)
{
  self->client->ps.saberAnimLevel = SS_STAFF;
}

Combining these fixes into my solution, I am happy to report a partial success. Single and Dual-wielding NPCs are no longer affected! However staff users still are. Linken, is there any chance you may know the other part(s) to the solution you found? Perhaps mixed in with a different commit?

Everyone, see my below post. Full credit goes to @Linkenfor the fix and help!

Posted

Well everyone, happy to say that not only does Linken's code work, but I'm an idiot.

Somehow between adding the partial fix and the full fix, I had managed to switch my directories. I was adding the newly compiled code to my backup😅😅😅

So yeah I never saw the fix in action because I was still using the partial fix. Amazing! Ha....

Despite wasting hours trying to debug it, at least now I can say that this is the solution to fix the bug I've described.

I'd recommend to anyone developing OpenJK to add this patch immediately though. I found it occurring not only in OpenJK base, but Jedi Academy umodified. It's a serious immersion breaker for dual and staff users.

Thank you @Linken for the assistance!

EDIT: ONE MORE THING! The fix Linken described in AI_Jedi is slightly different than the one above. You HAVE to add SS_STAFF as the end range for Jedi_AdjustSaberAnim. Otherwise the glitch persists. Linken did do this in the first commit he made on the bug, so that's how I knew about it.

  • Solution
Posted

One more minor update (hopefully the last one)

NPCs still had a tendency to switch to fast, albeit very briefly, if you were a staff user and they were a staff user, with the above fixes. As well, for whatever reason, the rebornmasterstaff NPC was still completely afflicted, he was the only one.

But, the solutions are fairly simple that I found.

In NPC_reactions, switch the ordering of the if statements and connect their execution through else if, like so:

 

if (self->client->ps.saber[0].type == SABER_STAFF)
{
  self->client->ps.saberAnimLevel = SS_STAFF;
}
else if (self->client->ps.saberStylesKnown & (1 << SS_FAST))
{
  self->client->ps.saberAnimLevel = SS_FAST;//next attack must be a quick attack
}

And in AI_Jedi, add this if statement after the client check in Jedi_AdjustSaberAnim, to perform an immediate check and return if they have the staff saber type:

 

if (self->client->ps.saber[0].type == SABER_STAFF)
{
  self->client->ps.saberAnimLevel = SS_STAFF;
  return;
}

Now having tested all the base given NPCs (and JK2 ones), I can safely say the glitch does not rear its head anymore, with any NPC. That is with the base NPCs though, so I'm not entirely sure how custom created NPCs fair, but I feel as long as they use _humanoid animations its very likely they'll be ok too.

Linken likes this

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...