Jump to content

How Do I create a magic effect? (bound item until 0 magic)


Recommended Posts

I feel like this should be relatively simple to do.

How do I create a magic effect to bound an item, like a sword (but not the vanilla bound sword) and then have it stayed bound until I run out of magic?

 

I know I would need to create a scripted magic effect, and I think I would need to use the player.additem and player.removeitem commands, but that's about all I know when it comes to scripting.

 

edit:

it would also be nice if we could set some sort of cool-down timer after the magic runs out. I would think a slightly more passive (and dynamic) way of handling this would be to just only allow casting the spell if the player has 100% magic.

Edited by iColour
Link to comment
Share on other sites

So I tried my own hand at scripting today...and I didn't make it very far. I've tried a bunch of different ways of handling the script but the best I can do is have the spell equip the weapon when cast...but it doesn't ever remove the weapon.

 

Here is my CURRENT compiled script, however, below I will mention the other methods I tried:

scriptname aaSummonLuxMae

short updateCount
short DoOnce

Begin ScriptEffectStart
	if player.GetActorValue Magicka >= 50 && DoOnce == 0
			player.addspell aaLuxMaeDrain
			player.additem 00LuxOH 1
			player.additem 00LuxOFF 1
			player.EquipItem 00LuxOH 1
			player.EquipItem 00LuxOFF 1
			set DoOnce to 1
	endif

	if player.GetActorValue Magicka <=20
		player.removespell aaLuxMaeDrain
		player.UnEquipItem 00LuxOH 1
		player.UnEquipItem 00LuxOFF 1
		player.removeitem 00LuxOH 1
		player.removeitem 00LuxOFF 1
	else
		set updateCount to updateCount + 1
	endif
end

Begin ScriptEffectFinish
	if UpdateCount == 1
		set DoOnce to 0
  		Message "Spell is finished. ScriptEffectUpdate was run %.0f times", updateCount
	endif
End

The message at the bottom was part of the tutorial I read. However, I left it attached to the script to see if the script even reached the end...it did not.

 

I've tried using the DoOnce value to move between blocks. So the first begin block starts on cast. Then the second one would check if the DoOnce command had been complete to set the update, then if the updatecount was higher than 1, it (was supposed to) remove the drain magic spell and the items. That method didn't work either.

 

So I tried using a quest. Maybe I didn't script the quest properly. Basically I used a repeating quest with 2 stages. The first stage was if the the player did not have the weapon summoned. Once the weapon was summon the quest would move to stage 2. Stage 2 (I thought) would check to see how much MP the player has. I used a quest condition for this. If the MP was less than the amount specified, it would remove the spell and items and reset the quest back to stage 1.

Of course, however I did it, it obviously didn't work, otherwise I wouldn't be here posting about it.

 

Some help would be greatly appreciated.

Link to comment
Share on other sites

Well, your debug line specifically mentions "ScriptEffectUpdate" was run X times, but in your script you don't have a ScriptEffectUpdate block, it never updates until it runs out, provided you set a run out duration for the spell.

All you have here now is the run-once-at-the-casting ScriptEffectStart and the run-once-at-the-end ScriptEffectFinish blocks. Your update checks are inside a block which is never run again and will only check once.

 

I myself have had bad experience with the reliability of ScriptEffectUpdate blocks, but in your case it should work as intended.

 

 

If you stick to the spell-based approach, you can use ScriptEffectStart, ScriptEffectUpdate and ScriptEffectFinish blocks to do the work just like you did here. Just make sure your script is saved as a Spell-Script and attached to a spell as well.

ScriptEffectUpdate will run roughly less than every frame. The exact frequency I could not determine, as it always didn't update every step in my tests.

 

If you switch to a quest-based approach, you will also have to switch away from ScriptEffectStart, -Update and -Finish as well. Only GameMode and MenuMode blocks will work in that case.

For Quest-Scripts GameMode / MenuMode blocks will run once every "fQuestDelayTime" seconds, which can be defined at the top of your script for each quest and the default should be 3 or 4 I think.

 

You can also use GameMode / MenuMode blocks on Spell-Scripts, which will then run once every frame, I think, but there'll be little to no way to determine when the spell was casted then or when it runs out like before.

 

Also while multiple blocks of the same type do theoretically indeed chain, or so I heard, it isn't exactly advisable to have more than one of a kind at the same time. Certain script code structures can prevent all code coming after them from even being considered anymore, and this will most definitely break the proper function of such multiple chained blocks then. And that's just the start. So having 2 ScriptEffectStart blocks, for example, is really not a good idea.

Link to comment
Share on other sites

