Page 1 of 1

SWITCH Statement with No Cases Error

Posted: Fri Apr 21, 2006 6:55 am
by Exar Kun
I'm getting the error when I try to compile my function into my script. Is there a problem with putting a case statement in a function call?

Here's a copy of the function:

Code: Select all

function StatIncrease ( character, attribute )

case ( attribute )

	ALCHEMY:
	ANATOMY:
	DETECTHIDDEN:
	LEADERSHIP:
	INVOCATION:
	MAGERY:
	MAGICRESISTANCE:
	MEDITATION:
	NECROMANCY:
	TACTICS:
	TRACKING:
	VETERINARY:

		var currentInt := GetObjProperty ( character, "int" );
		var rawCurrentInt := BaseToRaw ( currentInt * 10 );

		rawCurrentInt := ( rawCurrentInt + 1 );

		var newCurrentInt := RawToBase ( rawCurrentInt );

		newCurrentInt := ( newCurrentInt / 10 );
		SetObjProperty ( character, "int", newCurrentInt );

		var unmod_Int := CInt ( GetAttributeBaseValue ( character, "Intelligence" ) / 10 );

			if ( ( CInt ( newCurrentInt ) ) > unmod_Int )
				SetAttributeBaseValue ( character, "Intelligence", unmod_Int * 10 + 10 );
				RecalcVitals ( character );
			endif

	ARCHERY:
	FENCING:
	LOCKPICKING:
	STEALING:
	STEALTH:
	PARRY:
	TINKERING:
	TAILORING:
	CARTOGRAPHY:
	HIDING:
	MUSICIANSHIP:
	POISONING:
	INSCRIPTION:

		var currentDex := GetObjProperty ( character, "dex" );
		var rawCurrentDex := BaseToRaw ( currentDex * 10 );

		rawCurrentDex := ( rawCurrentDex + 1 );

		var newCurrentDex := RawToBase ( rawCurrentDex );

		newCurrentDex := ( newCurrentDex / 10 );
		SetObjProperty ( character, "dex", newCurrentDex );

		var unmod_Dex := CInt ( GetAttributeBaseValue ( character, "Dexterity" ) / 10 );

			if ( ( CInt ( newCurrentDex ) ) > unmod_Dex )
				SetAttributeBaseValue ( character, "Dexterity", unmod_Dex * 10 + 10 );
				RecalcVitals ( character );
			endif

	LUMBERJACKING:
	MINING:
	WRESTLING:
	BLACKSMITHY:
	CARPENTRY:
	FISHING:
	MACEFIGHTING:
	SWORDSMANSHIP:
	CAMPING:
	DRUIDRY:

		var currentStr := GetObjProperty ( character, "str" );
		var rawCurrentStr := BaseToRaw ( currentStr * 10 );

		rawCurrentStr := ( rawCurrentStr + 1 );

		var newCurrentStr := RawToBase ( rawCurrentStr );

		newCurrentStr := ( newCurrentStr / 10 );
		SetObjProperty ( character, "str", newCurrentStr );

		var unmod_Str := CInt ( GetAttributeBaseValue ( character, "Strength" ) / 10 );

			if ( ( CInt ( newCurrentStr ) ) > unmod_Str )
				SetAttributeBaseValue ( character, "Strength", unmod_Str * 10 + 10 );
				RecalcVitals ( character );
			endif

	default:

		DohEth ( character );

endcase

Thanks.

Posted: Fri Apr 21, 2006 7:14 am
by tekproxy
What is charAttribute? It's not defined anywhere.

Posted: Fri Apr 21, 2006 7:42 am
by Exar Kun
Der, sorry.

I was trying something to get it to work. Replace charAttribute with attribute.

Posted: Fri Apr 21, 2006 8:20 am
by Exar Kun
Thanks to Tritan for pointing out that my case statements have to be in quotes because they're strings!

You da man!

Posted: Fri Apr 21, 2006 9:32 am
by tekproxy
Thank you for posting your solution to the forums. You'd be suprised how many people don't think to do stuff like that. :?

Posted: Fri Apr 21, 2006 9:46 am
by Exar Kun
No problem. I'm in technical support where I work, so I'm all about documentation of issues.