Jump to content

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


toxsickcity

Recommended Posts

Hi,

 

I need some help with how to proceed with my fun mod, (mod creates npc's that do things in normal conditions such as playing flute/waving/playing drums... I have even changed a few animations on a 2nd mod as an optional very naughty mod)

 

tho I am feeling some script work here might help alot..

 

 

using the PCEA (alternative path animations) Mod, I created a quick race and replaced some random idles such as Drum/flute play replaced the animation files to dance animations, some sexy some not.

I have also started to add some naughty scenes to this mod as an option!

 

the mod is just simple, no scripting, just editing hkt/hkp/hkx animation/behavior files.

quite tiresome to edit these files? and finding it really difficult to link audio to the animations. I am looking for a more efficient way and if someone can code using skse or add MCM menu options and provide me some learning along the way I would really appreciate the help and might allow me to improve some other mods I have made once I learn. for the moment I am lost on it. but I am good at learning from codes.

 

 

can I have some ideas on where to go next?

whats the best way to continue this mod? I mean how do I add audio/sounds to animations as they play? and is learning skse/script based modding going to provide me a great deal of efficiency in terms of changing animation styles etc.

 

the animation replacement system works well as it's fairly random, and works with my 1 race I choose for this..

 

EDIT:

I have read that adding sounds to animations needs to be done in the behaviour files and If I am releasing this mod to public, this might be bad due to FNIS making changes and etc etc..

so I await your ideas :)

 

Link to comment

Hello.

Adding directly audio to HKX files is difficult.

It is way more easy, if you start the animation in some way, to add just a few lines of code to:

* Play a Wav file (sound descriptor), like the moans of SexLab

* play a Xwm file (music usually), it is not 100% synchronized but usually goes pretty well.

 

If you need scripting help I can assist.

Link to comment

Is it possible that a script can do the following?

I would want it to detect when the animation starts
I usually start animations via floor idle markers

I might make a spell to start animations. I have not experiment yet

Then the script will need to add audio
But only to NPC's of 1 race! Lets call the race DanceRace
It can apply to any NPC whos race is DanceRace.

I seen many mods that work from distance of player.
So a random activator if I choose spells

Link to comment

You can attach the code to the idle markers (but usually it is better to use triggers), and in the code you can catch the actor, then the actorbase, then the race, and then filter if you want to star the music or not.

 

Link to comment

A trigger is an "Area" put inside a cell that will trigger some events when NPC and player go in and out.

To create a trigger, first create an Activator in the CK. Then click on the IconTrigger.png small box of the top bar of CK to create a trigger volume in the current cell. Select the activator you just created.

Size the trigger box in the way you like. (Be sure markers are visible in the cell, or you will not see the trigger box. Press the key M to activate/deactivate markers visibility.)

Then create a Sound Descriptor, add to it a wav file you want to play. (The file should be in data\Sound\fx\<yourmod>\)

Then create a Sound Marker, and point it to the sound descriptor you just created.

 

In the activator attach a script. Put inside something like this:

 

 

Actor Property PlayerRef Auto
Sound Property mySound Auto
 
Event OnTriggerEnter(ObjectReference akActionRef)
  if (akActionRef as Actor) == PlayerRef
    Debug.Notification("The Player is inside the trigger")
    mySound.play(akActionRef)
  endIf
EndEvent

 

Attach the properties. Sound will be your Sound Descriptor.

 

Run the game, and go with the player inside the trigger you just created. You should receive a notification and the sound should play.

 

To play a music you can define a Music Track, the format has to be XVM.

Then define a Music Type, and add the track to it.

Define a property in your script: MusicType Property myMusic Auto

 

And then to play the track just do: myMusic.add()

 

Please be aware that the music does not start immediately, while the sound starts right away.

 

 

Link to comment

Thankyou CPU,

 

 

I did as you asked and I did get a sound to play when I walk into the area, I like how the script allows selection of a character.

 

got a few questions for you

 

