Jump to content

Scripting help would be appreciated


xcafe

Recommended Posts

Trying to make a mod that :

 

A. Changes your two-handed, heavy armor, block, and light armor skills to match the level of your highest level magic skill

B. Changes all your magic skills to 0 (yes, I do mean 0, not 15)

C. Changes all of your stats back when you unequip the ring that I have the script attached to.

 

I've got a (really long) script written for it, but for some reason it isn't working.

 

 

 

Scriptname Polymind extends objectreference
Float Property DestructionSkill Auto
Float Property AlterationSkill Auto
Float Property ConjurationSkill Auto
Float Property IllusionSkill Auto
Float Property RestorationSkill Auto
Float Property THSkill Auto
Float Property LASkill Auto
Float Property HASkill Auto
Float Property BlockSkill Auto
Float Property NSL Auto
Event OnEquip(Actor Player)
DestructionSkill = Game.GetPlayer().GetActorValue("Destruction")
AlterationSkill = Game.GetPlayer().GetActorValue("Alteration")
ConjurationSkill = Game.GetPlayer().GetActorValue("Conjuration")
IllusionSkill = Game.GetPlayer().GetActorValue("Illusion")
RestorationSkill = Game.GetPlayer().GetActorValue("Restoration")
THSkill = Game.GetPlayer().GetActorValue("TwoHanded")
LASkill = Game.GetPlayer().GetActorValue("LightArmor")
HASkill = Game.GetPlayer().GetActorValue("HeavyArmor")
BlockSkill = Game.GetPlayer().GetActorValue("Block")
If Game.GetPlayer().GetActorValue("Destruction") >= Game.GetPlayer().GetActorValue("Alteration") && Game.GetPlayer().GetActorValue("Destruction") >= Game.GetPlayer().GetActorValue("Conjuration") && Game.GetPlayer().GetActorValue("Destruction") >= Game.GetPlayer().GetActorValue("Illusion") && Game.GetPlayer().GetActorValue("Destruction") >= Game.GetPlayer().GetActorValue("Restoration")
NSL = Game.GetPlayer().GetActorValue("Destruction")
EndIf
If Game.GetPlayer().GetActorValue("Alteration") >= Game.GetPlayer().GetActorValue("Destruction") && Game.GetPlayer().GetActorValue("Alteration") >= Game.GetPlayer().GetActorValue("Conjuration") && Game.GetPlayer().GetActorValue("Alteration") >= Game.GetPlayer().GetActorValue("Illusion") && Game.GetPlayer().GetActorValue("Alteration") >= Game.GetPlayer().GetActorValue("Restoration")
NSL = Game.GetPlayer().GetActorValue("Alteration")
EndIf
If Game.GetPlayer().GetActorValue("Conjuration") >= Game.GetPlayer().GetActorValue("Alteration") && Game.GetPlayer().GetActorValue("Conjuration") >= Game.GetPlayer().GetActorValue("Destruction") && Game.GetPlayer().GetActorValue("Conjuration") >= Game.GetPlayer().GetActorValue("Illusion") && Game.GetPlayer().GetActorValue("Conjuration") >= Game.GetPlayer().GetActorValue("Restoration")
NSL = Game.GetPlayer().GetActorValue("Conjuration")
EndIf
If Game.GetPlayer().GetActorValue("Illusion") >= Game.GetPlayer().GetActorValue("Alteration") && Game.GetPlayer().GetActorValue("Illusion") >= Game.GetPlayer().GetActorValue("Conjuration") && Game.GetPlayer().GetActorValue("Illusion") >= Game.GetPlayer().GetActorValue("Destruction") && Game.GetPlayer().GetActorValue("Illusion") >= Game.GetPlayer().GetActorValue("Restoration")
NSL = Game.GetPlayer().GetActorValue("Illusion")
EndIf
If Game.GetPlayer().GetActorValue("Restoration") >= Game.GetPlayer().GetActorValue("Alteration") && Game.GetPlayer().GetActorValue("Restoration") >= Game.GetPlayer().GetActorValue("Conjuration") && Game.GetPlayer().GetActorValue("Restoration") >= Game.GetPlayer().GetActorValue("Illusion") && Game.GetPlayer().GetActorValue("Restoration") >= Game.GetPlayer().GetActorValue("Destruction")
NSL = Game.GetPlayer().GetActorValue("Restoration")
EndIf
Game.GetPlayer().SetActorValue("Destruction", 0)
Game.GetPlayer().SetActorValue("Alteration", 0)
Game.GetPlayer().SetActorValue("Conjuration", 0)
Game.GetPlayer().SetActorValue("Illusion", 0)
Game.GetPlayer().SetActorValue("Restoration", 0)
Game.GetPlayer().SetActorValue("TwoHanded", NSL)
Game.GetPlayer().SetActorValue("LightArmor", NSL)
Game.GetPlayer().SetActorValue("HeavyArmor", NSL)
Game.GetPlayer().SetActorValue("Block", NSL)
EndEvent
Event OnUnequip(Actor Player)
Game.GetPlayer().SetActorValue("Destruction", DestructionSkill)
Game.GetPlayer().SetActorValue("Alteration", AlterationSkill)
Game.GetPlayer().SetActorValue("Conjuration", ConjurationSkill)
Game.GetPlayer().SetActorValue("Illusion", IllusionSkill)
Game.GetPlayer().SetActorValue("Restoration", RestorationSkill)
Game.GetPlayer().SetActorValue("TwoHanded", THSkill)
Game.GetPlayer().SetActorValue("LightArmor", LASkill)
Game.GetPlayer().SetActorValue("HeavyArmor", HASkill)
Game.GetPlayer().SetActorValue("Block", BlockSkill)
EndEvent

