Jump to content

Staff Scripting


Medusa30

Recommended Posts

Hello,

 

I recently made a staff, that fires life force beams, and a throwable lance that should explode once you shoot at it with the new staff and unleashes a chain reaction of explosions. But now Im stucking.

 

* The staff is running on stamina and if this is too low it runs on health. How do I subtract stamina / health from the player / shooter even if I dont hit an actor like it works with OnEffectStarted?

 

* How do you check for those lances at the beams ending points?

 

I have no idea how to manage that. The lance btw is a projectile once its stucking in someones body or the ground. Pretty much like an arrow.

Edited by Medusa30
Link to comment
Share on other sites

I managed to do this so far. But, how do you check in a script if the actor has such a spear stucking in the body or inventory? Cause the way I made it, it only checks if spear is stucking anywhere in the navmesh:

 

Scriptname AsenQiLanceBeamExplosionScript extends ObjectReference  

Actor PlayerRef
int Property BeamStaminaCost Auto
PROJECTILE Property AsenSpearToLookFor Auto
Spell Property AsenSpearExplosionSpell Auto
ObjectReference TargetRef

Event OnInit()
	PlayerRef = Game.GetPlayer()
	if (PlayerRef.GetAV("Stamina") >= BeamStaminaCost)
		PlayerRef.DamageAV("Stamina", BeamStaminaCost)
	else
		PlayerRef.DamageAV("Health", BeamStaminaCost * 1.5)
		Debug.Notification("The Qi Lance is damaging your health!")
	endif

	TargetRef = Game.FindClosestReferenceOfTypeFromRef(AsenSpearToLookFor, self, 128) as ObjectReference
	if (TargetRef != none)
		self.SetPosition(TargetRef.GetPositionX(), TargetRef.GetPositionY(), TargetRef.GetPositionZ() + 100)
		AsenSpearExplosionSpell.cast(self)
	endif

;	Utility.wait(1.0)

	TargetRef.disable()
	TargetRef.delete()
	self.disable()
	self.delete()
EndEvent

How it works so far? The beam has an explosion which spawns a dummy object that launches this script.

 

Another question:

How to I set the position of my dummy jus a bit, lets say 64 units, towards the player so that the casted spell is inside the world? Giving Z + 100 units solves a few bugs - for example if you are throwing the spears into terrain the damage spell will now work quite well and it works small wooden walls as well -, but gates and other larger surfaces the spears can stuck in, the spell damage will be blocked (the art is still visible).

Link to comment
Share on other sites

  • Recently Browsing   0 members

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