Jump to content

Need Help with Papyrus


Syfor

Recommended Posts

I need help with this script, it should increase the charge of the weapon in the left hand with 50 per second.

 

Scriptname ChargeLH extends ActiveMagicEffect

{Charge the weapon equiped in Left Hand of caster}

 

MagicEffect Property ChargeLHWeapon Auto

 

Event OnEffectStart(Actor Target, Actor Caster)

While ( Target.HasMagicEffect( ChargeLHWeapon ) )

float ChargeWeapon = Target.GetAV("LeftItemCharge")

ChargeWeapon = ChargeWeapon +50

Target.SetAV("LeftItemCharge", ChargeWeapon)

Utility.Wait(1.0)

EndWhile

EndEvent

 

This script is attached to a concentration magic effect called ChargeLHWeapon.

 

When I use this in a spell in-game, nothing hapens. Can anybody tell me what's wrong?

Link to comment
Share on other sites

Thanks for your reply Leeira. Unfortunately it still doesn't work.

I think that something goes wrong in this line:

While ( Target.HasMagicEffect( ChargeLHWeapon )

I think the scripts doesn't recognize ChargeLHWeapon as the proper magic effect.

 

This the magic effect I defined as ChargeLHWeapon:

ID: ChargeLHWeapon

Name: Charge LH Weapon

Effect Archetype: Script

Casting Type: Concentration

Delivery: Self

Magic Skill: Conjuration

 

Assoc. Item1: NONE

 

Papyrus Scripts:

ChargeLH

 

This is the script now:

Scriptname ChargeLH extends ActiveMagicEffect

{Charge the weapon equiped in Left Hand of caster}

 

MagicEffect Property ChargeLHWeapon Auto

 

Event OnEffectStart(Actor Target, Actor Caster)

While ( Target.HasMagicEffect( ChargeLHWeapon ) )

float ChargeWeapon = Target.GetAV("LeftItemCharge")

ChargeWeapon += 50

Target.SetAV("LeftItemCharge", ChargeWeapon)

Utility.Wait(1.0)

EndWhile

EndEvent

Link to comment
Share on other sites

Give me more info.

When you say:

it should increase the charge of the weapon in the left hand with 50 per second.

Are you saying add 50 charges to the weapon every second or add 50 damage per second to the effect of the weapon? So a weapon with 10 fire damage per second should now be 60 fire damage per second.

When do you want this additional charge/effect applied?

Is this applying to an effect already on the weapon or are you creating a new effect?

Edited by Spinner385
Link to comment
Share on other sites

Edit: just found an easier way again I'll work on it when I get back from work tonight. I have some experience with spells so shouldn't be a problem. Just need to make sure papyrus agrees with it. If it works do you want the mod or directions to do it yourself? Edited by Spinner385
Link to comment
Share on other sites

Thank you for your time Spinner385, I really appreciate this. I would like to see the script with some explanation, so I can understand Papyrus myself. This was my first attempt of a script but I just couldn't figure out how to make a concentration version of this spell. I had to change it into a fire and forget version for my mod "Lost Magic" you can check it out here: http://steamcommunity.com/sharedfiles/filedetails/?id=82398601&searchtext=.

 

In the meanwhile I discovered that I could replace these lines:

float ChargeWeapon = Target.GetAV("LeftItemCharge")
ChargeWeapon += 50
Target.SetAV("LeftItemCharge", ChargeWeapon)

by only this

Target.ModAV("LeftItemCharge", 50)

 

My aim was a concentration spell, so I will make a new version of the Soulcharge spell and give you credit for the script.

Thanks again for trying to help me out.

Edited by Syfor
Link to comment
Share on other sites

Having a script test for the MagicEffect that it is attached to is a weird thing to do. The script will be killed as soon as the MagicEffect stops, so the test is meaningless.

 

I put in a little test to only charge the weapon if it's charge is less that 10%.

 

Scriptname ChargeLH extends ActiveMagicEffect 
{Charge the weapon equiped in Left Hand of caster}

bool loop = True

Event OnEffectStart(Actor Target, Actor Caster)
Debug.Notification("[ChargeLH] The MagicEffect is active")
float ChargeWeapon

While loop == True
	ChargeWeapon = Target.GetAVPercentage("LeftItemCharge")
	If ChargeWeapon <= 0.1
		Target.ModAV("LeftItemCharge", 50.0)
	EndIF
	Utility.Wait(1.0)
EndWhile
EndEvent

Event OnEffectFinish(Actor Target, Actor Caster)
{this safeguard is redundant as the script will end when the spell ends}
loop = False
       Debug.Notification("[ChargeLH] The MagicEffect just finished")
EndEvent

 

This version doesn't check how much charge the weapon has:

 

Scriptname ChargeLH extends ActiveMagicEffect 
{Charge the weapon equiped in Left Hand of caster}

bool loop = True

Event OnEffectStart(Actor Target, Actor Caster)
Debug.Notification("[ChargeLH] The MagicEffect is active")

While loop == True
	Target.ModAV("LeftItemCharge", 50.0)
	Utility.Wait(1.0)
EndWhile
EndEvent

Event OnEffectFinish(Actor Target, Actor Caster)
{this safeguard is redundant as the script will end when the spell ends}
loop = False
       Debug.Notification("[ChargeLH] The MagicEffect just finished")
EndEvent

 

I haven't tested this yet, btw.

Edit: oops, I forgot to pass parameters into OnEffectFinish :facepalm: .

Edited by steve40
Link to comment
Share on other sites

  • Recently Browsing   0 members

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