Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Gametee


Post Reply 
 
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with Crowbar script!
Author Message
Kyle Offline
Posting Freak

Posts: 911
Joined: Sep 2010
Reputation: 7
Post: #1
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.

10-17-2010 05:08 PM
Find all posts by this user Quote this message in a reply
Kyle Offline
Posting Freak

Posts: 911
Joined: Sep 2010
Reputation: 7
Post: #2
RE: Problem with Crowbar script!

Oh come on!! XD

10-17-2010 10:22 PM
Find all posts by this user Quote this message in a reply
theDARKW0LF Offline
Member

Posts: 150
Joined: Sep 2010
Reputation: 0
Post: #3
RE: Problem with Crowbar script!

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

Check out my custom stories(1)(2)!
10-18-2010 01:38 AM
Find all posts by this user Quote this message in a reply
Datenshi92 Offline
Junior Member

Posts: 7
Joined: Sep 2010
Reputation: 0
Post: #4
RE: Problem with Crowbar script!

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
10-18-2010 01:48 AM
Find all posts by this user Quote this message in a reply
Kyle Offline
Posting Freak

Posts: 911
Joined: Sep 2010
Reputation: 7
Post: #5
RE: Problem with Crowbar script!

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

10-18-2010 01:58 AM
Find all posts by this user Quote this message in a reply
Kyle Offline
Posting Freak

Posts: 911
Joined: Sep 2010
Reputation: 7
Post: #6
RE: Problem with Crowbar script!

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.

10-18-2010 11:10 AM
Find all posts by this user Quote this message in a reply
jens Offline
Frictional Games

Posts: 4,095
Joined: Apr 2006
Reputation: 202
Post: #7
RE: Problem with Crowbar script!

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.
10-18-2010 11:17 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Kyle Offline
Posting Freak

Posts: 911
Joined: Sep 2010
Reputation: 7
Post: #8
RE: Problem with Crowbar script!

Okay, thanks! I'll try it! Smile

10-18-2010 11:45 AM
Find all posts by this user Quote this message in a reply
Kyle Offline
Posting Freak

Posts: 911
Joined: Sep 2010
Reputation: 7
Post: #9
RE: Problem with Crowbar script!

OMFG! I got it to work! Big Grin

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

10-18-2010 09:23 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)