Difference between revisions of "User talk:Lisselli"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Lisselli
m
imported>Lisselli
Line 50: Line 50:
      
      
EndFunction  
EndFunction  
</source>
<source lang="papyrus">
Float Function HasCellReset(Bool abSetDayLastEntered=True)
; RETURN VALUES: -1.0 = False | 100.0 = True
; Morning Star ; 0 ; days 31 :: Sun's Height ; 6 ; days 31 
; Sun's Dawn  ; 1 ; days 28 :: Last Seed    ; 7 ; days 31
; First Seed  ; 2 ; days 31 :: Hearthfire  ; 8 ; days 30
; Rain's Hand  ; 3 ; days 30 :: Frostfall    ; 9 ; days 31
; Second Seed  ; 4 ; days 31 :: Sun's dusk  ; 10 ; days 30
; Midyear      ; 5 ; days 30 :: Evening Star ; 11 ; days 31
; Store the current month and day this function was called.
MonthEntered = GameMonth.GetValue()
DayEntered = GameDay.GetValue()
    ; Store RespawnTime game setting and convert it into days by dividing the result by 24.
Float GetHoursToRespawnCell = Game.GetGameSettingInt("iHoursToRespawnCell") / 24 as Float
      if abSetDayLastEntered == False
if MonthEntered == 7
iMonthNumDays = 31
Float CurrentMonth = GameMonth.GetValue()
Float CurrentDay = GameDay.GetValue()
if MonthEntered == CurrentMonth
if DayEntered < CurrentDay
; return days remaining
Float DaysRemaining = CurrentDay - DayEntered
if DaysRemaining < GetHoursToRespawnCell
; return days left for cell to respawn
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
;/
elseif MonthEntered == 1
iMonthNumDays = 28
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>

Revision as of 14:58, 15 July 2017

GetName - Form Member of: Form Script

Gets the name of the form, full name if possible. Requires F4SE 0.03.1.

Syntax

string Function GetName() native

Parameters

None

Return Value

The name of the form.

Examples

; 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)

See Also

Form Script


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 HasCellReset(Bool abSetDayLastEntered=True)
	; RETURN VALUES: -1.0 = False | 100.0 = True
	
	; Morning Star ; 0 ; days 31 :: Sun's Height ; 6 ; days 31  
	; Sun's Dawn   ; 1 ; days 28 :: Last Seed    ; 7 ; days 31
	; First Seed   ; 2 ; days 31 :: Hearthfire   ; 8 ; days 30
	; Rain's Hand  ; 3 ; days 30 :: Frostfall    ; 9 ; days 31
	; Second Seed  ; 4 ; days 31 :: Sun's dusk   ; 10 ; days 30
	; Midyear      ; 5 ; days 30 :: Evening Star ; 11 ; days 31
	
	; Store the current month and day this function was called.
	MonthEntered = GameMonth.GetValue()
	DayEntered = GameDay.GetValue()

     ; Store RespawnTime game setting and convert it into days by dividing the result by 24.
	Float GetHoursToRespawnCell = Game.GetGameSettingInt("iHoursToRespawnCell") / 24 as Float
	
      if abSetDayLastEntered == False
	
	
	
		if MonthEntered == 7
			iMonthNumDays = 31
			Float CurrentMonth = GameMonth.GetValue()
			Float CurrentDay = GameDay.GetValue()
			if MonthEntered == CurrentMonth
				if DayEntered < CurrentDay
					; return days remaining 
					Float DaysRemaining = CurrentDay - DayEntered
					if DaysRemaining < GetHoursToRespawnCell
						; return days left for cell to respawn
						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
	;/	
	elseif MonthEntered == 1
		iMonthNumDays = 28
	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