My own actors making sounds

Topics regarding Scripting with Reality Factory
incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

My own actors making sounds

Post by incenseman2003 » Fri Dec 08, 2006 2:15 am

I have created a actor file for my game. It does just what is made to do. I use the genericmelee.s to run it. I have tried many different ways to add sound for this new actor to play until the actor is killed. I have looked through the perfectai.s and tried to use that as an example. I got toally lost after about the 100th failure. Is there anyone that might be able to give some detail on the matter?
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.

User avatar
jonas
Posts: 779
Joined: Tue Jul 05, 2005 5:43 pm
Location: Texas, USA
Contact:

Post by jonas » Fri Dec 08, 2006 2:39 am

you mean like run continueously like a chainsaw?


you would need to use the SoundLoop(true);
Jonas

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren't sure which way to do something, do it both ways and see which works better. - John Carmack

incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

Post by incenseman2003 » Fri Dec 08, 2006 3:26 pm

jonas wrote:you mean like run continueously like a chainsaw?


you would need to use the SoundLoop(true);
there is no setting for that in the pawn entity and I cannot find the command in the manual.

does it go into a script or an ini file?
How do I specify the wav file to use?
How do I tell it what actor uses it?

Your is the only info I have. I am no expert. Can you give some detail?

Thanks.
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.

User avatar
jonas
Posts: 779
Joined: Tue Jul 05, 2005 5:43 pm
Location: Texas, USA
Contact:

Post by jonas » Fri Dec 08, 2006 11:17 pm

incenseman2003 wrote:
does it go into a script or an ini file?
How do I specify the wav file to use?
How do I tell it what actor uses it?

Your is the only info I have. I am no expert. Can you give some detail?

Thanks.
Sure thing.
You said your using the genericmelee.s script to control it right?

You need to insert this code into your script

Code: Select all

SoundLoop(true);
PlaySound(loopingsound.wav);
Stick it in Idle() like so.

Code: Select all

Idle[ ()
	{
         SoundLoop(true);
         PlaySound(loopingsound.wav);

		PlayAnimation(STAND, true, ""); // stand at idle
		if(random(1,10)>6) // turn side to side sometimes
		{
			if(random(1,10)>5) // turn to left 90 degrees and turn back
			{
				Rotate(TURNL, 102, 0, 90, 0, "");
				PlayAnimation(STAND, true, "");
				Rotate(TURNR, 108, 0, -90, 0, "");
			}
			else // turn to right 90 degrees and turn back
			{
				Rotate(TURNR, 108, 0, -90, 0, "");
				PlayAnimation(STAND, true, "");
				Rotate(TURNL, 102, 0, 90, 0, "");
			}
		}
		RestartOrder();
	} ]	
then in death() you would need to stop your loop.

Code: Select all

Death[ ()
	{

SoundLoop(false);
PlaySound(loopingsound.wav);	
	
DelTimerOrder(1);	// remove alert timer
		AddPainOrder("IdlePain", 0);	// remove pain order
		FindTargetOrder(0, "FoundTarget", DAMAGEATTRIBUTE);	// remove target finding
		DelTriggerOrder("IdleToAlert");	// remove alert trigger
		SetNoCollision();	// remove bounding box so there are no collisions with corpse
		switch(random(1,4)) // chose between 4 death animations
		{
			case 1
			{
				AnimateStop(DIE, DIEHOLD, "");
			}
			case 2
			{
				AnimateStop(DIE1, DIEHOLD, "");
			}
			case 3
			{
				AnimateStop(DIE2, DIEHOLD, "");
			}
			case 4
			{
				AnimateStop(DIE, DIEHOLD, "");
			}
		}
		FadeOut(DIEFADE, 0); // fade out corpse
		Remove(true);	// remove actor
	} ]
Note: I didn't have time to test this.
Last edited by jonas on Wed Jan 03, 2007 5:12 pm, edited 1 time in total.
Jonas

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren't sure which way to do something, do it both ways and see which works better. - John Carmack

incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

Post by incenseman2003 » Sun Dec 10, 2006 2:32 pm

I added the following to the script fil in exactly the places that you indicated.

SoundLoop(true);
PlaySound(loopingsound.wav);

I did change the "loopingsound.wav" to the name of the wav file that is the sound that I want to use.

However the actor doesnt make any sound ingame.

I was extremely carefull to follow your directions to the letter.

Is there any demo that does this already? If there is I might get some tips from that.

Thanks for the effort.
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.

User avatar
jonas
Posts: 779
Joined: Tue Jul 05, 2005 5:43 pm
Location: Texas, USA
Contact:

Post by jonas » Sun Dec 10, 2006 10:08 pm

ok let me back up a little bit. You said your using this script to control your weapon. How did you go about setting that weapon up to use that script?
Jonas

Focused, hard work is the real key to success. Keep your eyes on the goal, and just keep taking the next step towards completing it. If you aren't sure which way to do something, do it both ways and see which works better. - John Carmack

incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

Post by incenseman2003 » Mon Dec 11, 2006 1:51 am

jonas wrote:ok let me back up a little bit. You said your using this script to control your weapon. How did you go about setting that weapon up to use that script?
"I have created a actor file for my game. It does just what is made to do. I use the genericmelee.s to run it. I have tried many different ways to add sound for this new actor to play until the actor is killed. I have looked through the perfectai.s and tried to use that as an example. I got toally lost after about the 100th failure. Is there anyone that might be able to give some detail on the matter?"

Not a weapon.
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.

shadow
Posts: 81
Joined: Mon Jul 25, 2005 5:37 am

Post by shadow » Mon Dec 11, 2006 12:54 pm

You probably already know this, and I'm stating the obvious but the wav file (loopingsound.wav) has to exist in the Audio directory of RF.
If that file name isn't there it won't run.

incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

Post by incenseman2003 » Mon Dec 11, 2006 7:36 pm

I made sure that was taken care of. It was the very first thing I did. Ty shadow.
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.

User avatar
Spyrewolf
Posts: 450
Joined: Tue Jul 05, 2005 4:53 am
Location: Wellington::New Zealand

Post by Spyrewolf » Mon Dec 11, 2006 8:43 pm

um not sure...

is loopingsound.wav the file name?

if so try shorten the name, i think the length of the file name could be buggering it up,

to something like lpngsnd.wav

i think that long file name greater than 12 characters screws up, i vaguely remember this in the past.

see if that helps.

incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

Post by incenseman2003 » Mon Dec 11, 2006 10:01 pm

Spyrewolf wrote:um not sure...

is loopingsound.wav the file name?

if so try shorten the name, i think the length of the file name could be buggering it up,

to something like lpngsnd.wav

i think that long file name greater than 12 characters screws up, i vaguely remember this in the past.

see if that helps.

As I stated in my original post, I did rename the file. It is definately shorter than 12 characters. then name "loopingsound.wav" was an example name from jonas to me. I took his script snippet and pasted in the script and then changed the name right away to the name of that file that I want to use. I will remember your input so that I dont have issues with that. Thank you.

Just a reminder that it is easy to misunderstand a post unless you read the original post carefully and the posts from others as well.

You people are the experts Im still really new it this.

Keep the ideas coming.
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.

User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post by QuestOfDreams » Sat Dec 16, 2006 12:52 am

SoundLoop is a high level command whereas PlaySound is a low level command :!: You can't mix them :!:
For high level you would use AddRandomSound/DelRandomSound instead of PlaySound.
But that's not even necessary since all those PlayAnimation, Move, Rotate etc commands can take a sound as an optional parameter. So call SoundLoop(true) in your setup order then in the first command that can take a soundfile as parameter specify your sound (in genericmelee.s this would be PlayAnimation(STAND, true, "loopingsound.wav"); in the Idle order).
Note that since the filename is a character string it has to be quoted when used in an argument list -> "loopingsound.wav" (or you define a variable and use the variable name instead eg
MYSOUND [loopingsound.wav]
-> PlayAnimation(STAND, true, MYSOUND); )

