Jump to content

Need some help with adding sounds to my mod? anyone want to help?


toxsickcity

Recommended Posts

Cpu,

 

If I want to use a IF situation to completely skip and end my script

in the event that a music integrated animation is playing lets call it TestModAE3

 

 

can I use this? from your guide?

 

bool function IsActorActive(Actor ActorRef) 
 
I think this wont work because it is check only 1 actor.
I can also add a line for each actor.
 
 
--------------------
 
 
Link to comment

"IsActorActive" is a SexLab function that tell you if an actor is participating in a SexLab animation.

 

If you want to check this for, let's say, three actors then you can do something like:

 

 

if SexLab.IsActorActive(act1) || SexLab.IsActorActive(act2) || SexLab.IsActorActive(act3)

 ; -> At least one actor is active

 

 

if SexLab.IsActorActive(act1) && SexLab.IsActorActive(act2) && SexLab.IsActorActive(act3)

 ; -> All actors are active

 

 

if !SexLab.IsActorActive(act1) && !SexLab.IsActorActive(act2) && !SexLab.IsActorActive(act3)

 ; -> No actors are active

 
 
Link to comment

Depends on what you want to check.

 

What means for you "IsActorActive" ?

 

What do you want to check?

 

 

Probably the answer is YES. But how to do it depends on what you want to check.

Link to comment

Sorry CPU I just read your guide in parts and am looking up animation idles and detection scripts.

 

so I am trying to find a way to skip in the event that my actors in the room are playing the specific animation...

 

i will then start another random generator to play a different set of animations which dont include the music.. as music will play on top of each other..

Link to comment

So, let me understand.

You want to understand if an actor that entered the trigger is actually playing a specific animation.

And in this case do something (play another anim, ignore the actor, etc.)

Am I understanding you correctly?

 

Link to comment

Hi CPU,

Sorry for not being clearer, hmmmm, ok.

 

I want to make it so that I can protect my mod so different or even if the same music tracks don't play at the same time... and create a kind of joining in dance Animation effect. by scripting a sort of detection routine

 

 

so in this example..

TestModAE1 = animation with sound effect... NO Music 5-10 second

TestModAE2 = animation with sound effect... No Music 5-10 second

TestModAE3 = dance animation with musmic to last the length of the animation 2-3minute

TestModAE3Silent = dance animation silent

TestModAE4 = different dance animation with music to land the length of the animation. 2-3minute

TestModAE4Silent = different dance animation Silent

 

so if actor 1 has moved to the trigger, and TestModAE3 (dance animation with music) was randomly selected and started to play.

actor 1 will continue to dance for 2-3 minutes

 

 

1 Minute Later,

Actor 2 has moved into the trigger and I want to add in the script, something that would apply to all 3 actors.

to see if animations TestModAE3 or TestModAE4 are playing with actor 1,2 or 3.

 

If actor 1, actor 2 or actor 3 happen to be playing the TestModAE3 or TestModAE4 animation I would want Actor 1 instantly change to the Actor 2's chosen animation.  except it will be a non music alternative.. Perhaps, TestModAE3Silent or TestModAE4Silent... so there is no overlapped music which would create a reverb/echoed music.

so essentially it would make actor 1 use the non-music animation. 

 

Same would happen for the 3rd Actor also.. they would Start a new animation and actors 1 and 2 would join in to their animation style..

 

thats basically my whole mod.

 

thankyou

 

 

 

 

Link to comment

OK. Now it is clear. I will start with one consideration, and then I will write some code for you + instructions.

 

So: Actor 1 starts playing the Anim1+Music, that lasts 3 minutes.

Actor2 gets the trigger, you find that Actor1 is dancing, and you know that is Anim1, so Actor2 starts Anim2NoMusic.

BUT: Actor1 will be already one minute after the start, while Actor2 will start from the begin. So Actor2 will not be synchronized with the music.

I don't see a way to avoid this.

 