just out of curiosity, using that same script.. what if I was to want any NPC so long as a certain custom race?

when the npc walks past the area, can it also start an animation on that race via script?

as it is another way to do it!! :)

 

 

I would like to try and link my sounds to an idlemarker. Can you advise me on how to make the sound play when the sweep idle animation is played?

 

I used your same script and I have tried 3 things and cannot get it to play. maybe I am just a little off!

 

I tried forcing all NPC's in RiverwoodINN to use 1 package sandbox and added the script in that, Not sure how that would work for me tho!

 

I have added the script to the sweepidlemarker from the 3D cell view's selections.. ( added to each idlemarker)

 

I have tried adding it to the sandbox package again but in the Papyrus Fragment, as I seen I can put a script into the IDLE; ON begin, on end and on change

perhaps it like the code to be a little different as it didn't work I couldn't even compile that!

 

 

 

 

 

Link to comment

Let's go in order.
 

just out of curiosity, using that same script.. what if I was to want any NPC so long as a certain custom race?
when the npc walks past the area, can it also start an animation on that race via script?
as it is another way to do it!! :)

The event OnTriggerEnter gives you the ObjectReference that entered in the trigger area. You can convert it to an Actor (that is a particular ObjectReference) and then do something like:

if (akActionRef as Actor).getleveledActorBase().getRace()==theRaceIwant
...blah blah blah...

 

I would like to try and link my sounds to an idlemarker. Can you advise me on how to make the sound play when the sweep idle animation is played?

Just add the idle marker to a cell. Then Edit the reference to the idle marker in the cell. Go to the last tab and add a script. The script will extend an ObejctReference, so you can use the events of the ObjectReference (but in this case OnTriggerEnter will not work.)
There no event on playing Idles as far as I know.

 

I tried forcing all NPC's in RiverwoodINN to use 1 package sandbox and added the script in that, Not sure how that would work for me tho!

The package is not the right place to put the script I did before. The previous script was supposed to be used in a trigger. Package fragments have no events.
 

I have added the script to the sweepidlemarker from the 3D cell view's selections.. ( added to each idlemarker)

The Idle Markers do not trigger the OnTriggerEnter, because they are not "triggers".
 

I have tried adding it to the sandbox package again but in the Papyrus Fragment, as I seen I can put a script into the IDLE; ON begin, on end and on change
perhaps it like the code to be a little different as it didn't work I couldn't even compile that!

Ditto. packages do not send the OnTriggerEnter event.


You can try a couple of events (but I am not really sure about what you try to accomplish):
1) Create a trigger area, and then the code will be start when a NPC enters the triggering area.
2) Create a furniture (also invisible, like a marker), that NPC can use and then wait for the OnActivate event (but this is complex)

Link to comment

Hey, adding sound to animations is quite easy actually with FNIS. First find the name of the soundmarker you want to play. Then open FNIS list. You need to write something like that:

 

b -TSoundPlay.YourSoundMarker/2.00 YourAnimation YourAnimation.HKX

 

There, "YourAnimation" should play "YourSoundMarker" in 2 sec. That's if you're adding your custom animations of course. 

 

If you're not using FNIS to add animations, just modifying/overwriting existing ones, you can add an annotation to the animation like SoundPlay.SoundMarker to hardcode a sound into the animation. 

Link to comment

Thankyou both CPU and BAHOW

 

I am trying to make npcs dance, touch themselves sometimes animate sexy

I will eventually want to make the animation and sound match

I am using exsisting idle markers with a PCEA twist

I will make 1 race use PCEA and that race instead of sweeping the floor or play drums or flute will start to dance/do something sexy/something naughty

 

Your trigger gave me an idea to simplify the entire mod. As it would simplify the mod, make it so I dont have to find a ways to find solutions to why the flute stays in the npc hand when they masturbate! (i know why.. But means more work)

The script (on trigger) needs

 

Have my special race walk past then start start these components..

