Screen shake onDamage possible?
Screen shake onDamage possible?
I'm just curious whether it is possible to add a minor screenshake upon taking damage or landing critical hits. I've been messing around with a few scripts, but I'm unable to get any solid results.
- Skuggasveinn
- Posts: 562
- Joined: Wed Sep 26, 2012 5:28 pm
Re: Screen shake onDamage possible?
onDealDamage = function(self, champion, damage)
party:shakeCamera(0.5, 0.3)
party:playScreenEffect("damage_screen")
something along this line ?
party:shakeCamera(0.5, 0.3)
party:playScreenEffect("damage_screen")
something along this line ?
Re: Screen shake onDamage possible?
That basically the same to what I'm using. I'm just not sure what to add for (self, champion, damage). Especially damage.
Re: Screen shake onDamage possible?
you don't need to add anything if you don't want to, they're just useful options
Finished Dungeons - complete mods to play
- JohnWordsworth
- Posts: 1397
- Joined: Fri Sep 14, 2012 4:19 pm
- Location: Devon, United Kingdom
- Contact:
Re: Screen shake onDamage possible?
I would consider doing something like the following in order to have the screen shake whenever the player takes damage (it's a tad harder for monsters, as you have to hook into every monster I believe).
You have to modify the default behaviour when the player takes damage by adding a party hook - these let you have custom lua functions, that you define, called when certain things happen to the party. Either add the following to init.lua or add it to a new file, party.lua and then add an import line to your init file to link in the new file.
Simple Shake Code (based on @Skugasveinn's script).
Slightly More Complex Shake Code (shakes more on more damage).
The function bit defines your custom logic - champion, damage and damType are parameters passed to your code from the game engine. Here we use those to shake the screen more if you take a higher proportion of damage.
You have to modify the default behaviour when the player takes damage by adding a party hook - these let you have custom lua functions, that you define, called when certain things happen to the party. Either add the following to init.lua or add it to a new file, party.lua and then add an import line to your init file to link in the new file.
Simple Shake Code (based on @Skugasveinn's script).
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onDamage = function(champion, damage, damType)
party:shakeCamera(0.5, 0.3);
party:playScreenEffect("damage_screen");
return true;
end,
}
The function bit defines your custom logic - champion, damage and damType are parameters passed to your code from the game engine. Here we use those to shake the screen more if you take a higher proportion of damage.
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onDamage = function(champion, damage, damType)
local intensity = damage / champion:getStatMax("health");
party:shakeCamera(intensity, 0.3);
party:playScreenEffect("damage_screen");
return true;
end,
}
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
Re: Screen shake onDamage possible?
That LUA works wonderfully. Much thanks, John. 
Re: Screen shake onDamage possible?
Those are pretty straightforward and clear. I love messing with simple math in functions, it can get clever very fast, good stuff. 
You can also leave off the "return true" line. It always returns true as a default, you only need to put something if you want it to "return false" or perhaps return some other value (rare/advanced).
You can also leave off the "return true" line. It always returns true as a default, you only need to put something if you want it to "return false" or perhaps return some other value (rare/advanced).
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onDamage = function(champion, damage, damType)
party:shakeCamera(0.5, 0.3);
party:playScreenEffect("damage_screen");
end,
}Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onDamage = function(champion, damage, damType)
local intensity = damage / champion:getStatMax("health");
party:shakeCamera(intensity, 0.3);
party:playScreenEffect("damage_screen");
end,
}Finished Dungeons - complete mods to play
