Jump to content

[LE] Scripting Armor Enchantments with scalable values


Recommended Posts

BarierHealth.SetBaseArmorHealth = baseArmorHealth

That's changing SetBaseArmorHealth in the armor to be the same as baseArmorHealth, I think you want to do exactly the opposite, right? or I have understood you wrong?

 

Not sure what you mean by "cast" as the comment by the side of the property. That usually means changing the script type of something, like you could cast an objectreference as actor in order to run some functions from the actor script in it. Or a general form as the particular types, book, weapon, armor, etc. Or casting a float as Int or viceversa.

 

So, you want to have multiple versions of the GuardEnchScript, reacting to different keywords and such and also have different versions of the armor with BarrierHealthControl having different values for SetBaseArmorHealth on these armor forms. And so you get these variants to combine with each other, is that it?

 

With what form exactly are you filling the BarrierHealth property then? On each magic effect you are going to have to fill there a specific preset form so does it actually give any more variety than having the property on the magic effect? In the end you have to attach an enchantment to a particular form and fill the property on the magic effect to point to it, right? I don't know, maybe I'm not understanding what you want to do, it's 2 AM.

Edited by FrankFamily
Link to comment
Share on other sites

I´m Sorry if I am unclear.

 

BarierHealth.SetBaseArmorHealth = baseArmorHealth

That's changing SetBaseArmorHealth in the armor to be the same as baseArmorHealth, I think you want to do exactly the opposite, right? or I have understood you wrong?

 

Yes, you understood me right. I want the value of SetBaseArmorHealth to overwrite whatever float value is in baseArmorHealth in the GuardEnchScript.

 

I spent some time debugging this and BarrierHealth.SetBaseArmorHealth does not seem to carry over the value from the BarierHealthControl to the GuardEnchScript at all.

 

I am using the second example from this creation kit wiki page:

