Bug #2172: Saenus Lusius doesn't stop attacking

Everything about development and the OpenMW source code.
Post Reply
dteviot
Posts: 144
Joined: 17 Dec 2014, 20:29

Bug #2172: Saenus Lusius doesn't stop attacking

Post by dteviot » 06 Apr 2015, 07:05

https://bugs.openmw.org/issues/2172

I'm looking into this.
According to Scripting for Dummies
Another caution regarding StopCombat is that it stops combat for all actors involved, other than the player.
But, when I look at our implementation of the StopCombat command, it only applies to the Actor it's invoked against.

Doing some Googling to confirm Scripting for Dummies, I get mixed messages. Some claim all actors, others just one. Does anyone know the correct answer?

Thanks.

User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Bug #2172: Saenus Lusius doesn't stop attacking

Post by scrawl » 06 Apr 2015, 12:04

I did a bunch of research on this two months ago and came to the conclusion that a complete rewrite of the combat tracking code is required. I don't remember all the details, but the basic problem is that combat is handled as state when it shouldn't be in most cases. I was planning to tackle this once I've analyzed how combat is stored in the vanilla save files. That should give some more insight.

silentthief
Posts: 422
Joined: 18 Apr 2013, 01:20
Location: Currently traversing the Ascadian Isles

Re: Bug #2172: Saenus Lusius doesn't stop attacking

Post by silentthief » 08 Apr 2015, 07:54

Does anyone know the correct answer? (stopcombat)

The target the script is run on, or the target given will stop combat. Only that actor. Any other combatant can and will still wail on the actor when they stop combat. Also, this does not affect any "followers" - if an actor is AIfollowing another actor and you stop combat on the leader, the follower will still run in and defend the leader

This was also used to "trick" NPCs into having thier weapon drawn, with startcombat and stopcombat script being run sequentially - as the first action in a startcombat action sequence is mot likely to draw weapon or put up your dukes. But I seem to remember that this had issues as well (actor would draw weapon but not defend themselves?)

I think the combat code should clear a status, but should still allow for combat to occur normally (like if player attacks the NPC). Running this constantly would of course keep someone from ever attacking.

ST
EDIT - for typos and clarity
"You like to dance close to the fire, don't you?."

dteviot
Posts: 144
Joined: 17 Dec 2014, 20:29

Re: Bug #2172: Saenus Lusius doesn't stop attacking

Post by dteviot » 07 May 2015, 03:50

@scrawl
scrawl wrote:I did a bunch of research on this two months ago and came to the conclusion that a complete rewrite of the combat tracking code is required. I don't remember all the details, but the basic problem is that combat is handled as state when it shouldn't be in most cases. I was planning to tackle this once I've analyzed how combat is stored in the vanilla save files. That should give some more insight.
You've probably already discovered this, but just in case you haven't.

Some assorted notes on how combat may be recorded in save game file.

Short form:
I think the TGTN subrecord in current CELL tells you when someone is fighting, and who they're fighting.
There are also TGTN subrecords in the REFR record with a name of “PlayerSaveGame”.


More notes.

Was using the save game from the FrostMoth Smugglers (Bug 2172). Seeing what changed in save game before and during combat.

Noticed the following:

1. Does not appear to be stored with the NPCC record.
2. The AI_F record isn't just a string, there's 6 bytes that change in each save file.


REFR record with name of “PlayerSaveGame” may be important.
Have noticed that when combat started, the record acquired a TGTN sub record of “gualtierus spurius”. (It also had a FGTN sub record of “saenus lusius”)
Speculation:
“FGTN” == Following?
“TGTN” == targeting?

Also note,
WNAM changed from “almsivi intervention enchantmen” to “calm humanoid” (I did cast “calm humanoid” to stop the battle, but once it wore off, combat restarted.)
XNAM was “sc_almsiviintervention”. XNAM and YNAM sub records were missing.
I think WNAM may be “Weapon name”, the name of the weapon (or spell or magical artefact currently selected.)

