Any help? The script runs a calculation on the player to determine what armor he is wearing (and as such, change a gvar), and then runs a hit check on the player to determine if a stun effect should apply or not.
I'm using SKSE functions GetKeyword but I can't get it to work at all like the example mentions it should.
My script:
actor Property PlayerRef AutoSpell Property CPO_LA_LightArmorKnockdown Autobool HeavyArmorCuirassEquippedfloat KnockdownRandomChanceint PlayerLightArmorSkillfloat ThreatLevelfloat ArmorMultiplierfloat EnemyHealthint EnemyLevelint PlayerHealthfloat EnemyPowerAttackMultiplierEvent OnInit() Keyword MaterialDragonscale = Keyword.GetKeyword("ArmorMaterialDragonscale") Keyword MaterialGlass = Keyword.GetKeyword("ArmorMaterialGlass") Keyword MaterialHide = Keyword.GetKeyword("ArmorMaterialHide") Keyword MaterialImperialLight = Keyword.GetKeyword("ArmorMaterialImperialLight") Keyword MaterialImperialStudded = Keyword.GetKeyword("ArmorMaterialImperialStudded") Keyword MaterialLeather = Keyword.GetKeyword("ArmorMaterialLeather") Keyword MaterialScaled = Keyword.GetKeyword("ArmorMaterialScaled") Keyword MaterialStormcloak = Keyword.GetKeyword("ArmorMaterialStormcloak") Keyword MaterialStudded = Keyword.GetKeyword("ArmorMaterialStudded") KnockdownRandomChance = Utility.RandomFloat(1, 2) PlayerLightArmorSkill = PlayerRef.GetActorValue("Light Armor") as int PlayerHealth = PlayerRef.GetActorValue("Health") as int ArmorMultiplier = 0.66endEventEvent OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) if akBaseObject As Armor if (akBaseObject As Armor).IsLightArmor() && (akBaseObject As Armor).IsCuirass() PlayerRef.RemovePerk(CPO_LA_SpeedSkillCuirass) if (akBaseObject As Armor).HasKeyword(MaterialDragonscale) CPO_LAMaterialDragonscale.SetValue(0) ArmorMultiplier = 0.66 elseif (akBaseObject As Armor).HasKeyword(MaterialGlass) CPO_LAMaterialGlass.SetValue(0) ArmorMultiplier = 0.66 elseif (akBaseObject As Armor).HasKeyword(MaterialElven) CPO_LAMaterialElven.SetValue(0) ArmorMultiplier = 0.66 elseif (akBaseObject As Armor).HasKeyword(MaterialHide) CPO_LAMaterialHide.SetValue(0) ArmorMultiplier = 0.66 elseif (akBaseObject As Armor).HasKeyword(MaterialImperialLight) CPO_LAMaterialImperialLight.SetValue(0) ArmorMultiplier = 0.66 elseif (akBaseObject As Armor).HasKeyword(MaterialImperialStudded) CPO_LAMaterialImperialStudded.SetValue(0) ArmorMultiplier = 0.66 elseif (akBaseObject As Armor).HasKeyword(MaterialLeather) CPO_LAMaterialLeather.SetValue(0) ArmorMultiplier = 0.66 elseif (akBaseObject As Armor).HasKeyword(MaterialScaled) CPO_LAMaterialScaled.SetValue(0) ArmorMultiplier = 0.66 elseif (akBaseObject As Armor).HasKeyword(MaterialStormcloak) CPO_LAMaterialStormcloak.SetValue(0) ArmorMultiplier = 0.66 elseif (akBaseObject As Armor).HasKeyword(MaterialStudded) CPO_LAMaterialStudded.SetValue(0) ArmorMultiplier = 0.66 endif endif if (akBaseObject As Armor).IsHeavyArmor() && (akBaseObject As Armor).IsCuirass() HeavyArmorCuirassEquipped = false endif if (akBaseObject As Armor).IsLightArmor() && (akBaseObject As Armor).IsBoots() PlayerRef.RemovePerk(CPO_LA_SpeedSkillBoots) endif endifendEventEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) if HeavyArmorCuirassEquipped == false if (akProjectile) == false && abHitBlocked == false if akAggressor.HasKeywordString("ActorTypeCreature") EnemyHealth = akAggressor.GetActorValue("health") as int EnemyLevel = akAggressor.GetLevel() as int ThreatLevel = (EnemyHealth / 10) + (EnemyLevel * 6) elseif akAggressor.HasKeywordString("ActorTypeNPC") EnemyHealth = akAggressor.GetActorValue("health") as int EnemyLevel = akAggressor.GetLevel() as int if akAggressor.GetActorValue("OneHanded") >= akAgressor.GetActorValue("TwoHanded") ThreatLevel = (EnemyHealth / 5) + (EnemyLevel * 3) + (akAgressor.GetActorValue("OneHanded") / 1.5) elseif akAggressor.GetActorValue("OneHanded") <= akAgressor.GetActorValue("TwoHanded") ThreatLevel = (EnemyHealth / 5) + (EnemyLevel * 3) + (akAgressor.GetActorValue("TwoHanded") / 1.5) endif endif if abPowerAttack == true EnemyPowerAttackMultiplier = 1.5 else EnemyPowerAttackMultiplier = 1 endif if (ThreatLevel * EnemyPowerAttackMultiplier * ArmorMultiplier) > (((PlayerLightArmorSkill * 2) + (PlayerHealth / 1.2)) * KnockdownRandomChance) ;Skill-check, with random dice roll. KnockdownEffect.Apply() CPO_LA_LightArmorKnockdown.Cast(PlayerRef) debug.Notification("Knocked off balance!") endif endif endifEndEvent
Here's what my compile errors say:
What confuses me is suddenly, "GetActorValue" doesn't exist when I know for a fact it does, and it says my MaterialTypes are undefined when I identify them right under OnInit (I know I am missing one or two like elven, but it says I don't have any). Whats even more confusing is when I try to define them at the top of the script (i.e. by going "Keyword = etcetc" it'll throw out an error saying I already defined it. The spelling appears to be correct as well.
I assume the only reason why the "cannot cast non to an int" errors are occurring is because for some reason the scripting engine no longer recognizes GetActorValue or GetLevel as proper functions, even though they are.
I have to be spelling something wrong or missing a period or something, but I looked through it and it seemed to be correct. I must be missing something obvious..