Jump to content

NPC issue


icecreamassassin

Recommended Posts

So I have an NPC which enables in a spot during a quest and when the player comes back around the house they are there and the NPC approaches and talks to the player, tells them her story, then offers to buy the house or challenge to a duel for it. If you choose duel, the NPC attacks the player until one or the other drops down below around 50 health, then she ends combat and goes into conversation, her aggression is set to 0 (encase a stray hit lands on her before she reaches you for conversation) and says the duel is over, you win, blah blah. If she wins she says something different and the quest progresses accordingly. If she wins or you sell the place, you have 24 hours til the cell changes ownership (i.e. get your crap out of the house) you can also sucker punch her and kill her outright after the duel (which stops the count down and progresses the quest to a different stage)

 

This all works great except for one thing, when the duel ends, she does the win or yield topic like she should, it ends, and she then immidiately tries to initiate her initial conversation and challenge again. Her AI pack has the condition to travel to the player when you are both in the same cell, and when the duel is at stage 0, no matter the choice or outcome, the duel stage should be set to something other than 0, and hence she should not be looking for the player, but it doesn't work that way for some reason. She talks to you, you choose duel again, makes like she's going to fight you, but then immediately re-engages in conversation and gives the yield/win topic (depending on which outcome occurred before) and then when you leave the post duel talk the second time, she is free from her desire to acquire you for conversation and just stands there (which is correct at this point)

 

Her only code is to set the duel global and quest stage to a certain value and stage on her death. Otherwise this is the code which occurs in the quest code:

 

Scn souleaterscript

Float fQuestDelayTime
Short state
short moveday

Begin Gamemode

set fQuestDelayTime to 0.3

if CRJunDuel == 1


if CRjungrogasREF.getav health <= 75
	CRjungrogasREF.stopcombat
	CRjungrogasREF.setav aggression 0
	CRjungrogasREF.startconversation player, CRjunyields
	set CRJunDuel to -1
elseif player.getav health <= 50
	CRjungrogasREF.stopcombat
	CRjungrogasREF.setav aggression 0
	CRjungrogasREF.startconversation player, CRjunwins		
	set CRJunDuel to 2
endif
endif

if CRJunDuel == 2
set moveday to gamedayspassed
set CRJunDuel to 3
endif

if CRJunDuel == 3
if gamedayspassed == moveday + 1
	SetCellOwnership GrogasVilla CRJunGrogas
	SetCellOwnership GrogasVillabasement CRJunGrogas
	messagebox "The Grogas Villa is now in the hands of Jun Grogas"
	set CRJunDuel to -1
	set CRGrogasbought to 0
endif
endif	

if CRJunGrogasRef.getdistance player < 300
if CRJunDuel == 0
	CRJunGrogasREF.startconversation player
endif
endif

;;;;; separate code starts here for another handler for the quest and is totally unrelated and is functioning swimmingly

end

Edited by icecreamassassin
Link to comment
Share on other sites

Problem I noticed in testing this however is that setting her aggression to 0 between the health threshold trigger and the yield/win startconversation topic begining doesn't seem to prevent a stray hit from the player from initiating combat again. Any suggestions on how to resolve this?

 

Also I found that increasing the questdelaytime helped to avoid the first problem a bit (not every time) but in general it helps, any suggestions? I tried reordering the order of the aggression setting, the stopcombat and the startconversation topic options but they all seem to happen fast enough in succession that it seems to have no variance.

Edited by icecreamassassin
Link to comment
Share on other sites

I do not see a line changing the CRJunDuel variable from 0 to 1 anywhere. Did you have that changed in the result script for the dialogue?

 

That said, you do not need to script the NPC to start a conversation if the NPC has a Find package. When an NPC finds a target actor, he/she will either attack or initiate dialogue (depending on aggression/disposition values). Try removing this part entirely:

 

if CRJunGrogasRef.getdistance player < 300
       if CRJunDuel == 0
               CRJunGrogasREF.startconversation player
       endif
endif

 

If that still doesn't work, try throwing in an EvaluatePackage somewhere for after the duel ends.

Link to comment
Share on other sites

ok so I have made some improvement, she is MUCH faster at rejoining conversation. Basically I changed out all the "Startconversation" calls and put in stopcombat and EVP calls and just conditionalized the yield/win topic which occurs from a find package on her to a global script which is set by the outcome of the duel. Problem is though if I am at a distance or happen to be mid swing and land it after the duel "ends" but before she talks to me, I land the hit and she goes back into combat, even though her aggression is set at 0. Could it be that her Disposition is also at 0 after the duel? would it help to artificially mod the disposition up so that the attacks on her at 0 aggression don't throw her into combat (like 0 aggression is supposed to do)

 

anyways, here's what I;m working with now: (and yes, the "CRJunDuel" is a global variable set by the conversation

 

Begin Gamemode

if CRJunGrogasREF.getdistance CRGVmarker <10
CRJunGrogasREF.Disable
endif

set fQuestDelayTime to 0.01

if CRJunDuel == 1


if CRjungrogasREF.getav health <= 75
	set CRJunDuelValue to 1
	CRjungrogasREF.stopcombat
	CRJunGrogasREF.evp
;		CRjungrogasREF.startconversation player, CRjunyields
	CRjungrogasREF.setav aggression 0
	set CRJunDuel to -1
elseif player.getav health <= 50
	set CRJunDuelValue to 2
	CRjungrogasREF.stopcombat
	CRJunGrogasREF.evp
;		CRjungrogasREF.startconversation player, CRjunwins
	CRjungrogasREF.setav aggression 0
	CRjungrogasREF.stopcombat
	set CRJunDuel to 2
endif
endif

if CRJunDuel == 2
set moveday to gamedayspassed
set CRJunDuel to 3
endif

if CRJunDuel == 3
if gamedayspassed == moveday + 1
	SetCellOwnership GrogasVilla CRJunGrogas
	SetCellOwnership GrogasVillabasement CRJunGrogas
	messagebox "The Grogas Villa is now in the hands of Jun Grogas"
	set CRJunDuel to -1
	set CRGrogasbought to 0
endif
endif	

Link to comment
Share on other sites

Even if the NPC's aggression is set to 0, it will still defend itself when attacked... Have you tried playing around with SetIgnoreFriendlyHits and ModDisposition? If that doesn't work, I guess you can try disabling her AI for a couple of seconds while flashing a message on the screen that the duel has ended, before going ahead with the post combat stuff.
Link to comment
Share on other sites

With high aggression the disposition would be an issue, as when aggression is higher than disposition an NPC will fight you (or whoever they have a lower disposition towards).
Link to comment
Share on other sites

I've made sure that the disposition is higher than the Aggression when coming out of the duel and it doesn't seem to affect things

 

I've never tried the setignorefriendlyhits. I'll give that a shot.

 

As far as the aggression level goes the construction set wiki says

 

"A setting of zero means it will refuse combat even if attacked or a fellow faction member is attacked."

Link to comment
Share on other sites

  • Recently Browsing   0 members

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