Making Hammer and Chipper break open door? - serbusfish - 04-21-2013
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?
RE: Making Hammer and Chipper break open door? - PutraenusAlivius - 04-21-2013
PHP Code: void OnStart() { AddUseItemCallback("", "HammerChipper", "RustyLock", "DoorUnlockAnim", true); }
void DoorUnlockAnim(string &in asItem, string &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", false, false); //Change doorname to whatever your door's name is. PlaySoundAtEntity("", "LOCKBREAK.snt", "Player", 0.0f, false); //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.
RE: Making Hammer and Chipper break open door? - serbusfish - 04-21-2013
You are a legend, thank you
Question, where it says 'Hammer', 'Chipper' and 'HammerChipper', do I need to replace all these with the names of my items?
RE: Making Hammer and Chipper break open door? - PutraenusAlivius - 04-21-2013
(04-21-2013, 02:02 PM)serbusfish Wrote: You are a legend, thank you
Question, where it says 'Hammer', 'Chipper' and 'HammerChipper', do I need to replace all these with the names of my items?
Yep.
RE: Making Hammer and Chipper break open door? - serbusfish - 04-21-2013
For some reason it wont work, it just says I cant use the item here. Here is my inventory code just for reference:
Code: //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:
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.
RE: Making Hammer and Chipper break open door? - PutraenusAlivius - 04-21-2013
(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:
Code: //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:
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".
RE: Making Hammer and Chipper break open door? - serbusfish - 04-21-2013
(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?
RE: Making Hammer and Chipper break open door? - PutraenusAlivius - 04-21-2013
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.
RE: Making Hammer and Chipper break open door? - serbusfish - 04-21-2013
(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?
RE: Making Hammer and Chipper break open door? - PutraenusAlivius - 04-21-2013
(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.
|