Jump to content

What Am I Doing Wrong With This Script?


Kyle8497

Recommended Posts

Although, I have found out that if I enter it more than once while burning, then the healing stacks. Any thoughts on only making it work once at a time?

 

set another magiceffect for your healing spell and check it tgt at the line where the burn magiceffect is.

If Game.GetPlayer().HasMagicEffect(Burn) && !Game.GetPlayer().HasMagicEffect(HealingMG)
Edited by fantasy19
Link to comment
Share on other sites

Here is how I personally would do this. There are multiple correct ways so this might not be right for you.

 

If I understand correctly, you want the player to wade into a magical pool. If they have a specific spell effect, then the pool will heal them and also remove that effect.

 

First of all your script. I would keep it as simple as possible. In my opinion it's always better to keep scripts as simple as possible and let the engine do as much of the processing as possible.

spell Property BurnDispel Auto
 
Event OnTriggerEnter(ObjectReference akActionRef)
  If akActionRef == Game.GetPlayer()
       BurnDispel.Cast(akActionRef)
  EndIf
EndEvent

That's all you need. Now you can reuse this script whenever you want to cast a spell on the PC when it enters the trigger.

 

Then I would set up my magic effect for BurnDispel like so:

 

 

 

The first condition should prevent this effect from occurring if the target does not have the "Burn" effect. The second condition prevents this effect from occurring if the target already has the "BurnDispel" effect. That will prevent the healing from stacking.

Edited by lofgren
Link to comment
Share on other sites

 

Although, I have found out that if I enter it more than once while burning, then the healing stacks. Any thoughts on only making it work once at a time?

 

set another magiceffect for your healing spell and check it tgt at the line where the burn magiceffect is.

If Game.GetPlayer().HasMagicEffect(Burn) && !Game.GetPlayer().HasMagicEffect(HealingMG)

 

Wouldn't that make it work only if they're burning and are already being healed?

Link to comment
Share on other sites

Try how lofgren suggests first. I don't do much with magic effects and spells and his stuff seems to make sense.

 

However, if you want it all done via scripting... You could try this. It is based on the code you stated earlier was working but caused it to repeat healing if still burning. This applies a bool which should allow only one healing cast.

 

 

Scriptname RidleyDispelFirePool extends ObjectReference
 
Spell Property DispelPoolSpell Auto
 
MagicEffect Property Burn Auto

Bool Healing = false
 
Event OnTriggerEnter(ObjectReference akActionRef)
	If akActionRef == Game.GetPlayer()
		If Game.GetPlayer().HasMagicEffect(Burn) && Healing == false
			DispelPoolSpell.Cast(akActionRef)
			Healing = true
			RegisterForSingleUpdate(1.0)
		EndIf
	EndIf
EndEvent

Event OnUpdate()
	While Game.GetPlayer().HasMagicEffect(Burn)
		;wait for player to be healed
		;this while loop keeps it open without having to 
		;continually register for a single update
		;the wait call just puts some space between loop runs
		Utility.Wait(0.1)
	EndWhile
	If !(Game.GetPlayer().HasMagicEffect(Burn))
		Healing = false
	EndIf
EndEvent 

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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