-i would want the script to seperate the race, allow any npc in that race to play a sound+animate I would want delays on both when sound starts and animation start. (tuning the sync of sound to animation)

-If use trigger i would want for animation to start after5 seconds

(to help and hope the npcs dont all go on the floor in the same spot. The 5 seconds gives them time to move on.)

-Possibly randomly choose 1 of say, 12 animation and sound pairs (for variety)

 

Will 1 single script do all that?

Can someone write the script I would need for me to start work on it. You will be credited too

....

 

 

 

You have provided a plethora of information and I will start experimenting.

 

Bahow, you mentioned fnis list?

Is this a list I can create and have it be added to fnis folder for FNIS to scan or is this a master list?

I ask in relation to the installation of my mod for other users?

 

I am interested in the edit the animation file.. Might be actually easiest for me since I know how the hkxcmd tool works!

 

So with an animation file, when opened in xml format I see alot of what look like headder info then bones then raw numbers

 

I want to add a new line as the way the headders are usually written?

Eg: this format, <hkparam name="duration">12.000000</hkparam>

 

This scripting is a real headache to wrap my head around. Sorry CPU but it just is.. Ive had no programming experience and took me hours to multiply a tes5edit script to allow me to change paths and allow me to enter 8 new/old data entrys rather than just the 1

I got lost where thr ends had to go and omg

I will continue to play around tho.

 

The trigger was cool! But might want to see if I can make that trigger also run an animation at the same time as play a sound

Link to comment

To trigger an animation just use a line like:

 

Debug.SendAnimationEvent(actorDancer, "animationid")

 

actorDancer is the actor that will play the animation.

animationid is the ID of the animations.

 

Now, about FNIS.

You can add to Skyrim extra custom havok animations (hkx files), to add them you ahve to place them in a specific folder, and generate a FNIS file that will simply set the id of the anim associated with the anim file.

When you generate FNIS for modders FNIS reads this file, grabs the anims and creates the behavior file.

Then, using the behavior file, you can add the animevent in Ck, and then play them with SendAnimationEvent.

 

The full SexLab is based on this.

 

Link to comment

Can I please have an example of what the modder file for fnis format should be?

 

I tried downloading fnis for modders guide but owner has hidden it

 

Try again. I cannot hide single files, and I haven't hidden anything.

 

If you want examples you should look into existing animation mods. FNIS Spells has a selection of different types of animations, and SexLab has a LOT of them.

 

If you are looking for sound then there are 2 ways:

  1. As part of the animation. As far as I know that only works if you animate with 3DS. But it only works if you add a note track at a very particular place. Don't remember exactly where, but I can search in my older threads. But as far as I remember it doesn't work for all types of animations, in patricular not for creatures.

     

  2. As part of the behaviors. Add a soundplay trigger parameter to the FNIS definition. Page 6 of the FNIS modders' doc.

 

But I have one general advice. You HAVE to learn how to script if you want to do this. It can't work when you ask people to write scripts for you. You will always be at your wits end.

Link to comment

I got the sound to play via FNIS

I couldnt get my script to work because I kept copy the new edited script to another folder :P

 

here is my script

 

Scriptname zsound extends ObjectReference
Race Property RacePicker Auto
Actor Property actorDancer Auto
 
Event OnTriggerEnter(ObjectReference akActionRef)
if (akActionRef as Actor).getleveledActorBase().getRace()== RacePicker
Debug.SendAnimationEvent(actorDancer, "TestModAE1")
Debug.Notification("The Player is inside the trigger")
EndIf
EndEvent

 

The Script works, but I want to know why the animation plays on 1 single NPC? Is it because in Creation kit I have selected the NPC in the script's options..

 

 

I have a feeling I need to either use

 

(akActionRef as Actor).Debug.SendAnimationEvent

 

or add and use

 

if (akActionRef as Actor) == PlayerRef

Debug.SendAnimationEvent(PlayerRef, "TestModAE1")

 

