Scripting Help Required, at my wit's end

Post » Mon Nov 19, 2012 12:30 am

I have a concentration type spell with a projectile with an explosion with a placed object with the following OnLoad script.

Scriptname Portal_OnLoadFillAlias extends ObjectReferenceFormList Property DamnNearEverything autoReferenceAlias Property Thrown autoGlobalVariable Property ShouldThrow autoObjectReference Pulledevent OnLoad()if Thrown.GetReference()==NONE  Pulled = Game.FindClosestReferenceOfAnyTypeInListFromRef(DamnNearEverything, self, 45.0)  Debug.Notification(Pulled.GetBaseObject().GetName())  ;if Pulled as ObjectReference   ShouldThrow.SetValue(1)   Debug.Notification("executed if statement")   Thrown.ForceRefIfEmpty(Pulled)   ;Thrown.GetReference().disable()   Debug.Notification(Thrown.GetReference().GetBaseObject().GetName())   Thrown.GetReference().SplineTranslateTo(Thrown.GetReference().GetPositionX(), Thrown.GetReference().GetPositionY(), (Thrown.GetReference().GetPOsitionZ() + 64.0), 0.0, 0.0, 0.0, 1.0, 100.0, 30.0)   Utility.Wait(5)  ;endIFendIfself.disable()Utility.Wait(1)self.delete()endEvent

The first notification correctly identifies the object that you point the spell at by name. So, that's working. It's about the only working line of code though. If I uncomment the first if statement, the "executed if statement" doesn't appear. It's as if it has forgotten what Pulled is already. So I commented it out to look at the rest of the code. Here's where things go completely sideways. The notification to get Thrown's reference's name (should be the same as the first notification) doesn't execute at all. Furthermore, I don't get anything in my debug log about it, implying that it isn't doing a "cannot call function getbaseobject on a NONE object", the error that would be thrown if the alias was empty. It simply does nothing at all. However, if I uncomment the line about disabling the reference, that works fine. So I know that the alias is filling properly. The real crux of the problem though is that the translation event doesn't occur. I need that darn translation to happen, it's half the purpose of this script. But, nothing.

Why are some functions executing on the alias property and not others? I'm SO confused.
The alias is flagged as reuseable and optional. No other flags, but the alias does have a script attached. Here's that too if it helps.

Scriptname PCKP_Script_GravThrownAlias extends ReferenceAlias  GlobalVariable Property ShouldThrow autoReferenceAlias Property HitActor autoActor Property PlayerREF autoint DealDamage=0 ;could use a bool i guess, but maybe i'll need to set this to a non 1 or 0 value someday. I dunno.event OnTranslationComplete()if ShouldThrow.GetValue() as int==1 ;1 is actually the false condition, as long as the player remains casting the spell;ShouldThrow will be 1 due to the previous script. This means that the object in question will continue to track with the;player's hand. In other words, 1 means don't throw it.GetReference().SplineTranslateToRefNode(PlayerRef, "NPC R Hand [RHnd]", 1, 1024)elseIf ShouldThrow.GetValue() as int==0 && HitActor.GetReference()!=NONE && DealDamage==0 ;now, once the player;has hit an actor with the projectile (which puts him in HitActor alias) and has the item tracking and the object has not;tracked to the hitactor yet, it now will fly at the hitactor's head and set dealdamage to true (the player needs also have;let go of the spell to trigger the OnEffectFinish event, which sets the ShouldThrow to 0)GetReference().SplineTranslateToRefNode(HitActor.GetReference(), "NPC Head [Head]", 1, 1280)DealDamage=1elseIf  ShouldThrow.GetValue() as int==0 && HitActor.GetReference()!=NONE && DealDamage==1float DamageDealt = (GetReference().GetMass() * 20) ;the third step, once the translation to the hitactor has been taken;care of, is to deal damage to the hitactor, so now I need this to execute and then clear out the aliases(HitActor.GetReference() as Actor).DamageActorValue("Health", DamageDealt)HitActor.Clear();ShouldThrow.SetValue(0)Clear()else ;this is basically a catch all for if, for example, the player lets go of the spell, and there is no hitactor selected or;whatever. Should make whatever you're manipulating fall to the ground. I only want a direct clear statement if all of the;above if statements have failed, not the moment that the hitactor alias is filled.Clear()endIfendEventevent OnUpdate() ;this is an experiment I tried. I realized that while I can't seem to get Thrown.GetReference() to translate;properly from the other script, I could update (tested with a PlayerREF.KillSilent(), which executed.) the alias. This too,;however, did not execute.GetReference().TranslateTo(GetReference().GetPositionX(), GetReference().GetPositionY(), (GetReference().GetPositionZ() + 64), 0, 0, 0, 10, 128)endEvent
User avatar
CSar L
 
