Make this function smaller with a calculation

Post » Fri Aug 22, 2014 3:23 pm

Hey guys I'm looking for some help with calculations. Maths isn't my strong point and I'd like to improve my scripts using calculations if possible. Could you take a look at these and see if there's a better more efficient way to achieve them? I'm not necessarily looking to "optimise" my code, because this function is lighting fast, just improve my coding skills really.

Cheers!


Set quest marker to object
Spoiler
Function SetQuestMarker(ObjectReference akTrap, HISAnimalTrapScript01 TrapScript)	Int MyQuestID = 0	ObjectReference TrapAliasRef	Bool BaitKnown	if TrapScript.BaitKnownNameObjectRef != None; if the known bait dummy object has been placed		TrapAliasRef = TrapScript.BaitKnownNameObjectRef		BaitKnown = True	else		TrapAliasRef = TrapScript.MyActivator		BaitKnown = False	endif	if !MyTrap01.GetReference()		MyTrap01.ForceRefTo(TrapAliasRef)		if BaitKnown == False			SetObjectiveDisplayed(11)		else			SetObjectiveDisplayed(21)		endif		MyQuestID = 1	elseif !MyTrap02.GetReference()		MyTrap02.ForceRefTo(TrapAliasRef)		if BaitKnown == False			SetObjectiveDisplayed(12)		else			SetObjectiveDisplayed(22)		endif		MyQuestID = 2	elseif !MyTrap03.GetReference()		MyTrap03.ForceRefTo(TrapAliasRef)		if BaitKnown == False			SetObjectiveDisplayed(13)		else			SetObjectiveDisplayed(23)		endif		MyQuestID = 3	elseif !MyTrap04.GetReference()		MyTrap04.ForceRefTo(TrapAliasRef)		if BaitKnown == False			SetObjectiveDisplayed(14)		else			SetObjectiveDisplayed(24)		endif		MyQuestID = 4	elseif !MyTrap05.GetReference()		MyTrap05.ForceRefTo(TrapAliasRef)		if BaitKnown == False			SetObjectiveDisplayed(15)		else			SetObjectiveDisplayed(25)		endif		MyQuestID = 5	elseif !MyTrap06.GetReference()		MyTrap06.ForceRefTo(TrapAliasRef)		if BaitKnown == False			SetObjectiveDisplayed(16)		else			SetObjectiveDisplayed(26)		endif		MyQuestID = 6	elseif !MyTrap07.GetReference()		MyTrap07.ForceRefTo(TrapAliasRef)		if BaitKnown == False			SetObjectiveDisplayed(17)		else			SetObjectiveDisplayed(27)		endif		MyQuestID = 7	elseif !MyTrap08.GetReference()		MyTrap08.ForceRefTo(TrapAliasRef)		if BaitKnown == False			SetObjectiveDisplayed(18)		else			SetObjectiveDisplayed(28)		endif		MyQuestID = 8	elseif !MyTrap09.GetReference()		MyTrap09.ForceRefTo(TrapAliasRef)		if BaitKnown == False			SetObjectiveDisplayed(19)		else			SetObjectiveDisplayed(29)		endif		MyQuestID = 9	elseif !MyTrap10.GetReference()		MyTrap10.ForceRefTo(TrapAliasRef)		if BaitKnown == False			SetObjectiveDisplayed(20)		else			SetObjectiveDisplayed(30)		endif		MyQuestID = 10	else; no trap aliases are free		HISTrapNoMarkersFreeMessage.Show(); notification		Return	endif	SetTrapQuestID(akTrap, MyQuestID)EndFunction



Remove the objects quest marker

Spoiler
Function RemoveQuestMarker(HISAnimalTrapScript01 TrapScript)	Bool BaitKnown	if TrapScript.BaitKnownNameObjectRef != None; if the known bait dummy object has been placed		BaitKnown = True	else		BaitKnown = False	endif	Int MyQuestID = TrapScript.MyTrapQuestID	if MyQuestID == 1		MyTrap01.Clear()		SetObjectiveDisplayed(11, false)		SetObjectiveDisplayed(21, false)		TrapScript.MyTrapQuestID = 0	elseif MyQuestID == 2		MyTrap02.Clear()		if BaitKnown == False			SetObjectiveDisplayed(12, false)		else			SetObjectiveDisplayed(22, false)		endif		TrapScript.MyTrapQuestID = 0	elseif MyQuestID == 3		MyTrap03.Clear()		if BaitKnown == False			SetObjectiveDisplayed(13, false)		else			SetObjectiveDisplayed(23, false)		endif		TrapScript.MyTrapQuestID = 0	elseif MyQuestID == 4		MyTrap04.Clear()		if BaitKnown == False			SetObjectiveDisplayed(14, false)		else			SetObjectiveDisplayed(24, false)		endif		TrapScript.MyTrapQuestID = 0	elseif MyQuestID == 5		MyTrap05.Clear()		if BaitKnown == False			SetObjectiveDisplayed(15, false)		else			SetObjectiveDisplayed(25, false)		endif		TrapScript.MyTrapQuestID = 0	elseif MyQuestID == 6		MyTrap06.Clear()		if BaitKnown == False			SetObjectiveDisplayed(16, false)		else			SetObjectiveDisplayed(26, false)		endif		TrapScript.MyTrapQuestID = 0	elseif MyQuestID == 7		MyTrap07.Clear()		if BaitKnown == False			SetObjectiveDisplayed(17, false)		else			SetObjectiveDisplayed(27, false)		endif		TrapScript.MyTrapQuestID = 0	elseif MyQuestID == 8		MyTrap08.Clear()		if BaitKnown == False			SetObjectiveDisplayed(18, false)		else			SetObjectiveDisplayed(28, false)		endif		TrapScript.MyTrapQuestID = 0	elseif MyQuestID == 9		MyTrap09.Clear()		if BaitKnown == False			SetObjectiveDisplayed(19, false)		else			SetObjectiveDisplayed(29, false)		endif		TrapScript.MyTrapQuestID = 0	elseif MyQuestID == 10		MyTrap10.Clear()		if BaitKnown == False			SetObjectiveDisplayed(20, false)		else			SetObjectiveDisplayed(30, false)		endif		TrapScript.MyTrapQuestID = 0	else; no trap quests ID found		Return	endif	ReturnEndFunction
User avatar
meghan lock
 
Posts: 3451
Joined: Thu Jan 11, 2007 10:26 pm

Post » Fri Aug 22, 2014 8:36 am

It's a little early for me to be thinking about math, a quick look for your 1st script you need to get MyTrap01 .......10 as an integer (function maybe) then you might be able to assign you objectives displayed from that as either +10 or +20. For you 2nd script you will need a function to go back the other way using MyQuestID as the integer.

User avatar
Red Sauce
 
Posts: 3431
Joined: Fri Aug 04, 2006 1:35 pm


Return to V - Skyrim