Problem with Crowbar script!
I was trying to use a crowbar to open a door, and it didn't work. It said that it cannot be used when I used the crowbar on the door. The entities involved are: "cellar_wood01_slow_2" , "crowbar_1". The scriptareas that are involved are: "BreakDoor" , "AreaUseCrowbar" , "AreaBreakEffect". In the scriptarea "AreaUseCrowbar", ItemInteraction is checked.
void OnStart()
{
PreloadSound("general_chain_rattle_single.snt");
AddEntityCollideCallback("Player" , "ScriptArea_2" , "PlaySound01" , false , 1);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "BarrelFall" , true , 1);
AddEntityCollideCallback("Player" , "ScriptArea_3" , "MonsterFunc1" , true , -1);
AddUseItemCallback("" , "HatchKey" , "HatchDoor" , "UsedKeyOnDoor" , true);
}
void BarrelFall(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("barrel01_20" , true);
}
void PlaySound01(string &in asParent , string &in asChild , int alState)
{
PlaySoundAtEntity("ChainSound" , "general_chain_rattle_single.snt" , "chain_pipe03_1" , 0 , true);
}
void MonsterFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("servant_grunt2" , true);
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_1", 5.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_2", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_3", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_4", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_5", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_7", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_8", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_9", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_10", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_11", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_12", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_13", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_14", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_15", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_16", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_17", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_18", 0.0f, "");
AddEnemyPatrolNode("servant_grunt2", "PathNodeArea_19", 0.0f, "");
}
void UsedKeyOnDoor(string &in asItem , string &in asEntity)
{
SetSwingDoorLocked(asEntity , false , true);
SetLevelDoorLocked(asEntity , false);
PlaySoundAtEntity("UnlockSound" , "unlock_door.snt" , asEntity , 0.0f , false);
RemoveItem(asItem);
}
-------------------------------------------------------------------
void UseCrowbarOnDoor(string &in asItem, string &in asEntity)
{
AddTimer(asEntity, 0.2, "TimerSwitchShovel");
PlaySoundAtEntity("pickupcrow","player_crouch.snt", "Player", 0.05, false);
//Remove callback incase player never touched door
SetEntityPlayerInteractCallback("cellar_wood01_slow_2", "", true);
SetEntityPlayerInteractCallback("AreaUseCrowbar", "", true);
RemoveItem(asItem);
}
void TimerSwitchShovel(string &in asTimer)
{
PlaySoundAtEntity("attachshovel","puzzle_place_jar.snt", asTimer, 0, false);
SetEntityActive("crowbar_joint_1", true);
}
void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
GiveSanityBoostSmall();
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
SetSwingDoorLocked("cellar_wood01_slow_2", false, false);
SetSwingDoorDisableAutoClose("cellar_wood01_slow_2", true);
SetSwingDoorClosed("cellar_wood01_slow_2", false,false);
PlaySoundAtEntity("break","break_wood_metal", "AreaBreakEffect", 0, false);
CreateParticleSystemAtEntity("breakps", "ps_hit_wood", "AreaBreakEffect", false);
AddPropImpulse("cellar_wood01_slow_2", -3, 0, 0, "world");
SetEntityActive("crowbar_joint_1", false);
SetEntityActive("crowbar_dyn_1", true);
AddTimer("pushdoor", 0.1, "TimerPushDoor");
AddTimer("voice2", 1, "TimerDanielVoices");
AddDebugMessage("Break door!", false);
}
void TimerPushDoor(string &in asTimer)
{
AddPropImpulse("cellar_wood01_slow_2", -1, 2, -4, "world");
AddTimer("doorclose", 1.1, "TimerDoorCanClose");
}
void TimerDoorCanClose(string &in asTimer)
{
SetSwingDoorDisableAutoClose("cellar_wood01_slow_2", false);
}
void OnEnter()
{
}
void OnLeave()
{
}
--------------------------------------------------------------------
Added script in section above.
|