Posts: 3404
Joined: Fri Nov 09, 2007 9:36 pm

Post » Mon Nov 19, 2012 5:08 am

Try carving out all instances of 'Self' when not passed as an argument (in both scripts)? The bottommost Clear() calls needn't 'Self' nor GetReference(). 'Self', BTW, doesn't work for ReferenceAlias scripts.

Spoiler
ScriptName PCKP_Script_GravThrownAlias Extends ReferenceAliasGlobalVariable Property ShouldThrow AutoReferenceAlias Property HitActor AutoActor Property PlayerREF AutoBool DealDamage = FalseEvent OnTranslationComplete()	If ShouldThrow.GetValue()		GetReference().SplineTranslateToRefNode(PlayerRef, "NPC R Hand [RHnd]", 1, 1024)	ElseIf HitActor.GetReference()		Clear()	ElseIf DealDamage ; && !ShouldThrow.GetValue() && !HitActor.GetReference() <--- These two are already seen to if the script makes it this far		Float DamageDealt = (GetReference().GetMass() * 20)		(HitActor.GetReference() As Actor).DamageActorValue("Health", DamageDealt)		HitActor.Clear()		;ShouldThrow.SetValue(0)		Clear()	Else		GetReference().SplineTranslateToRefNode(HitActor.GetReference(), "NPC Head [Head]", 1, 1280)		DealDamage = True	EndIfEndEvent
Also, you shouldn't need to wait between Disable and Delete like was necessary in FO3 if Disabling/Marking for deletion in the same frame (it won't CTD).
User avatar
Greg Cavaliere
 
Posts: 3514
Joined: Thu Nov 01, 2007 6:31 am

Post » Mon Nov 19, 2012 8:37 am

Hey Ducey:

I assume you are testing for NONE (first if test) because of this:

"akSource can be None if hit by a projectile attack where the projectile was not fired by a weapon or spell" - http://www.creationkit.com/OnHit_-_ObjectReference ??

So that seems like a decent approach.


So that second if statement:

Should it not just be:

if (Pulled)

??

As in:

if Pulled != NONE

??

If you do it like that, does that second test fire OK (and you then do see "executed if statement")?
User avatar
StunnaLiike FiiFii
 
Posts: 3373
Joined: Tue Oct 31, 2006 2:30 am

Post » Mon Nov 19, 2012 12:57 am

Wait Justin, so do I just cut out the word self and leave it as GetReference().WhateverI'mDoing() does that work?
And Havent, I am not using the OnHit event at all, so...no. I'll try changing the syntax on the pulled thing though.
EDIT: Your pulled syntax worked, as did deleting the selfs not passed as parameters. The debu of getreference.getbaseobject.getname didn't fire though, nor did the translation function. Back to square 1.
User avatar
Adam
 
Posts: 3446
Joined: Sat Jun 02, 2007 2:56 pm

Post » Sun Nov 18, 2012 5:29 pm

