What's wrong with this script?

Post » Wed Aug 26, 2009 12:00 am

Okay, so I'm trying to make myself a script, that gives me a bonus to chameleon when I'm sneaking. The higher my sneak is, the greater the chameleon boost is.
Begin aahidescriptshort PCSneakingshort sneakskillif ( GetPCSneaking == 1 )	if ( player->getsneak => 50 )		if ( player->getsneak =< 59 )			player->addspell "aahide1"		endif	endif	if ( player->getsneak => 60 )		if ( player->getsneak =< 69 )			player->addspell "aahide2"			player->removespell "aahide1"		endif	endif	if ( player->getsneak => 70  )		if ( player->getsneak =< 79 )			player->addspell "aahide3"			player->removespell "aahide2"		endif	endif	if ( player->getsneak => 80 )		if ( player->getsneak =< 89 )			player->addspell "aahide4"			player->removespell "aahide3"		endif	endif	if ( player->getsneak => 90 )		if ( player->getsneak =< 99 )			player->addspell "aahide5"			player->removespell "aahide4"		endif	endif	if ( player->getsneak => 100 )		player->addspell "aahide6"		player->removespell "aahide5"		endifendifend

User avatar
laila hassan
 
Posts: 3476
Joined: Mon Oct 09, 2006 2:53 pm

Post » Wed Aug 26, 2009 8:10 am

You want the spell to be in effect only when the player is sneaking, right?
Maybe something like this will work:

Begin Scriptshort DoOnceif ( GetPCSneaking == 0 )	if ( DoOnce == 1 )		Player->RemoveSpell aahide6		Player->RemoveSpell aahide5		Player->RemoveSpell aahide4		Player->RemoveSpell aahide3		Player->RemoveSpell aahide2		Player->RemoveSpell aahide1		Set DoOnce to 0	endif	Returnendifif ( DoOnce == 1 )	Returnendifif ( Player->GetSneak => 100 )	Player->AddSpell aahide6	Set DoOnce to 1	Returnelseif ( Player->GetSneak => 90 )	Player->AddSpell aahide5	Set DoOnce to 1	Returnelseif ( Player->GetSneak => 80 )	Player->AddSpell aahide4	Set DoOnce to 1	Returnelseif ( Player->GetSneak => 70 )	Player->AddSpell aahide3	Set DoOnce to 1	Returnelseif ( Player->GetSneak => 60 )	Player->AddSpell aahide2	Set DoOnce to 1	Returnelseif ( Player->GetSneak => 50 )	Player->AddSpell aahide1	Set DoOnce to 1	ReturnendifEnd

User avatar
Jessica Thomson
 
Posts: 3337
Joined: Fri Jul 21, 2006 5:10 am

Post » Wed Aug 26, 2009 5:53 am

thanks!
User avatar
Nicholas C
 
Posts: 3489
Joined: Tue Aug 07, 2007 8:20 am

Post » Wed Aug 26, 2009 12:58 am

Since the lower half of the script only runs a single frame when the player hits the sneak button, "return" at each branch doesn't really affect performance; also there's no point in duplicating "set doOnce to 1".
Begin Scriptshort DoOnceif ( GetPCSneaking == 0 )	if ( DoOnce == 1 )		Player->RemoveSpell aahide6		Player->RemoveSpell aahide5		Player->RemoveSpell aahide4		Player->RemoveSpell aahide3		Player->RemoveSpell aahide2		Player->RemoveSpell aahide1		Set DoOnce to 0	endif	Returnendifif ( DoOnce == 1 )	ReturnendifSet DoOnce to 1if ( Player->GetSneak => 100 )	Player->AddSpell aahide6elseif ( Player->GetSneak => 90 )	Player->AddSpell aahide5elseif ( Player->GetSneak => 80 )	Player->AddSpell aahide4elseif ( Player->GetSneak => 70 )	Player->AddSpell aahide3elseif ( Player->GetSneak => 60 )	Player->AddSpell aahide2elseif ( Player->GetSneak => 50 )	Player->AddSpell aahide1endifEnd
The simpler it is, the easier it is to handle later. :D
User avatar
Svenja Hedrich
 
Posts: 3496
Joined: Mon Apr 23, 2007 3:18 pm


Return to III - Morrowind