script help...

Post » Sat May 28, 2011 10:22 am

Okay, Im normally working in oblivion, so im not 100% on the morrowind scripting.....but i cant figure out the problem here.

I though that scripts in morrowind ran every frame......however this script i have seems ot stop after it has run once....any ideas?

It is on the Dwemer Shock Centerion you get during the telvanni questline, Im just trying ot make it into a proper companion everything seems ot work.....but then this problem suddenly came up which seems to stop the script dead. The script runs fine, right up till the first time it runs through the if state == -1 part.....then it will run once and stop......the testing messagebox i put in will appear when i load into the same cell as the centurion.....but after that nothing in the script ever runs again.


Begin baladasCenturion;makes the centurion pop out of Arvs Drelen;because of Velothi collision issuesshort stateshort p_speedshort Companionshort levitated	float myxfloat myyfloat myzfloat timerif ( state > -1 )	if ( GetJournalIndex HT_DahrkMezalf < 10 )		;if quest has not yet started, stop		return	endif	if ( CellChanged == 0 )		;only pop on cellchange		return	endif	if ( GetJournalIndex HT_DahrkMezalf < 100 )		PositionCell -87017 95351 1226 283 "GnisWis"		Disable	endif	if ( GetJournalIndex HT_DahrkMezalf >= 100 )		AiFollow Player 0 0 0 0		Set state to -1		Enable		AddTopic Follow		AddTopic Wait		Set Companion to 1	endifelseif ( state == -1 )	; ENABLES COMPANION SHARE OPTION	; Used along with "short companion" (above).		set myx to ( Player->GetPos x )	set myy to ( Player->GetPos y )	set myz to ( Player->GetPos z )	messagebox "Testing" "okay"	; WARPING TO PLAYER ( Used to improve "following" ability)	if ( GetCurrentAiPackage == 3 )		if ( GetWeaponDrawn == 1 )			return		elseif ( GetSpellReadied == 1 )			return		elseif ( GetDistance Player > 800 )			messagebox "800 away"			set timer to timer + GetSecondsPassed			if ( timer > 8 )				set timer to 0				SetPos x myx				SetPos y myy				SetPos z myz			endif		endif	endif		; LEVITATION	if ( Player->GetEffect, sEffectLevitate == 1 && levitated == 0 )		if ( GetEffect, sEffectLevitate == 0 )			AIWander 0 0 0 0			set levitated to 1		endif	endif	if ( Player->GetEffect, sEffectLevitate == 0 && levitated == 1 )		if ( GetCurrentAiPackage == 0 )			AIFollow Player 0 0 0 0			set levitated to 0		endif	endifendif;if ( GetDeadCount "centurion_shock_baladas" > 0 );	if ( getitemcount ingred_scrap_metal_01 > 2 );		removeitem ingred_scrap_metal_01 2;		resurrect;		if ( state == -1 );			AiFollow Player 0 0 0 0		;		endif;	endif;endifEnd baladasCenturion

User avatar
SWagg KId
 
Posts: 3488
Joined: Sat Nov 17, 2007 8:26 am

Post » Sat May 28, 2011 4:41 am

do you get any error messages? it sounds like the script is terminating unexpectedly.

break this line up -

if ( Player->GetEffect, sEffectLevitate == 1 && levitated == 0 )


into -
if ( ( "player"->geteffect seffectlevitate ) == 1 )        if ( levitated == 0 )


there is no "and" in morrowind. oh you can safely ignore the extra brackets, i wrap functions in contitionals with extra brackets, sometimes going without breaks scripts, but it's rare from what i hear.

this script is attached to the actor, yes?

you can try quoting player references, i have a script that does not function unless player is quoted like "player"

do you need to getpos every frame? perhaps wrap the getpos in a 3 second timer?

aipackage check is superfluous. the state is only -1 if in aifollow mode.

do creatures ready weapons or spells? i dont know myself, might be the problem... you also might try breaking that series of elseifs into three if statements, sometimes MW does not like using elseif on more than one thing just the same way it does not like to check the same thing more than once sometimes.

here are some examples

if ( state == 1 )        ;do stuffelseif ( state == 2 )        ;do other stuffendif


seems to work better than

if ( state == 1 )        ;do stuffendifif ( state == 2 )        ;do other stuffendif


it checks the first time, but it wont check the second. note that this is in "top level conditionals" only. checking the same thing again under a different conditional seems to work just fine. perhaps its just in the same if-block level.

if ( varx == 1 )        ;do stuffelseif ( vary == 2 )        ;do other stuffendif


this does not work all the time... it will check varx, but never vary. you want to break them apart so that -

if ( varx == 1 )        ;do stuffendifif ( vary == 1 )        ;do other stuffendif


oh, you also might try using positive states in your script. instead of state > 0 and the "main" state being -1, try state < 1 and the main state being 1. if your states are only two in number, it might benifit you more to be exact in the script rather than using catchalls like greater than and less than.
User avatar
Destinyscharm
 
Posts: 3404
Joined: Sun Jul 23, 2006 6:06 pm


Return to III - Morrowind