Jump to content

How to turn this script for non specific NPCs ?


Delzaron

Recommended Posts

Posted

Hi

 

I use that script for play animations on player (for example, player in milkpump)

 

event OnSit(ObjectReference akFurniture)
  if akFurniture.HasKeyword(zbfFurnitureMilkOMatic)
    PlayerRef.SetExpressionOverride(9)
    PlayerRef.EquipItem(ZaZMoMSuctionCups01,true)
    Debug.SendAnimationEvent(PlayerRef,"ZaZMOMBoundFurn_13")
  endif
endevent

event OnGetup(ObjectReference akFurniture)
  if akFurniture.HasKeyword(zbfFurnitureMilkOMatic)
    PlayerRef.ClearExpressionOverride()
    PlayerRef.UnEquipItem(ZaZMoMSuctionCups01)
    PlayerRef.removeItem(ZaZMoMSuctionCups01)
  endif
endevent

Keyword property zbfFurnitureMilkOMatic auto
Armor property ZaZMoMSuctionCups01 auto
actor property playerref auto

 

But I wish to adapt this script for non specific NPCs...

 

How I can do that ?

 

Thanks in advance.

Posted

I would use the OnActivate event in a script attached to the furniture itself. The actor who activates the furniture will be passed to the event.

 

Yes, but hiow to write something like "actor.SetExpressionOverride(9)" and blablabla ?

Posted

Clean way:

 

Add a ReferenceAlias, and attach your scripts to the refalias.

 

Then add a script to the furniture, and catch the OnActivate event.

You will get the actor as parameter, and you can force the alias to the actor when the OnActivate is done.

 

And then, inside the alias, the OnGetUp will fire too, and you can remove the actor from the alias.

Posted
Event OnActivate(ObjectReference akActivator)
Actor akActor = akActivator As Actor  
 
If akActor
 
akActor.SetExpressionOverride(9)
 
EndIf
 
EndEvent

Clean way:

 

Add a ReferenceAlias, and attach your scripts to the refalias.

 

Then add a script to the furniture, and catch the OnActivate event.

You will get the actor as parameter, and you can force the alias to the actor when the OnActivate is done.

 

And then, inside the alias, the OnGetUp will fire too, and you can remove the actor from the alias.

 

Using an alias requires a quest. Doesn't that mean it can only be used as long as the alias is not used by another furniture with the same script? 

Posted

 

Using an alias requires a quest. Doesn't that mean it can only be used as long as the alias is not used by another furniture with the same script? 

 

 

Yes and no.

 

If the OnActivate event is attached to specific ObjectReferences, then you can have the Alias as Property of the script of the ObjectReference, so the map between ObjRefs and Alias will be one to one.

 

Or, in case you attach the script to the base object (usually I don't like doing that, but is a possibility), then you may want to create (inside a Quest) a controller function, an array of aliases and an array of "used aliases", then the controller function you will grab the first not used alias and set it to the actor.

And you will release the alias with another function in the quest script.

Posted

Cpu is right about that the clean way is to store the actor as a reference alias to remove the effects by leaving the furniture. Maybe this could also be achieved with storing the actor inside the script and letting it go with the next activation while blocking other actors from entering. Using reference aliases might be a bit clunky just to release an actor but it also might be the safest way.

Posted

Yes...

 

I tested your solution, and it doesn't work. I guess the script dont suceed to recognize and attribute the effet to the NPCs.

 

event OnSit(ObjectReference akFurniture, actor akActivator)
    Actor akActor = akActivator As Actor  
      if akFurniture.HasKeyword(zbfFurnitureMilkOMatic)
        akActivator.SetExpressionOverride(9)
        akActivator.EquipItem(ZaZMoMSuctionCups01,true)
        Debug.SendAnimationEvent(akActor,"ZaZMOMBoundFurn_13")
    endif
endevent

event OnGetup(ObjectReference akFurniture, actor akActivator)
    Actor akActor = akActivator As Actor  
    if akFurniture.HasKeyword(zbfFurnitureMilkOMatic)
        akActivator.ClearExpressionOverride()
        akActivator.UnEquipItem(ZaZMoMSuctionCups01)
        akActivator.removeItem(ZaZMoMSuctionCups01)
    endif
endevent

Keyword property zbfFurnitureMilkOMatic auto
Armor property ZaZMoMSuctionCups01 auto
actor property playerref auto

Posted

 

...and it doesn't work...

 

 

 

Hello Delzaron,

 

I am not aware of available events called:

  event OnSit(ObjectReference akFurniture, actor akActivator)
and
  event OnGetup(ObjectReference akFurniture, actor akActivator)
 
They are not in ObjectReference, nor in Actor.
 
So, they may not be called just because nobody is expected to call them.
 

 

If the script is attached to an Actor, then the events are:

 
   Event OnSit(ObjectReference akFurniture)
and
   Event OnGetUp(ObjectReference akFurniture)
 
 
If the script is attached to an ObjectReference, then the only possible event is:
Event OnActivate(ObjectReference akActionRef)
 
Where akActionRef can be cast to the actor using the furniture.
Posted

I made a new script :

 

Event OnSit(ObjectReference akActionRef)
;     if akFurniture.HasKeyword(zbfFurnitureMilkOMatic)
    If akActionRef == playerref
        playerref.SetExpressionOverride(9)
        playerref.EquipItem(ZaZMoMSuctionCups01,true)
        Debug.SendAnimationEvent(playerref,"ZaZMOMBoundFurn_13")
    ElseIf akActionRef != playerref
        akactionref == milkedactor
        milkedactor.SetExpressionOverride(9)
        milkedactor.EquipItem(ZaZMoMSuctionCups01,true)
        Debug.SendAnimationEvent(milkedactor,"ZaZMOMBoundFurn_13")
    endif
endevent

event OnGetup(ObjectReference akActionRef)
;    if akFurniture.HasKeyword(zbfFurnitureMilkOMatic)
    If akActionRef == playerref
        playerref.ClearExpressionOverride()
        playerref.UnEquipItem(ZaZMoMSuctionCups01)
        playerref.removeItem(ZaZMoMSuctionCups01)
    ElseIf akActionRef != playerref
        akactionref == milkedactor
        milkedactor.ClearExpressionOverride()
        milkedactor.UnEquipItem(ZaZMoMSuctionCups01)
        milkedactor.removeItem(ZaZMoMSuctionCups01)
    endif
endevent

Keyword property zbfFurnitureMilkOMatic auto
Armor property ZaZMoMSuctionCups01 auto
actor property playerref auto
actor milkedactor

 

I will see if it's working...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...