Frictional Games Forum (read-only)

Full Version: How can I make it look like someone bangs on the door? + chase around corner
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was wondering how I can make it look like someone's banging on the door, like it sort of shakes a little.

Anyone got any ideas?

I'm also wondering how you can make the monster chase you around corner.
Well, if we look at the coding for Justine, there is an event like this in the library. Some of the code is below.
Code:
void CollidePoundDoor(string &in asParent, string &in asChild, int alState)
{
AddTimer("DoorPoundLoop", 1, "TimerDoorPoundLoop");
}
//No more door pounding.
void CollideAreaStopPoundDoor(string &in asParent, string &in asChild, int alState)
{
RemoveTimer("DoorPoundLoop");

AddDebugMessage("No More Quarter Pounder. Veggie of course.", false);
}void TimerDoorPoundLoop(string& asTimer)
{
AddLocalVarInt("PoundDoorCount", 1);
if(GetLocalVarInt("PoundDoorCount") == 5) return;

AddPropImpulse("mansion_1", -2,0,0,"World");
PlaySoundAtEntity("pound", "hit_wood", "AreaPoundDoorEffect", 0, false);
PlaySoundAtEntity("enemy", "L02_attack", "AreaPoundDoorEffect", RandFloat(0.0f, 0.5f), false);
CreateParticleSystemAtEntity("pound_dust","ps_hit_wood","AreaPoundDoorEffect", false);

AddTimer("DoorPoundLoop", RandFloat(14, 50), "TimerDoorPoundLoop");

AddDebugMessage("Pound pound", false);
}

Assuming you want this in your CS and the script is there from the start, we can put the callback adding function in the OnStart area and adjust the code as needed;

Code:
void OnStart()
{
       AddEntityCollideCallback("Player", "AreaPoundDoor", "CollidePoundDoor", true, 1);
       AddEntityCollideCallback("Player", "AreaStopPound", "CollideAreaStopPoundDoor", true, 1);
}    
      //The Player character must collide with a scriptarea named AreaPoundDoor which is
      //done from the level editor, then later can optionally collide with a script called AreaStopPound
      //which will stop the banging. Then we chuck in the rest of the code.

void CollidePoundDoor(string &in asParent, string &in asChild, int alState)
{
        AddTimer("DoorPoundLoop", 1, "TimerDoorPoundLoop");
}
//No more door pounding.
void CollideAreaStopPoundDoor(string &in asParent, string &in asChild, int alState)
{
        RemoveTimer("DoorPoundLoop");
}void TimerDoorPoundLoop(string& asTimer)
{
        AddLocalVarInt("PoundDoorCount", 1);
        if(GetLocalVarInt("PoundDoorCount") == 5) return;
        AddPropImpulse("mansion_1", -2,0,0,"World");
        CreateParticleSystemAtEntity("pound_dust","ps_hit_wood","AreaPoundDoorEffect", false);
        AddTimer("DoorPoundLoop", RandFloat(14, 50), "TimerDoorPoundLoop");
        AddDebugMessage("Pound pound", false);
}
Some things you may need to do to the above:
Code:
AddPropImpulse("mansion_1", -2,0,0,"World");

1. Change mansion_1 to the name of your door if needed.
2. (You May need to) Change the way the door is supposed to move. In this code, the door will move along the x axis at -2. It should not have to move along the y, but may need to be moved along the z coordinate.

CreateParticleSystemAtEntity("pound_dust","ps_hit_wood","AreaPoundDoorEffect", false);
1. Create a ScriptArea named AreaPoundDoorEffect and place it in the middle of the door.

