Jump to content

Easy Script Creation Help


TangerineDog

Recommended Posts

I tried a new script based on the Well Rested script, and that works. It adds SpellHunger02 correctly after a set period of time. I'll continue to work in that direction.

 

EDIT: Yes, it worked in the test runs. The effect duration and the time it takes 'till the spell is removed are two separate things now, though, and ideally, of course, they should match. I'll post the script tomorrow.

Edited by TangerineDog
Link to comment
Share on other sites

In C\Users\MyName\Steam.

Hmm... Not sure why you'd have issues that would require you to run in admin mode from that directory. If it were in Program Files then that would be a definite cause for issues.

Oh well, at least it works when in admin mode.

 

Good luck with your modding.

Link to comment
Share on other sites

You're damn right ;)

 

ANyway, here's the script:

 

ScriptName ScriptHunger01 extends activemagiceffect

Spell Property SpellHunger01 Auto
Spell Property SpellHunger02 Auto
Int Property pHoursToWait Auto

Event OnUpdateGameTime()

; debug.trace(self + "OnUpdateGameTime")
Game.GetPlayer().RemoveSpell(SpellHunger01)
Game.GetPlayer().AddSpell(SpellHunger02, false)
Debug.Notification("You are starving")

EndEvent

Event OnEffectStart(Actor akTarget, Actor akCaster)

; start timer
RegisterForSingleUpdateGameTime(pHourstoWait)

EndEvent

 

 

In the properties, I set pHoursToWait to 6, and after 6 hours, I get the notification and have the spell SPellHUnger02 in my active effects, SpellHunger01 gets removed correctly.

 

Now I just have to get food to reduce the hunger, and of course, food is making trouble, too. OnEffectStart seems to work just as well als OnEffectFinish...

Link to comment
Share on other sites

Can you spot the error in this script:

 

 

ScriptName ScriptAleTest extends activemagiceffect

Spell Property SpellHunger01 Auto
Spell Property SpellHunger02 Auto
Spell Property SpellHunger03 Auto
Spell Property SpellHunger04 Auto
Spell Property EffectHunger01 Auto
Spell Property EffectHunger02 Auto
Spell Property EffectHunger03 Auto
Spell Property EffectHunger04 Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)


If (Game.GetPlayer().HasMagicEffect(EffectHunger04))
Game.GetPlayer().RemoveSpell(SpellHunger04)
Game.GetPlayer().AddSpell(SpellHunger03, false)
Debug.Notification("You are hungry")
ElseIf (Game.GetPlayer().HasMagicEffect(EffectHunger03))
Game.GetPlayer().RemoveSpell(SpellHunger03)
Game.GetPlayer().AddSpell(SpellHunger02, false)
Debug.Notification("You have an appetite")
ElseIf (Game.GetPlayer().HasMagicEffect(EffectHunger02))
Game.GetPlayer().RemoveSpell(SpellHunger02)
Game.GetPlayer().AddSpell(SpellHunger01, false)
Debug.Notification("You are fine")
ElseIf (Game.GetPlayer().HasMagicEffect(EffectHunger01))
Debug.Notification("Much good that has done")
Else
Game.GetPlayer().AddSpell(SpellHunger01, false)
Debug.Notification("Happy Hunger Games")
Endif

EndEvent

 

 

It's telling me there's a type mismatch in the If and ElseIf lines, each time between the "l" and "a" of Player.

 

EDIT: Maybe it's because I declared the effects as spells. What kind of property is a magic effect?

Edited by TangerineDog
Link to comment
Share on other sites

Probably because it may not like having an ELSE after a series of ELSEIFs

Try this instead:

 

 

ScriptName ScriptAleTest extends activemagiceffect

Spell Property SpellHunger01 Auto
Spell Property SpellHunger02 Auto
Spell Property SpellHunger03 Auto
Spell Property SpellHunger04 Auto
Spell Property EffectHunger01 Auto
Spell Property EffectHunger02 Auto
Spell Property EffectHunger03 Auto
Spell Property EffectHunger04 Auto
Actor Property PlayerRef Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
    If PlayerRef.HasMagicEffect(EffectHunger04) || PlayerRef.HasMagicEffect(EffectHunger03) || PlayerRef.HasMagicEffect(EffectHunger02) || PlayerRef.HasMagicEffect(EffectHunger01)
        If PlayerRef.HasMagicEffect(EffectHunger04)
            PlayerRef.RemoveSpell(SpellHunger04)
            PlayerRef.AddSpell(SpellHunger03, false)
            Debug.Notification("You are hungry")
        ElseIf PlayerRef.HasMagicEffect(EffectHunger03)
            PlayerRef.RemoveSpell(SpellHunger03)
            PlayerRef.AddSpell(SpellHunger02, false)
            Debug.Notification("You have an appetite")
        ElseIf PlayerRef.HasMagicEffect(EffectHunger02)
            PlayerRef.RemoveSpell(SpellHunger02)
            PlayerRef.AddSpell(SpellHunger01, false)
            Debug.Notification("You are fine")
        ElseIf PlayerRef.HasMagicEffect(EffectHunger01)
            Debug.Notification("Much good that has done")
        EndIf
    Else
        PlayerRef.AddSpell(SpellHunger01, false)
        Debug.Notification("Happy Hunger Games")
    Endif
EndEvent 

 

 

Link to comment
Share on other sites

Unfortunately, it returns the same error. Maybe it's about the properties after all? I'm looking for a list of the different ones like Spell and Shout, but nothing turned up so far.

 

EDIT: AHA! There was one in the CK. the property type is MagicEffect, and now it compiled like a charm. Now to see if it works.

Edited by TangerineDog
Link to comment
Share on other sites

A magic effect would be MagicEffect. That would be a cause for it to complain if you are using the wrong thing in the function. Don't know why it would specifically mention the IF or ELSEIF statements if that were the case. Unless that were just communication error between your sharing of the error and my interpretation of what was said. Its better to just post the compiler error as that pinpoints the exact line and character position where it sees an issue.

Link to comment
Share on other sites

Update: works. On both scripts. I replaced

Spell Property EffectHunger01 Auto
Spell Property EffectHunger02 Auto
Spell Property EffectHunger03 Auto
Spell Property EffectHunger04 Auto]/spoiler] with

MagicEffect Property EffectHunger01 Auto
MagicEffect Property EffectHunger02 Auto
MagicEffect Property EffectHunger03 Auto
MagicEffect Property EffectHunger04 Auto

and that did it. I also found a list of the property types as I clicked the Properties-button at the bottom right corner of the magic effect window after highlighting a script I had added to that effect, clicked Add Property in the pop-up window and opened the drop-down list Type. There they were.

 

EDIT: It propably pointed to these specific lines because they were the ones to refer to the magic effects. The other lines added and removed the spells that contained the effects.

 

And yes, I will post the exact error report next time - although I really hope the time of big errors is over now :smile:

Thank you!

Edited by TangerineDog
Link to comment
Share on other sites

  • Recently Browsing   0 members

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