Jump to content

Need help with scripting a simple detect if player is involved in a scene


Recommended Posts

Posted (edited)

Hello,

 

I would appreciate some help with scripting (I'm very new to it) in creation kit (SE 1.5.97). The goal is to edit an existing mod to reward the player for being a virgin as long as possible (with gold).

 

I am editing a script from the defloration mod and I'd like to know how to detect if the player is involved in a scene. Currently the mod checks all scenes, and I would just like it to check if the pc is involved.

 

Here is the script:

Spoiler

Actor[] defloratedActors
SexLabFramework Property SexLab Auto
MiscObject Property Gold001 auto
GlobalVariable Property TimeAsVirgin auto
 
; This is executed when the quest is initialized, only once.
Event OnInit()
  ; Global registration for the SexLab event "Animation Start", the function "checkDefloration" will be called.
  RegisterForModEvent("AnimationStart", "checkDefloration")
  ; Initialize the array of deflorated actors, to avoid to check if it is null every time
  defloratedActors = new Actor[1]
  defloratedActors[0] = None
EndEvent
 
; This event is called by SexLab every time a sex animation starts.
event checkDefloration(string eventName, string argString, float argNum, form sender)
  ; Grab the animation and check if it is Vaginal
  sslBaseAnimation theAnim = SexLab.HookAnimation(argString)
  if !theAnim.hasTag("Vaginal")
    return 
  endIf
  ; Grab the first NPC of the animation, we need to do some checking to understand if was a real defloration.
  ; The position 0 (the passive one) has to be a real female
  ; The animation has to have at least two participant (a masturbation will not deflorate...)
  Actor[] npcs = SexLab.HookActors(argString)
  if !npcs || npcs.length<2 || npcs[0].getLeveledActorBase().GetSex()!=1
    return
  endIf
  Actor theGirl = npcs[0]
  ; Check if this girl was already deflorated...
  if defloratedActors.Find(theGirl)==-1
    ; Not yet deflorated, do it
    defloratedActors = PapyrusUtil.PushActor(defloratedActors, theGirl)
    TimeAsVirgin.setvalue(Utility.GetCurrentGameTime() * 24)
    Debug.Notification("The girl " + theGirl.getLeveledActorBase().getName() + " becomes a woman after: " + TimeAsVirgin.GetValue() + "hours.")
  endIf
EndEvent

 

Thanks!

Edited by genericuser27
Posted

 

AnimationStart event carries the ThreadID and a HasPlayer boolen.

 

All you need to do is change the arguments for your checkDefloration event and add a Return condition if HasPlayer is false.

This also provides you with an easier way of fetching the animation an the actors too.

 

Example stub:

event checkDefloration( Int ThreadID, Bool HasPlayer )

  If !HasPlayer
	Return
  EndIf

  sslThreadController Controller = Sexlab.ThreadSlots.GetController( ThreadID )

  If !Controller.Animation.hasTag( "Vaginal" )
    Return 
  EndIf

  Actor[] npcs = Controller.Positions

 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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