Keyword in script

Post » Tue Jun 19, 2012 10:51 am

I'm having an issue with

Scriptname aaEquipRestrictScript extends ReferenceAliasKeyword Property ArmorLight  Auto int armorRatingint playerArmorint newPlayerArmorEvent onInit()playerArmor = GetActorRef().getAV("DamageResist") as intendEventEvent OnObjectUnEquipped(Form akBaseObject, ObjectReference akReference)if akBaseObject as Armor  playerArmor = GetActorRef().getAV("DamageResist") as intendifendEventEvent OnObjectEquipped(Form akBaseObject, ObjectReference akReference)if akBaseObject as ArmornewPlayerArmor = GetActorRef().getAV("DamageResist") as intarmorRating = (newPlayerArmor - (playerArmor + 1)) as intif (akBaseObject.HasKeyword(ArmorLight))GetActorRef().UnequipItem(akBaseObject, false, false)endifendifendEvent

Basically the long term idea is to auto unequip armor and weapons if you don't have enough skill for it (ie: a light gauntlet with 4 armor rating would require you to have X light armor in order to equip)

However the problem is "if (akBaseObject.HasKeyword(ArmorLight))" always returns 0 regardless of anything, is there a workaround for this, or is it just bugged?
User avatar
Captian Caveman
 
Posts: 3410
Joined: Thu Sep 20, 2007 5:36 am

Post » Tue Jun 19, 2012 12:43 pm

Are you sure you've associated the value of your property correctly with the right keyword?

Cipscis
User avatar
Rhysa Hughes
 
Posts: 3438
Joined: Thu Nov 23, 2006 3:00 pm

Post » Mon Jun 18, 2012 11:24 pm

Are you sure you've associated the value of your property correctly with the right keyword?

Cipscis

Yep, I've tried a ton of different ways to get it to work but nothing has so far
User avatar
Kate Murrell
 
Posts: 3537
Joined: Mon Oct 16, 2006 4:02 am

Post » Tue Jun 19, 2012 11:16 am

bump
User avatar
Dawn Farrell
 
Posts: 3522
Joined: Thu Aug 23, 2007 9:02 am

Post » Tue Jun 19, 2012 11:28 am

wait, give me a couple mins or so ill help you i am working on it now, popping up the ck as we speak
User avatar
Abel Vazquez
 
Posts: 3334
Joined: Tue Aug 14, 2007 12:25 am

Post » Tue Jun 19, 2012 12:31 am

Use, http://www.creationkit.com/WornHasKeyword_-_Actorinstead of HasKeyword

wouldn't that effect anything the player has, rather than the specific object you're equipping?
User avatar
Miss K
 
Posts: 3458
Joined: Sat Jan 20, 2007 2:33 pm

Post » Tue Jun 19, 2012 1:19 pm

ya i totaly mis-read everything that is why i edited it, see edited post
User avatar
Monika
 
Posts: 3469
Joined: Wed Jan 10, 2007 7:50 pm

Post » Tue Jun 19, 2012 12:20 pm

wait, give me a couple mins or so ill help you i am working on it now, popping up the ck as we speak

Ah cool! I'm actually about to go to work, I'll be back in about 4 hours, if you like the idea of the mod at all we could work on it together
User avatar
Vicky Keeler
 
Posts: 3427
Joined: Wed Aug 23, 2006 3:03 am

Post » Tue Jun 19, 2012 2:32 am

is this script attached to the Player directly? if so might want to use Actor instead of ReferenceAlias?
User avatar
Floor Punch
 
Posts: 3568
Joined: Tue May 29, 2007 7:18 am

Post » Tue Jun 19, 2012 6:35 am

is this script attached to the Player directly? if so might want to use Actor instead of ReferenceAlias?

It's attached to a script that's attached to the player using an alias
User avatar
Eduardo Rosas
 
Posts: 3381
Joined: Thu Oct 18, 2007 3:15 pm

Post » Tue Jun 19, 2012 7:35 am

ok you forgot to Cast to the akBaseObject as a armor , revised script it worked for me

Spoiler

ScriptName ZZ_HasObjectKeyword Extends   ReferenceAlias  Keyword Property ArmorLight  AutoInt armorRatingInt playerArmorInt newPlayerArmorEvent OnInit()    playerArmor = GetActorRef().getAV("DamageResist") As IntEndEventEvent OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)    If akBaseObject As Armor        playerArmor = GetActorRef().getAV("DamageResist") As Int        Debug.Notification("We unequipped a armor")    EndIfEndEventEvent OnObjectEquipped(Form akBaseObject, ObjectReference akReference)    If akBaseObject As Armor        newPlayerArmor = GetActorRef().getAV("DamageResist") As Int        armorRating = (newPlayerArmor - (playerArmor + 1)) As Int        If ((akBaseObject As Armor).HasKeyword(ArmorLight))            Debug.Notification("We equipped a lightarmor object")            GetActorRef().UnequipItem(akBaseObject, False, False)        EndIf    EndIfEndEvent
User avatar
FABIAN RUIZ
 
