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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help [SOLVED] Using a Single Crowbar on Multiple Doors
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#11
RE: Using a Single Crowbar on Multiple Doors

Let's take another look then.

Are you sure the areas are in the right locations? Make sure AreaEffect_1 is by Door_1 and so on, as that's how the callbacks are set up. Also make sure they're close enough for the crowbar to actually hit them.

PS: I noticed the GiveItem line gives you the crowbar with the internal name of "crowbar" but the callbacks are set to use "Crowbar_1" which makes me think that this will only work once unless you match them up.

(This post was last modified: 09-22-2014, 07:26 AM by Mudbill.)
09-22-2014, 07:25 AM
Find
AGP Offline
Senior Member

Posts: 448
Threads: 45
Joined: Dec 2012
Reputation: 23
#12
RE: Using a Single Crowbar on Multiple Doors

(09-22-2014, 07:25 AM)Mudbill Wrote: Let's take another look then.

Are you sure the areas are in the right locations? Make sure AreaEffect_1 is by Door_1 and so on, as that's how the callbacks are set up. Also make sure they're close enough for the crowbar to actually hit them.

PS: I noticed the GiveItem line gives you the crowbar with the internal name of "crowbar" but the callbacks are set to use "Crowbar_1" which makes me think that this will only work once unless you match them up.

I'm pretty sure the areas are matched up. I've gone over them several times making sure they were in just the right position.
__________________________________________________________
EDIT:

Turns out I went in and changed "AreaBreak" in the AddEntityCollideCallback function. Putting back the _"+i that had been taken out, the first three doors worked, however it was without the door break sound or particle effect and you could still hear the crowbar bending as the door swung open.

The fourth door did not work; the crowbar again moved only back and forth, and I ended up with three crowbars in the inventory.
And in regards to the crowbar, yes, I thought something like like too, but I wasn't sure how to go about fixing that.

(This post was last modified: 09-22-2014, 07:32 AM by AGP.)
09-22-2014, 07:27 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#13
RE: Using a Single Crowbar on Multiple Doors

Post your script, yet another time, because I'm not sure how it looks now ^_^

Trying is the first step to success.
09-22-2014, 08:12 AM
Find
AGP Offline
Senior Member

Posts: 448
Threads: 45
Joined: Dec 2012
Reputation: 23
#14
RE: Using a Single Crowbar on Multiple Doors

Spoiler below!
void OnStart()
{  
    for(int i=1; i<=4; ++i) AddUseItemCallback("crowbarondoors", "Crowbar_1", "Door_"+i, "UseCrowbarOnDoor", false);
    for(int i=1; i<=4; ++i) AddEntityCollideCallback("Joint_Door_"+i, "AreaBreak_"+i, "BreakDoor", true, 1);
}
    
void UseCrowbarOnDoor(string &in asItem, string &in asEntity)
{
    RemoveItem("asItem");
    PlaySoundAtEntity("", "player_crouch.snt", "Player", 0.05, false);
    AddTimer(asEntity, 0.2, "TimerPlaceCrowbar");

    SetLocalVarString("CrowbarDoor", asEntity);
}
    
void TimerPlaceCrowbar(string &in asTimer)
{
    SetEntityActive("Joint_"+asTimer, true);
    PlaySoundAtEntity("", "puzzle_place_jar.snt", asTimer, 0, false);
}
    
void BreakDoor(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive(asParent, false);
  
    SetSwingDoorLocked(GetLocalVarString("CrowbarDoor"), false, false);
    SetSwingDoorClosed(GetLocalVarString("CrowbarDoor"), false, false);
    SetSwingDoorDisableAutoClose(GetLocalVarString("CrowbarDoor"), true);
    
    AddPropImpulse(GetLocalVarString("CrowbarDoor"), 0, 0, 3, "world");

    CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "AreaEffect", false);
    PlaySoundAtEntity("", "break_wood_metal", "AreaEffect", 0, false);
    
    GiveSanityBoostSmall();
    
    PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
    
    AddTimer("", 0.1, "TimerPushDoor");

    GiveItem("crowbar", "Puzzle", "crowbar", "crowbar.tga", 1);
}

void TimerPushDoor(string &in asTimer)
{
        AddPropImpulse(GetLocalVarString("CrowbarDoor"), -4, 2, 1, "world");
        AddTimer("", 1.1, "TimerDoorCanClose");
}
    
void TimerDoorCanClose(string &in asTimer)
{
        SetSwingDoorDisableAutoClose(GetLocalVarString("CrowbarDoor"), false);
}


09-22-2014, 08:13 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#15
RE: Using a Single Crowbar on Multiple Doors

Oh! Haha, one thing at least.

In your script it says: RemoveItem("asItem");

You cannot have the two "" for it to work. It must be:

RemoveItem(asItem);


Ok, so now the problem is just that the crowbar doesn't work on the 4th door?
Please check that ALL names are correct.

Also, try adding AddDebugMessage("Test", false); to the UseCrowbarOnDoor function, and enable debug messages, just to see if the thing is actually calling.

Trying is the first step to success.
09-22-2014, 08:33 AM
Find
AGP Offline
Senior Member

Posts: 448
Threads: 45
Joined: Dec 2012
Reputation: 23
#16
RE: Using a Single Crowbar on Multiple Doors

The names are all correct. After removing the two quotation marks, only the first door will unlock.

Here's a download link for the .map and .hps files. This isn't my actual map; this was made to test out the script before adding it into everything.

https://www.mediafire.com/?vqek4b0w4vgcsu0

09-22-2014, 08:52 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#17
RE: Using a Single Crowbar on Multiple Doors

Ok! I found another thing!
Will look at your map when I get home.

You have 'true' in AddEntityCollideCallback("Joint_Door_"+i, "AreaBreak_"+i, "BreakDoor", true, 1);

When you have true here, it will delete the Collide callback after it has been called once...
And then it makes sense it's only working once..

Trying is the first step to success.
09-22-2014, 09:03 AM
Find
AGP Offline
Senior Member

Posts: 448
Threads: 45
Joined: Dec 2012
Reputation: 23
#18
RE: Using a Single Crowbar on Multiple Doors

I changed it to false, but the other three doors are still no longer working.

09-22-2014, 09:07 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#19
RE: Using a Single Crowbar on Multiple Doors

I suggest renaming your crowbar item to just "crowbar" like you have it within GiveItem, and then also rename "Crowbar_1" in the callback to just "crowbar" in order to keep it the same.

This is because the crowbar you pick up (which is named Crowbar_1) will be possible to use to on any of the doors, but after using it, you're given a new crowbar item which is NOT named Crowbar_1, therefore it won't work on the doors. Make those names the same and it should, unless there's something else preventing it.

(This post was last modified: 09-22-2014, 09:11 AM by Mudbill.)
09-22-2014, 09:09 AM
Find
AGP Offline
Senior Member

Posts: 448
Threads: 45
Joined: Dec 2012
Reputation: 23
#20
RE: Using a Single Crowbar on Multiple Doors

That worked! All four doors now open!

There is still the bug with the sound and particle effects, or lack of particle effects. But the doors open!! Hooray! XD

09-22-2014, 09:12 AM
Find




Users browsing this thread: 2 Guest(s)