(https://www.creationkit.com/index.php?title=Variables_and_Properties#Getting_Properties_From_Any_Other_Script)

 

 

Not sure what you mean by "cast" as the comment by the side of the property. That usually means changing the script type of something, like you could cast an objectreference as actor in order to run some functions from the actor script in it. Or a general form as the particular types, book, weapon, armor, etc. Or casting a float as Int or viceversa.

 

So, you want to have multiple versions of the GuardEnchScript, reacting to different keywords and such and also have different versions of the armor with BarrierHealthControl having different values for SetBaseArmorHealth on these armor forms. And so you get these variants to combine with each other, is that it?

 

With what form exactly are you filling the BarrierHealth property then? On each magic effect you are going to have to fill there a specific preset form so does it actually give any more variety than having the property on the magic effect? In the end you have to attach an enchantment to a particular form and fill the property on the magic effect to point to it, right? I don't know, maybe I'm not understanding what you want to do, it's 2 AM.

 

 

I just really want to have one copy of the GuardEnchScript and the BarierHealthControl scripts, to be filled out with the desired values through the properties window in the creation kit for different armour sets.

 

In my mind, this should keep it clean enough to add other magic effects to the enchantment without affecting the script that drives this magic effect, I am trying to create.

 

Keywords:

I intend to make use of Keyword properties in similar fashion to identify the damage and create some math to reduce it in some cases. I could probably just use already existing enchantments for that though.

 

ps:

If you still find me unclear, could we have a chat over discord or something?

Edited by AslanKebab
Link to comment
Share on other sites

ok got it, then you definitely have the assignment the other way around, you should do this instead:

 

baseArmorHealth = BarrierHealth.SetBaseArmorHealth

 

you want to read from SetBaseArmorHealth and assign that to baseArmorHealth

Edited by FrankFamily
Link to comment
Share on other sites

Okej

 

That made a lot of sense...I made that change and now the only problem is that BarrierHealth.SetBaseArmorHealth does not seem to carry over the value of SetBaseArmorHealth from the BarierHealthControl to the GuardEnchScript at all.

I´ve followed the example in the creation kit wiki and re-compiled both scripts, I have no idea where to start looking for what's missing... :ohmy:

Link to comment
Share on other sites

Not sure, if you have the assignment now in the right order and the property is filled it should work. Note the value of a property is baked into the saved game and will take priority over any changes to the default value of that property in ck, so test on new saves if you change the value.

Other than that, have debug messages to make sure the proper events are firing correctly and such general debugging.

Edited by FrankFamily
Link to comment
Share on other sites

I usually use the console COC "area of choice" command for testing out stuff so it shouldn't be a problem save data wise.

 

Here: what I´ve tried so far:

 

- I did change the order to be baseArmorHealth = BarrierHealth.SetBaseArmorHealth as suggested which I think you are right about

 

- I have debuged the code and it seemed at first a timing issue as the scripts seems to try to run parallel, but even with a "utility wait" on the GuardEnch script does not seem to help. I also ran an On update event to check if these values are updated later on but does not seems to work.

 

is there something else I could do in troubleshooting this?

 

If you have the time, I would be grateful if you copied the code I posted earlier (and just switch order as you suggested) add put GuardEnchScript on a magic effect and attach it to a dummy enchantment and add the second BarierHealthControl script to an armour piece and see if you can spot where things go wrong.

Edited by AslanKebab
Link to comment
Share on other sites

Progress Report:

 

So I tried doing a cast from the GuardEnchscript to get the value from BarrierHealthControl:

baseArmorHealth = (barrierHealthRef as BarierHealthControl).SetBaseArmorHealth

This compiles but doesn´t update the value.

 

Sidenote: I confirmed that the problem isn't that of the timing of both scripts using, RegisterForUpdate in the OnEffectStart Event and onUpdate event to debug for whether or not the values updates later on than expected.

 

I also tried Casting the value to GuardEnchscript from BarrierHealth control using

Event OnMagicEffectApply(ObjectReference akCaster, MagicEffect akEffect)

    ;theoretically this should say that the enchantment effect was applied on self
    Debug.Notification(" applied the  on us")
    (akEffect as GuardEnchScript).baseArmorHealth = ArmorHealth
EndEvent

 

Which gives me the following compilation error

 

cannot cast a magiceffect to a guardenchscript, types are incompatible

 

Not sure how I would rectify this....

 

Sidenote 2: when I only run the OnMagicEffectApply with the example debug notification in the BarrierHealthControl script it does not seem to run, but it does compile.

 

I´ll keep figuring this out in my spare time.

Edited by AslanKebab
Link to comment
Share on other sites

Well, that compilation error is logical, you are attempting to cast a magic effect (that is, the form) to an active magic effect (a running instance of that effect), they are not the same thing. Just like an object reference of an item is not the same as its form (weapon, armor, etc).

If it's not assigning the value then the property is probably the problem, more specifically, with what are you filling it?

Edited by FrankFamily
Link to comment
Share on other sites

That´s fair, I have run the same line of code now in an OnInit event in the GuardenchScript

Event OnInit()
	Debug.Notification(" Init running")
	BarierHealthControl ref = self as BarierHealthControl
	baseArmorHealth = (barrierHealthRef as BarierHealthControl).ArmorHealth

EndEvent

but still get the same error.

 

 

cannot cast a guardenchscript to a barierhealthcontrol, types are incompatible

 

So the question remains is there any other way to get a values sent from an objectrefrence(a script placed on an armor) script to an activemagiceffect script?

 

Because these two don´t seem to like each other.

Edited by AslanKebab
Link to comment
Share on other sites

First of all, I'm explaining myself badly, I'll try to do it better. You get that because those types are essentially different, you cannot cast a quest as objectreference, it doesn't make sense. The same with an activemagiceffect and an object reference (which BarrierHealthControl extends and therefore what it "is"). Is not that the types don't like each other. When you have:

Scriptname GuardEnchScript extends ActiveMagicEffect

;here some function
BarierHealthControl ref = self as BarierHealthControl

Calling self in that script gives a reference to the object holding the script (in this case it's an active magic effect, not the player, not the armor). Then you are making a new variable, called "ref" with type BarrierHealthControl (type that is an objectreference) and attempting to fill it with an activemagiceffect (a different type of object), you see how that can't work?. You can check here the hierarchy of script objects: https://www.creationkit.com/index.php?title=Category:Script_Objects

 

BarrierHealthControl extends ObjectReference which extends Form

GuardEnchScript extends activemagiceffect which doesn't extend anything because it isn't a form, the form is the MagicEffect, same relation as an ObjectReference and its base object (armor, weapon, quest, etc)

 

Valid casting is for example an Actor as ObjectReference because Actor extends ObjectReference; a generic form as Book/weapon/armor which would only work if the form in question is actually that kind of item; float as Int and viceversa because both are numbers in the end, etc.

 

Basically what you did the there is as if the magic effect holding GuardEnchScript also had a script called BarrierHealthControl, but that isn't the case. And still you'd have to do "(self as activemagiceffect) as BarrierHealthControl" I think, one step at a time in the hierarchy. But as said that is not what you have nor what you want, just thought I'd try to clarify that.

 

If you have any other doubt, do ask and I'll see what I can do in explaining what I know.

 

------------------ The actual matter:

 

Now, what you want is to dynamically reference the armor that the player has equipped, which could be one of different sets you have made with different values for the barrier health in their property, correct?

That's why I asked with what did you fill "BarierHealthControl Property BarierHealth Auto" in your script, where does that property point to?

 

For your purpose a property is not what you want to sue, because to fill that you'd need to drop an armor into world and point it to that particular reference which would defeat the purpose of the combination of armor and enchantment since it would always give the same value and therefore you might as well make a float property on GuardEnchScript.

 

To get the current equipped armor you would need https://www.creationkit.com/index.php?title=GetWornForm_-_Actor afaik, which requires SKSE and you'd need to change BarrierHealthControl to extend Armor not ObjectReference, you don't want to do anything particular with the reference itself (if I've finally understood what you wanted to acomplish), you just want to add extra data to the armor form, like it has armor rating, weight, value, etc you want barrier health, correct?.

Well, obtaining objectreferences to items inside containers (the player's inventory) is a pain and it would be unnecessarily complicated for this.

 

That's why I'd recommend using keywords instead, because that's what they do, add data to a form. In this case I guess you'd make a set of keywords, as many as you need for the different values. Add them to the apropiate armors and then you can check directly from the activemagiceffect if the player has armor equipped containing those keywords with https://www.creationkit.com/index.php?title=WornHasKeyword_-_Actor and assign different values to the barrier health. What is it that you want to get from that script that you wouldn't get from armor?

Edited by FrankFamily
Link to comment
Share on other sites

  • Recently Browsing   0 members

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