Frictional Games Forum (read-only)
Hammer animation - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Hammer animation (/thread-9090.html)

Pages: 1 2


Hammer animation - DRedshot - 07-12-2011

I would like to get the hammer to move as i use it on an entity, like it does in the actual game. I looked at the code in the actual game, and it uses "SetMoveObjectState".
The problem with this is that it makes the hammer move only vertically up or down, whereas i want the hammer to hit something on the wall.
So I was wondering, how do you make the hammer move horizontally using scripts ( i think "stone_hammer_move" is a static entity so i cant use AddPropForce )

Also, in the level Editor i found a setting, "AngularOffsetArea -- When mode is angular, this is the point it rotates around"
How do i make mode angular, and would this enable the hammer to swing like i want it to?

If anyone can help i would appreciate it, Thanks!


RE: Hammer animation - Roenlond - 07-12-2011

Probably not the most efficient way of doing it, but here's my script.

Code:
void OnStart()
{
AddUseItemCallback("breaklock", "stone_hammer_chipper", "padlock_1", "BreakLock", true);
}

void BreakLock(string &in asItem, string &in asEntity)
{
SetEntityActive("stone_hammer_move_1", true);
SetEntityActive("stone_chipper_move_1", true);
CreateParticleSystemAtEntity("cloud", "ps_dust_drilling.ps", "padlock_1", false);
CreateParticleSystemAtEntity("cloud", "ps_enemy_disappear_per_bone_small.ps", "padlock_1", false);
AddTimer("removelock", 0.7f, "RemoveLock");
AddTimer("bangbang", 0.2f, "bangbang");
AddTimer("removehammer", 0.8f, "removehammer");
SetMoveObjectState("stone_hammer_move_1", 0.2f);
SetMoveObjectState("stone_chipper_move_1", 0.2f);
PlayGuiSound("15_hammer1.ogg", 1);
CompleteQuest("opencellar", "OpenCellar");
}

void RemoveLock(string &in asTimer)
{
SetPropActiveAndFade("padlock_1", false, 1.0f);
SetSwingDoorLocked("CellarToWaterPart", false, true);
CreateParticleSystemAtEntity("hit", "ps_hit_metal.ps", "padlock_1", false);
CreateParticleSystemAtEntity("dust", "ps_break_wood_pulley_blocker.ps", "padlock_1", false);
}

void bangbang (string &in asTimer)
{
SetMoveObjectState("stone_hammer_move_1", -0.2f);
SetMoveObjectState("stone_chipper_move_1", -0.2f);
PlayGuiSound("15_hammer2.ogg", 1);
}

Various timers run commands at different times and plays sounds to "break" the lock. Some particles make it more realistic. There's probably a better way to do it, but I couldn't find any information about it so I experimented with it and my result looks nice Smile


RE: Hammer animation - DRedshot - 07-12-2011

Thanks for trying to help me, but this didn't work Sad , it's the SetMoveObjectState command, it only seems to let me move my object vertically in the y axis, there is no option to let it move in the x or z axis, so i have no way of making the hammer move forwards/backwards, SetMoveObjectState only moves up/down. I hope you understand what i'm trying to say? does anyone else have any suggestion on how i can get the hammer to move properly? or can anyone answer my other questions above? please help, thanks in advance Smile


RE: Hammer animation - Roenlond - 07-12-2011

Yeah, it worked like you were saying on my custom story. It looked as if you banged the chipper on the padlock.


RE: Hammer animation - DRedshot - 07-12-2011

Yeah im glad you understand, the problem with me is that im not using the hammer on a padlock - the padlock is angled slighty, so downwards motion can still hit it.

Im using my hammer on a flat wall section, with no parts that it can hit if it just moves down, so the hammer just floats, moving up and down, hitting nothing... very annoying.


RE: Hammer animation - Roenlond - 07-12-2011

That is very odd indeed, I'm not entirely sure what could be causing it. Perhaps mine works because it's tilted somewhat? You're using the _move hammer, right?


RE: Hammer animation - DRedshot - 07-12-2011

yep, the only difference between my script and yours, is that i'm not using the chipper at all
edit, also, i tried mine tilted, still no luck..


RE: Hammer animation - Kyle - 07-12-2011

Why not have the player hold a hammer and bang it on whatever you're trying to bang it on. In my custom story demo that I released, I had the player find a rather large hammer and take it and, by themselves, bang it on a rusty lock to break it off so they could open the door. It is really cool that you could have the normal objects around you to be used for puzzles and stuff. It definately makes it more immersive. Smile


RE: Hammer animation - DRedshot - 07-12-2011

Actually, i deleted something in the entity tab of my hammer in the editor
(It was the thing in AngularOffsetArea) and now it seems to be behaving itself. It seems illogical to me that it now rotates when I Disable AngularOffsetArea, because i thought if I enabled it, it would act as a hinge...... Anyways, thanks a lot for your help, I can Finally continue with my custom story! Smile

Edit: just read your post kyle and it seems like a very cool idea i might do that actually, even after spending all day getting this script to work Smile)


RE: Hammer animation - DRedshot - 07-13-2011

ok, sorry about this but i think i have found some sort of bug.
The animation script works great! the particles show up, the hammer swings, sounds play etc..,

But as soon as I press F5 and quickload, the hammer glitches into the wall, flies up to the ceiling and causes havoc! The problem is stopped consistantly everytime i click Quick Map Reload, and occurs again if I quickload... This has happened 5 times in a row, has anyone else ever had this problem?