EndEvent

 

 

It doesn't bring up any compiler errors, but when I get in the game, it just doesn't do anything at all. I'd appreciate some assistance!

Edited by xcafe
Link to comment
Share on other sites

What is the script attached to? Are all the references filled? Does this work with only the following in the OnEquip event?:

{

Game.GetPlayer().SetActorValue("Destruction", 0)
Game.GetPlayer().SetActorValue("Alteration", 0)
Game.GetPlayer().SetActorValue("Conjuration", 0)
Game.GetPlayer().SetActorValue("Illusion", 0)
Game.GetPlayer().SetActorValue("Restoration", 0)

}

 

Maybe you need to check if NSL has been filled before setting everything to 0.

Link to comment
Share on other sites

o.O

 

 

 

Scriptname Polymind extends ObjectReference
Actor Property PlayerRef Auto ; <- need to "edit value" then "autofill" this from the CK
Float[] Cache
;
Event OnInit()
Cache =(New Float[11])
GoToState("Park")
EndEvent
;---------------------------------
Event OnEquipped(Actor akActor)
Self.Sort()
PlayerRef.SetAV("Destruction",0)
PlayerRef.SetAV("Alteration",0)
PlayerRef.SetAV("Conjuration",0)
PlayerRef.SetAV("Illusion",0)
PlayerRef.SetAV("Restoration",0)
PlayerRef.SetAV("OneHanded",Cache[0])
PlayerRef.SetAV("TwoHanded",Cache[0])
PlayerRef.SetAV("LightArmor",Cache[0])
PlayerRef.SetAV("HeavyArmor",Cache[0])
PlayerRef.SetAV("Block",Cache[0])
GoToState("Park")
EndEvent
;---------------------------------
Event OnUnequipped(Actor akActor)
PlayerRef.SetAV("Destruction",Cache[1])
PlayerRef.SetAV("Alteration",Cache[2])
PlayerRef.SetAV("Conjuration",Cache[3])
PlayerRef.SetAV("Illusion",Cache[4])
PlayerRef.SetAV("Restoration",Cache[5])
PlayerRef.SetAV("OneHanded",Cache[6])
PlayerRef.SetAV("TwoHanded",Cache[7])
PlayerRef.SetAV("LightArmor",Cache[8])
PlayerRef.SetAV("HeavyArmor",Cache[9])
PlayerRef.SetAV("Block",Cache[10])
GoToState("Park")
EndEvent
;---------------------------------
Function Sort()
Cache[0]=(0.0) ; <- will be our result
Cache[1]=(PlayerRef.GetAV("Destruction"))
Cache[2]=(PlayerRef.GetAV("Alteration"))
Cache[3]=(PlayerRef.GetAV("Conjuration"))
Cache[4]=(PlayerRef.GetAV("Illusion"))
Cache[5]=(PlayerRef.GetAV("Restoration"))
Cache[6]=(PlayerRef.GetAV("OneHanded"))
Cache[7]=(PlayerRef.GetAV("TwoHanded"))
Cache[8]=(PlayerRef.GetAV("LightArmor"))
Cache[9]=(PlayerRef.GetAV("HeavyArmor"))
Cache[10]=(PlayerRef.GetAV("Block"))
Int r0=(6)
While(r0)
r0-=(1)
If(Cache[r0]>=(Cache[0]))
Cache[0]=(Cache[r0])
EndIf
EndWhile
;Debug.Notification(Cache[0])
EndFunction
;---------------------------------
State Park
;parking
EndState
;

 

 

 