If you stick to the spell-based approach, you can use ScriptEffectStart, ScriptEffectUpdate and ScriptEffectFinish blocks to do the work just like you did here. Just make sure your script is saved as a Spell-Script and attached to a spell as well.

ScriptEffectUpdate will run roughly less than every frame. The exact frequency I could not determine, as it always didn't update every step in my tests.

 

So, originally, my first attempt at scripting this used the Begin-Block for ScriptEffectStart, and ScriptEffectUpdate, and ScriptEffectFinish.

However, when I did this, it still never removed the weapons.

When I cast the spell, it would summon the weapons and the drain magic spell (which I have a bug with that as well, but that's a different issue), but, when my magic reached less than 20, it never removed the weapons. It only removed the weapons *IF* I cast the spell again when I was below 20 magic. Which is obviously not the intended effect.

(for testing purposes)

The spell is suppose to add and equip the weapons until the player's magic reaches less than 20 magic points. Once the player reaches less than 20 magic points, it should *automatically* unequip and remove the weapons from the player.

 

(once I can get the spell to behave as intended, I will set the magic points to <= 0 magic points. But as of right now, I cannot get it to behave as intended)

 

p.s.

a note about the drain spell.

It seems to add the proper effect. As you can see in the script, it just adds an ability to the player "drain magicka". However, the actual drain effect doesn't seem to work.

 

Once I cast the summon weapon spell, it definite adds the drain magicka ability. I can go to the active abilities tab and see it there. However, it is not affecting the player.

http://i.imgur.com/Ho8od2e.jpg

Some notes about the spell currently.

I set it as a disease with 9999 duration because the FIRST TIME I tried using the spell...it didn't work. My first attempt at making the spell work was set as an ability with 0 duration - assuming it should indefinitely apply the effect until it is removed.

Regardless, neither method as a disease or ability works properly. the spell does not drain the player's magic.

Link to comment
Share on other sites

I'm not sure you even can use a Drain effect on Self. Somebody else shine some light on this here, if you know more. Maybe Damage Magicka would be a better choice? Unless it harms your Max. Magicka level that is.

 

What duration does the spell that summons the weapon and checks for your Magicka to go below 20 have? It must also run like infinitely, else ScriptEffectUpdate will no longer trigger once it ran out.

 

Coming to think of it, I think my observations of unreliability of ScriptEffectUpdate blocks have been made with Ability type spells as well. Chances are Abilities don't always run the -Update block repeatedly at all.

Link to comment
Share on other sites

Coming to think of it, I think my observations of unreliability of ScriptEffectUpdate blocks have been made with Ability type spells as well. Chances are Abilities don't always run the -Update block repeatedly at all.

 

My first attempt had the skill set to 0 duration. I think I later tried 9999 duration. And, as of the time of writing this response, I had it set to 1 duration.

Link to comment
Share on other sites

I don't know about spell duration 0, but spell duration 1 will most definitely have the spell run out and the script stop long before your Magicka ever comes even close to <20.

 

One thing I always do when in doubt my blocks are even running is add a PrintToConsole debug output line at the top of each block and check the console in game what blocks are run and how often, if at all.

Link to comment
Share on other sites

I don't know about spell duration 0, but spell duration 1 will most definitely have the spell run out and the script stop long before your Magicka ever comes even close to <20.

 

One thing I always do when in doubt my blocks are even running is add a PrintToConsole debug output line at the top of each block and check the console in game what blocks are run and how often, if at all.

Busy work week, sorry for the late reply.

I finally sat down and took another crack at it and it looks like it worked! I think you were right about the duration and the ScriptEffectUpdate block. Here is the final working script:

scriptname aaSummonLuxMae

short updateCount
short DoOnce

Begin ScriptEffectStart
	if player.GetActorValue Magicka >= 50 && DoOnce == 0
			player.addspell aaLuxMaeDrain
			player.additem 00LuxOH 1
			player.additem 00LuxOFF 1
			player.EquipItem 00LuxOH 1
			player.EquipItem 00LuxOFF 1
			set DoOnce to 1
	endif
end

Begin ScriptEffectUpdate
	if DoOnce == 1&& player.GetActorValue Magicka <=20
		player.removespell aaLuxMaeDrain
		player.UnEquipItem 00LuxOH 1
		player.UnEquipItem 00LuxOFF 1
		player.removeitem 00LuxOH 1
		player.removeitem 00LuxOFF 1
	else
		set updateCount to updateCount + 1
	endif
end

Begin ScriptEffectFinish
	if UpdateCount == 1
		set DoOnce to 0
  		Message "Spell is finished. ScriptEffectUpdate was run %.0f times", updateCount
	endif
End

I will now take some time to refine the parameters, but at least now I know it works correctly.

Thank you!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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