Is the lack of a name only applicable to onHit?? (I don't know ... just thinking out loud, really). I mean, do projectile's from spells carry a name over - other than NONE - to any function??


And a question, for clarity:
Debug.Notification(Pulled.GetBaseObject().GetName())
What, if anything, did that one add to the logfile??
User avatar
David Chambers
 
Posts: 3333
Joined: Fri May 18, 2007 4:30 am

Post » Mon Nov 19, 2012 1:14 am

Clear shouldn't be called on the references filling the aliases, but the aliases themselves, thus it can be called implicitly. For an ObjectReference script 'Self' is entirely unnecessary unless passed as an argument. A ReferenceAlias will still need GetReference() to refer to whatever/whoever's filling the slot.

I reworked the Alias script above and it should explain what I'm saying. Couldn't help myself and I optimized the conditions. Sorry >_<
User avatar
trisha punch
 
Posts: 3410
Joined: Thu Jul 13, 2006 5:38 am

Post » Mon Nov 19, 2012 6:26 am

@h4vent - I don't think you're picking up what I'm laying down. OnHit is not used. Ever. The projectile doesn't even get the name, that isn't the point. The explosion from the projectile lays an object down that OnLoad finds the object you're casting at. That's the only way to do it really. The actual script on the magiceffect only fills the hitactoralias, and then oneffectfinish sets ShouldThrow to 0.

EDIT: @JO - I understood what you were saying. Also your conditions don't do what I want to do I don't think. I'm about to comment my code to help you understand.
EDIT2: Done.
User avatar
Pumpkin
 
Posts: 3440
Joined: Sun Jun 25, 2006 10:23 am

Post » Sun Nov 18, 2012 6:32 pm

Anyone?
EDIT: I found this error:

[alias Thrown on quest Portal_GravAliasHolder (03001870)].PCKP_Script_GravThrownAlias.OnTranslationComplete() - Patch Script is working
[09/06/2012 - 02:32:38PM] error: Failed to setup moving reference because it has no parent cell or no 3D
stack:
[ (000DCB88)].ObjectReference.SplineTranslateToRefNode() - "" Line ?
[alias Thrown on quest Portal_GravAliasHolder (03001870)].PCKP_Script_GravThrownAlias.OnTranslationComplete() - "PCKP_Script_GravThrownAlias.psc" Line 12
[09/06/2012 - 02:32:51PM] VM is freezing...
[09/06/2012 - 02:32:51PM] VM is frozen
[09/06/2012 - 02:32:51PM] Log closed

The weird part is, this code should only be executing OnTranslationComplete, which should only occur if the first translation I have set up in my first script executes, which at least visually, it isn't. Secondly, why wouldn't it have a parent cell or 3D stack exactly? Doesn't make sense to me. Hopefully one of you boys or girls can shed some light.
User avatar
Siobhan Wallis-McRobert
 
Posts: 3449
Joined: Fri Dec 08, 2006 4:09 pm

Post » Mon Nov 19, 2012 2:32 am

Okay. so I added a couple of
if GetReference().Is3DLoaded()
PlayerREF.KillSilent()
endIf

things in there, and a few odd things happened. First off, it killed me. So, the 3D is loaded in the alias. The weird part is though, it fired the OnTranslationComplete event just fine. But no translation happened visually at all. It's as if the function is moving everything about the object except for its 3D. I have no idea. Please someone help me understand what is happening with these translation functions.
EDIT: I did the same for GetParentCell(). It also is saying that I am in the same parent cell as the objectreference. So...apparently my error log is dead wrong. I dunno. Stupid translation functions.
User avatar
Scarlet Devil
 
Posts: 3410
Joined: Wed Aug 16, 2006 6:31 pm

Post » Sun Nov 18, 2012 5:29 pm

Havok objects don't respond to Translate functions unless you use http://www.creationkit.com/SetMotionType_-_ObjectReference and set their motiontype to Motion_KeyFramed. Perhaps that's the issue you're running into?

Beware: the last time I tried converting object motiontypes between Keyframed and Dynamic, I ran into a CTD bug when deleting the object via script.
User avatar
Ron
 
Posts: 3408
Joined: Tue Jan 16, 2007 4:34 am

Post » Mon Nov 19, 2012 2:53 am

I won't be deleting these objects, so it shouldn't be a problem. Did you run into the CTD if you changed them back to simulated first?
User avatar
Ladymorphine
 
Posts: 3441
Joined: Wed Nov 08, 2006 2:22 pm

Post » Mon Nov 19, 2012 8:18 am

It's been a while since I messed with it, but it seemed to happen randomly when deleting traprock objects after converting their movement to Keyframed. It may have been related to the trap script more than the motiontype, but the whole experience was intensely frustrating so I've been leery of SetMotionType ever since. It -only- happened while deleting the objects, and only about 1 in 10 times.
User avatar
Devils Cheek
 
Posts: 3561
Joined: Sun Aug 13, 2006 10:24 pm

Post » Sun Nov 18, 2012 10:16 pm

IT WORKED! Well, sort of. There are kinks to take care of, but I think I can take it from here. (Well, I hope so anyway)
User avatar
Nicola
 
Posts: 3365
Joined: Wed Jul 19, 2006 7:57 am

Post » Mon Nov 19, 2012 6:20 am

This is Papyrus. There are ALWAYS kinks :P Glad it worked!
User avatar
Robert Jr
 
Posts: 3447
Joined: Fri Nov 23, 2007 7:49 pm


Return to V - Skyrim