Ask again if you have any questions :-) Good luck
(04-12-2013, 04:42 PM)ROMul8r Wrote: [ -> ]Well, if we look at the coding for Justine, there is an event like this in the library. Some of the code is below.
Code:
void CollidePoundDoor(string &in asParent, string &in asChild, int alState)
{
AddTimer("DoorPoundLoop", 1, "TimerDoorPoundLoop");
}
//No more door pounding.
void CollideAreaStopPoundDoor(string &in asParent, string &in asChild, int alState)
{
RemoveTimer("DoorPoundLoop");

AddDebugMessage("No More Quarter Pounder. Veggie of course.", false);
}void TimerDoorPoundLoop(string& asTimer)
{
AddLocalVarInt("PoundDoorCount", 1);
if(GetLocalVarInt("PoundDoorCount") == 5) return;

AddPropImpulse("mansion_1", -2,0,0,"World");
PlaySoundAtEntity("pound", "hit_wood", "AreaPoundDoorEffect", 0, false);
PlaySoundAtEntity("enemy", "L02_attack", "AreaPoundDoorEffect", RandFloat(0.0f, 0.5f), false);
CreateParticleSystemAtEntity("pound_dust","ps_hit_wood","AreaPoundDoorEffect", false);

AddTimer("DoorPoundLoop", RandFloat(14, 50), "TimerDoorPoundLoop");

AddDebugMessage("Pound pound", false);
}

Assuming you want this in your CS and the script is there from the start, we can put the callback adding function in the OnStart area and adjust the code as needed;

Code:
void OnStart()
{
       AddEntityCollideCallback("Player", "AreaPoundDoor", "CollidePoundDoor", true, 1);
       AddEntityCollideCallback("Player", "AreaStopPound", "CollideAreaStopPoundDoor", true, 1);
}    
      //The Player character must collide with a scriptarea named AreaPoundDoor which is
      //done from the level editor, then later can optionally collide with a script called AreaStopPound
      //which will stop the banging. Then we chuck in the rest of the code.

void CollidePoundDoor(string &in asParent, string &in asChild, int alState)
{
        AddTimer("DoorPoundLoop", 1, "TimerDoorPoundLoop");
}
//No more door pounding.
void CollideAreaStopPoundDoor(string &in asParent, string &in asChild, int alState)
{
        RemoveTimer("DoorPoundLoop");
}void TimerDoorPoundLoop(string& asTimer)
{
        AddLocalVarInt("PoundDoorCount", 1);
        if(GetLocalVarInt("PoundDoorCount") == 5) return;
        AddPropImpulse("mansion_1", -2,0,0,"World");
        CreateParticleSystemAtEntity("pound_dust","ps_hit_wood","AreaPoundDoorEffect", false);
        AddTimer("DoorPoundLoop", RandFloat(14, 50), "TimerDoorPoundLoop");
        AddDebugMessage("Pound pound", false);
}
Some things you may need to do to the above:
Code:
AddPropImpulse("mansion_1", -2,0,0,"World");

1. Change mansion_1 to the name of your door if needed.
2. (You May need to) Change the way the door is supposed to move. In this code, the door will move along the x axis at -2. It should not have to move along the y, but may need to be moved along the z coordinate.

CreateParticleSystemAtEntity("pound_dust","ps_hit_wood","AreaPoundDoorEffect", false);
1. Create a ScriptArea named AreaPoundDoorEffect and place it in the middle of the door.
Ask again if you have any questions :-) Good luck

Thanks, I'll give it a try.
Also, to make the enemy chase around the corner, you would have to add some pathnodes for which the enemy can use so they dont continuously bump into the wall. To make the chase begin straight away, after the timer ends (say, they collide with the AreaStopPound ScriptArea) add this code in (Assuming the enemy is inactive and behind the door):
Code:
SetPropHealth("<door>", 0);
SetEntityActive("<Enemy's name>", true);
ShowEnemyPlayerPosition("<Enemy's name>");
(04-12-2013, 04:55 PM)ROMul8r Wrote: [ -> ]Also, to make the enemy chase around the corner, you would have to add some pathnodes for which the enemy can use so they dont continuously bump into the wall. To make the chase begin straight away, after the timer ends (say, they collide with the AreaStopPound ScriptArea) add this code in (Assuming the enemy is inactive and behind the door):
Code:
SetPropHealth("<door>", 0);
SetEntityActive("<Enemy's name>", true);
ShowEnemyPlayerPosition("<Enemy's name>");

Already done that bit, exactly the same way but thanks.