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


Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Chipper And Hammer Animation
HoyChampoy Offline
Junior Member

Posts: 43
Threads: 16
Joined: Jun 2012
Reputation: 0
#4
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: [Image: 3i32l.jpg]
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! Wink
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: [Image: 3i32l.jpg]
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! Wink
Never mind i got it to works. Thanks very much!
(This post was last modified: 07-15-2012, 10:08 PM by HoyChampoy.)
07-15-2012, 10:06 PM
Find


Messages In This Thread
Chipper And Hammer Animation - by HoyChampoy - 07-15-2012, 11:34 AM
RE: Chipper And Hammer Animation - by i3670 - 07-15-2012, 12:26 PM
RE: Chipper And Hammer Animation - by Ongka - 07-15-2012, 02:19 PM
RE: Chipper And Hammer Animation - by HoyChampoy - 07-15-2012, 10:06 PM
RE: Chipper And Hammer Animation - by Ongka - 07-15-2012, 11:04 PM
RE: Chipper And Hammer Animation - by HoyChampoy - 07-16-2012, 09:48 AM



Users browsing this thread: 1 Guest(s)