Making NPCs Attack After Recieving A Journal Entry

Post » Fri May 27, 2011 2:42 am

For starters, I have a 5 step quest going. The 4th step is killing the person and taking their medallion as proof (I know, not very original). How do I get a journal entry saying "You recovered the medallion, etc." at that moment?

Next, if there are any guards still alive outside (there's 2 guards outside the door and 2 more up a hill out of view), I want them to automatically attack, since the medallion was taken and their leader killed, and the next journal entry was given. Is there a way to do this?
User avatar
Rachel Tyson
 
Posts: 3434
Joined: Sat Oct 07, 2006 4:42 pm

Post » Fri May 27, 2011 11:11 am

For starters, I have a 5 step quest going. The 4th step is killing the person and taking their medallion as proof (I know, not very original). How do I get a journal entry saying "You recovered the medallion, etc." at that moment?


Lots of ways to do this. You could put a script on the medallion that checks for http://www.uesp.net/morrow/editor/mw_cstypes.shtml#onpcadd so it recognizes when the medallion is added to the player's inventory and then does a http://www.uesp.net/morrow/editor/mw_cstypes.shtml#journal command for the appropriate quest stage.

Here's an example from Bloodmoon:
Begin bm_bloodskal_sword;activates the draugr and skeletons when player picks up swordshort OnPCAddshort doonceif (doonce==1)	returnendifif (OnPCAdd == 1)	set doonce to 1	Journal BM_Bloodskal01 10	returnendifEnd


Next, if there are any guards still alive outside (there's 2 guards outside the door and 2 more up a hill out of view), I want them to automatically attack, since the medallion was taken and their leader killed, and the next journal entry was given. Is there a way to do this?


You could attach scripts to the guards that use http://www.uesp.net/morrow/editor/mw_cstypes.shtml#getjournalindex to check for the above quest journal index you did when the medallion is taken and then do a http://www.uesp.net/morrow/editor/mw_cstypes.shtml#startcombat.

Here's an example from Morrowind:
begin eydisScriptshort noloreshort doonceif ( doonce == -1 )	returnendifif ( GetJournalIndex FG_KillCronies >= 10 )	if ( GetDistance Player <= 256 )			ForceGreeting		StartCombat Player		set doonce to -1	endifendifend eydisScript

You wouldn't need the ForceGreeting, unless you want them to address the player first.
User avatar
suzan
 
Posts: 3329
Joined: Mon Jul 17, 2006 5:32 pm

Post » Thu May 26, 2011 9:46 pm

Ahh ok. So the 'GetJournalIndex FG_KillCronies >= 10' section of the last script is searching for the index number of the journal entry when the medallion is recieved, which is FG-KillCronies #10. If this comes up greater than or equal to recieving it, then they automatically attack. If not, nothing. I think I get the picture. I can't quite grasp the concept of scripting. But the dialog and some functions/variables have been getting easier to understand.
User avatar
Mike Plumley
 
Posts: 3392
Joined: Wed Sep 05, 2007 10:45 pm

Post » Fri May 27, 2011 3:36 am

To bump up the realism (this isn't necessary, but it'd be nice), I'd add a check when the leader dies, something like:
if ( "guardA"->GetLOS "player" ); saw them die	Set guardA.doAttack To 1endifif ( "guardA"->GetDistance "player" < 256 ); heard them die   Set guardA.doAttack to 1endif


It'd take some playing with, obviously, to get it right. You could replace set guardA.doAttack with just "guardA"->SetFight 100 and StartCombat player, which would be more reliable in most cases. But checking for hearing and seeing the player kill their leader in the OnDeath segment of the leader's script seems to be best.
User avatar
Nicole Coucopoulos
 
Posts: 3484
Joined: Fri Feb 23, 2007 4:09 am

Post » Fri May 27, 2011 11:29 am

@ peachykeen: The leader is in an interior cell and the guards are in an exterior cell. What does this script do exactly and will it work in my situation?

I want to use this script on the leader when the player comes in uninvited. It's the same script as the Morrowind script above:

begin my_leader

short nolore
short doonce

if ( doonce == -1 )
return
endif

if ( GetDistance Player <= 256 )
ForceGreeting
Messagebox "Now you die!"
StartCombat Player
set doonce to -1
endif
endif

end my_leader

Does this look right?
User avatar
Jessie Rae Brouillette
 
Posts: 3469
Joined: Mon Dec 11, 2006 9:50 am


Return to III - Morrowind