I hate forcegreeting

Post » Mon May 02, 2011 2:29 am

Begin SM_forcescriptshort do_onceif ( do_once == 0 )		If ( player->getjournalindex "SM_glass2" >= 10 )			set do_once to 1		endifelseif ( do_once == 1 )	If ( PLAYER->GetPos, X <= 5200 ) 			If ( player->GetPos, X >= 4300 )				If ( player->GetPos, Y <= 4500 )					If ( player->GetPos, Y >= 4100 )						IF ( player->getpos, z <= 14790 )							If ( player->getpos, z >= 14786 )										set do_once to 2							"SM_telvanni guard"->forcegreeting							endif						endif					endif			endif		endif	endif		elseif ( DO_oNCE >= 2 )stopscript SM_forcescriptendifEnd



It continously loops and i don't know exactly how to stop that. What am i doing wrong? another thing thats wrong is that the force greeting still happens even when the player isn't in those cordinates. So what the heck? how does it even execute the force greeting if the above isn't true? I don't understand. any help would be nice.
User avatar
Dalton Greynolds
 
Posts: 3476
Joined: Thu Oct 18, 2007 5:12 pm

Post » Sun May 01, 2011 5:44 pm

:wacko: Why don't you just use GetDistance? It's much simpler.

Otherwise, if you positively *must* use coordinates, try to turn your nested if into a chain:
elseif ( do_once == 1 )	If ( PLAYER->GetPos, X > 5200 ) 		return	endif	If ( player->GetPos, X < 4300 )		return	endif	If ( player->GetPos, Y > 4500 )		return	endif	If ( player->GetPos, Y < 4100 )		return	endif	IF ( player->getpos, z > 14790 )		return	endif	If ( player->getpos, z < 14786 )		return	endif	set do_once to 2	"SM_telvanni guard"->forcegreetingendif	

User avatar
Jordyn Youngman
 
Posts: 3396
Joined: Thu Mar 01, 2007 7:54 am

Post » Mon May 02, 2011 3:41 am

What exactly does return do? All i got from MSFD is that it stops the script running for the frame. Also how does getdistance function? Does it check all cordinates at once? x, y, and z?
User avatar
Teghan Harris
 
Posts: 3370
Joined: Mon Mar 05, 2007 1:31 pm

Post » Sun May 01, 2011 2:11 pm

What exactly does return do? All i got from MSFD is that it stops the script running for the frame.

That is basically what it does. The script stops running at the point where return is called but is run as normal next frame.

Also how does getdistance function? Does it check all cordinates at once? x, y, and z?

It returns the distance between two objects.

It is much simpler to say (for example) if the player gets within 500 units of the guard the guard force greets the player rather than checking if the player is within a area.
if (  "SM_telvanni guard"->getDistance player < 500 )    set do_once to 2    "SM_telvanni guard"->forcegreetingendif


Although this does depend a bit on what you want do do. Checking bounds may be the only way :shrug:
User avatar
Jinx Sykes
 
Posts: 3501
Joined: Sat Jan 20, 2007 11:12 pm

Post » Mon May 02, 2011 2:41 am

Begin SM_forcescriptshort do_onceif ( do_once == 0 )		If ( player->getjournalindex "SM_glass2" >= 10 )			set do_once to 1			return		endifelseif ( do_once == 1 )	If ( PLAYER->GetPos, X <= 5200 ) 		return			endif			If ( player->GetPos, X >= 4300 )				return			endif				If ( player->GetPos, Y <= 4500 )					return					endif						If ( player->GetPos, Y >= 4100 )						return						endif								IF ( player->getpos, z <= 14790 )								return								endif														If ( player->getpos, z >= 14786 )								return								endif																		set do_once to 2											"SM_TELVANNI GUARD"->forcegreeting											return				elsestopscript SM_forcescriptendifEnd


Alright it tried this baby it still continusouly loops. I'm starting this script via the result box.


Someone else helped me this script which is some what similar and it works perfectly.

Begin SM_followscriptshort do_onceif ( do_once == 0 )	"hasell"->AIFollowCell "player" "Sadrith Mora, Guild of Fighters" 0 0 0 0		set do_once to 1		elseif ( do_once == 1 )		If ( "HASELL"->GetPos, X <= 5600 ) 			If ( "hasell"->GetPos, X >= 5030 )				If ( "hasell"->GetPos, Y <= 4660 )					If ( "hasell"->GetPos, Y >= 4170 )											set do_once to 2												journal "SM_FGquest" 30													ForceGreeting					ENDIF				ENDIF			endif		endifelseif ( do_once >= 2 )	"hasell"->aiwander, 0, 0, 0	stopscript SM_followscriptendifend



It's practically the same damn thing i really don't understand why it loops. It doesn't even check to see if i'm in those cordinates either. It's like it totally bypasses it. What am i doing wrong? har har har

*edit*

if ( "SM_telvanni guard"->getDistance player < 500 )
set do_once to 2
"SM_telvanni guard"->forcegreeting
endif[/code]

Although this does depend a bit on what you want do do. Checking bounds may be the only way :shrug:


