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
AGP Offline
Senior Member

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

Oh my goodness, Flawless!! Thank you so much! I knew something needed to happen with the +i, but thought it was the _x (facepalm). And it all made complete sense to me, so thank you thank you thank you!

Unfortunately though, I'm trying to run this on my test map, and I can't even use the crowbar on the door. I'm wondering if maybe some of the names don't match up, but this has become such a scrambled mess in my own head, I'm probably just looking it right over.

Here is the revised .hps:

Spoiler below!
void OnStart()
{  
    for(int i=1; i<=4; ++i) AddUseItemCallback("crowbarondoors", "crowbar", "mansion_"+i, "UseCrowbarOnDoor", false);
    AddEntityCollideCallback("Joint", "AreaBreak", "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);
}


And here are the assets we are starting out with:

Crowbar: Crowbar_1
Door: Door_1
Joint: Joint_Door_1
Areas: AreaBreak_1 (for where the joint hits to call the script)
AreaEffect_1 (for the particles as the door opens)

So the question I have is: do I need to do the same variable technique for the areas as well? Is there anything else that I am missing?


________________________________________________________________
EDIT:

Nvm! I realized that some of the more obvious names were not changed!

Now, the crowbar is not showing up after using the crowbar on the door. The sounds is played, but there is no crowbar!

Revised script is as so:

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_Door_"+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);
}


(This post was last modified: 09-22-2014, 02:59 AM by AGP.)
09-22-2014, 01:04 AM
Find


Messages In This Thread
RE: Using a Single Crowbar on Multiple Doors - by AGP - 09-22-2014, 01:04 AM



Users browsing this thread: 1 Guest(s)