Another possibility would be to attach an AudioSource3D entity to your actor and trigger it as needed...

incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

Post by incenseman2003 » Sat Dec 16, 2006 5:54 pm

Here is what I did in the setup.


// spawn pawn and do setup work

Spawn[ ()
{
SoundLoop(true); // Set sound that monster makes
Console(false);
BoxWidth(BOXWIDTH); // set bounding box width/depth
AttributeOrder(HEALTHATTRIBUTE, HEALTH, "Death"); // give monster health
HostilePlayer(HOSTILEPLAYER); // set who monster is hostile to
HostileSame(HOSTILESAME);
HostileDifferent(HOSTILEDIFFERENT);
SetFOV(FOV); // set field of view
SetGroup(GROUP); // assign a group to belong to
FindTargetOrder(SIGHTDIST, "FoundTarget", DAMAGEATTRIBUTE); // seen a target to chase
AddPainOrder("IdlePain", 100); // show pain and trigger alert
AddTriggerOrder("IdleToAlert", ALERTTRIGGER, 0); // go to alert when triggered
NewOrder("Idle");





"bug1.wav" is the name of the sound file I want to use. Here is what I did in the idle.


Idle[ ()
{
PlayAnimation(STAND, true, "bug1.wav"); // stand at idle
if(random(1,10)>6) // turn side to side sometimes
{
if(random(1,10)>5) // turn to left 90 degrees and turn back
{
Rotate(TURNL, 102, 0, 90, 0, "");
PlayAnimation(STAND, true, "");
Rotate(TURNR, 108, 0, -90, 0, "");
}
else // turn to right 90 degrees and turn back
{
Rotate(TURNR, 108, 0, -90, 0, "");
PlayAnimation(STAND, true, "");
Rotate(TURNL, 102, 0, 90, 0, "");
}
}
RestartOrder();


This did not produce the desired results. Did I mess it up somehow?


The availible settings for the AudioSource3D are as follows.

bLoopSound
BoneName
EtityName
fRadius
Model
origin
szEntityName
szSoundFile
TriggerName

There is no place to attach the entity to my actor monster. If I make the actor a model the the game crashes, saying in the log the following.

*ERROR* File C:\RealityFactory\source\CGenesisEngine.cpp - Line 1217: Loaded level 'rfeditpro1.bsp' failed to create World
*ERROR* File C:\RealityFactory\source\CCommonData.cpp - Line 1059: Level [rfeditpro1.bsp] failed to load!
*ERROR* Failed to initialize first level

I have the actor set not to be a model the game runs fine but there is no sound to my monster.
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post by Juutis » Sat Dec 16, 2006 6:36 pm

Attaching an entity to another:
(the AudioSource3D entity to your pawn, in this case)

Name your pawn, something like 'monster1' will do. The name of a pawn is defined in the field 'szEntityName'
Then set up the AudioSource3D like this:

BoneName = the bone of the pawn, to which you want the sound to attach
EntityName = monster1
Model = <null>
Pain is only psychological.

incenseman2003
Posts: 320
Joined: Sat Mar 11, 2006 11:41 pm

Post by incenseman2003 » Sun Dec 17, 2006 3:38 pm

Juutis

The detail that you gave made the monster have the sound that I wanted it to have. However the sound kept going even after the monster was dead. Only after the monster had faded out completely did the sound stop. Is there a way to get the sound to stop when the monster is killed but has not faded out yet?

I’m sure you realize how important the little things can be in a game. They can make or break it.

I really appreciate all the input that I have been getting lately. You people have been nothing short of super. I will be adding all of the names that contributed something that worked to get my game off the ground to the game credits. If you have contributed and would like your name and email address added to the game credits just send me your info. If the game sells then you will get exposure, if not then nothing lost.

Thanks a bunch,
Patience and tolerance are the keys to the passage of knowledge. Even those that are the most knowledgeable started with many questions.

Post Reply