Lastly, I read about needing to make the same NPC play a standard idle after my animation or they get stuck? is this going to be a problem?

Link to comment

Hello.

 

In your code you are sending the animation event to a specific NPC (that is your property.)

 

You can simply do this:

 

Scriptname zsound extends ObjectReference
Race Property RacePicker Auto
 
Event OnTriggerEnter(ObjectReference akActionRef)
  if (akActionRef as Actor).getleveledActorBase().getRace()== RacePicker
    Debug.SendAnimationEvent(akActionRef as Actor, "TestModAE1")
    Debug.Notification((akActionRef as Actor).getleveledActorBase().getName() + " is inside the trigger")
  EndIf
EndEvent
 
An extra idle at the end may be required if:
* You animation is a looping one (so it never ends)
OR
* You animation has an AnimObject attached and the AnimObject is not removed by the HKX file itself (Animation graph is not clean.)
 
in all other cases, you don't need it.
 
Link to comment

Thankyou so much CPU, your help is appreciated..

 

I am confused by one thing

  if (akActionRef as Actor).getleveledActorBase().getRace()== RacePicker

the () / () / () why empty?

if I wanted to select a race within the script is possible? eg Remove the "race property" and change racepicker to nord?

  if (akActionRef as Actor).getleveledActorBase().getRace()== Nord

 

 

Thats awesome, I am excited that this has been accomplished, I cannot wait to see what scripting will open for me.

I have seen sexlab has a texture clean which might be useful for my SCOCLB mod.

I will try to learn more on my own as I have been looking into delays / else if / shuffle scripts

 

Thanks again

Link to comment

Thankyou so much CPU, your help is appreciated..

 

I am confused by one thing

  if (akActionRef as Actor).getleveledActorBase().getRace()== RacePicker

the () / () / () why empty?

if I wanted to select a race within the script is possible? eg Remove the "race property" and change racepicker to nord?

  if (akActionRef as Actor).getleveledActorBase().getRace()== Nord

 

 

Thats awesome, I am excited that this has been accomplished, I cannot wait to see what scripting will open for me.

I have seen sexlab has a texture clean which might be useful for my SCOCLB mod.

I will try to learn more on my own as I have been looking into delays / else if / shuffle scripts

 

Thanks again

 

OK, some explanations on parentheses.

 

Parentheses in Papyrus are used for:

