stopping combat with multiple NPC's

Post » Sat May 28, 2011 1:50 pm

hi! i am busy making a mod in wich you commit a crime (or get scammed or something) but the only way i could get the guards to "arrest" you was by making them fight you and when they got close, make them stop combat and forcegreet. i used this script:
begin DBtestscriptIf ( menumode )	returnendifif ( mycrime == 2 )	SetFight 100endifif ( GetDistance "player" <= 256 )	StopCombat	SetFight 30	Set stopkillingme to 1	if ( mycrime == 2 )		ForceGreeting		set mycrime to 3		return	endifelse	if ( stopkillingme == 1 )		StopCombat		set stopkillingme to 0	endifendifend DBtestscript


now the problem is this:
i have this test setup already made with the 3 guards.
whenever you do your "crime", they come running up as they should. but then only one stops combat and the others beat you up.
it is very frustrating since i have no idea what seems to be the problem. i've tried everything! but when i use code to stop combat if the conditions aren't right, you can never fight them since they will always stop combat. any ideas?

Hacklefellar
User avatar
adame
 
Posts: 3454
Joined: Wed Aug 29, 2007 2:57 am

Post » Sat May 28, 2011 4:02 pm

bumb o_o
User avatar
Laura Wilson
 
Posts: 3445
Joined: Thu Oct 05, 2006 3:57 pm

Post » Sun May 29, 2011 3:10 am

I hope to have understood what you would like to do. Assuming mycrime is a global short set to 2 somewhere else, I'd try something like this
begin DBtestscript;If ( menumode );return;endifif ( mycrime < 2 )	returnelseif ( mycrime == 2 ); all guards attacking	SetFight 100	set mycrime to 3	returnelseif ( mycrime == 3 )	if ( GetDistance "player" <= 256 )		set mycrime to 4; current state changes; nearest guard stops and greet		SetFight 30		StopCombat		ForceGreeting	endif	returnelseif ( mycrime == 4 ); all guards stop combat	StopCombat	SetFight 30	set mycrime to 0endifend
[EDIT] typos
[EDIT2] commented menumode test
User avatar
Kirsty Wood
 
Posts: 3461
Joined: Tue Aug 15, 2006 10:41 am

Post » Sat May 28, 2011 9:04 pm

script didn't work. there are multiple guards and only one stops. do i have to make a new part for every guard? :S cuz this is in a city and there are gonna be a lot. can't i make like a timer or something that resets some variable AFTER they all have checked if they have to kill me? or would that make matters even more complicated?
User avatar
Nancy RIP
 
Posts: 3519
Joined: Mon Jan 29, 2007 5:42 am

Post » Sat May 28, 2011 11:23 pm

begin DBtestscript;If ( menumode );return;endifshort stateif ( mycrime < 2 )	returnelseif ( mycrime == 2 ); all guards attacking	SetFight 100	set mycrime to 3	returnelseif ( mycrime == 3 )	if ( GetDistance "player" <= 256 )		set mycrime to 4; current state changes; nearest guard stops and greet		SetFight 30		StopCombat		ForceGreeting	endif	returnelseif ( mycrime < 4 + <NUM_GUARDS> ); all guards stop combat	if ( state == 0 )		if ( GetWeaponReadied == 1 )			set state to 1		elseif ( GetSpellReadied == 1 )			set state to 1		endif	elseif ( state == 1 )		StopCombat		SetFight 30		set mycrime to ( mycrime + 1 )		set state to 3	endifelseif ( mycrime >= 4 + <NUM_GUARDS> )	set mycrime to 0endifend


The way you have it, the first one that stops combat will set mycrime to 0, meaning that the rest of them never get the chance to stopcombat. The way I set it up, mycombat is incremented every time one of the guards stops combat (and they only stop combat once). Since your base value for mycrime is 4 at this stage, just add the number of guards that are stopping combat to 4 (if you have 3 guards, it will be 4 + 3). In this example, the script only stops when mycrime is 4 + 3, meaning it's only stopped when when 3 guards have stopped combat.
User avatar
Joanne Crump
 
Posts: 3457
Joined: Sat Jul 22, 2006 9:44 am

Post » Sat May 28, 2011 5:08 pm

what is GetWeaponsReadied? because it isn't recognised in my script :S
User avatar
Prue
 
Posts: 3425
Joined: Sun Feb 11, 2007 4:27 am

Post » Sat May 28, 2011 10:50 pm

GetWeaponDrawn, not GetWeaponReadied. My bad.

GetWeaponDrawn (short)
GetSpellReadied (short)

if ( player->GetWeaponDrawn )

These functions can be used to determine whether or not an Actor has their weapon out or
whether or not they have a spell readied for casting.

User avatar
Sophie Payne
 
Posts: 3377
Joined: Thu Dec 07, 2006 6:49 am

Post » Sun May 29, 2011 1:55 am

i finally got it to work!

although i had to use a code that covers each one of the guards seperately. so i think it's useless with more than 3 guards. but who needs more of em anyway?

it's now
begin DBtestscriptshort onlyoneIf ( menumode )	returnendifif ( mycrime == 2 )	SetFight 100	if ( GetDistance "player" <= 256 )		StopCombat		SetFight 30		ForceGreeting		set mycrime to 3		return	else		return	endifelse	if ( stopkillingme >= 1 )		SetFight 30		StopCombat		if ( onlyone == 0 )			set stopkillingme to 2			set onlyone to 1			return		else			set stopkillingme to 0		endif	endifendifend DBtestscript


if anyone can clean that up for me or show me a better/more efficient way to do it, wich works. i would be so happy! but it works for now so no rush.
thnx all! i got some great ideas from this! :)

*EDIT*

wow how about that eh, it works on as many guards as i can fit into the room! maybe it has something to do with the fact that it runs over the script multiple times and then sees there's no need to come charging in. either way i'm happy. this has bugged me for over half a year.
User avatar
celebrity
 
Posts: 3522
Joined: Mon Jul 02, 2007 12:53 pm


Return to III - Morrowind