Yea, the only reason i can't do that is because I'm in this three level telvanni tower and i could be standing right on top of the npc and that would force the greeting when the npc isn't even on the same level. That's why i had it set up to check for all three cordinates.
User avatar
Mizz.Jayy
 
Posts: 3483
Joined: Sat Mar 03, 2007 5:56 pm

Post » Sun May 01, 2011 11:00 pm

oops. Another script was effecting the forcegreeting and I totally didn't remember it.

This worked fine for me.

Begin SM_forcescriptshort do_Onceif ( do_Once == 0 )		If ( player->GetPos, Z >= 14780 )			If ( player->GetPos, Z <= 14810 )				If ( player->GetPos, X <= 5200 )					If ( player->GetPos, X >= 4300 )						If ( player->GetPos, Y <= 4500 )							If ( player->GetPos, Y >= 4100 )									set do_Once to 1									  "SM_telvanni guard"->ForceGreeting								endif						endif					endif				endif			endif		endifelseif ( Do_once == 1 )	stopscript SM_forcescriptendifend


Now what i'm trying to do is have either NPC-A force greeting or NPC-B force greeting and if either one forces the greeting first it will not allow the other to force the greeting. So in other words i just want one of the npc's to force the greeting if i get within x amount of feet of them.


Begin SM_forcescriptshort do_Onceif ( do_Once == 0 )		If ( player->GetPos, Z >= 14780 )			If ( player->GetPos, Z <= 14810 )				If ( player->GetPos, X <= 5200 )					If ( player->GetPos, X >= 4300 )						If ( player->GetPos, Y <= 4500 )							If ( player->GetPos, Y >= 4100 )									set do_Once to 1									  "SM_telvanni guard"->ForceGreeting								endif						endif					endif				endif			endif		endifelseIF ( DO_oNCE == 0 )				If ( player->GetPos, Z >= 15684 )			If ( player->GetPos, Z <= 15776 )				If ( player->GetPos, X <= 5550 )					If ( player->GetPos, X >= 4826 )						If ( player->GetPos, Y <= 4052 )							If ( player->GetPos, Y >= 3383 )									set do_Once to 1									  "SM3_telvanni guard"->ForceGreeting								endif						endif					endif				endif			endif		endifelseif ( Do_once == 1 )	stopscript SM_forcescriptendifend



I thought maybe i could make this work but it doesn't. Any hints?


*edit* i just did it for two seperate scripts.

Begin SM_forcescriptshort do_Onceif ( do_Once == 0 )	If ( player->getjournalindex "SM_glass" < 40 )		If ( player->GetPos, Z >= 14780 )			If ( player->GetPos, Z <= 14810 )				If ( player->GetPos, X <= 5200 )					If ( player->GetPos, X >= 4300 )						If ( player->GetPos, Y <= 4500 )							If ( player->GetPos, Y >= 4100 )									set do_Once to 1									  "SM_telvanni guard"->ForceGreeting								endif						endif					endif				endif			endif		endif	endifelseif ( Do_once == 1 )	stopscript SM_forcescriptendifend


Begin SM_force2scriptshort do_onceIF ( DO_oNCE == 0 )	If ( Player->getjournalindex	"SM_glass" < 40 )		If ( player->GetPos, Z >= 15684 )			If ( player->GetPos, Z <= 15776 )				If ( player->GetPos, X <= 5550 )					If ( player->GetPos, X >= 4826 )						If ( player->GetPos, Y <= 4052 )							If ( player->GetPos, Y >= 3383 )									set do_Once to 1									  "SM3_telvanni guard"->ForceGreeting								endif						endif					endif				endif			endif		endif	endifelseif ( Do_once == 1 )	stopscript SM_force2scriptendifend


Is there any way to combine the two so it functions?
User avatar
Harinder Ghag
 
Posts: 3405
Joined: Wed Jan 17, 2007 11:26 am

Post » Sun May 01, 2011 7:17 pm

Is the distance between levels really so neglectable to make six checks of coordinates more preferable than a single check of distance? Simpler scripts are always easier to handle. You might just move your guards horizontally so that the distance between them would be somewhat longer than now - then the distance check with the player wouldn't give a false positive.

Second, your combined script doesn't work because of elseif separating two blocks of ifs. Since the control goes through the first block when do_Once=0, it won't have a chance to reach the second. Split it to separate "endif" / "if ( do_Once == 0 )" commands.

(You'll have to split "elseif ( Do_once == 1 )" as well).
User avatar
Sharra Llenos
 
Posts: 3399
Joined: Wed Jan 17, 2007 1:09 pm

Post » Sun May 01, 2011 11:21 pm

Thanks i was able to get it work.

Is the distance between levels really so neglectable to make six checks of coordinates more preferable than a single check of distance? Simpler scripts are always easier to handle. You might just move your guards horizontally so that the distance between them would be somewhat longer than now - then the distance check with the player wouldn't give a false positive.



Yea, it's just the way the telvanni tower is designed. I could set like a really small distance so you would have to be almost face to face with the npc i gues or re do the level which is something i don't want to do. Thanks for all the help!
User avatar
Veronica Flores
 
Posts: 3308
Joined: Mon Sep 11, 2006 5:26 pm


Return to III - Morrowind