Creating an item at a missed spell

Post » Sat May 28, 2011 12:44 pm

would it be possible to create a script attached to an inventory object which tracks the movement of a spell projectile, and if it does not hit an actor or a container, use placeatme to create an object where it hits? I'm assuming it would use getfirstref, getnextref, and so on, as well as getpos and setpos, but I have no idea as to how it could detect when the spell hits an invalid target. I have OBSE v18.
User avatar
Kayleigh Mcneil
 
Posts: 3352
Joined: Thu Jun 29, 2006 7:32 am

Post » Sat May 28, 2011 5:40 am

would it be possible to create a script attached to an inventory object which tracks the movement of a spell projectile, and if it does not hit an actor or a container, use placeatme to create an object where it hits? I'm assuming it would use getfirstref, getnextref, and so on, as well as getpos and setpos, but I have no idea as to how it could detect when the spell hits an invalid target. I have OBSE v18.

If you're trying to track the trajectory of a specific spell, this might be doable, as follows:

1. Each frame, object script uses ref-walking to detect any projectiles of spell X
2. If it detects one (this is much easier with only one projectile, it gets tricky if you want to have multiple spells flying at once), it records the coordinates of the projectile
3. Repeat until, in the current frame, the projectile is gone
4. Place your object at the last known coordinates of the projectile

Like I said, though, this gets a lot trickier if you've got multiple projectiles flying around at once.

It might also be very slow, since it would do a ref-walk each frame.
User avatar
Peter lopez
 
Posts: 3383
Joined: Mon Sep 10, 2007 5:55 pm

Post » Sat May 28, 2011 1:01 pm

It would be possible to have multiples of the spell in the air at once, so it'll be hard.
User avatar
lauraa
 
Posts: 3362
Joined: Tue Aug 22, 2006 2:20 pm

Post » Sat May 28, 2011 7:10 am

You can (probably) use the script detailed http://cs.elderscrolls.com/constwiki/index.php/Running_Scripts_On_Arrows to get access to the spell projectiles, which you can then store in an array and track. If it's going to be used by NPCs as well as the player though this won't really work.
User avatar
Katey Meyer
 
Posts: 3464
Joined: Sat Dec 30, 2006 10:14 pm

Post » Sat May 28, 2011 6:53 pm

You can (probably) use the script detailed http://cs.elderscrolls.com/constwiki/index.php/Running_Scripts_On_Arrows to get access to the spell projectiles, which you can then store in an array and track. If it's going to be used by NPCs as well as the player though this won't really work.


Actually, that triggerzone approach is probably unnecessary with OBSE and ref-walking available.

If you want to work with multiple projectiles, you will have to use OBSE's array functions, as RandomSpecification said.

Now the script would have to look like this:

1. Each frame, object script uses ref-walking to detect any projectiles of spell X
2. If it detects any, it saves the ref of each projectile in an array and records the coordinates of eachprojectile in a separate array
3. Repeat each frame, updating or adding coordinates to the second array as needed.
4. If one of the projectiles in your first array ceases to exist, place your object at the last known coordinates of that projectile (stored in the second array)

That's a pretty intensive script to run every frame. It might be faster (i.e. use fewer processor cycles) to use the triggerzone approach, but then (as RandomSpecification said) you'd miss any spells cast by NPCs.

EDIT: Also, depending on your frame rate, you might get the last coordinates of a projectile somewhere in mid-air near the final obstacle it collides with. So if you're placing a burn mark decal or something like that, you're going to get some weird decals floating a few inches or even feet from the wall, etc.
User avatar
Horror- Puppe
 
Posts: 3376
Joined: Fri Apr 13, 2007 11:09 am


Return to IV - Oblivion