Difference between revisions of "User talk:Lisselli"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Lisselli
imported>Lisselli
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
GetName - Form
<br>
'''Member of:''' [[Form Script]]
 
Gets the name of the form, full name if possible. Requires F4SE 0.03.1.
 
== Syntax ==
<source lang="papyrus">
string Function GetName() native
</source>
 
== Parameters ==
None
== Return Value ==
The name of the form.
 
== Examples ==
<source lang="papyrus">
; If you want to know the name of the player's current cell.
String sCellName = Game.GetPlayer().GetParentCell().GetName()
debug.trace("My cell's name is: " +sCellName)
</source>
 
== See Also ==
[[Form Script]]
 
 


<source lang="papyrus">
<source lang="papyrus">
Line 51: Line 26:
EndFunction  
EndFunction  
</source>
</source>
<br>
<source lang="papyrus">
<source lang="papyrus">
Float Function HasCellReset(Bool abSetDayLastEntered=True)
Float Function GetDaysInMonth(Float afMonth=0.0) Global
; RETURN VALUES: -1.0 = False | 100.0 = True
; Returns number of days of a month
 
; Morning Star ; 0 ; days 31 :: Sun's Height ; 6 ; days 31   
; Morning Star ; 0.0 ; days 31.0 :: Sun's Height ; 6.0 ; days 31.0  
; Sun's Dawn  ; 1 ; days 28 :: Last Seed    ; 7 ; days 31
; Sun's Dawn  ; 1.0 ; days 28.0 :: Last Seed    ; 7.0 ; days 31.0
; First Seed  ; 2 ; days 31 :: Hearthfire  ; 8 ; days 30
; First Seed  ; 2.0 ; days 31.0 :: Hearthfire  ; 8.0 ; days 30.0
; Rain's Hand  ; 3 ; days 30 :: Frostfall    ; 9 ; days 31
; Rain's Hand  ; 3.0 ; days 30.0 :: Frostfall    ; 9.0 ; days 31.0
; Second Seed  ; 4 ; days 31 :: Sun's dusk  ; 10 ; days 30
; Second Seed  ; 4.0 ; days 31.0 :: Sun's dusk  ; 10.0 ; days 30.0
; Midyear      ; 5 ; days 30 :: Evening Star ; 11 ; days 31
; Midyear      ; 5.0 ; days 30.0 :: Evening Star ; 11.0 ; days 31.0
 
; Store the current month and day this function was called.
if afMonth == 0.0
MonthEntered = GameMonth.GetValue()
  return 31.0
DayEntered = GameDay.GetValue()
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
</source>


    ; Store RespawnTime game setting and convert it into days by dividing the result by 24.
<source lang="papyrus">
Float GetHoursToRespawnCell = Game.GetGameSettingInt("iHoursToRespawnCell") / 24 as Float
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")
      if abSetDayLastEntered == False
Int index = fSkills.Length
Int iCount
if abGetNonMaxed
While index
if MonthEntered == 7
index -= 1                  ; Start from the last index
iMonthNumDays = 31
if fSkills[index] == 100.0  ; Find any skill that is lvl 100.
Float CurrentMonth = GameMonth.GetValue()
iCount += 1            ; record how many were found.
Float CurrentDay = GameDay.GetValue()
endif
if MonthEntered == CurrentMonth
EndWhile
if DayEntered < CurrentDay
else
; return days remaining
While index
Float DaysRemaining = CurrentDay - DayEntered
index -= 1                  ; Start from the last index
if DaysRemaining < GetHoursToRespawnCell
if fSkills[index] < 100.0  ; Find any skill that is lvl 100.
; return days left for cell to respawn
iCount += 1            ; record how many were found.
return GetHoursToRespawnCell - DaysRemaining
elseif DaysRemaining >= GetHoursToRespawnCell
; cell has respawned
return DaysRemaining - GetHoursToRespawnCell
endif
endif
else
; it's a different month, so of course it's reset long time ago
return 100.0
endif
endif
endif
EndWhile
endif
endif
;/
elseif MonthEntered == 1
return iCount
iMonthNumDays = 28
EndFunction
elseif MonthEntered == 2
iMonthNumDays = 31
elseif MonthEntered == 3
iMonthNumDays = 30
elseif MonthEntered == 4
iMonthNumDays = 31
elseif MonthEntered == 5
iMonthNumDays = 30
elseif MonthEntered == 6
iMonthNumDays = 31
elseif MonthEntered == 7
iMonthNumDays = 31
elseif MonthEntered == 8
iMonthNumDays = 30
elseif MonthEntered == 9
iMonthNumDays = 31
elseif MonthEntered == 10
iMonthNumDays = 30
elseif MonthEntered == 11
iMonthNumDays = 31
endif
/;
EndFunction
</source>
</source>

Latest revision as of 06:44, 15 August 2017


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