Jump to content

[LE] Force projectile to fire vertically


Elias555

Recommended Posts

I want to have a projectile fire vertically from an actor. I had an attempt but it didn't even compile.

Scriptname AceProjectileAngleScript extends activemagiceffect  


Spell Property MySpell Auto
;Float ProjectileAngleZ 
 
Event OnEffectStart(Actor akTarget, Actor akCaster)

	Float ProjectileAngleZ = akTarget.GetAngleZ() + 90

	MySpell.cast(akTarget.ProjectileAngleZ)

EndEvent

"ProjectileAngleZ is not a property on script actor or one of its parents"

 

I tried declaring the float but I got another error about it already being defined. Is this even the correct method?

Link to comment
Share on other sites

First error is because the script is trying to read a property called ProjectileAngleZ in aktarget, with doesn't exists. The second is because of the duplicity between the "external" variable and the variable within the event, having the same name. In any case cast doesn't take an angle, it takes an objectreference source and an optional objectreference target. So I think you'd need to spawn/move something and positition it to be used as target.

 

Something like this for example:

Scriptname AceProjectileAngleScript extends activemagiceffect  

Spell Property MySpell Auto
Static Property MyTargetMarker Auto
 
Event OnEffectStart(Actor akTarget, Actor akCaster)
	ObjectReference Mytarget = akCaster.Placeatme(MyTargetMarker) ;place marker at caster location
	Mytarget.MoveTo(akCaster, 0.0, 0.0, 500.0) ;move it 500 units above the actor
	MySpell.cast(akCaster, MyTarget) ;cast the spell from caster to this placed marker
	Mytarget.Delete() ;delete our marker
	MyTarget = None ;clearing the variable should make sure its deleted but I guess the event ending also clears it
EndEvent

Or you could have a marker placed in a holding cell in CK, make an objectreference to it and move it around instead of spawning a new one.

Link to comment
Share on other sites

I did think of using a target like that but my concern was what happens when there's a ceiling or if I want to give the projectile a trajectory?

If there's no other way, I'll just go with that method. Is there any reason you use a static and not an activator? I've always used activators for that sort of thing.

Link to comment
Share on other sites

Yeah an activator would work too for this purpose. And i just put the offset in Z because you had Z + 90, Its possible to get offsets for any point at any angle you want with some math, it's a pain with sines and cosines.

 

This is an example of doing that in the wiki:

; Moves a portal 120 units in front of the player, 35 units under their height
Actor PlayerRef = Game.GetPlayer()
Portal.MoveTo(PlayerRef, 120.0 * Math.Sin(PlayerRef.GetAngleZ()), 120.0 * Math.Cos(PlayerRef.GetAngleZ()), PlayerRef.GetHeight() - 35.0)
Edited by FrankFamily
Link to comment
Share on other sites

Oh right, I've used that before but someone else did the calculations for me. I think I'll just go with a similar script to yours. Thanks FF!

 

Edit:

Hmm, not working as intended.

Spell Property MySpell Auto
Activator Property MyActivator Auto
 
Event OnEffectStart(Actor akTarget, Actor akCaster)

	ObjectReference MyTarget = akTarget.Placeatme(MyActivator)
	MyTarget.MoveTo(akTarget, 0.0, 0.0, 500.0);It needs to be placed in reference to the akTarget since the caster is the PC
	MySpell.cast(akTarget, MyTarget);This is what I want but it's not working. Swapping these around works though
	;Utility.Wait(0.3)
	;MyTarget.Delete()
	;MyTarget = None 

EndEvent

The projectile fires in front of the akTarget, not towards the activator. I made the marker visible so it's definitely being placed where I want it to be.

 

Edit2:

The problem is the projectile wants to move in the direction the actor is moving. When standing still, the projectile moves towards the activator. Looks like I need to create 2 markers unless someone has a more elegant solution.

 

Edit3:

This works. Not sure what will happen when the actor is oversized.

Scriptname AceProjectileAngleScript extends activemagiceffect  


Spell Property MySpell Auto
Activator Property MyActivator Auto
 
Event OnEffectStart(Actor akTarget, Actor akCaster)

	ObjectReference MyTarget = akTarget.Placeatme(MyActivator)
	ObjectReference akTargetLocation = akTarget.Placeatme(MyActivator)
	MyTarget.MoveTo(akTarget, 0.0, 0.0, 500.0) 
	akTargetLocation.MoveTo(akTarget, 0.0, 0.0, 150.0) 
	MySpell.cast(akTargetLocation, MyTarget)

	MyTarget.Delete()
	MyTarget = None 
	akTargetLocation.Delete()
	akTargetLocation= None 

EndEvent
Edited by Elias555
Link to comment
Share on other sites

  • 9 months later...

Posting here for future reference. It sounds like the CK is wired to override aim to the player controller. Damn, that's dumb. Please do tell if anyone ever finds a better solution. Thanks for doing the hard work for the rest of us.

Huh? The post above yours shows how I scripted it in the end. It all worked out. You just place an activator above the actor and force the actor to fire to it/have an activator fire to it.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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