Game.FindClosestReferenceOfAnyTypeInList: Does it even work?

Post » Mon Nov 19, 2012 12:47 am

Here's my script, but I've made a number of others.

Scriptname PCKP_Script_KillSpell extends ObjectReference Projectile Property LightPortal autoProjectile Property DarkPortal autoFormList Property PortalProjList autoObjectReference Property Smokey autoEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \  bool abBashAttack, bool abHitBlocked)if akProjectile==LightPortal || akProjectile == DarkPortal  ObjectReference TheProj = Game.FindClosestReferenceOfAnyTypeInListFromRef(PortalProjList, Smokey, 50.0)    TheProj.disable()   TheProj.delete() endifendEvent

The reason I'm doing this is as a bassackwards method of casting a Projectile as an ObjectReference, something that cannot normally be done. The script compiles fine, and my list contains the Projectiles in question. But, the script seemingly does nothing in game.

I've attempted several scripts using this function in the past, and no matter what I do I always get a NONE as a return value for it.

What am I doing wrong here?
User avatar
Trish
 
Posts: 3332
Joined: Fri Feb 23, 2007 9:00 am

Post » Mon Nov 19, 2012 2:06 am

I can confirm that the function does work. Maybe try increasing the "50" to something a bit larger, like 100 or 150, and see if that helps?
User avatar
Meghan Terry
 
Posts: 3414
Joined: Sun Aug 12, 2007 11:53 am

Post » Sun Nov 18, 2012 5:36 pm

Tried that, no go.
User avatar
hannah sillery
 
Posts: 3354
Joined: Sun Nov 26, 2006 3:13 pm

Post » Sun Nov 18, 2012 9:37 pm

Weird. I haven't used projectiles at all, but maybe there is something about them that is preventing it from working. The code that I have, that works, looks just like yours; for example:

ObjectReference ClosestBed = Game.FindClosestReferenceOfAnyTypeInListFromRef(BedFurnitureList, Self.GetActorRef(), 384.0)
User avatar
Shannon Lockwood
 
Posts: 3373
Joined: Wed Aug 08, 2007 12:38 pm

Post » Sun Nov 18, 2012 11:26 pm

Perhaps OnHit events don't register on activators? I could try this...
event OnTriggerEnter(ObjectReference akActionRef)ObjectReference PortalProj = Gamer.FindClosestReferenceOfAnyTypeInListFromRef(PortProjList, Self, 100.0)PortalProj.disable()PortalProj.delete()endEvent

I had been trying to use TriggerEnter functions before, but there was no way to cast them as a projectile, so I couldn't do a test to see if they were the right type of projectile to delete. The Game function should make an if statement unnecessary.

Nope, that didn't take either.
User avatar
tiffany Royal
 
Posts: 3340
Joined: Mon Dec 25, 2006 1:48 pm

Post » Sun Nov 18, 2012 6:23 pm

Not really sure what you are trying to do, but if you are trying to get the REF of an arrow projectile after it hits an actor...you cannot. Unlike Oblivion the REF no longer exists in the game world once it hits an actor. THAT I know for a fact. It MAY be the same for magic projectiles but I am only guessing on that part.

I spent months trying to find a way to grab the projectile ref the moment BEFORE it would hit the actor and had found no practical way to do it that would not tax the frame rate too much. This was easy to do in Oblivion (in fact I had several different ways to do it in Oblivion) and that allowed me to create amazing features for archery and magic combat. I had one feature for example where the magic user would grab the magic missile and throw it back at the attacker. Or punch the magic missile and make it explode before it hit the intended actor. I wish I could do the same (get projectile REF and data like xyz the moment before and after it hits it's target) in Skyrim.
User avatar
Jenna Fields
 
Posts: 3396
Joined: Mon Dec 11, 2006 11:36 am

Post » Sun Nov 18, 2012 3:30 pm

Not really sure what you are trying to do, but if you are trying to get the REF of an arrow projectile after it hits an actor...you cannot. Unlike Oblivion the REF no longer exists in the game world once it hits an actor. THAT I know for a fact. It MAY be the same for magic projectiles but I am only guessing on that part.

I spent months trying to find a way to grab the projectile ref the moment BEFORE it would hit the actor and had found no practical way to do it that would not tax the frame rate too much. This was easy to do in Oblivion (in fact I had several different ways to do it in Oblivion) and that allowed me to create amazing features for archery and magic combat. I had one feature for example where the magic user would grab the magic missile and throw it back at the attacker. Or punch the magic missile and make it explode before it hit the intended actor. I wish I could do the same (get projectile REF and data like xyz the moment before and after it hits it's target) in Skyrim.

Here's the weird thing. Making an activator that simple

OnTriggerEnter(ObjectReference akActionref)
akActionRef.disable()
akActionRef.delete()
endEvent

WORKS! It shouldn't, but it does. It automatically converts the projectile to an objectreference when it hits the L_ProjectileZone trigger box. The problem is, I can't get this to be selective for just my portal spells.
So aggravating.
User avatar
Jay Baby
 
Posts: 3369
Joined: Sat Sep 15, 2007 12:43 pm

Post » Sun Nov 18, 2012 7:21 pm

I FIGURED IT OUT!
The trick is that OnTriggerEnter functions return projectiles as ObjectReferences, which luckily for us has the member function GetBaseObject. So, you actually can cast the ObjectReference as a projectile for the purposes of comparison to determine what kind of projectile it is, and then you still have akActionRef to rely on for ObjectReference member functions such as disable/delete.

Had my cake, ate it too.
User avatar
Miragel Ginza
 
Posts: 3502
Joined: Thu Dec 21, 2006 6:19 am

Post » Sun Nov 18, 2012 7:19 pm

I guess I really did not understand what you were after. er...still don't... so this is a trigger box around a target and you are making it disappear when it is hit but only with a particular projectile?

so...Hit with a fire ball nothing, but hit with DuceyMagicMissile and it disappears?

ah...so your problem was in detecting what type of magic missile hit it? Why couldn't you just detect the spell that resulted on the activator?

will Skyrim Activator not run spells? Doors in Oblivion would...


I FIGURED IT OUT!
The trick is that OnTriggerEnter functions return projectiles as ObjectReferences, which luckily for us has the member function GetBaseObject. So, you actually can cast the ObjectReference as a projectile for the purposes of comparison to determine what kind of projectile it is, and then you still have akActionRef to rely on for ObjectReference member functions such as disable/delete.

Had my cake, ate it too.
User avatar
Stephy Beck
 
Posts: 3492
Joined: Mon Apr 16, 2007 12:33 pm

Post » Sun Nov 18, 2012 3:54 pm

Yes, exactly.
User avatar
Jani Eayon
 
Posts: 3435
Joined: Sun Mar 25, 2007 12:19 pm


Return to V - Skyrim