[script] Activator check object in space

Post » Tue Jun 19, 2012 6:12 pm

I'd like to find a way that that if the player leaves an item in an area (trigger) and then uses a particular activator an event happens..
Could someone mentor me on this one a little?

Currently Im thinking around the idea of following pseudo-code but need help with real syntax/functions.

Trigger:

ingredient Property itemX autoEvent OnTrigger(ObjectReference akActionRef)   if(akActionRef == itemX)	  VAR = true   endifEndEventEvent OnTriggerLeave(ObjectReference akActionRef)   if(akActionRef == itemX)	  VAR = false   endifEndEvent

Activator:

Event OnActivate(ObjectReference akActionRef)   if(VAR == true) ;	  do something	  delete itemX in the trigger	  VAR = false;   endifEndEvent

Issues: How would i set a global variable (VAR) to true? How do I delete the object in the trigger?

Would love help!
User avatar
Bad News Rogers
 
Posts: 3356
Joined: Fri Sep 08, 2006 8:37 am

Post » Wed Jun 20, 2012 12:32 am

In http://www.creationkit.com/ObjectReference_Script you want to check the Disable/Delete functions ( Not sure which was which) and I think the GetBaseObject one to compare an ingredient form with an object reference.
User avatar
Stacy Hope
 
Posts: 3391
Joined: Thu Jun 22, 2006 6:23 am

Post » Tue Jun 19, 2012 11:07 pm

You can use the trick given by Cipsis there : http://www.gamesas.com/topic/1354202-need-help-with-a-function-please/page__p__20409878#entry20409878

Use that to set the object reference in the trigger to the activator and flag the activator to be ready to be used.
User avatar
Trish
 
Posts: 3332
Joined: Fri Feb 23, 2007 9:00 am

Post » Tue Jun 19, 2012 6:03 pm

Thanks for the help, I know my code must seem very vague, i should have given more background.

What im trying to do:
I made a http://skyrim.nexusmods.com/downloads/file.php?id=11079, and i thought it would be cool if you could offer a sacrifice in order to receive a Daedric gift. SO leaving an item on the altar (in trigger) and then using the blessing (Activator) should give player an item. (I'd rather the gift appear on the altar but that'll come later. One step at a time.)

Am feeling pretty lost, but this is what I have so far:

Trigger:
I've put it all on the trigger for the moment to see if I can check if an object is in an area.
This compiles, but the "if" doesnt work.

Scriptname hircineBlessingGiftScript extends ObjectReference  MiscObject Property itemX autoAmmo Property giftItem autoSound Property giftSFX autoImageSpaceModifier Property giftVFX autoEvent OnTriggerEnter(ObjectReference akActionRef)	MiscObject sacrifice = akActionRef.GetBaseObject() as MiscObject   if(sacrifice == itemX)	  akActionRef.DisableNoWait(true)	  giftVFX.Apply()	  int instanceID = giftSFX.play(self)	  Game.GetPlayer().AddItem(giftItem, 5)   endifEndEvent
User avatar
Stefanny Cardona
 
Posts: 3352
Joined: Tue Dec 19, 2006 8:08 pm

Post » Tue Jun 19, 2012 11:14 pm

please
User avatar
stacy hamilton
 
Posts: 3354
Joined: Fri Aug 25, 2006 10:03 am

Post » Tue Jun 19, 2012 12:44 pm

Change...
MiscObject sacrifice = akActionRef.GetBaseObject() as MiscObject
MiscObject sacrifice = akActionRef as MiscObject
It's also a good idea to add some lines in your code to tell you what's going on and the value of variables etc.
Debug.Notification("sacrifice:=" + sacrifice)
User avatar
Javier Borjas
 
Posts: 3392
Joined: Tue Nov 13, 2007 6:34 pm

Post » Wed Jun 20, 2012 2:09 am

Got it working!
That amendment gives me the compile error: "cannot cast a objectreference to a miscobject, types are incompatible"

So I changed it back, BUT adding the debug note revealed that the trigger wasn't working unless it was triggered by the player.
So, I looked around the reference window and found the "Collision Layer" option under "Primitive" and changed that from L_ACTORZONE to L_TRIGGER

Now that I know that much works I'll try and separate the scripts and post my findings here.

Thanks for all the pro tips guys.

This is the current script:

Spoiler
Scriptname hircineBlessingGiftScript extends ObjectReference  MiscObject Property itemX autoAmmo Property giftItem autoSound Property giftSFX autoImageSpaceModifier Property giftISM autoEffectShader Property giftVFX autoEvent OnTriggerEnter(ObjectReference akActionRef)MiscObject sacrifice = akActionRef.GetBaseObject() as MiscObjectDebug.Notification("sacrifice:=" + sacrifice) if(sacrifice == itemX)giftVFX.Play(akActionRef)giftISM.Apply()int instanceID = giftSFX.play(self)akActionRef.DisableNoWait(true)Game.GetPlayer().AddItem(giftItem, 5)akActionRef.DeleteWhenAble()endifEndEvent
User avatar
DAVId Bryant
 
Posts: 3366
Joined: Wed Nov 14, 2007 11:41 pm

Post » Tue Jun 19, 2012 11:05 pm

All working! Thanks for the help everyone!

Trigger:

Scriptname hircineBlessingGiftScript extends ObjectReference  MiscObject Property itemX autoBool Property isSacrifice autoObjectReference Property sacrificeRef autoEvent OnTriggerEnter(ObjectReference akActionRef)MiscObject sacrifice = akActionRef.GetBaseObject() as MiscObject ;Debug.Notification("sacrifice:=" + sacrifice) if(sacrifice == itemX)sacrificeRef = akActionRefisSacrifice = trueendifEndEventEvent OnTriggerLeave(ObjectReference akActionRef)MiscObject sacrifice = akActionRef.GetBaseObject() as MiscObjectif(sacrifice == itemX)isSacrifice = falseendifEndEvent

Activator:
Scriptname hircineBlessingGiftGoScript extends ObjectReference  ObjectReference Property altar autoAmmo Property giftItem autoSound Property giftSFX autoImageSpaceModifier Property giftISM autoEffectShader Property giftVFX autoEvent OnActivate(ObjectReference akActionRef)if ((altar as hircineBlessingGiftScript).isSacrifice == true);Debug.Notification("isSacrifice is true")ObjectReference sacrifice = (altar as hircineBlessingGiftScript).sacrificeRefGame.GetPlayer().AddItem(giftItem, 5)giftVFX.Play(sacrifice)giftISM.Apply()int instanceID = giftSFX.play(self)sacrifice.DisableNoWait(true)sacrifice.DeleteWhenAble()endifEndEvent
User avatar
Pumpkin
 
Posts: 3440
Joined: Sun Jun 25, 2006 10:23 am

Post » Tue Jun 19, 2012 4:09 pm

Finally finished this mod to standard im happy with, please check it out and comment! http://skyrim.nexusmods.com/downloads/file.php?id=13516
User avatar
Lovingly
 
Posts: 3414
Joined: Fri Sep 15, 2006 6:36 am


Return to V - Skyrim