Posts: 3495
Joined: Mon Oct 15, 2007 11:13 am

Post » Tue Jun 19, 2012 1:38 pm

ok you forgot to Cast to the akBaseObject as a armor , revised script it worked for me
Spoiler
 ScriptName ZZ_HasObjectKeyword Extends ReferenceAlias Keyword Property ArmorLight Auto Int armorRating Int playerArmor Int newPlayerArmor Event OnInit() playerArmor = GetActorRef().getAV("DamageResist") As Int EndEvent Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) If akBaseObject As Armor playerArmor = GetActorRef().getAV("DamageResist") As Int Debug.Notification("We unequipped a armor") EndIf EndEvent Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) If akBaseObject As Armor newPlayerArmor = GetActorRef().getAV("DamageResist") As Int armorRating = (newPlayerArmor - (playerArmor + 1)) As Int If ((akBaseObject As Armor).HasKeyword(ArmorLight)) Debug.Notification("We equipped a lightarmor object") GetActorRef().UnequipItem(akBaseObject, False, False) EndIf EndIf EndEvent 

You're amazing! I'm going to get a formula to get an alpha or beta version of this mod working ^^
User avatar
Louise Lowe
 
Posts: 3262
Joined: Fri Jul 28, 2006 9:08 am

Post » Tue Jun 19, 2012 1:58 am

No problem :) glad i could be some assistance
User avatar
Leticia Hernandez
 
Posts: 3426
Joined: Tue Oct 23, 2007 9:46 am

Post » Tue Jun 19, 2012 1:44 am

ok you forgot to Cast to the akBaseObject as a armor , revised script it worked for me
Spoiler
 ScriptName ZZ_HasObjectKeyword Extends ReferenceAlias Keyword Property ArmorLight Auto Int armorRating Int playerArmor Int newPlayerArmor Event OnInit() playerArmor = GetActorRef().getAV("DamageResist") As Int EndEvent Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) If akBaseObject As Armor playerArmor = GetActorRef().getAV("DamageResist") As Int Debug.Notification("We unequipped a armor") EndIf EndEvent Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) If akBaseObject As Armor newPlayerArmor = GetActorRef().getAV("DamageResist") As Int armorRating = (newPlayerArmor - (playerArmor + 1)) As Int If ((akBaseObject As Armor).HasKeyword(ArmorLight)) Debug.Notification("We equipped a lightarmor object") GetActorRef().UnequipItem(akBaseObject, False, False) EndIf EndIf EndEvent 

I don't mean to bump this but I'm trying to understand how this script works.

Why is it it nessicary to set what the armorRating variable is in this script, when it appears that all you are doing is just setting that variable?

I'm just confused why you're decalring all the variables, but none of them are actually being used or checked in the script (it seems like the only thing actually done script wise is checking if the armor = ArmorLight keyword...)

How does -only- checking if the keyword is light armor related, have anything to with checking if a player is high enough level to use the armor?
User avatar
Georgia Fullalove
 
Posts: 3390
Joined: Mon Nov 06, 2006 11:48 pm

Post » Tue Jun 19, 2012 3:00 pm

How does -only- checking if the keyword is light armor related, have anything to with checking if a player is high enough level to use the armor?

I think the rewrittern version is just testing the keyword check...Presumably once he has that working he'll be doing the comparison before unequipping it.
User avatar
Heather M
 
Posts: 3487
Joined: Mon Aug 27, 2007 5:40 am

Post » Tue Jun 19, 2012 5:52 am

I think the rewrittern version is just testing the keyword check...Presumably once he has that working he'll be doing the comparison before unequipping it.

Ah, makes sense :tongue:

So if this were to be complete, then I assume the script would check if the armorRating variable is at least at X pre-determined value right after the check for the ArmorLight keyword passes, and if not, then the script continues with the unequip?

So in essence, he's checking first if an armor piece is light armor or heavy armor (since heavy armor would have a naturally higher damage resistance, so that would need to be taken into account). After he determines what type the armor is, he then would check what current damage resistence value is for that single armor piece. This is done by compairing the new damage resistance to what the previous DR value was (determined whenever a player unequips an item, or when the script starts). Once this is figured out, it sets the value of the armorRating variable. After armorRating is figured out, he might check if the armorRating variable >= 10 (for example). Now he has an idea of how "good" that light armor piece is. If it gives a big enough boost, the script might go "okay, well if you have at least a DR of 10 for this one piece then that means the item is high level, and as such we're going to unequip it".

Just trying to understand how the scripting logic would work in this situation ;)
User avatar
OTTO
 
Posts: 3367
Joined: Thu May 17, 2007 6:22 pm


Return to V - Skyrim