Difference between revisions of "User:PROXiCiDE/MathUtil"

Jump to navigation Jump to search
2,206 bytes added ,  00:12, 27 April 2014
m
Categorized / Added Example for Bit Manipulation
imported>PROXiCiDE
(Bit Manipulation requires SKSE)
imported>PROXiCiDE
m (Categorized / Added Example for Bit Manipulation)
Line 1: Line 1:
==Non SKSE==
===Math Code===
<source lang="papyrus">
<source lang="papyrus">
;---------------------------------------------------------------------------------[Math]
;---------------------------------------------------------------------------------[Math]
Line 7: Line 9:
; 0.2 - Optimizations by Cipscis
; 0.2 - Optimizations by Cipscis
; IsNumberEven ,IsNumberOdd ,InRange
; IsNumberEven ,IsNumberOdd ,InRange
; 0.3 - Bit Set/Get/Clear
; 0.3 - Bit Set/Xor/SetBool/Get/Clear/ClearFrom


;---------------------------------------------------------------------------------[Min]
;---------------------------------------------------------------------------------[Min]
Line 112: Line 114:
     EndIf
     EndIf
EndFunction
EndFunction
</source>


==Requires SKSE==
===Bit Code===
<source lang = "papyrus">
;---------------------------------------------------------------------------------[Bit Manipulation]
;---------------------------------------------------------------------------------[Bit Manipulation]
; Requires SKSE
; Requires SKSE
Line 173: Line 179:
Return 0
Return 0
EndIf
EndIf
EndFunction
</source>
===Bit Manipulation Example===
Following Example is incomplete code and only serves as a skeletal example for Bit Manipulation methods
<source lang = "papyrus">
Int PerkCTX_Bits = 0
;Perk Bits
Int PerkCTX_Bit_Ordered = 1
Int PerkCTX_Bit_PerkReset = 2
Int PerkCTX_Bit_SkillOverrideInit = 3
Int PerkCTX_Bit_SkillOverride = 4
Function PerkUI_Init(Int[] aiPerkCTX, Bool abOrdered = True, Bool abPerkReset = True, String asActorValue = "", Int aiPerkMult = 20, Int aiPerkRankMult = 20, Bool abSkillReqOverride = False)
If Bit_Get(aiPerkCTX[PerkCTX_Bits],PerkCTX_Bit_SkillOverrideInit)
_sSkillName = New String[18]
;Combat
_sSkillName[0] = "Marksman"
_sSkillName[1] = "Block"
_sSkillName[2] = "HeavyArmor"
_sSkillName[3] = "OneHanded"
_sSkillName[4] = "Smithing"
_sSkillName[5] = "TwoHanded"
;Magic
_sSkillName[6] = "Alteration"
_sSkillName[7] = "Conjuration"
_sSkillName[8] = "Destruction"
_sSkillName[9] = "Enchanting"
_sSkillName[10] = "Illusion"
_sSkillName[11] = "Restoration"
;Stealth
_sSkillName[12] = "Alchemy"
_sSkillName[13] = "LightArmor"
_sSkillName[14] = "Lockpicking"
_sSkillName[15] = "Pickpocket"
_sSkillName[16] = "Sneak"
_sSkillName[17] = "Speechcraft"
Bit_SetBool(aiPerkCTX[PerkCTX_Bits],PerkCTX_Bit_SkillOverrideInit,True)
EndIf
Bit_SetBool(aiPerkCTX[PerkCTX_Bits], PerkCTX_Bit_Ordered, abOrdered)
Bit_SetBool(aiPerkCTX[PerkCTX_Bits], PerkCTX_Bit_PerkReset, abPerkReset)
Bit_SetBool(aiPerkCTX[PerkCTX_Bits], PerkCTX_Bit_SkillOverride, abSkillReqOverride)
aiPerkCTX[PerkCTX_PerkMult] = MakeDWord(aiPerkMult,aiPerkRankMult)
aiPerkCTX[PerkCTX_PerkReserved] = 0 ; Reserved
aiPerkCTX[PerkCTX_PerkSkillAttribute] = PerkUI_SetSkillNameToIndex(asActorValue)
EndFunction
Function PerkUI_ApplyByFormList(FormList akList, Int[] aiPerkCTX, Bool abAddPerks = True, Int[] aiSkillOverride)
If akList == None
Return
EndIf
Bool abOrdered = Bit_Get(aiPerkCTX[PerkCTX_Bits],PerkCTX_Bit_Ordered)
Bool abPerkReset = Bit_Get(aiPerkCTX[PerkCTX_Bits],PerkCTX_Bit_PerkReset)
...
... Rest of Code
...
EndFunction
EndFunction
</source>
</source>
Anonymous user

Navigation menu