Jump to content

[LE] Spent days trying to get a script to work...


yudhi108

Recommended Posts

[sOLVED, for now]

 

Yeah I worked on several versions of a long complicated script for a spell and couldn't get it to work. Then I decided to make sure I know how to make any kind of script work in game and I guess I don't.

 

I made several spells, and edited some, and all my spells work in game as long as there are no scripts attached to the spells.

 

I'm trying to edit a spell by adding a magical effect script to it. The spell is a fire and forget aimed spell. So, I made the magical effect script also fire and forget + aimed, but it's not working!

 

Even this simple script won't do anything when coded as such and added to my fire and forget aimed spell:

 

 

 

Actor Property PlayerRef Auto
Actor Property akcaster Auto
Actor Property aktarget Auto
 
Event OnEffectStart(actor akcaster, actor aktarget)
  debug.notification("testing")
  PlayerRef.DamageAV("Magicka", 10000)
EndEvent

 

 

 

Can anyone tell me how to make a script to damage my MP and send a notification like I tried to do in the above spoiler? This is to make sure I can get any script to work when attached to my spell.

Link to comment
Share on other sites

Does it fire when you hit an actor? I think that FF, Aimed scripts will only fire when they make contact with something that can be affected by the spell.

 

Dude thanks so much! It does indeed work if I actually hit a target with it. It's too bad I can't get a script to work with a fire and aim spell with out having it hit a target but this is a start. Now I can actually try to make the spell (effect) I want to make! THanks!

Link to comment
Share on other sites

You don't have to list akcaster / aktarget as properties as they are contained within the OnEffectStart.

 

Otherwise, you've defined your PlayerRef, and DamageAV look right as if you wanted to drain 10000 magicka from the player if the Spell works. Personally I like to write out the full DamageActorValue than abbreviating (but both supposedly work). Have you defined in your properties PlayerRef?

 

That said, you've compiled the script? It looks like it should compile fine, but just checking to see if you actually compiled it.

 

The notification works, I assume? If not, that means your Effect is not starting which means you might have set up some condition either at the Spell or Effect level which is failing resulting in your spell to not fire.

 

Otherwise here's my source from one of my scripts which does the same thing you're looking for (based from my spell Soulgem Cannon from Synthesis Redux):

Scriptname z2018mjhSoulgemCannonScript extends ActiveMagicEffect  

soulgem property mjhSoulgem auto
soulgem property mjhSoulgem2 auto
actor property PlayerRef auto
float property Timer auto
visualeffect Property mjhVFX auto
sound Property mjhAudFX auto
imagespacemodifier Property mjhImod auto

Actor TargetActor

EVENT OnEffectStart(Actor Target, Actor Caster)
Float fPlayerMagic = PlayerRef.GetActorValue("Magicka")
Float fPlayerHealth = PlayerRef.GetActorValue("Health")
Float fPlayerStamina = PlayerRef.GetActorValue("Stamina")
mjhImod.Apply(1.00000)
	If Game.GetPlayer().GetItemCount(mjhSoulgem) <= 0
		debug.notification("You do not have a black soul gem, forcing the spell to backfire, and absorb some of your life force.")
		PlayerRef.DamageActorValue("Health", fPlayerHealth / 2)
		PlayerRef.DamageActorValue("Magicka", fPlayerMagic)
		PlayerRef.DamageActorValue("Stamina", fPlayerStamina)
		mjhVFX.Play(PlayerRef)
		mjhAudFX.Play(PlayerRef)
		utility.wait(Timer)
		mjhVFX.Stop(PlayerRef)
	ElseIf Game.GetPlayer().GetItemCount(mjhSoulgem) >= 1
		PlayerRef.RemoveItem(mjhSoulgem,1)
		If Target.IsDead()
			debug.notification("Your target is dead, forcing the spell to backfire, and absorb some of your life force.")
			PlayerRef.DamageActorValue("Health", fPlayerHealth / 2)
			PlayerRef.DamageActorValue("Magicka", fPlayerMagic)
			PlayerRef.DamageActorValue("Stamina", fPlayerStamina)
			mjhVFX.Play(PlayerRef)
			mjhAudFX.Play(PlayerRef)
			utility.wait(Timer)
			mjhVFX.Stop(PlayerRef)
		Else
			Target.AddItem(mjhSoulgem2,1)
			utility.wait(Timer)
			mjhVFX.Play(Target)
			mjhAudFX.Play(Target)
			Target.TrapSoul(Target)
			utility.wait(Timer)
			Target.Kill(PlayerRef)
			debug.notification("The target's soul has been absorbed into the soul gem, killing the target in the process.")
			mjhVFX.Stop(Target)
		EndIf
	EndIf
utility.wait(Timer)
mjhImod.Remove()
EndEvent

You can ignore the extra lines for added visual FX and the removal of the soulgem and subsequent addition of one.

I run a getactovrvalue check at the beginning as I want the amount drained based on how much the player has in the first place, and then the drain occurs in either place if the spell meets a condition for spell failure I have set up in the script itself.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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