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
Making Hammer and Chipper break open door?
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#1
Making Hammer and Chipper break open door?

I have successfully made it so you pick up the hammer and chipper separately and combined them, but what I want to happen now is you use it on a door with a rusty lock, this breaks the lock giving the door a bit of damage (not totally destroying it) and in turn unlocks the door.

I think im ok with the majority of the scripting, im just not sure how to make the hammer and chipper play the animation?

04-21-2013, 01:27 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: Making Hammer and Chipper break open door?

PHP Code: (Select All)
void OnStart()
{
AddUseItemCallback("""HammerChipper""RustyLock""DoorUnlockAnim"true);
}

void DoorUnlockAnim(string &in asItemstring &in asEntity)
{
SetPropHealth("RustyLock"0.0f); //RustyLock is the Lock.
SetPropHealth("DoorName"0.0f); //Door is hit with damage too as you explained it. Change doorname to what ever your door's name is.
SetSwingDoorLocked("DoorName"falsefalse); //Change doorname to whatever your door's name is.
PlaySoundAtEntity("""LOCKBREAK.snt""Player"0.0ffalse); //Change LOCKBREAK.snt to the sound of a lock broken with the extension .snt.
SetEntityActive("Hammer"true); //Hammer.
SetEntityActive("Chipper"true); //Chipper.
AddTimer(""1.4f"HammerChipperMove");
}

void HammerChipperMove(string &in asTimer)
{
SetMoveObjectState("Hammer"0.40);
SetMoveObjectState("Chipper"0.40);
AddTimer(""1.1f"HammerChipperMove2");
}

void HammerChipperMove2(string &in asTimer)
{
SetMoveObjectState("Hammer"0.1f);
SetMoveObjectState("Chipper"0.1f);
AddTimer(""0.5f"TimerLoop");
}

void TimerLoop(string &in asTimer)
{
AddTimer(""0.2f"HammerChipperMove");
AddTimer(""0.3f"HammerChipperMove2");
AddTimer(""2.4f"HammerChipperEnd"); //Change 2.4f to how long you want the smashing process to endure.
}

void HammerChipperEnd(string &in asTimer)
{
SetEntityActive("Hammer"false);
SetEntityActive("Chipper"false);
RemoveTimer("HammerChipperMove");
RemoveTimer("HammerChipperMove2");

Please note that I've wrote this from scratch - meaning that some errors must be in there. Just try it out.

"Veni, vidi, vici."
"I came, I saw, I conquered."
04-21-2013, 01:59 PM
Find
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#3
RE: Making Hammer and Chipper break open door?

You are a legend, thank you Smile

Question, where it says 'Hammer', 'Chipper' and 'HammerChipper', do I need to replace all these with the names of my items?

(This post was last modified: 04-21-2013, 02:25 PM by serbusfish.)
04-21-2013, 02:02 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#4
RE: Making Hammer and Chipper break open door?

(04-21-2013, 02:02 PM)serbusfish Wrote: You are a legend, thank you Smile

Question, where it says 'Hammer', 'Chipper' and 'HammerChipper', do I need to replace all these with the names of my items?

Yep.

"Veni, vidi, vici."
"I came, I saw, I conquered."
04-21-2013, 02:27 PM
Find
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#5
RE: Making Hammer and Chipper break open door?

For some reason it wont work, it just says I cant use the item here. Here is my inventory code just for reference:

//COMBINE HAMMER//
////////////////////

void hammer_chipper(string &in asItemA, string &in asItemB)
{
PlayGuiSound("15_make_hammer", 1.0f);
RemoveItem(asItemA); RemoveItem(asItemB);
GiveItem("stone_hammer_chipper", "Puzzle", "stone_hammer_chipper", "stone_hammer_chipper.tga", 0);
}

////////////////////////////
// Run at the start of the game.
void OnGameStart()
{

/////HAMMER & CHIPPER COMBO/////
AddCombineCallback("hammer_chipper", "hammer_1", "chipper_1", "hammer_chipper", false);

}

And how I used your code:

void OnStart()

{

AddUseItemCallback("", "hammer_chipper", "RustyLock", "DoorUnlockAnim", true);

}

void DoorUnlockAnim(string &in asItem, string &in asEntity)
{
        SetPropHealth("RustyLock", 5.0f); //Door is hit with damage too as you explained it. Change doorname to what ever your door's name is.
        SetSwingDoorLocked("RustyLock", false, false); //Change doorname to whatever your door's name is.
        PlaySoundAtEntity("", "break_wood_metal.snt", "Player", 0.0f, false); //Change LOCKBREAK.snt to the sound of a lock broken with the extension .snt.
        SetEntityActive("hammer_1", true); //Hammer.
        SetEntityActive("chipper_1", true); //Chipper.
        AddTimer("", 1.4f, "HammerChipperMove");
}

    void HammerChipperMove(string &in asTimer)
    
  {
        SetMoveObjectState("hammer_1", 0.40);
        SetMoveObjectState("chipper_1", 0.40);
        AddTimer("", 1.1f, "HammerChipperMove2");
  }
    
    void HammerChipperMove2(string &in asTimer)
  {
            SetMoveObjectState("hammer_1", 0.1f);
            SetMoveObjectState("chipper_1", 0.1f);
            AddTimer("", 0.5f, "TimerLoop");
  }
    
    void TimerLoop(string &in asTimer)
{
        AddTimer("", 0.2f, "HammerChipperMove");
        AddTimer("", 0.3f, "HammerChipperMove2");
        AddTimer("", 2.4f, "HammerChipperEnd"); //Change 2.4f to how long you want the smashing process to endure.
}
    
    void HammerChipperEnd(string &in asTimer)
    
    {
            SetEntityActive("hammer_1", false);
            SetEntityActive("chipper_1", false);
            RemoveTimer("HammerChipperMove");
            RemoveTimer("HammerChipperMove2");
    }

^I removed the lock from it as I only have a Cellar door, not a gate with the lock prop.

04-21-2013, 02:59 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#6
RE: Making Hammer and Chipper break open door?

(04-21-2013, 02:59 PM)serbusfish Wrote: For some reason it wont work, it just says I cant use the item here. Here is my inventory code just for reference:

//COMBINE HAMMER//
////////////////////

void hammer_chipper(string &in asItemA, string &in asItemB)
{
PlayGuiSound("15_make_hammer", 1.0f);
RemoveItem(asItemA); RemoveItem(asItemB);
GiveItem("stone_hammer_chipper", "Puzzle", "stone_hammer_chipper", "stone_hammer_chipper.tga", 0);
}

////////////////////////////
// Run at the start of the game.
void OnGameStart()
{

/////HAMMER & CHIPPER COMBO/////
AddCombineCallback("hammer_chipper", "hammer_1", "chipper_1", "hammer_chipper", false);

}

And how I used your code:

void OnStart()

{

AddUseItemCallback("", "hammer_chipper", "RustyLock", "DoorUnlockAnim", true);

}

void DoorUnlockAnim(string &in asItem, string &in asEntity)
{
        SetPropHealth("RustyLock", 5.0f); //Door is hit with damage too as you explained it. Change doorname to what ever your door's name is.
        SetSwingDoorLocked("RustyLock", false, false); //Change doorname to whatever your door's name is.
        PlaySoundAtEntity("", "break_wood_metal.snt", "Player", 0.0f, false); //Change LOCKBREAK.snt to the sound of a lock broken with the extension .snt.
        SetEntityActive("hammer_1", true); //Hammer.
        SetEntityActive("chipper_1", true); //Chipper.
        AddTimer("", 1.4f, "HammerChipperMove");
}

    void HammerChipperMove(string &in asTimer)
    
  {
        SetMoveObjectState("hammer_1", 0.40);
        SetMoveObjectState("chipper_1", 0.40);
        AddTimer("", 1.1f, "HammerChipperMove2");
  }
    
    void HammerChipperMove2(string &in asTimer)
  {
            SetMoveObjectState("hammer_1", 0.1f);
            SetMoveObjectState("chipper_1", 0.1f);
            AddTimer("", 0.5f, "TimerLoop");
  }
    
    void TimerLoop(string &in asTimer)
{
        AddTimer("", 0.2f, "HammerChipperMove");
        AddTimer("", 0.3f, "HammerChipperMove2");
        AddTimer("", 2.4f, "HammerChipperEnd"); //Change 2.4f to how long you want the smashing process to endure.
}
    
    void HammerChipperEnd(string &in asTimer)
    
    {
            SetEntityActive("hammer_1", false);
            SetEntityActive("chipper_1", false);
            RemoveTimer("HammerChipperMove");
            RemoveTimer("HammerChipperMove2");
    }

^I removed the lock from it as I only have a Cellar door, not a gate with the lock prop.
It seems like you're using it on the wrong entity. You must used it with an entity under the name "RustyLock".

"Veni, vidi, vici."
"I came, I saw, I conquered."
04-21-2013, 03:01 PM
Find
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#7
RE: Making Hammer and Chipper break open door?

(04-21-2013, 03:01 PM)JustAnotherPlayer Wrote: It seems like you're using it on the wrong entity. You must used it with an entity under the name "RustyLock".

I named the door "RustyLock", I thought that would work ok?

(This post was last modified: 04-21-2013, 03:16 PM by serbusfish.)
04-21-2013, 03:15 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#8
RE: Making Hammer and Chipper break open door?

The script that I gave you said that "hammer_chipper" was the item. Yet in the Inventory.hps, it clearly states that it's "stone_hammer_chipper". You have the incorrect name for the item.

"Veni, vidi, vici."
"I came, I saw, I conquered."
04-21-2013, 03:20 PM
Find
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#9
RE: Making Hammer and Chipper break open door?

(04-21-2013, 03:20 PM)JustAnotherPlayer Wrote: The script that I gave you said that "hammer_chipper" was the item. Yet in the Inventory.hps, it clearly states that it's "stone_hammer_chipper". You have the incorrect name for the item.

Ah I see, schoolboy error on my part. Im very new to scripting, I used a tutorial to make that script and presumed 'hammer_chipper' was the final product.

Anyway now it works, and im sorry to be a pain but it doesnt play an animation, it simply breaks a hole in the door and unlocks it. Then once I had walked through the door my game started lagging immensely which led to me ctrl alt del to exit it. I noticed the hammer and chipper was still in my inventory too.

Im probably wrong but looking at the script again I would have thought all the stuff under 'DoorUnlockAnim' should go AFTER everything else? Because from what I can tell atm the game is breaking the door first with all the animation stuff afterwards.

But im only a n00b at scripting so am probably wrong?

(This post was last modified: 04-21-2013, 03:43 PM by serbusfish.)
04-21-2013, 03:40 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#10
RE: Making Hammer and Chipper break open door?

(04-21-2013, 03:40 PM)serbusfish Wrote:
(04-21-2013, 03:20 PM)JustAnotherPlayer Wrote: The script that I gave you said that "hammer_chipper" was the item. Yet in the Inventory.hps, it clearly states that it's "stone_hammer_chipper". You have the incorrect name for the item.

Ah I see, schoolboy error on my part. Im very new to scripting, I used a tutorial to make that script and presumed 'hammer_chipper' was the final product.

Anyway now it works, and im sorry to be a pain but it doesnt play an animation, it simply breaks a hole in the door and unlocks it. Then once I had walked through the door my game started lagging immensely which led to me ctrl alt del to exit it. I noticed the hammer and chipper was still in my inventory too.

Im probably wrong but looking at the script again I would have thought all the stuff under 'DoorUnlockAnim' should go AFTER everything else? Because from what I can tell atm the game is breaking the door first with all the animation stuff afterwards.

But im only a n00b at scripting so am probably wrong?
Oh yeah, I forgot that you need an inactive Hammer and Chipper at the door. It should be in Entities/Item and have the name "stone_hammer_move" and "stone_chipper_move" without the quotation marks.

"Veni, vidi, vici."
"I came, I saw, I conquered."
04-21-2013, 03:48 PM
Find




Users browsing this thread: 1 Guest(s)