Jump to content

Help with setting up equation


Woverdude

Recommended Posts

Alright, so I'm trying to create the skill script for Unarmed that will be used in my Way of the Monk mod:http://tesmods.blogspot.com/2012/03/new-unarmed-mod-way-of-monk.html

 

The problem is that I am a noob scripter.

 

Here's the basic idea of what I'm trying to do:

 

I have three global variables that I want to use in the equation. For now I'll call them "Use", "Mod", and "Level". Whenever the player hits an enemy, I want the value of Use to be raised by the value of Mod. Whenever Use is >= 100, it should be "reset" by subtracting 100 from it. As that "reset" occurs, Level should be increased by 1. So:

 

When player attacks:

 

Use = Use(current value) + Mod

 

If Use >= 100

 

then Use = Use(current value) - 100

 

and Level = Level(current value) +1

 

Now, the way that I planned on doing this was by writing this script:

 

Scriptname UnarmedDamageScaleScript extends Form
{Scales Unarmed Damage over time and use.}

GlobalVariable Property Use auto
GlobalVariable Property Mod auto
GlobalVariable Property Level auto

Event OnHit(Objectreference akAgrressor, Form akWeapon)
Use.SetValue(Use.value+Mod.value)
if Use.value >= 100
	Use.SetValue(Use.value-100)
	Level.Setvalue(Level.value+1)
endif
EndEvent

 

The main part that I'm unsure about is the "Use.Value >= 100" part. Is that the right way to code it?

 

And the way that I will apply this is by adding a perk to the player, using an effect that runs this script on enemies when they are hit by the player.

 

However, whenever I try to compile this script, I get

(11,19): no viable alternative at input 'value'
(11,28): required (...)+ loop did not match anything at input ')'

 

Now, I understand that this might be the totally worst way to do this. But the fact is that I have been working on this (what should be very simple) for hours and hours. I have tried everything that I can think of. I have tried doing this entirely different ways, as well. I've also gone through the tutorials, read the wiki references and articles, and I am just so dreadfully stuck and confused.

 

So, can someone either help me get this script working or show me a different, better way to do it?

Link to comment
Share on other sites

Scriptname UnarmedDamageScaleScript extends Form
{Scales Unarmed Damage over time and use.}

GlobalVariable Property Use auto ; float of accumulated usage.
GlobalVariable Property Mod auto ; float of how much to increase (eg. 0.05)

Event OnHit(Objectreference akAgrressor, Form akWeapon)
   float UseNow = Use.Mod( Mod.GetValue() )
EndEvent

 

Thats it.

What about the level and progress to the next level gain you ask?

You still have access to those when you want.

 

GlobalVariable Property Use auto ; float of accumulated usage

float UseNow = Use.GetValue()
int level = UseNow  As Int ; Grab the whole number part
float progress = UseNow % 1 ; Grab the fractional part

int level = Use.GetValueInt() ; Grab the whole number part directly
float progress = Use.GetValue() % 1 ; Grab the fractional part directly

Edited by tunaisafish
Link to comment
Share on other sites

Scriptname UnarmedDamageScaleScript extends Form
{Scales Unarmed Damage over time and use.}

GlobalVariable Property Use auto ; float of accumulated usage.
GlobalVariable Property Mod auto ; float of how much to increase (eg. 0.05)

Event OnHit(Objectreference akAgrressor, Form akWeapon)
   float UseNow = Use.Mod( Mod.GetValue() )
EndEvent

 

Thats it.

What about the level and progress to the next level gain you ask?

You still have access to those when you want.

 

GlobalVariable Property Use auto ; float of accumulated usage

float UseNow = Use.GetValue()
int level = UseNow  As Int ; Grab the whole number part
float progress = UseNow % 1 ; Grab the fractional part

int level = Use.GetValueInt() ; Grab the whole number part directly
float progress = Use.GetValue() % 1 ; Grab the fractional part directly

 

Thank you greatly. :-)

 

As far as I could tell, this doesn't modify the Level global. I might be wrong, of course. If it does, could you explain how you did it? I need the Level global so that I can use it in perks.

 

As far as the second part, are you saying that I use that when I want to get the value in another script, or when in this same script? I'm sorry for my noobishness. I'm still pretty new at scripting. :-/

 

I have another request for a script, if you're interested. I'll gladly credit you and list you as a contributor. :-) Having someone else do the important scripts would save me a lot of time and effort.

Link to comment
Share on other sites

You could get rid of the level global altogether, as your conditions can check the value of Use.

The Use above holds the level part before the decimal point, and the progress part after the decimal point.

So your Perk conditions can still read the level of 40+ with [use >= 40.0].

 

The good thing about doing it this way too is that the OnHit is thread-safe, and as there are likely to be many OnHit's in succession that's a good thing to go for :)

Later you may also decide that you want 200 hits to increase a level. That would just mean setting Mod to 0.005. I'm assuming you're going to slowly decrease Mod as the levels increase.

 

Yep the second part was just showing you that you'd not actually lost the 'level' information, even though that global was not used.

You can still access both level and progress via other scripts, and level in conditions.

 

BTW, the only thing I saw 'wrong' with your original script was you wrote 'value' instead of 'GetValue()'. I took your invitation to offer an improvement though :)

 

I'm too busy to make any promises, as you'll find many modders are.

You did a good job on this one though so if you post when you get stuck on the next I'm sure someone here will fill in the gaps.

Link to comment
Share on other sites

You could get rid of the level global altogether, as your conditions can check the value of Use.

The Use above holds the level part before the decimal point, and the progress part after the decimal point.

So your Perk conditions can still read the level of 40+ with [use >= 40.0].

 

The good thing about doing it this way too is that the OnHit is thread-safe, and as there are likely to be many OnHit's in succession that's a good thing to go for :)

Later you may also decide that you want 200 hits to increase a level. That would just mean setting Mod to 0.005. I'm assuming you're going to slowly decrease Mod as the levels increase.

 

Yep the second part was just showing you that you'd not actually lost the 'level' information, even though that global was not used.

You can still access both level and progress via other scripts, and level in conditions.

 

BTW, the only thing I saw 'wrong' with your original script was you wrote 'value' instead of 'GetValue()'. I took your invitation to offer an improvement though :)

 

I'm too busy to make any promises, as you'll find many modders are.

You did a good job on this one though so if you post when you get stuck on the next I'm sure someone here will fill in the gaps.

 

Well, I also wanted the Level global so that I could use it to scale the UnarmedDamage Actor Value. If, for instance, the Level was 30, then the player would do 3 times the base Unarmed damage. But, I guess I could also do that by dividing Use by 100 and rounding it to the nearest whole number. I'd need to figure out how to round numbers, though... Either way, I'll fiddle around with it and use the one that works better.

 

Yes, in fact that was the script I was wondering whether you could create. :D What I want is to have the Mod lowered by .01 every time the Level is raised. That way, at level 1 it would 100 hits to levelup, at level 10 it would take about 110. at level 20 it would take 125, etc.

 

Thank you for all your help and advice. If I get stuck again, I will leave another post in the forums. Thanks. :smile:

Link to comment
Share on other sites

  • Recently Browsing   0 members

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