Game.FindClosestReferenceOfTypeFromRef(AshPileObject, Target

Post » Sun Nov 18, 2012 3:59 am

Not working in game:

Objectreference DustPile = Game.FindClosestReferenceOfTypeFromRef(AshPileObject, Target, 80.0)
if Dustpile != none
debug.messagebox("works")
endif


Now, AshPileObject property is an ACTIVATOR not a Objectreference, but if I do this i get a compiling error:

Activator DustPile = Game.FindClosestReferenceOfTypeFromRef(AshPileObject, Target, 80.0)


I will this next:

Objectreference DustPile = Game.FindClosestReferenceOfTypeFromRef(AshPileObject, Target, 80.0) as Objectreference

but if this will not work what else can I do?
User avatar
Maria Leon
 
Posts: 3413
Joined: Tue Aug 14, 2007 12:39 am

Post » Sun Nov 18, 2012 3:52 am

Try

[color=#00ff00]Objectreference DustPile = Game.FindClosestReferenceOfTypeFromRef((AshPileObject.GetBaseObject()), Target, 80.0)[/color]

The function returns one specific in-game reference, not a form, so that is why you your DustPile variable needs to be of type ObjectReference. The function takes a Form as the first parameter, not an activator, so that is why I added the .GetBaseObject() there.

If that doesn't do the trick, the problem must be in one of the following:
- Target is a property which is not properly set
- AshPileObject is a property which is not properly set
- There isn't actually any ash pile within 80 game units of the target, try a larger distance just for testing.
User avatar
Danny Blight
 
Posts: 3400
Joined: Wed Jun 27, 2007 11:30 am

Post » Sat Nov 17, 2012 9:44 pm

If that doesn't do the trick, the problem must be in one of the following:
- Target is a property which is not properly set
- AshPileObject is a property which is not properly set
- There isn't actually any ash pile within 80 game units of the target, try a larger distance just for testing.
I was too lazy to answer this, but you got it covered. With Target though, it's not going to be a Property... It's likely the function-scope variable in the OnEffectStart(Caster, Target) event. So my recommendation is to make sure Target is actually what you want. Maybe Caster is more appropriate depending on the spell. Usually the Target is the Caster (cast on self).
User avatar
Daramis McGee
 
Posts: 3378
Joined: Mon Sep 03, 2007 10:47 am

Post » Sun Nov 18, 2012 9:52 am

Both the target and ashpile are set right as the script works fine if I do not do the .FindClosestReferenceOfTypeFromRef line.


This is an AOE type spell so yes target is what I need.
And the rest of the script works fine if I remove the check for the ashpile being near the target.
4 feet (80 units) should be more than enough, more than that and I risk getting other actor that are near by.
This ashpile is attached to the actor so it technically should be ZERO units away...

...er... maybe that is the issue...it is attached to the actor so it is not in the world! :facepalm:

Ok then I will drop a token on the dead vampire instead. Thanks anyway guys.


Scriptname aadpAquireActors extends activemagiceffectActivator Property AshPileObject  AutoGlobalVariable Property aadpClassicVampires  AutoFaction Property VampireFaction  AutoWEAPON Property aadpMrPointy  AutoKeyword Property Vampire AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)actor Target = akTargetif (Target.IsDead()) || (target.IsDisabled())if (Target.haskeyword(vampire)) && (Target.IsDead())Objectreference DustPile = Game.FindClosestReferenceOfTypeFromRef((AshPileObject.GetBaseObject()), Target, 80.0) ; <-- compile error	if aadpClassicVampires.getvalue() > 0 && DustPile == none	target.SetCriticalStage(Target.CritStage_DisintegrateStart)	target.SetAlpha(0.0, true)	target.AttachAshPile(AshPileObject)	target.SetCriticalStage(target.CritStage_DisintegrateEnd)	target.additem(aadpMrPointy, 1)	;debug.MessageBox("Ashpile set.")  endifendifendevent

The compile error: "aadpAquireActors.psc(61,81): GetBaseObject is not a function or does not exist
User avatar
mollypop
 
Posts: 3420
Joined: Fri Jan 05, 2007 1:47 am

Post » Sun Nov 18, 2012 2:06 am

It is an activator, not an objectref.
Add a objectref property as AshPileObject . :smile:
User avatar
MISS KEEP UR
 
Posts: 3384
Joined: Sat Aug 26, 2006 6:26 am

Post » Sun Nov 18, 2012 2:25 am

That is not how Bethesda did in in their Zombie Resurrection deaths.

They used Activators.

I cannot do that anyway as you cannot set the ashpile to an object ref in the CK. I TRIED to do that once and found that the ashpiles were all activators.

It is an activator, not an objectref.
Add a objectref property as AshPileObject . :smile:
User avatar
Rude_Bitch_420
 
Posts: 3429
Joined: Wed Aug 08, 2007 2:26 pm

Post » Sun Nov 18, 2012 8:13 am

I've gotten around limitations in the FindClosest*FromRef functions by using the related http://www.creationkit.com/FindClosestReferenceOfAnyTypeInListFromRef_-_Game function, even for single objects. In this case, create a Formlist called OnlyAshpilesList or something (there is more than one type of ashpile used in-game, anyway, so this might work better for you) and put all the Ashpiles you want to check for in it. Then use
Dustpile = Game.FindClosestReferenceOfAnyTypeInListFromRef(OnlyAshpilesList,Target,80.0)
. It might seem roundabout but, for me, it "just works".

Also note that 80 is a really small radius and it is not unusual for the actor's (invisible) body to end up a fair distance away from its attached Ashpile. If that's what you're using as Target, then you may need to increase your radius to succeed.

Also, "Ashpiles" starts to sound really weird when you type it or say it a lot.
User avatar
Lisa Robb
 
Posts: 3542
Joined: Mon Nov 27, 2006 9:13 pm


Return to V - Skyrim