Frictional Games Forum (read-only)

Full Version: Help with sounds!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
MulleDK19 seems to know his way around the editor/scripting Tongue

He's probably helped the most besides the developers.
(09-17-2010, 02:11 AM)Armored Cow Wrote: [ -> ]MulleDK19 seems to know his way around the editor/scripting Tongue

He's probably helped the most besides the developers.

Yeah! Hahaha. I have another question, anyone feel free to answer. In this scenario, I want the door to creak open by itself once you step into the script area. I can make the sound (but need the .snt for the best wooden creak noise), but I don't know how to put in the actual action of opening. Any help is welcome!

P.S. I see the - void SetMoveObjectState(string& asName, float afState); - function, and it seems to be what I need, but I'm not sure how to implement that into the script.

Coding so far:

Code:
void OnStart()

{
    PlaySoundAtEntity("bang", "10_close_door", "Player", 0, false);
    
    AddEntityCollideCallback("Player", "area_squeal", "Collidearea_squeal", true, 1);
    
    AddEntityCollideCallback("Player", "area_scratch", "Collidearea_scratch", true, 1);
    
    AddEntityCollideCallback("Player", "opendoor", "Collideopendoor", true, 1);
    
    SetEntityPlayerInteractCallback("lantern_1", "LanternTaken", true);
    
    AddUseItemCallback("useexit", "PrisonKey", "PrisonDoor", "UseKey", true);
}    

void UseKey(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked(asEntity, false, true);

    RemoveItem(asItem);
}

void Collidearea_squeal(string &in asParent, string &in asChild, int alState)
{
    PlaySoundAtEntity("animal_squeal", "custom_animal_squeal01.snt", "Player", 0, false);
}

void Collidearea_scratch(string &in asParent, string &in asChild, int alState)
{
    AddTimer("hit_wood.snt", 0.5f, "TimerSoundSequence");
    AddTimer("hit_wood.snt", 1.0f, "TimerSoundSequence");
    AddTimer("hit_wood.snt", 1.4f, "TimerSoundSequence");
}
void LanternTaken(string &in asEntity)
{
    PlaySoundAtEntity("scratch", "05_wall_scratch", "Player", 0, false);
}

void TimerSoundSequence(string &in asTimer)
{
    PlaySoundAtEntity("hitwood", asTimer, "castle_arched01_1", 0, false);
}

void Collideopendoor(string &in asParent, string &in asChild, int alState)
{
    PlaySoundAtEntity("open", "door_level_wood_open.snt", "castle_arched01_1", 1, true);
}
Thanks!
(09-17-2010, 03:21 AM)Cgturner Wrote: [ -> ]
(09-17-2010, 02:11 AM)Armored Cow Wrote: [ -> ]MulleDK19 seems to know his way around the editor/scripting Tongue

He's probably helped the most besides the developers.

Yeah! Hahaha. I have another question, anyone feel free to answer. In this scenario, I want the door to creak open by itself once you step into the script area. I can make the sound (but need the .snt for the best wooden creak noise), but I don't know how to put in the actual action of opening. Any help is welcome!

P.S. I see the - void SetMoveObjectState(string& asName, float afState); - function, and it seems to be what I need, but I'm not sure how to implement that into the script.

Code:
SetSwingDoorDisableAutoClose("door", true);
AddPropImpulse("door", 0.0f, 0.0f, -1.0f, "prop");

Not sure whether the local coordinate system is actually called "prop" or if it's called "local".
Here's what I've got:
Code:
void Collideopendoor(string &in asParent, string &in asChild, int alState)
{
    PlaySoundAtEntity("open", "door_level_wood_open.snt", "castle_arched01_1", 1, true);
    SetSwingDoorDisableAutoClose("castle_arched01_1", true);
    AddPropImpulse("castle_arched01_1", 0.0f, 0.0f, -1.0f, "prop");
}

The sound plays correctly, but the door remains closed.

EDIT:
Well I've manipulated that code as much as possible, and the door still remains shut. What is supposed to be done? Is it something with the "prop" variable?
Okay, I am now working on the description when the door is interacted with (locked, and once unlocked).

Code:
AddEntityCollideCallback("Player","PrisonDoor","CollidePlayerWithPrisonDoor");

    AddEntityCollideCallback("Player","castle_arched01_1","CollidePlayerWithcastle_arched01_1");

void CollidePlayerWithPrisonDoor()
{
    if(HasItem("PrisonKey") == true)
    {
        SetMessage("Use your inventory to select the key and use it on the door.", 10);
    }
    else
    {
        SetMessage("You will need a key to open the cell door.", 5);
    }

}