Pros: Works well, let's you edit your skill trees at the modified skill level.

Cons: If stats change while ring is on then when ring is removed they will revert to the before ring worn state.

Two of such items would cause havoc ... A much deeper real-time check is needed vs what is stored in the

"Cache" array when setting the values back upon ring unequip.

 

[ basically ... you still need to add a check as they unequip the ring that stores the difference between anything that has changed from the time the ring was equiped.

then adding that difference back to the stats after the unequip has returned the stats back to before the ring was equiped. ]

(I'm not talking about the ring effect ... What if the player raises a skill while wearing the ring kinda stuff)

 

[ in short: ... make a 2nd array and use it as this tool ... I take the ring off, the 1st command in the OnUnequipped(Actor akActor) function is to fill the 2nd array,

the 1st array is subtracted from the 2nd array (leaving the difference), the difference is added to the stats after the ring has returned the stats back to before

the ring was equiped. ]

 

 

I also added OneHanded cuz shaaa :tongue:

Edited by NexusComa
Link to comment
Share on other sites

 

What is the script attached to? Are all the references filled? Does this work with only the following in the OnEquip event?:

{

Game.GetPlayer().SetActorValue("Destruction", 0)

Game.GetPlayer().SetActorValue("Alteration", 0)

Game.GetPlayer().SetActorValue("Conjuration", 0)

Game.GetPlayer().SetActorValue("Illusion", 0)

Game.GetPlayer().SetActorValue("Restoration", 0)

}

Maybe you need to check if NSL has been filled before setting everything to 0.

The script is attached to a ring in the game, I believe all the float properties should be set equal to the actor values after this:

DestructionSkill =  Game.GetPlayer().GetActorValue("Destruction")
AlterationSkill =  Game.GetPlayer().GetActorValue("Alteration")
ConjurationSkill =  Game.GetPlayer().GetActorValue("Conjuration")
IllusionSkill =  Game.GetPlayer().GetActorValue("Illusion")
RestorationSkill =  Game.GetPlayer().GetActorValue("Restoration")
 
THSkill =  Game.GetPlayer().GetActorValue("TwoHanded")
LASkill =  Game.GetPlayer().GetActorValue("LightArmor")
HASkill =  Game.GetPlayer().GetActorValue("HeavyArmor")
BlockSkill =  Game.GetPlayer().GetActorValue("Block")

If the creation kit wiki is anything to go by. Also, I have no idea whether or not the NSL is being filled correctly, how would I go about checking that?

 

 

And I'm about to boot up the CK to try out your script NexusComa, thanks for writing that up! :D

 

Edit: Tried out your scrip NexusComa, and the same nothing happened as when I tried mine. I'm going to try again in a clean game (e.g. no mods) and see if that helps.

 

Edit Part Two: Tried out both NexusComa's script and my own on a clean save, both worked perfectly. Now all I have to do is figure out which out of my 200+ mods is causing the problem X_X

Edited by xcafe
Link to comment
Share on other sites

Ya you don't want to be calling Game.GetPlayer() that many times. Once or Twice maybe ... more then that go the the ref.

 

It's like this example: ... This is what's going on to the code

(this is just logic example not actually whats being called)

 

Let's say the call to get the players reference was really just this calculation "(14000 / 7 +33003 -4442 *45 -23 +6)"

 

This would be the PlayerRef method

--------------------

A=PlayerRef ... (1555228)

 

B=PlayerRef ... B=(1555228)

C=PlayerRef ... C=(1555228)

D=PlayerRef ... D=(1555228)

E=PlayerRef ... E=(1555228)

--------------------

 

This would be the Game.GetPlayer() method

--------------------

A=Game.GetPlayer() ... (14000 / 7 +33003 -4442 *45 -23 +6)

 

B=Game.GetPlayer() ... B=(14000 / 7 +33003 -4442 *45 -23 +6)

C=Game.GetPlayer() ... C=(14000 / 7 +33003 -4442 *45 -23 +6)

D=Game.GetPlayer() ... D=(14000 / 7 +33003 -4442 *45 -23 +6)

E=Game.GetPlayer() ... E=(14000 / 7 +33003 -4442 *45 -23 +6)

--------------------

 

 

Also OnEquip(Actor Player) needed to be OnEquipped(Actor akActor) and OnUnequip(Actor Player) to OnUnequipped(Actor akActor)

And there needs to be "State Park" or "State Done" so the code don't sit and eat up processor time.

 

Something like this ...

 

If Game.GetPlayer().GetActorValue("Illusion") >= Game.GetPlayer().GetActorValue("Alteration") && Game.GetPlayer().GetActorValue("Illusion") >= Game.GetPlayer().GetActorValue("Conjuration") && Game.GetPlayer().GetActorValue("Illusion") >= Game.GetPlayer().GetActorValue("Destruction") && Game.GetPlayer().GetActorValue("Illusion") >= Game.GetPlayer().GetActorValue("Restoration")
NSL = Game.GetPlayer().GetActorValue("Illusion")
EndIf
Should look like this ... (without all the Game.GetPlayer() of course)
If Game.GetPlayer().GetActorValue("Illusion") >= Game.GetPlayer().GetActorValue("Alteration")
If Game.GetPlayer().GetActorValue("Illusion") >= Game.GetPlayer().GetActorValue("Conjuration")
If Game.GetPlayer().GetActorValue("Illusion") >= Game.GetPlayer().GetActorValue("Destruction")
If Game.GetPlayer().GetActorValue("Illusion") >= Game.GetPlayer().GetActorValue("Restoration")
NSL = Game.GetPlayer().GetActorValue("Illusion")
EndIf
EndIf
EndIf
EndIf

 

Kind of the same rule as with the Getplayer thing one or two "&&" is ok - more then that needs a different method.

Both ways will work one way is much faster and smoother on your computer with a less likely chance of errors.

(it's also way easier to read)

 

 

The difference between our codes is about 50,000+ CPU cycles - Not much really ... but if all the code was this way it would be huge.

And - without a "State Park" or as more commonly used "State Done" the code will continue to eat CPU cycles ... not good.

Edited by NexusComa
Link to comment
Share on other sites

Hey xcafe,

 

Why don't you try throwing different debug.notifications through your script to see if different parts are actually happening?

 

Maybe one right after the OnEquip that goes something like this:

 

Debug.Notification("Script Has Started")

 

Maybe others to go inside the IF functions like this one:

Debug.Notification("DESTRUCTION is the highest magic skill!")

 

As this may help you figure out what is going on, if anything.

 

 

 

-Tons

Link to comment
Share on other sites

Ok - That was hard to explain that last part and I'm not even sure if you plan on wearing the ring for anything other then the stat tree.

But - There is a possibility however slight the player will wear the ring and improve one of the stats that are stored in the "Buffer/Cache" and then lose that progress.

 

And - we can't be havein' that ... :P

 

 

 

 

Scriptname Polymind extends ObjectReference
Actor Property PlayerRef Auto ;<- need to "edit value" then "autofill" this from the ck
Float[] c0
Float[] c1
;
Event OnInit()
c0 =(New Float[11])
c1 =(New Float[11])
GoToState("Park")
EndEvent
;---------------------------------
Event OnEquipped(Actor akActor)
Self.Sort()
PlayerRef.SetAV("Destruction",0)
PlayerRef.SetAV("Alteration",0)
PlayerRef.SetAV("Conjuration",0)
PlayerRef.SetAV("Illusion",0)
PlayerRef.SetAV("Restoration",0)
PlayerRef.SetAV("OneHanded",c0[0])
PlayerRef.SetAV("TwoHanded",c0[0])
PlayerRef.SetAV("LightArmor",c0[0])
PlayerRef.SetAV("HeavyArmor",c0[0])
PlayerRef.SetAV("Block",c0[0])
GoToState("Park")
EndEvent
;---------------------------------
Event OnUnequipped(Actor akActor)
Int r0=(0)
;---
c1[0]=(0.0) ; <- not using
c1[1]=(PlayerRef.GetAV("Destruction"))
c1[2]=(PlayerRef.GetAV("Alteration"))
c1[3]=(PlayerRef.GetAV("Conjuration"))
c1[4]=(PlayerRef.GetAV("Illusion"))
c1[5]=(PlayerRef.GetAV("Restoration"))
c1[6]=(PlayerRef.GetAV("OneHanded"))
c1[7]=(PlayerRef.GetAV("TwoHanded"))
c1[8]=(PlayerRef.GetAV("LightArmor"))
c1[9]=(PlayerRef.GetAV("HeavyArmor"))
c1[10]=(PlayerRef.GetAV("Block"))
r0=(11)
While(r0!=(6)) ;<- stop after 6
r0-=(1)
c1[r0]=(c1[r0]-c0[0])
EndWhile
r0=(11)
While(r0)
r0-=(1)
c0[r0]=(c0[r0]+c1[r0])
EndWhile
PlayerRef.SetAV("Destruction",c0[1])

PlayerRef.SetAV("Alteration",c0[2])
PlayerRef.SetAV("Conjuration",c0[3])
PlayerRef.SetAV("Illusion",c0[4])
PlayerRef.SetAV("Restoration",c0[5])
PlayerRef.SetAV("OneHanded",c0[6])
PlayerRef.SetAV("TwoHanded",c0[7])
PlayerRef.SetAV("LightArmor",c0[8])
PlayerRef.SetAV("HeavyArmor",c0[9])
PlayerRef.SetAV("Block",c0[10])
GoToState("Park")
EndEvent
;---------------------------------
Function Sort()
Int r0=(0)
;---
c0[0]=(0.0) ; <- will be our result
c0[1]=(PlayerRef.GetAV("Destruction"))
c0[2]=(PlayerRef.GetAV("Alteration"))
c0[3]=(PlayerRef.GetAV("Conjuration"))
c0[4]=(PlayerRef.GetAV("Illusion"))
c0[5]=(PlayerRef.GetAV("Restoration"))
c0[6]=(PlayerRef.GetAV("OneHanded"))
c0[7]=(PlayerRef.GetAV("TwoHanded"))
c0[8]=(PlayerRef.GetAV("LightArmor"))
c0[9]=(PlayerRef.GetAV("HeavyArmor"))
c0[10]=(PlayerRef.GetAV("Block"))
r0=(6)
While(r0)
r0-=(1)
If(c0[r0]>=(c0[0]))
c0[0]=(c0[r0])
EndIf
EndWhile
;Debug.Notification(c0[0])
EndFunction
;---------------------------------
State Park
;parking
EndState
;

 

 

 

Link to comment
Share on other sites

Duly noted on the shortening stuff, I'll have to go back and change that! Also, the "losing progress" thing was intentional, as I needed a con to balance out the ring. Would've been kind of overpowered IMHO if I didn't put in some drawbacks! :tongue:

 

By the way if you're interested, the mod is up at http://www.nexusmods.com/skyrim/mods/74984/?tab=1&navtag=http%3A%2F%2Fwww.nexusmods.com%2Fskyrim%2Fajax%2Fmoddescription%2F%3Fid%3D74984%26preview%3D&pUp=1

 

Now I just have to work on making the quest, dungeon, and npcs I'll need to actually finish the mod I want to include the ring in...all of which I've never done before. RIP my vacation time.

Edited by xcafe
Link to comment
Share on other sites

I think the 0 on all them magic skills covers the "con" ... If I can't build skills I'm not wearing the ring kinda thing will end up happening.

The last code is perfect - tested it myself. I would surly hope that code is now on that ring. o.O

 

You did everything right in your description ... You broke down what you wanted the script to do and not do by the letters then gave an example

of the concept ... Programmers love that! You get 1 kudo and 1 code :P

Link to comment
Share on other sites

  • Recently Browsing   0 members

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