Now, to track the animations you need to use an external container (an array, a faction cannot work), because there is no way (in my knowledge) to understand what is the animation currently played by a NPC (I will look more but I don't think so.)

So, you can create an array of actors for each animation you want to play, and then add the actor to the array as soon as you send the animation event to play the animation.

 

When a new actor enters, you can check these arrays to understand which animation to play.

 

A small problem will be: how to remove an actor from the array?

You can solve this by registering for AnimationEvents. You register for each actor you send an animation.

Then when the event is received, you can remove the actor from the array.

 

Be aware that you have to specify for your animation an animation event that will be sent when the animation ends.

 

Some basic code:

 

 

script testscript extends ObjectReference
 
ObjectReference[] npcOnAnim1
ObjectReference[] npcOnAnim1NoMusic
 
Event OnInit()
  npcOnAnim1 = new String[16]
  npcOnAnim1NoMusic = new String[16]
EndEvent
 
Event OnTriggerEnter(npcRef as ObejctReference)
  if !(npcRef as Actor)
    return
  endIf
 
  ; check if it playing already
  if npcOnAnim1.find(npcRef)!=-1 || npcOnAnim1NoMusic.find(npcRef)!=-1
    ; Already playing
    return
  endIf
  ; Check if somebody is already playing with music
  bool alreadyPlaying = false
  int i = npcOnAnim1.length
  while i
    i -= 1
    if npcOnAnim1[i]
      alreadyplaying = true
      i = 0
    endIf
  endWhile
  if !alreadyplaying
    debug.sendAnimationEvent(npcRef as Actor, "Anim1")
    i = npcOnAnim1.length
    while i
      i -= 1
      if !npcOnAnim1[i]
        npcOnAnim1[i] = npcRef
        i = 0
      endIf
    endWhile
    RegisterForAnimationEvent(npc, "MyEndAnimationEvent") ; The event has to be defined in the animation
  else
    ; Someone is already dancing, for simplicity it will be the first animation and music
    debug.sendAnimationEvent(npc, "Anim1NoMusic")
    int i = npcOnAnim1NoMusic.length
    while i
      i -= 1
      if !npcOnAnim1NoMusic[i]
        npcOnAnim1NoMusic[i] = npcRef
        i = 0
      endIf
    endWhile
    RegisterForAnimationEvent(npcRef, "MyEndAnimationEvent") ; The event has to be defined in the animation, can be the same as the other
  endIf
EndEvent
 
Event OnAnimationEvent(ObjectReference akSource, string asEventName)
  if asEventName!="MyEndAnimationEvent"
    return
  endIf
  int i = npcOnAnim1.length
  while i
    i -= 1
    if npcOnAnim1[i] == akSource
      npcOnAnim1[i] = None
      unregisterForAnimationEvent(akSource, "MyEndAnimationEvent")
      i = 0
    endIf
  endWhile

  i = npcOnAnim1NoMusic.length
  while i
    i -= 1
    if npcOnAnim1NoMusic[i] == akSource
      npcOnAnim1NoMusic[i] = None
      unregisterForAnimationEvent(akSource, "MyEndAnimationEvent")
      i = 0
    endIf
  endWhile
EndEvent

 

 

 

 

 

Link to comment
Hi CPU,
 
again a huge THANK-YOU :)
 
This is impressive and so complex, and I see how routing path is flowing, very cool stuff.. I am still a little hazy on how things link together. from ck/script to scrip
I have few questions and cannot wait to trial it and expand it with more.
 
so is npcOnAnim1 & npcOnAnim1NoMusic both the animation name? or are we basically just referencing here?
in this script do I need to assign actor names etc?
 
you said that it's not really possible to detect what animation is being played by a npc.. is this the case in the script you wrote now? as this is a tracking script?
 
you wrote
So, you can create an array of actors for each animation you want to play, and then add the actor to the array as soon as you send the animation event to play the animation.
in case I have missed it and please confirm, how do I assign my actors? is this via script to script or in CK?
 
Also Do I understand correctly? that this whole script is for 1 animation?, and I should reference this script in the event TestModAE3 is choosen? which will check if an dance animation is currently playing.
 
 
 
------
you also said that cannot sync dancing..  if one already has started, I think so too timing and other factors eliminate this.,
 
 
 
 
does this script possibly reset the dancers and make them dance in sync?
 
or is it that music once started cannot be stopped? as in, if the animation is changed?
 
---------------------------------
 
it seems that actor 2 cannot become the new lead dancer,
 