CELL record “Solstheim, Gandrung Caverns” looks to be important as well.
When combat starts, the entry for “gualtierus spurius” gets the following subrecords that with a value of “saenus lusius”
CSTN
LSTN
CSHN
TGTN <=== note, same subrecord as appears in REFR record.
Also, a second “TGTN” record appears with a value of “PlayerSaveGame”

Also in CELL, the entry for “saenus lusius” gains the following sub records, with value of “gualtierus spurius”
CSTN
TGTN

Now have look at changes to save game file after I use “command humanoid” from aryon's glove to make Fargoth my follower and start a fight by attacking “eldafire”

The CELL entry for “Seyda Neen”
  • “elda fire” gains the following CSHN & TGTN for “PlayerSaveGame” + TGTN for “fargoth”.
  • “fargoth” gains CSTN, CSHN & TGTN for “eldafire”, + TGTN for “Imperial Guard00000002” + FGTN for “PlayerSaveGame”
  • “Imperial Guard00000000” gains CSTN, CSHN & TGTN for “PlayerSaveGame”
  • “Imperial Guard00000002” gains CSTN & TGTN for “PlayerSaveGame” + TGTN “fargoth”
  • “Imperial Guard00000001” gains LSTN & TGTN for “PlayerSaveGame”
Also a new REFR record is created with name “PlayerSaveGame”.
Has the following:
NAME: PlayerSaveGame
CSTN: eldafire00000000
CSHN: eldafire00000000
TGTN: eldafire00000000
TGTN: Imperial Guard00000000
TGTN: Imperial Guard00000002
FGTN: fargoth00000000
WNAM: aryongloveleft_en_unique
XNAM: aryongloveleft


Other notes:
(speculation) in NPCC record, XHLT sub record is location of item (if being worn)

User avatar
fireballsniper
Posts: 1
Joined: 07 May 2015, 10:33

Re: Bug #2172: Saenus Lusius doesn't stop attacking

Post by fireballsniper » 07 May 2015, 10:35

CSTN=Combat stance?

User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Bug #2172: Saenus Lusius doesn't stop attacking

Post by scrawl » 07 May 2015, 15:12

2. The AI_F record isn't just a string, there's 6 bytes that change in each save file.
If it changes with each save, that is most likely just uninitialized memory. I know that the format pads most strings to 16, 32 or 64 bytes (with the unused bytes usually being garbage).

Most of your observations are already in the essimporter code: XHLT is the charge (condition) of an item - integer for armor/weapons, float for lights. WNAM and XNAM are selected enchanted item / spell.
REFR is just the player record, with its structure being mostly the same as a cell ref (FRMR) for a regular NPC.
The CELL entry for “Seyda Neen”
“elda fire” gains the following CSHN & TGTN for “PlayerSaveGame” + TGTN for “fargoth”.
“fargoth” gains CSTN, CSHN & TGTN for “eldafire”, + TGTN for “Imperial Guard00000002” + FGTN for “PlayerSaveGame”
“Imperial Guard00000000” gains CSTN, CSHN & TGTN for “PlayerSaveGame”
“Imperial Guard00000002” gains CSTN & TGTN for “PlayerSaveGame” + TGTN “fargoth”
“Imperial Guard00000001” gains LSTN & TGTN for “PlayerSaveGame”

Also a new REFR record is created with name “PlayerSaveGame”.
Has the following:
NAME: PlayerSaveGame
CSTN: eldafire00000000
CSHN: eldafire00000000
TGTN: eldafire00000000
TGTN: Imperial Guard00000000
TGTN: Imperial Guard00000002
FGTN: fargoth00000000
I'm seeing a pattern here. For all NPCs that are attacking someone (CSTN/CSHN), that someone has a TGTN (being attacked by?) from that particular NPC. Looks like redundant information though.

dteviot
Posts: 144
Joined: 17 Dec 2014, 20:29

