Jump to content

Help with public properties?


Pandaman

Recommended Posts

Hey folks, my brain's about pooped and I can't figure out what must be a blatantly obvious mistake I've made, but I'm stuck trying to get one script to access and alter variables/properties in another script. Supposedly all I need to do is include "parentScriptNameHere Property roofus Auto", then in the child script add "roofus." in front of the variable name I want to play with. Abridged version of the code I'm working on below:

 

 

 

Armor script:

Scriptname aaDAFArmorScript extends ObjectReference

Armor[] Property dynamicArmorProperty Auto
Spell Property dynamicSpellProperty Auto
Message Property damagedMessage Auto
Message Property destroyedMessage Auto
int Property damagePerStage Auto
int Property damageFromPowerAttack Auto
int Property damageFromNormalAttack Auto
int Property numStages Auto
int Property currentStage Auto
int Property currentDamage Auto
int newStage
;--------------------------------------------------------------------------------------------------------------------------
Event OnEquipped(Actor akActor)
    ; Initialize values if this is the first time wearing the armor.
    if (currentStage == 0)
        numStages = GetNumStages(dynamicArmorProperty)
        currentStage = 1
        currentDamage = 0
    endif

    ; Equip the ability with the OnHit script and the current stage of the armor.
    GoToState("")
    akActor.EquipItem(dynamicArmorProperty[currentStage], true, true)
    akActor.AddSpell(dynamicSpellProperty, false)
    GoToState("Inactive")
endEvent
;--------------------------------------------------------------------------------------------------------------------------

Magic effect script:

Scriptname aaDAFEffectScript extends ActiveMagicEffect

aaDAFArmorScript Property dynamicArmorRef Auto

int newStage
;--------------------------------------------------------------------------------------------------------------------------
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
    Actor actorRef = GetTargetActor()
    if ((abHitBlocked != true) && (akProjectile == None))
        debug.notification("Damage taken.")
        if (abPowerAttack == true)
            dynamicArmorRef.currentDamage += dynamicArmorRef.damageFromPowerAttack
        else
            dynamicArmorRef.currentDamage += dynamicArmorRef.damageFromNormalAttack
        endif
    endif

    if ((dynamicArmorRef.currentStage != dynamicArmorRef.numStages) && (dynamicArmorRef.currentDamage >= dynamicArmorRef.damagePerStage))
        debug.notification("Damage registered.")
        newStage = dynamicArmorRef.currentStage + 1
        if (newStage < dynamicArmorRef.numStages)
            actorRef.EquipItem(dynamicArmorRef.dynamicArmorProperty[newStage], true, true)
            actorRef.RemoveItem(dynamicArmorRef.dynamicArmorProperty[dynamicArmorRef.currentStage], 1, true)
            dynamicArmorRef.currentStage = newStage
            dynamicArmorRef.damagedMessage.Show()
        elseif (newStage == dynamicArmorRef.numStages)
            actorRef.EquipItem(dynamicArmorRef.dynamicArmorProperty[newStage], true, true)
            actorRef.RemoveItem(dynamicArmorRef.dynamicArmorProperty[dynamicArmorRef.currentStage], 1, true)
            dynamicArmorRef.currentStage = newStage
            dynamicArmorRef.destroyedMessage.Show()
        endif
        dynamicArmorRef.currentDamage = 0
    endif
endEvent
;--------------------------------------------------------------------------------------------------------------------------

 

 

 

While the scripts compile just fine, when I try it out in game the values are all returning the default 0, even the ones I set in the CK (damagePerStage, damageFromPowerAttack, and damageFromNormalAttack). Does anyone know what's going on? Do I just need a slap upside the head? Thanks in advance!

 

Edit: aaaand just by clicking the "scripting" tag I see there's already a post on this subject.

 

Edit II: still can't see what I'm doing wrong :(

Link to comment

Yep.

 

This script

Scriptname _sc_player_knockout_mes extends activemagiceffect  

event OnEffectStart(Actor akTarget, Actor akCaster)
	re.strikeISM.Apply()
	Game.ForceFirstPerson()
	Game.DisablePlayerControls(true,true,true,true,true,true)
	akTarget.PlayIdle(re.knockoutPlayer)
	Utility.Wait(10.0)
	Game.FadeOutGame(true, true, 0.0, 4.0)
	Utility.Wait(4.0)
	re.GameHour.Mod( Utility.RandomFloat(20.0, 28.0) )
	re.slaveryTrigger.SendStoryEvent( aiValue1 = 1, aiValue2 = ae.countCompanions() )
endEvent

event OnEffectFinish(Actor akTarget, Actor akCaster)

endEvent

_sc_mcm_script   property mcm              auto
_sc_ae_script    property ae               auto
_sc_resources    property re               auto ;<<< Selected in the next pic.

Its attached to the _sc_hobble_player_me Magic effect.

post-3866-0-05276800-1384536158_thumb.jpg

 

Clicking the properties button allows you to connect each defined property to it's reference. 

post-3866-0-07986800-1384535449_thumb.jpg
 
In the case of the property re, it points to the _sc_base quest.
post-3866-0-05935600-1384535666_thumb.jpg

 

That has the _sc_resources script attached to it.

post-3866-0-90190300-1384535851_thumb.jpg

Scriptname _sc_resources extends questVersioning  

Armor               property zbfGagRing      auto

; VERSION 5
Armor               property zbfBindings     auto
Idle                property knockoutPlayer  auto  
Idle                property getUpPlayer     auto  
ImageSpaceModifier  property strikeISM       auto  ; <<< used in _sc_player_knockout_mes
Keyword             property slaveryTrigger  auto  ; <<< used in _sc_player_knockout_mes

; VERSION 6
Outfit              property nudeOutfit      auto

; VERSION 7
GlobalVariable      property GameHour        auto  ; <<< used in _sc_player_knockout_mes

That actually contains the object

post-3866-0-30678600-1384536557_thumb.jpg

Link to comment

Hmm, I thought I might have to do that, but when I go to fill in the value for the property, I get the "Pick Reference in Render Window" button, a Cell selection, and Reference selection instead of a single Object reference.:

 

post-416-0-45910800-1384559163_thumb.jpg

 

Which is what's making me think there's something wrong with the way I'm declaring the script that should be accessed. If there's nothing wrong with the script itself, is it because the script I'm accessing is an ObjectReference? I really hope that's not the cause.

 

Edit:

And that was, in fact, the reason. Just needed to replace ObjectReference with Armor, I'm surprised it was that simple.

Scriptname aaDAFArmorScript extends Armor

Edit 2: Apparently OnEquipped and OnUnequipped do not work on a script that extends armor. Why, Bethesda? Whhhhh-h-h-hy?

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use