Well, if we look at the coding for Justine, there is an event like this in the library. Some of the code is below.
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;
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:
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