HoyChampoy
Junior Member
Posts: 43
Threads: 16
Joined: Jun 2012
Reputation:
0
|
RE: Chipper And Hammer Animation
(07-15-2012, 02:19 PM)Ongka Wrote: A little tutorial:
You need an object where the hammer is pointing at, in this case it's "HammerDoor".
The next thing is an Area which defines where the hammer rotates.
And obviously a hammer. (stone_hammer_move.ent)
You place it like in this image:
And enter the name of the area which the hammer will rotate around into AngularOffsetArea.
My area is called AreaHammerRotate.
Here's the script:
void OnStart()
{
AddUseItemCallback("HCOnBricks", "stone_hammer_1", "HammerDoor", "UseHCOnBricks", true);
//stone_hammer_1 is the name of the hammer, HammerDoor the entity where you use the hammer on
}
void UseHCOnBricks(string &in asItem, string &in asEntity)
{
SetEntityActive("stone_chipper_move_x_1",true);
SetEntityActive("stone_hammer_move_1",true);
PlaySoundAtEntity("cumble1", "15_rock_break", "AreaHammer", 0, false);
SetMoveObjectState("stone_hammer_move_1", 0.25f);
SetMoveObjectState("stone_chipper_move_x_1", 1.0f);
AddTimer("1", 0.6f, "TimerHammer");
AddTimer("2", 1.2f, "TimerHammer");
AddTimer("3", 1.8f, "TimerHammer");
AddTimer("4", 2.4f, "TimerHammer");
AddTimer("5", 3.0f, "TimerHammer");
SetEntityActive(asEntity, false); //Turns off interaction message on area.
//Remove hammer chisel as not needed any longer
if(HasItem("poison_gland")) RemoveItem(asItem);
}
void TimerHammer(string &in asTimer)
{
if(asTimer == "1"){
SetEntityInteractionDisabled("HammerDoor", true);
SetPropStaticPhysics("HammerDoor", true);
PlaySoundAtEntity("bang", "hit_wood", "Player", 0, false);
PlaySoundAtEntity("hammer", "15_hammer", "Player", 0, false);
SetMoveObjectState("stone_hammer_move_1", 0.25f);
SetMoveObjectState("stone_chipper_move_x_1", 0.0f);
}
if(asTimer == "2"){
SetMoveObjectState("stone_hammer_move_1", 0.0f);
SetMoveObjectState("stone_chipper_move_x_1", 1.0f);
}
if(asTimer == "3"){
SetMoveObjectState("stone_hammer_move_1", 0.25f);
SetMoveObjectState("stone_chipper_move_x_1", 0.0f);
PlaySoundAtEntity("bang", "hit_wood", "Player", 0, false);
PlaySoundAtEntity("hammer", "15_hammer", "Player", 0, false);
}
if(asTimer == "4"){
SetMoveObjectState("stone_hammer_move_1", 0.0f);
SetMoveObjectState("stone_chipper_move_x_1", 1.0f);
}
if(asTimer == "5"){
SetEntityActive("stone_chipper_move_x_1",false);
SetEntityActive("stone_hammer_move_1",false);
PlaySoundAtEntity("bang", "hit_wood", "Player", 0, false);
PlaySoundAtEntity("hammer", "15_hammer", "Player", 0, false);
CreateParticleSystemAtEntity("dust", "ps_hit_rock.ps", "AreaHammerOnDoor", false);
SetLocalVarInt("UsedHC", 1);
SetPropHealth("HammerDoor", 0);
}
}
In this case i don't have a chipper, but it's still included in the script. You may have to adjust things a bit in order to fit together.
Basically what this script does is making the hammer hit the door and make a sound on the impact.
If you don't want to hit a door, you have to remove the sounds.
Feel free to ask questions if you have problems with the script or something doesn't work.
Good luck! thanks for the help but i cant get it to work. it followed everything, and renamed all the things that needed to be renamed. I want the player to use it on padlock. When I try it, it says the cannot be used on there. And the animation wont even show.
void OnStart()
{
AddUseItemCallback("HCOnBricks", "stone_hammer_1", "padlock_rusty_1", "UseHCOnBricks", true);
}
void UseHCOnBricks(string &in asItem, string &in asEntity)
{
SetEntityActive("stone_chipper_move_x_1",true);
SetEntityActive("stone_hammer_move_1",true);
PlaySoundAtEntity("cumble1", "15_rock_break", "AreaHammer", 0, false);
SetMoveObjectState("stone_hammer_move_1", 0.25f);
SetMoveObjectState("stone_chipper_move_x_1", 1.0f);
AddTimer("1", 0.6f, "TimerHammer");
AddTimer("2", 1.2f, "TimerHammer");
AddTimer("3", 1.8f, "TimerHammer");
AddTimer("4", 2.4f, "TimerHammer");
AddTimer("5", 3.0f, "TimerHammer");
SetEntityActive(asEntity, false); //Turns off interaction message on area.
//Remove hammer chisel as not needed any longer
if(HasItem("poison_gland")) RemoveItem(asItem);
}
void TimerHammer(string &in asTimer)
{
if(asTimer == "1"){
SetEntityInteractionDisabled("padlock_rusty_1", true);
SetPropStaticPhysics("padlock_rusty_1", true);
PlaySoundAtEntity("bang", "hit_wood", "Player", 0, false);
PlaySoundAtEntity("hammer", "15_hammer", "Player", 0, false);
SetMoveObjectState("stone_hammer_move_1", 0.25f);
SetMoveObjectState("stone_chipper_move_x_1", 0.0f);
}
if(asTimer == "2"){
SetMoveObjectState("stone_hammer_move_1", 0.0f);
SetMoveObjectState("stone_chipper_move_x_1", 1.0f);
}
if(asTimer == "3"){
SetMoveObjectState("stone_hammer_move_1", 0.25f);
SetMoveObjectState("stone_chipper_move_x_1", 0.0f);
PlaySoundAtEntity("bang", "hit_wood", "Player", 0, false);
PlaySoundAtEntity("hammer", "15_hammer", "Player", 0, false);
}
if(asTimer == "4"){
SetMoveObjectState("stone_hammer_move_1", 0.0f);
SetMoveObjectState("stone_chipper_move_x_1", 1.0f);
}
if(asTimer == "5"){
SetEntityActive("stone_chipper_move_x_1",false);
SetEntityActive("stone_hammer_move_1",false);
PlaySoundAtEntity("bang", "hit_wood", "Player", 0, false);
PlaySoundAtEntity("hammer", "15_hammer", "Player", 0, false);
CreateParticleSystemAtEntity("dust", "ps_hit_rock.ps", "AreaHammerOnDoor", false);
SetLocalVarInt("UsedHC", 1);
SetPropHealth("padlock_rusty_1", 0);
}
}
(07-15-2012, 02:19 PM)Ongka Wrote: A little tutorial:
You need an object where the hammer is pointing at, in this case it's "HammerDoor".
The next thing is an Area which defines where the hammer rotates.
And obviously a hammer. (stone_hammer_move.ent)
You place it like in this image:
And enter the name of the area which the hammer will rotate around into AngularOffsetArea.
My area is called AreaHammerRotate.
Here's the script:
void OnStart()
{
AddUseItemCallback("HCOnBricks", "stone_hammer_1", "HammerDoor", "UseHCOnBricks", true);
//stone_hammer_1 is the name of the hammer, HammerDoor the entity where you use the hammer on
}
void UseHCOnBricks(string &in asItem, string &in asEntity)
{
SetEntityActive("stone_chipper_move_x_1",true);
SetEntityActive("stone_hammer_move_1",true);
PlaySoundAtEntity("cumble1", "15_rock_break", "AreaHammer", 0, false);
SetMoveObjectState("stone_hammer_move_1", 0.25f);
SetMoveObjectState("stone_chipper_move_x_1", 1.0f);
AddTimer("1", 0.6f, "TimerHammer");
AddTimer("2", 1.2f, "TimerHammer");
AddTimer("3", 1.8f, "TimerHammer");
AddTimer("4", 2.4f, "TimerHammer");
AddTimer("5", 3.0f, "TimerHammer");
SetEntityActive(asEntity, false); //Turns off interaction message on area.
//Remove hammer chisel as not needed any longer
if(HasItem("poison_gland")) RemoveItem(asItem);
}
void TimerHammer(string &in asTimer)
{
if(asTimer == "1"){
SetEntityInteractionDisabled("HammerDoor", true);
SetPropStaticPhysics("HammerDoor", true);
PlaySoundAtEntity("bang", "hit_wood", "Player", 0, false);
PlaySoundAtEntity("hammer", "15_hammer", "Player", 0, false);
SetMoveObjectState("stone_hammer_move_1", 0.25f);
SetMoveObjectState("stone_chipper_move_x_1", 0.0f);
}
if(asTimer == "2"){
SetMoveObjectState("stone_hammer_move_1", 0.0f);
SetMoveObjectState("stone_chipper_move_x_1", 1.0f);
}
if(asTimer == "3"){
SetMoveObjectState("stone_hammer_move_1", 0.25f);
SetMoveObjectState("stone_chipper_move_x_1", 0.0f);
PlaySoundAtEntity("bang", "hit_wood", "Player", 0, false);
PlaySoundAtEntity("hammer", "15_hammer", "Player", 0, false);
}
if(asTimer == "4"){
SetMoveObjectState("stone_hammer_move_1", 0.0f);
SetMoveObjectState("stone_chipper_move_x_1", 1.0f);
}
if(asTimer == "5"){
SetEntityActive("stone_chipper_move_x_1",false);
SetEntityActive("stone_hammer_move_1",false);
PlaySoundAtEntity("bang", "hit_wood", "Player", 0, false);
PlaySoundAtEntity("hammer", "15_hammer", "Player", 0, false);
CreateParticleSystemAtEntity("dust", "ps_hit_rock.ps", "AreaHammerOnDoor", false);
SetLocalVarInt("UsedHC", 1);
SetPropHealth("HammerDoor", 0);
}
}
In this case i don't have a chipper, but it's still included in the script. You may have to adjust things a bit in order to fit together.
Basically what this script does is making the hammer hit the door and make a sound on the impact.
If you don't want to hit a door, you have to remove the sounds.
Feel free to ask questions if you have problems with the script or something doesn't work.
Good luck! Never mind i got it to works. Thanks very much!
(This post was last modified: 07-15-2012, 10:08 PM by HoyChampoy.)
|
|