Frictional Games Forum (read-only)
Problem with Crowbar script! - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Problem with Crowbar script! (/thread-5088.html)



Problem with Crowbar script! - Kyle - 10-17-2010

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.


RE: Problem with Crowbar script! - Kyle - 10-17-2010

Oh come on!! XD


RE: Problem with Crowbar script! - theDARKW0LF - 10-18-2010

It'd be much easier to read if you didn't show your entire .hps file.


RE: Problem with Crowbar script! - Datenshi92 - 10-18-2010

Whenever someone posts something like this I laugh and wonder how are people supposed to "read" that and solve it...
Maybe I'm just stupid and don't know a thing of it, but it sure looks like a seven headed monster to me xP


RE: Problem with Crowbar script! - Kyle - 10-18-2010

Sorry bout' my script of doom...

Here is the main part I am focusing on. Smile



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()
{
}


RE: Problem with Crowbar script! - Kyle - 10-18-2010

It runs, but it doesn't work... :\

I really need help with it. They should make a tutorial on combining objects and also interacting with those objects with other objects.


RE: Problem with Crowbar script! - jens - 10-18-2010

Add debug messages to your code to see if functions are really triggered and what is going on.

for example in UseCrowbarOnDoor

Add AddDebugMessage("Used Item: "+asItem+" On Entity: "+asEntity, false);
If you see no message, then the function is never called, if you see a message you can see what it calls the item and entity. This was just an example, but do these types of checks and you'll save time and can troubleshoot.


RE: Problem with Crowbar script! - Kyle - 10-18-2010

Okay, thanks! I'll try it! Smile


RE: Problem with Crowbar script! - Kyle - 10-18-2010

OMFG! I got it to work! Big Grin

The thing I was missing was the callbacks... :\