Jump to content

Need help with script!


Recommended Posts

I'm trying to get this script to work, and while the menu opening event works just fine, it doesn't seem to fire off my custom function of SetSkills() anyone got any advice?

Scriptname YAS_Script_Skills extends ReferenceAlias

Actor Property PlayerRef Auto Const
ActorValue Property YAS_AV_SkillBaseMult Auto Const
ActorValue Property YAS_AV_SkillAttributeBase Auto Const

Struct Skill
	ActorValue skill
	ActorValue attribute
	Float skillBase
	Float skillTempBonus
	Float attributeBase
	Float attributeTempBonus
	FormList skillEffectsList
	FormList skillEffectMultsList
EndStruct

Skill[] Property skills Auto

Event OnAliasInit()
	RegisterForMenuOpenCloseEvent("PipboyMenu")
EndEvent

Event OnMenuOpenCloseEvent(String asMenuName, Bool abOpening)
	If (asMenuName == "PipboyMenu")
		Debug.Notification("PipboyMenu abOpening = " + abOpening as String)
		SetSkills()
	EndIf
EndEvent

Function SetSkills()
	Int iIndex = 0
	While (iIndex < skills.Length)
		Debug.Notification("Skill Name: " + skills[iIndex].skill.GetName() + ", Governing Attribute: " + skills[iIndex].attribute.GetName())
		skills[iIndex].attributeBase = PlayerRef.GetBaseValue(skills[iIndex].attribute)
		skills[iIndex].attributeTempBonus = (PlayerRef.GetValue(skills[iIndex].attribute) as Float) - skills[iIndex].attributeBase
		skills[iIndex].skillBase = PlayerRef.GetBaseValue(skills[iIndex].skill)
		skills[iIndex].skillTempBonus = (skills[iIndex].attributeTempBonus * (PlayerRef.GetValue(YAS_AV_SkillAttributeBase) * PlayerRef.GetValue(YAS_AV_SkillBaseMult)))
		If (PlayerRef.GetValue(skills[iIndex].skill) < skills[iIndex].skillBase + skills[iIndex].skillTempBonus)
			PlayerRef.ModValue(skills[iIndex].skill, skills[iIndex].skillTempBonus)
		EndIf
		SetSkillEffectValues(skills[iIndex].skill, skills[iIndex].skillEffectsList, skills[iIndex].skillEffectMultsList)
		iIndex += 1
	EndWhile
EndFunction

Function SetSkillEffectValues(ActorValue skillValue, FormList effectsList, FormList effectMultsList)
	Int iIndex = 0
	While (iIndex < effectsList.GetSize())
		ActorValue thisEffect = effectsList.GetAt(iIndex) as ActorValue
		ActorValue thisEffectMult = effectMultsList.GetAt(iIndex) as ActorValue
		Float thisEffectValue = PlayerRef.GetValue(thisEffect)
		Float thisEffectMultValue = PlayerRef.GetValue(thisEffectMult)
		Float formula = (thisEffectValue * thisEffectMultValue) * PlayerRef.GetValue(skillValue)
		PlayerRef.SetValue(thisEffect, formula)
		iIndex += 1
	EndWhile
EndFunction
Link to comment
Share on other sites

Two things
(1) The skills variable array wont exist as it has not been instantiated.
Event OnAliasInit()
   RegisterForMenuOpenCloseEvent("PipboyMenu")
   skills = New Skill[0]
EndEvent
The array declaration (Skill[] Property skills Auto) is not an instatiation.
The naming conventions are also challenging if you change (Skill to SkillStructure) and (skills to SkillsArray) it all becomes so much easier to follow ... and maintain in the future.
SkillStructure[] Property SkillsArray Auto ; declaration

SkillsArray = New SkillStructure[0] ; instantiation 

(2) As DFM suggests when the script starts skills.Length will be zero (after it is instantiated) so the loop will never go anywhere. I cant follow what your trying to do with SkillsArray so you need to re think the processing logic.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...