User talk:Lisselli

Revision as of 02:06, 10 August 2017 by imported>Lisselli
Float Function GetEffectiveSpellCost(Actor akActor, Spell[] akSpells, Spell akSpell, String asSkillName, Float[] afBaseSpellCost)

; Technical Notes :
; Equipment and daul cast is not taken into account for it's difficult to get an item's enchantment magnitude.
; Dual cast needs to be taken into account some other way as there is no script function to detect dual casting.
; Returns the effective spell cost for the passed in spell that's been modified by skill level and perks if any.
; Well return -1.0 if actor or spell is none or the passed in spell was not found in the spell array.

; = Variables =
Float fBaseCost 
Float fPerkMulti = 0.50
Float fEquipMulti ; when necessary and/or is easy to figure out
Float DualCast = 2.8 ; spell cost is multliplied by this amount
Float fSkillMulti =  1 - (math.pow((akActor.GetActorValue(asSkillName) / 400), 0.65))
Int iPerkIndex
Int iPerks = akPerks.Length
; =============

; = Strings ===
String sDestruction = "Destruction"
String sAlteration = "Alteration"
String sConjuration = "Conjuration"
String sIllusion = "Illusion"
String sRestoration = "Restoration"

if (akActor == none) 
	return -1.0
endif

if (akSpell == none)
	return -1.0
endif

Int i
Int index = akSpells.Length

; We need to get the base spell cost for the passed in spell.
While i < index                      
	if akSpells[i] == akSpell        
		fBaseCost = afBaseSpellCost[i]   
		Float fEffectiveCost = fBaseCost * fSkillMulti * fPerkMulti as int ; remove the decimal.
		return fEffectiveCost		 
	else                            
		i += 1                       
	endif
EndWhile

return -1.0
EndFunction


Function SetActorValueCap(Actor akActor, String asValueName, Float afValueCap = 100.0)
    ; Store the base and current value.
    Float BaseValue = akActor.GetBaseActorValue(asValueName)
    Float CurrentValue = akActor.GetActorValue(asValueName)
    
    ; Cap default is 100. If checking for attributes, adjust the desired cap accordingly.
       
        ; Check if the current value is over the cap.
        if (BaseValue <= afValueCap && CurrentValue > afValueCap)
           
            ;Unless the base is also over the cap, we\ll assume it\s not.
            akActor.ForceActorValue(asValueName, afValueCap)
        
        elseif BaseValue > afValueCap && CurrentValue > BaseValue
            ; bring the base and current back down to the cap.
            BaseValue = BaseValue - (BaseValue - afValueCap)
            akActor.SetActorValue(asValueName, BaseValue)
            akActor.ForceActorValue(asValueName, afValueCap)
        else
            return
        endif
     
EndFunction


Float Function GetDaysInMonth(Float afMonth=0.0) Global
; Returns number of days of a month

; Morning Star ; 0.0 ; days 31.0 :: Sun's Height ; 6.0 ; days 31.0  
; Sun's Dawn   ; 1.0 ; days 28.0 :: Last Seed    ; 7.0 ; days 31.0
; First Seed   ; 2.0 ; days 31.0 :: Hearthfire   ; 8.0 ; days 30.0
; Rain's Hand  ; 3.0 ; days 30.0 :: Frostfall    ; 9.0 ; days 31.0
; Second Seed  ; 4.0 ; days 31.0 :: Sun's dusk   ; 10.0 ; days 30.0
; Midyear      ; 5.0 ; days 30.0 :: Evening Star ; 11.0 ; days 31.0

if afMonth == 0.0
   return 31.0
elseif afMonth == 1.0
   return 28.0
elseif afMonth == 2.0
    return 31.0
elseif afMonth == 3.0
    return 30.0
elseif afMonth == 4.0
    return 31.0
elseif afMonth == 5.0
    return 30.0
elseif afMonth == 6.0
    return 31.0
elseif afMonth == 7.0
    return 31.0
elseif afMonth == 8.0
    return 30.0
elseif afMonth == 9.0
    return 31.0
elseif afMonth == 10.0
    return 30.0
elseif afMonth == 11.0
    return 31.0
endif
EndFunction
Int Function GetNumMaxSkills(bool abGetNonMaxed=false)
	; returns the number of skills that are capped.
	Actor Player = Game.GetPlayer()
	Float[] fSkills = new Float[18]
	fSkills[0] = Player.GetActorValue("Alteration")
	fSkills[1] = Player.GetActorValue("Alchemy")
	fSkills[2] = Player.GetActorValue("Block")
	fSkills[3] = Player.GetActorValue("Conjuration")
	fSkills[4] = Player.GetActorValue("Destruction")
	fSkills[5] = Player.GetActorValue("Enchanting")
	fSkills[6] = Player.GetActorValue("HeavyArmor")
	fSkills[7] = Player.GetActorValue("Illusion")
	fSkills[8] = Player.GetActorValue("Lockpicking")
	fSkills[9] = Player.GetActorValue("LightArmor")
	fSkills[10] = Player.GetActorValue("Marksman")
	fSkills[11] = Player.GetActorValue("OneHanded")
	fSkills[12] = Player.GetActorValue("Pickpocket")
	fSkills[13] = Player.GetActorValue("TwoHanded")
	fSkills[14] = Player.GetActorValue("Restoration")
	fSkills[15] = Player.GetActorValue("Sneak")
	fSkills[16] = Player.GetActorValue("Smithing")
	fSkills[17] = Player.GetActorValue("Speechcraft")
	
	Int index = fSkills.Length
	Int iCount
	
	if abGetNonMaxed 
		While index
			index -= 1                  ; Start from the last index
			if fSkills[index] == 100.0  ; Find any skill that is lvl 100.
				iCount += 1             ; record how many were found.
			endif
		EndWhile
	else
		While index
			index -= 1                  ; Start from the last index
			if fSkills[index] < 100.0  ; Find any skill that is lvl 100.
				iCount += 1             ; record how many were found.
			endif
		EndWhile
	endif
	
	return iCount
EndFunction
Return to the user page of "Lisselli".