would it be possible that instead of detecting which animation is playing but to detect if xxxxx audio is playing (hence the idea is that if animation is going to activate xxxxx audio we would know which animation is playing, (do the audio usually stay with the actor?) as in game I can hear the music appear close to specific actor

then assign an animation to both/all actors currently dancing and then stop the animation on the actors once song has stopped playing?
 
EDIT: maybe I can create the audio files but mute them and we can pickup what actor is doing what?
 
EDITx2 Goodnight for tonight..
 
Link to comment

so is npcOnAnim1 & npcOnAnim1NoMusic both the animation name? or are we basically just referencing here?

in this script do I need to assign actor names etc?

No, they are the actor arrays used to track which NPC is playing which animation. 

 

you said that it's not really possible to detect what animation is being played by a npc.. is this the case in the script you wrote now? as this is a tracking script?

Exactly. You cannot use a function on an Actor to get the animation being played. I did not do a "tracking script", I just store the Actor in the array when I send the animation event to play the animation. Very light.

 

 

you wrote

So, you can create an array of actors for each animation you want to play, and then add the actor to the array as soon as you send the animation event to play the animation.

in case I have missed it and please confirm, how do I assign my actors? is this via script to script or in CK?

the actors that will be put in the arrays are the ones that will enter the trigger. You can filter them as usual.

 

 

Also Do I understand correctly? that this whole script is for 1 animation?, and I should reference this script in the event TestModAE3 is choosen? which will check if an dance animation is currently playing.

Yes. this example is for just one animation. If you need more animations the script requires to be way more complex. And probably slit in sub-functions. 

 

 

does this script possibly reset the dancers and make them dance in sync?

That is possible. It will be enough to re-send the animation event to the other actors.

But I think, if you followed FORE's advice to play music directly in the animation, then probably the music will be played twice.

 

 

or is it that music once started cannot be stopped? as in, if the animation is changed?

Depends on how did you start the music. If the music is directly attached to the anim file, then there is not way. (At least I am not aware of a possible way.)

 

 it seems that actor 2 cannot become the new lead dancer,

 

would it be possible that instead of detecting which animation is playing but to detect if xxxxx audio is playing (hence the idea is that if animation is going to activate xxxxx audio we would know which animation is playing, (do the audio usually stay with the actor?) as in game I can hear the music appear close to specific actor

 

then assign an animation to both/all actors currently dancing and then stop the animation on the actors once song has stopped playing?

 

No. No way to detect what audio is playing. You need pretty much the same code to track the sound, but in this case you will lose the possibility to keep track of the dancers.

The audio is completely not associated with the actor. It is just started when the anim is started. I don't think there will be a relationship after.

 

 

Link to comment

Hi cpu..

 

You have more idea of what my mod will evolve into now. I plan to just have random girls all over skyrim and will try to have upto 3 actors in each location i choose, then will add the script for each location. If this mean many scripts and I might have choose a difficult path.

 

Important question - do npcs do acting in skyrim when the cells are not loaded.. Eg if I am in riverwood.. Will riften run my script? Will this hurt skyrim?

 

Do you think my method to integrate the sound to start with the FNIS is my best option or is there a better option?

I add it to the mods behavior text file then use FNIS for modders and Users to add the new animations in.

 

Also sadly I will be wanting to add quite a few random animation dance moves. Maybe upto 10! Combo of anim and dance

 

So you said more complex.

Is that because how the you store them in the array. Will the script work standalone and can be used over and over for different locations in skyrim? Or will it be limited to the actors at 1 location.

The animation list will remain the same for all over skyrim but will want about 6 dance routines and maybe 4-6 standard sound effect animations which are harmless and wont effect the advanced stored array script.

 

What would be required for the script to handle 2 animations as adding the rest i would hope I can tackle that to learn the script.

Link to comment

Hi.

The script can be attached to the Activator that then you drag in the different cells.

So it can be just one script.

Each ObjectReference pointing to the Acttivator will run a "copy" of the script, so no need to worry about it.

 

The script will run only if an event is received. So if the cell is not loaded, nobody can trigger the trigger and run the script.

So it will be really light.

 

About the sound. FORE's method is perfect to have the max possible synchro, but cannot be controlled through scripts.

Another possibility is to add a "music" to the cell. This can be controlled, but it is not really synchronous.

 

About extending the script to allow multiple animation, this will require a little bit of time to be written.

The one I wrote before it is an example.

 

Give me time and I will do it.

 

Link to comment
  • 1 month later...

Hi cpu,

thanks for getting back to me, still no urgency on this request. just when you get a chance.

 

I want the script to able to run and do the following

 

 

some Facts to know about the scene in which the script will run,

1) there are going to be 4 NPCs using a Custom Race added (this is to ensure only my added NPC's will work in the script)

 

2a)6x short animations (1-6)

2b)4x Dance Longer Animations (7-10)

2c)4x Dance Longer Animations without Music (11-14)

 

3) if a dance animation is already being used, the remaining dance animations are not to be used until the first dance has finshed

4) if a 2nd NPC activates a  2C  animation can the animation be STOPPED once the first dancer with a 2B animation has finshed 

 

5) I want the (2c) animations to be played if only a (2b) animation with music is playing (never the other way around)

 

--------

 

so the script will run once my NPC's with CustomRace walk onto the trigger point, the script will then do the following,

 
if my custom NPC 1-4, lets say NPC3 walks onto trigger it will activate animation 2a or 2b (1-6 + 7-10) animations.
it will need to run a random generator selecting a animation 1-10 (first 1-6 short / last 7-10 are long dance)
 
lets say Animation no8 is picked,
 
if my npc 2 walks onto the trigger it will need to randomly select a animation and use these rules, eg:
 
if animation 2b is playing on other npc, selection can only be of 2a or 2c animation types (1-6 + 11-14)
if NPC3 finally ends the animation it needs to stop NPC2 animation and return to idle if it is running a 2c (11-14) animation only.. this should not apply to animation 2a (1-6) type.
 
the 2a (1-6) animations can play fine anytime. as no audio will be present, or if audio is present it wont be annoying hearing it duplicated within seconds apart!!!
 
------

 

you said you made the script use arrays so it can kind of remember which animation are being used.

i like the idea that we can try to stop and 2nd dancer animation if first dancer stops, and to stop them together, even if not animation synced, it like the 2nd dancer gets interested to dance but once music stops 2nd stops as well

 

so in laymans

short animations play randomly anytime

long dance can play 1 at a time maximum

long dance without music can only play if long dance animation are running, multiple NPCs can dance as long as a npc is running with a 2b animation.

 

if anything is unclear please ask.

 

 

 

Link to comment

I will give you help as soon my new mod will be completed.

No idea about the time, but should not take more than another couple of week-ends.

 

If you don't mind, remind me from time to time.

 

Link to comment

Archived

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

  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use