* prioritize the calculation (what is inside a parenthesis is calculated before the other items.

* call a function (inside the parenthesis you can put parameters if required.) All function calls require the parentheses after the function name.

 

 

Now, in the line of code:

(akActiorRef as Actor) here the parentheses are used to prioritize the operation "AS" (that is called CASTING), this because the vaiable (akActionRef) is an ObjectReference, but you need it as Actor. "akActiorRef as Actor" will transform the akActorRef to an Actor.

Then after this, on the new "Actor" you call the function .getLeveledActorBase() that is a function and has no parameters. So the parentheses are empty. This function will get the ActorBase from the Actor (Leveled so it will manage also generic actors like the guards.)

Then on the result (that is an ActorBase) you invoke the function .getName(), it is a function, no parameters, so it has at the end the empty parentheses. It will just return the name of the Actor from the ActorBase.

About the "Race". You have many options.

 

On the vanilla Papyrus you can compare the Race got from the ActorBase to an actual Race object.

.getRace() from an Actorbase will give you the Race.

Do you want NordRace? Just fill the property with NordRace.

 

You can do something more advanced using the SexLab/SKSE functions to get the race string ID.

in this case you can compare the race also with races proposed by Mods that are not actually loaded, without putting a dependency. But this will require a longer explanation.

 

Link to comment

Hi Again,

 

I am having a trial at adding some randomness to the script.

 

-----------------------

Scriptname zsound extends ObjectReference
Race Property RacePicker Auto
Debug.SendAnimationEvent Property TestModAE1 Auto
Debug.SendAnimationEvent Property TestModAE2 Auto
Debug.SendAnimationEvent Property TestModAE3 Auto
Debug.SendAnimationEvent Property AnimationAE Auto
Event OnTriggerEnter(ObjectReference akActionRef)
int random = Utility.RandomInt(0, 2)
  If random == 0
AnimationAE = TestModAE1
 
  ElseIf random == 1
AnimationAE = TestModAE2
 
  Elseif random == 2 or (Else)
AnimationAE = TestModAE3
  EndIf
 
  if (akActionRef as Actor).getleveledActorBase().getRace()== RacePicker
    Debug.SendAnimationEvent(akActionRef as Actor, "AnimationAE")
    Debug.Notification((akActionRef as Actor).getleveledActorBase().getName() + " is inside the trigger")
  EndIf
EndEvent
-----------------------------------
 
I am thinking I have lost my direction here, I am sure the random generator will use AnimationAE as the placed animation for 2half of the script but I am unsure if I need to add something that calls a reference to the animation file which is picked.
 
I have read a few pages and the help files state I should be adding properties for the animations and the compiler was requesting that I do it.
but I think making properties marks/selects an item and would render the random utility false?
 
I kind of get how the scripting works but I'm hazy understanding at this point what need to have properties and what the random utility does.
 
If I had the IF / elseIf / ElseIf, Do I need 3x endif?
 
I also feel I am missing a whole section for this script that links the random utility and the workload afterwards, I know random needs to be first. and also unsure if this needs to be seperated
 
I looked over the script attached by our friend in the last post, and seems that he has the idle's as properties but I dont see any random utility
 
Thankyou
 
 
Link to comment

Some errors in the script. Here an example about how you can make the animations random.

Just keep in mind that the "animations" that you use with SendAnimationEvents are Strings.

Scriptname zsound extends ObjectReference
Race Property RacePicker Auto
 
Event OnTriggerEnter(ObjectReference akActionRef)
  String[] anims = new String(4)
  anims[0] = "MyAnim1"
  anims[1] = "MyAnim2"
  anims[2] = "MyAnim3"
  anims[3] = "MyAnim4"
 
  if (akActionRef as Actor).getleveledActorBase().getRace()== RacePicker
    Debug.SendAnimationEvent(akActionRef as Actor, anims[Utility.RandomInt(0, anims.length - 1])
    Debug.Notification((akActionRef as Actor).getleveledActorBase().getName() + " is inside the trigger")
  EndIf
EndEvent
Link to comment

Hi, I get compile errors

 

C:\Program Files (x86)\Notepad++>"c:\Steam\SteamApps\Common\Skyrim\Papyrus Compiler\PapyrusCompiler.exe" "zsound.psc" -f="TESV_Papyrus_Flags.flg" -i="c:\games\Scripts\Source" -o="c:\Games\Scripts"
Starting 1 compile threads for 1 files...
Compiling "zsound"...
c:\games\Scripts\Source\zsound.psc(5,29): mismatched input '(' expecting LBRACKET
c:\games\Scripts\Source\zsound.psc(5,31): required (...)+ loop did not match anything at input ')'
c:\games\Scripts\Source\zsound.psc(12,94): extraneous input ']' expecting RPAREN
No output generated for zsound.psc, compilation failed.
 
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on zsound.psc
 
 
should it be??
 
Scriptname zsound extends ObjectReference
Race Property RacePicker Auto
 
Event OnTriggerEnter(ObjectReference akActionRef)
  String[] anims = new String[4]
  anims[0] = "TestModAE1"
  anims[1] = "TestModAE2"
  anims[2] = "TestModAE3"
  anims[3] = "TestModAE4"
 
  if (akActionRef as Actor).getleveledActorBase().getRace()== RacePicker
    Debug.SendAnimationEvent(akActionRef as Actor, anims[utility.RandomInt(0, anims.length - 1)])
    Debug.Notification((akActionRef as Actor).getleveledActorBase().getName() + " is inside the trigger")
  EndIf
EndEvent

 

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