Jump to content

Script for if caster equals player problem.


Recommended Posts

I'm trying to get a script I've got to only run the commands when the caster and/or target is the player but can't seem to get my head around how.

 

I've tried several ways already (they're fairly similar) but I'm asking in the hopes someone with an idea comes up and gives me the answer to fix it.

Currently tried these variations (seperated with spaces):

       if     (GetCasterActor() == togglespellplayer && togglespellglobal.getValue() == 0.0)
Actor Property togglespellplayer Auto
//Then coupling the property to the PlayerRef (00000014) actor referance.

       if     (GetCasterActor() == Game.GetPlayer() && togglespellglobal.getValue() == 0.0)

       if     (GetTargetActor() == Game.Getplayer() && togglespellglobal.getValue() == 0.0)

       if     (GetCasterActor() == "Player" && togglespellglobal.getValue() == 0.0)

 

This is the full script:

Scriptname togglespell extends activemagiceffect  

Event OnEffectStart(Actor akTarget, Actor akCaster)
       if     (GetCasterActor() == togglespellplayer && togglespellglobal.getValue() == 0.0)
               togglespellglobal.setValue(1.0)
               Game.GetPlayer().AddSpell(togglespellnegative) 
       elseif (GetCasterActor() == togglespellplayer && togglespellglobal.getValue() == 1.0)
               togglespellglobal.setValue(2.0)
               self.dispel()
               Game.GetPlayer().RemoveSpell(togglespellnegative) 
       endif
       if     (GetCasterActor() == togglespellplayer && Game.GetPlayer().GetActorValue("magicka") <= 25)
               togglespellglobal.setValue(2.0)
               self.dispel()
               Game.GetPlayer().RemoveSpell(togglespellnegative) 
       endif
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
       if (GetCasterActor() == togglespellplayer && togglespellglobal.getValue() == 2.0)
               togglespellglobal.setValue(0.0)
               Game.GetPlayer().RemoveSpell(togglespellnegative) 
       endif
       if (GetCasterActor() == togglespellplayer && Game.getPlayer().hasMagicEffect(togglespelleffect)!=1)
               togglespellglobal.setValue(0.0)
               Game.GetPlayer().RemoveSpell(togglespellnegative) 
       endif
EndEvent

MagicEffect Property togglespelleffect  Auto
GlobalVariable Property togglespellglobal  Auto
Spell Property togglespellnegative  Auto
Actor Property togglespellplayer Auto

Link to comment
Share on other sites

I'm not sure if GetCasterActor works. Beth only use it once themselves, in an OnLoad event.

 

Instead, use the event parameters akCastor & akTarget. They're reliable.

 

if (Game.GetPlayer() == akCaster)

 

Thank you very much.. I'll test it out and reply back if it works.

 

Yes it works just fine with akCaster.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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