Re: Bug #2172: Saenus Lusius doesn't stop attacking

Post by dteviot » 07 May 2015, 22:29

I believe the TGTN sub record means "Is a target of this actor".
e.g. All the imperial guards aquired "PlayerSaveGame" as a TGTN record. The only character I struck was eldafire.
Still I'll see if I can confirm this by going into Arile's tavern and stealling something.

dteviot
Posts: 144
Joined: 17 Dec 2014, 20:29

Re: Bug #2172: Saenus Lusius doesn't stop attacking

Post by dteviot » 08 May 2015, 01:03

On more investigation, I think the following for the sub records in the current CELL record of a save game file.
LSTN == "is listening to me".
FGTN == "I am following this person". If you use Aryan's dominator on someone, they gain this subrecord with a value of "PlayerSaveGame".
TGTN == "is someone I will attack". (i.e. Is a target). Note, an actor can have multiple targets.
CSTN == "person I am currently attacking" or possibly "is my primary target". There is always one of these when a TGTN record is present.
CSHN == unknown. Not always present. Although does seem to be related to combat.

Experiment 1.
Went to Arrille's tavern.
Walked around so that "Tolvise Orhralen" and "hrisskar flat-foot" spoke to me. (Note, I did NOT open the conversation dialog with them.)
Afterwards, CELL record for Arrile's tavern had added a LSTN sub record with value of "PlayerSaveGame" to "Tolvise Orhralen" and "hrisskar flat-foot".

Experiment 2.
Went to Arrille's tavern.
Used Aryan's dominator on "Tolvise Orhralen"
Put myself between Arrille and Tolvise.
Stole item in front of Arrille.
(Note, I did not attack anyone, but Arrille attacked me and Tolvise attacked Arrille.)

Subrecords added to CELL record for Arrile's tavern:

NAME: arrille00000000
CSTN: PlayerSaveGame
TGTN: PlayerSaveGame
TGTN: tolvise othralen00000000

NAME: tandram andalen00000000
CSTN: PlayerSaveGame
TGTN: PlayerSaveGame
TGTN: tolvise othralen00000000

NAME: Tolvise othralen00000000
CSTN: arrille00000000
CSHN: arrille00000000
TGTN: arrille00000000
TGTN: tandram andalen00000000
TGTN: albecius colollius00000000
TGTN: elone00000000
FGTN: PlayerSaveGame

NAME: albecius colollius00000000
CSTN: PlayerSaveGame
TGTN: PlayerSaveGame
TGTN: tolvise othralen00000000

NAME: elone00000000
CSTN: PlayerSaveGame
TGTN: PlayerSaveGame
TGTN: tolvise othralen00000000

Experiment 3.
Went to Arrille's tavern.
Stole item in front of Arrille.
I did not attack anyone. Just made sure I was seen stealing an item.

NAME: arrille00000000
CSTN: PlayerSaveGame
CSHN: PlayerSaveGame
TGTN: PlayerSaveGame

NAME: tandram andalen00000000
CSTN: PlayerSaveGame
TGTN: PlayerSaveGame

NAME: tolvise othralen00000000
CSTN: PlayerSaveGame
CSHN: PlayerSaveGame
TGTN: PlayerSaveGame

NAME: albecius colollius00000000
CSTN: PlayerSaveGame
TGTN: PlayerSaveGame

NAME: elone00000000
CSTN: PlayerSaveGame
TGTN: PlayerSaveGame

NAME: hrisskar flat-foot00000000
CSTN: PlayerSaveGame
CSHN: PlayerSaveGame
TGTN: PlayerSaveGame

I'll note
1. "raflod the braggart" did NOT get any CSTN, CSHN or TGTN subrecords.
2. There were also numberous changes to the ACDT, ACSC and ACSL subrecords of these people.
3. arrille's had a LSTN record that disappeared. (speculation, could this be "listen"?)

The REFR for PlayerSaveGame got TGTN records for all the above except "raflod the braggart"

Post Reply