void CollidePlayerWithcastle_arched01_1()
{
    if(HasItem("key_1") == true)
    {
        SetMessage("Use your inventory to select the key and use it on the door.", 10);
    }
    else
    {
        SetMessage("You will need a key to open this door.", 5);
    }

}
The game crashes upon starting when I use the code above. I got this off of the script functions wiki, but I may have used it the wrong way.

EDIT:
I would also like to know how to properly name in-game items, such as keys, so that it shows up both on-screen when the player is close enough, and in the inventory.
It looks good to me and I would test it but I can't at the moment due to other scripting problems Tongue


EDIT: Actually instead of an AddEntityCollideCallback for the Prison Door maybe you need SetEntityPlayerInteractCallback? Not sure.
(09-17-2010, 03:51 AM)Cgturner Wrote: [ -> ]Here's what I've got:
Code:
void Collideopendoor(string &in asParent, string &in asChild, int alState)
{
    PlaySoundAtEntity("open", "door_level_wood_open.snt", "castle_arched01_1", 1, true);
    SetSwingDoorDisableAutoClose("castle_arched01_1", true);
    AddPropImpulse("castle_arched01_1", 0.0f, 0.0f, -1.0f, "prop");
}

The sound plays correctly, but the door remains closed.

EDIT:
Well I've manipulated that code as much as possible, and the door still remains shut. What is supposed to be done? Is it something with the "prop" variable?

try with 1.0f instead of -1.0f
(09-17-2010, 03:56 PM)Cgturner Wrote: [ -> ]Okay, I am now working on the description when the door is interacted with (locked, and once unlocked).

Code:
AddEntityCollideCallback("Player","PrisonDoor","CollidePlayerWithPrisonDoor");

    AddEntityCollideCallback("Player","castle_arched01_1","CollidePlayerWithcastle_arched01_1");

void CollidePlayerWithPrisonDoor()
{
    if(HasItem("PrisonKey") == true)
    {
        SetMessage("Use your inventory to select the key and use it on the door.", 10);
    }
    else
    {
        SetMessage("You will need a key to open the cell door.", 5);
    }

}

void CollidePlayerWithcastle_arched01_1()
{
    if(HasItem("key_1") == true)
    {
        SetMessage("Use your inventory to select the key and use it on the door.", 10);
    }
    else
    {
        SetMessage("You will need a key to open this door.", 5);
    }

}
The game crashes upon starting when I use the code above. I got this off of the script functions wiki, but I may have used it the wrong way.

EDIT:
I would also like to know how to properly name in-game items, such as keys, so that it shows up both on-screen when the player is close enough, and in the inventory.

As it says on the wiki, the code is not complete and does not work, it is simplified to be an example of the actual syntax. That is why the game will crash.
MulleDK19,
Still nothing. The sound still plays correctly, and I know I have the right Entity because I checked, and the sound is emitted from the door.

Jens,
I thought by saying "simplified" on the wiki, it meant "this is a working script, minus the correct names for entities, script areas, etc". Do I have any chance of you telling me the correct syntax, or should I check some of the pre-made scripts in the game itself?
Well, this is both sound and particle system related. I want to make sure this is the correct way to make a timed sequence for sound/particle effects.

Code:
void Collidearea_scratch(string &in asParent, string &in asChild, int alState)
{
    AddTimer("hit_wood01.snt", 0.5f, "TimerSoundSequence");
    AddTimer("hit_wood01.snt", 1.0f, "TimerSoundSequence");
    AddTimer("hit_wood01.snt", 1.4f, "TimerSoundSequence");
    AddTimer("ps_impact_dust_low", 0.5f, "TimerSoundSequence");
    AddTimer("ps_impact_dust_high", 1.0f, "TimerSoundSequence");
    AddTimer("ps_impact_dust_high", 1.4f, "TimerSoundSequence");
}

void TimerSoundSequence(string &in asTimer)
{
    PlaySoundAtEntity("hitwood01", asTimer, "castle_arched01_1", 0, false);
    CreateParticleSystemAtEntity("psgal", "ps_impact_dust_low", "castle_arched01_1", false);
    CreateParticleSystemAtEntity("psgal", "ps_impact_dust_high", "dust_3", false);
    CreateParticleSystemAtEntity("psgal", "ps_impact_dust_low", "dust_1", false);
}

The sound plays correctly, from the correct entity, but the particle effects happen every time the sound starts, and I only want each particle effect to happen once. Thanks for any help!
Pages: 1 2 3