forked from Mirrors/openclonk
Add range parameter to ShakeViewport.
Controls the falloff distance, so you can create more localized (or more global) shakes.shapetextures
parent
2fcbd56316
commit
1deb7e8176
|
@ -26,11 +26,17 @@
|
|||
<name>x</name>
|
||||
<desc>Y offset in relative coordinates from the calling object.</desc>
|
||||
</param>
|
||||
<param>
|
||||
<type>int</type>
|
||||
<name>range</name>
|
||||
<desc>Range from shake center at which the effect falls off to zero. Defaults to 700.</desc>
|
||||
<optional />
|
||||
</param>
|
||||
</params>
|
||||
</syntax>
|
||||
<desc>Shake the player viewports near the given position. This disorienting effect is used for earthquakes, explosions
|
||||
and other rumbling effects. The further away the player is from the source, the less his viewport is shaken. The
|
||||
strength falls off linearly by distance from 100% to 0% when the player is 700 pixels away.</desc>
|
||||
strength falls off linearly by distance from 100% to 0% when the player is [range] pixels away.</desc>
|
||||
<related><funclink>SetViewOffset</funclink></related>
|
||||
</func>
|
||||
</funcs>
|
||||
|
|
|
@ -358,16 +358,17 @@ strength falls off linearly by distance from 100% to 0% when the player is 700 p
|
|||
as the explosion level.
|
||||
@param x_off x offset in relative coordinates from the calling object
|
||||
@param y_off y offset in relative coordinates from the calling object
|
||||
@param range range of clonk to explosion at which shaking falls off to 0%
|
||||
*/
|
||||
global func ShakeViewport(int level, int x_off, int y_off)
|
||||
global func ShakeViewport(int level, int x_off, int y_off, range)
|
||||
{
|
||||
if (level <= 0)
|
||||
return false;
|
||||
|
||||
x_off += GetX();
|
||||
y_off += GetY();
|
||||
|
||||
AddEffect("ShakeViewport", nil, 300, 1, nil, nil, level, x_off, y_off);
|
||||
|
||||
AddEffect("ShakeViewport", nil, 300, 1, nil, nil, level, x_off, y_off, range ?? 700);
|
||||
}
|
||||
|
||||
global func FxShakeViewportEffect(string new_name)
|
||||
|
@ -378,17 +379,17 @@ global func FxShakeViewportEffect(string new_name)
|
|||
return;
|
||||
}
|
||||
|
||||
global func FxShakeViewportStart(object target, effect e, int temporary, level, xpos, ypos)
|
||||
global func FxShakeViewportStart(object target, effect e, int temporary, level, xpos, ypos, range)
|
||||
{
|
||||
if(temporary != 0) return;
|
||||
|
||||
e.shakers = CreateArray();
|
||||
e.shakers[0] = { x = xpos, y = ypos, strength = level, time = 0 };
|
||||
e.shakers[0] = { x = xpos, y = ypos, strength = level, time = 0, range = range };
|
||||
}
|
||||
|
||||
global func FxShakeViewportAdd(object target, effect e, string new_name, int new_timer, level, xpos, ypos)
|
||||
global func FxShakeViewportAdd(object target, effect e, string new_name, int new_timer, level, xpos, ypos, range)
|
||||
{
|
||||
e.shakers[GetLength(e.shakers)] = { x = xpos, y = ypos, strength = level, time = e.Time};
|
||||
e.shakers[GetLength(e.shakers)] = { x = xpos, y = ypos, strength = level, time = e.Time, range = range };
|
||||
}
|
||||
|
||||
global func FxShakeViewportTimer(object target, effect e, int time)
|
||||
|
@ -409,7 +410,7 @@ global func FxShakeViewportTimer(object target, effect e, int time)
|
|||
|
||||
// shake strength lowers as a function of the distance
|
||||
var distance = Distance(cursor->GetX(), cursor->GetY(), shaker.x, shaker.y);
|
||||
var maxDistance = 700;
|
||||
var maxDistance = shaker.range;
|
||||
var level = shaker.strength * BoundBy(100-100*distance/maxDistance,0,100)/100;
|
||||
|
||||
// calculate total shake strength by adding up all shake positions in the player's vicinity
|
||||
|
|
Loading…
Reference in New Issue