forked from Mirrors/openclonk
speed is always set to 0 while climbing a ladder and position of clonk is subpixel precise (#190)
parent
154e40cfed
commit
5fde6df839
|
@ -1667,5 +1667,7 @@ Build = {
|
||||||
SetProperty("PerspectiveR", 20000, def);
|
SetProperty("PerspectiveR", 20000, def);
|
||||||
SetProperty("PerspectiveTheta", 20, def);
|
SetProperty("PerspectiveTheta", 20, def);
|
||||||
SetProperty("PerspectivePhi", 70, def);
|
SetProperty("PerspectivePhi", 70, def);
|
||||||
|
|
||||||
|
_inherited(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,12 +129,12 @@ public func OnLadderClimb(clonk, index)
|
||||||
|
|
||||||
public func GetLadderData(index, &startx, &starty, &endx, &endy, &angle)
|
public func GetLadderData(index, &startx, &starty, &endx, &endy, &angle)
|
||||||
{
|
{
|
||||||
startx = GetPartX(index);
|
startx = particles[index][0][0]*10;
|
||||||
starty = GetPartY(index);
|
starty = particles[index][0][1]*10;
|
||||||
if(index == 0)
|
if(index == 0)
|
||||||
{
|
{
|
||||||
endx = startx;
|
endx = startx;
|
||||||
endy = starty-5;
|
endy = starty-5000;
|
||||||
angle = Angle(particles[2][0][0], particles[2][0][1], particles[0][0][0], particles[0][0][1]);
|
angle = Angle(particles[2][0][0], particles[2][0][1], particles[0][0][0], particles[0][0][1]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -144,8 +144,8 @@ public func GetLadderData(index, &startx, &starty, &endx, &endy, &angle)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
angle = Angle(particles[index+1][0][0], particles[index+1][0][1], particles[index-1][0][0], particles[index-1][0][1]);
|
angle = Angle(particles[index+1][0][0], particles[index+1][0][1], particles[index-1][0][0], particles[index-1][0][1]);
|
||||||
endx = GetPartX(index-1);
|
endx = particles[index-1][0][0]*10;
|
||||||
endy = GetPartY(index-1);
|
endy = particles[index-1][0][1]*10;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,7 @@ local no_ladder_counter;
|
||||||
|
|
||||||
func GetTurnPhase() { return _inherited(...); }
|
func GetTurnPhase() { return _inherited(...); }
|
||||||
|
|
||||||
func Initialize()
|
func Definition(def) {
|
||||||
{
|
|
||||||
// add action
|
// add action
|
||||||
SetProperty("Climb", {
|
SetProperty("Climb", {
|
||||||
Prototype = Action,
|
Prototype = Action,
|
||||||
|
@ -25,13 +24,11 @@ func Initialize()
|
||||||
StartCall = "StartScale",
|
StartCall = "StartScale",
|
||||||
}, GetProperty("ActMap"));
|
}, GetProperty("ActMap"));
|
||||||
// save old phasecall of jump
|
// save old phasecall of jump
|
||||||
if(jump_startcall == nil)
|
var jump_startcall = GetProperty("StartCall", GetProperty("Jump", GetProperty("ActMap")));
|
||||||
{
|
// and add new one
|
||||||
jump_startcall = GetProperty("StartCall", GetProperty("Jump", GetProperty("ActMap")));
|
SetProperty("StartCall", "StartSearchLadder", GetProperty("Jump", GetProperty("ActMap")));
|
||||||
// and add new one
|
SetProperty("StartCallLadderOverloaded", jump_startcall, GetProperty("Jump", GetProperty("ActMap")));
|
||||||
SetProperty("StartCall", "StartSearchLadder", GetProperty("Jump", GetProperty("ActMap")));
|
_inherited(def);
|
||||||
}
|
|
||||||
return _inherited(...);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartScale()
|
func StartScale()
|
||||||
|
@ -43,8 +40,8 @@ func StartScale()
|
||||||
func StartSearchLadder()
|
func StartSearchLadder()
|
||||||
{
|
{
|
||||||
// call overwriten old phase call
|
// call overwriten old phase call
|
||||||
if(jump_startcall != nil && jump_startcall != "StartSearchLadder")
|
if(GetProperty("StartCallLadderOverloaded", GetProperty("Jump", GetProperty("ActMap"))))
|
||||||
Call(jump_startcall);
|
Call(GetProperty("StartCallLadderOverloaded", GetProperty("Jump", GetProperty("ActMap"))));
|
||||||
if(!GetEffect("InSearchLadder", this))
|
if(!GetEffect("InSearchLadder", this))
|
||||||
{
|
{
|
||||||
AddEffect("IntSearchLadder", this, 1, 5, this);
|
AddEffect("IntSearchLadder", this, 1, 5, this);
|
||||||
|
@ -80,7 +77,7 @@ func FxIntClimbControlStart(target, number, tmp, ladder)
|
||||||
EffectVar(0, target, number) = ladder;
|
EffectVar(0, target, number) = ladder;
|
||||||
SetXDir(0); SetYDir(0);
|
SetXDir(0); SetYDir(0);
|
||||||
SetComDir(COMD_Stop);
|
SetComDir(COMD_Stop);
|
||||||
EffectVar(2, target, number) = 0; // angle
|
EffectVar(2, target, number) = 0; // odd or even segment?
|
||||||
}
|
}
|
||||||
|
|
||||||
func FxIntClimbControlTimer(target, number)
|
func FxIntClimbControlTimer(target, number)
|
||||||
|
@ -94,6 +91,7 @@ func FxIntClimbControlTimer(target, number)
|
||||||
{
|
{
|
||||||
EffectVar(1, target, number) = 0;
|
EffectVar(1, target, number) = 0;
|
||||||
EffectVar(0, target, number) = EffectVar(0, target, number)->GetNextLadder();
|
EffectVar(0, target, number) = EffectVar(0, target, number)->GetNextLadder();
|
||||||
|
EffectVar(2, target, number) = !EffectVar(2, target, number);
|
||||||
}
|
}
|
||||||
if(EffectVar(0, target, number) == nil)
|
if(EffectVar(0, target, number) == nil)
|
||||||
{
|
{
|
||||||
|
@ -118,6 +116,7 @@ func FxIntClimbControlTimer(target, number)
|
||||||
{
|
{
|
||||||
EffectVar(1, target, number) = 100;
|
EffectVar(1, target, number) = 100;
|
||||||
EffectVar(0, target, number) = EffectVar(0, target, number)->GetPreviousLadder();
|
EffectVar(0, target, number) = EffectVar(0, target, number)->GetPreviousLadder();
|
||||||
|
EffectVar(2, target, number) = !EffectVar(2, target, number);
|
||||||
}
|
}
|
||||||
if(EffectVar(0, target, number) == nil)
|
if(EffectVar(0, target, number) == nil)
|
||||||
{
|
{
|
||||||
|
@ -135,15 +134,26 @@ func FxIntClimbControlTimer(target, number)
|
||||||
}
|
}
|
||||||
var startx, starty, endx, endy, angle;
|
var startx, starty, endx, endy, angle;
|
||||||
EffectVar(0, target, number)->GetLadderData(startx, starty, endx, endy, angle);
|
EffectVar(0, target, number)->GetLadderData(startx, starty, endx, endy, angle);
|
||||||
var x = startx + (endx-startx)*EffectVar(1, target, number)/100+5-10*GetTurnPhase()/100;
|
var x = startx + (endx-startx)*EffectVar(1, target, number)/100+5000-100*GetTurnPhase();
|
||||||
var y = starty + (endy-starty)*EffectVar(1, target, number)/100;
|
var y = starty + (endy-starty)*EffectVar(1, target, number)/100;
|
||||||
var old_x = GetX(), old_y = GetY();
|
var old_x = GetX(), old_y = GetY();
|
||||||
SetPosition(x, y);
|
SetPosition(LadderToLandscapeCoordinates(x), LadderToLandscapeCoordinates(y));
|
||||||
SetDTRotation(-angle);//EffectVar(2, target, number));
|
SetXDir(0); SetYDir(0);
|
||||||
|
SetLadderRotation(-angle, x-GetX()*1000, y-GetY()*1000);//EffectVar(2, target, number));
|
||||||
if(Stuck())
|
if(Stuck())
|
||||||
{
|
{
|
||||||
SetPosition(old_x, old_y);
|
SetPosition(old_x, old_y);
|
||||||
}
|
}
|
||||||
|
// Make the animation synchron with movement TODO: this only makes the feet synchronous for the arms the animation has to be adapted
|
||||||
|
var animation = GetRootAnimation(5);
|
||||||
|
if(animation != nil)
|
||||||
|
{
|
||||||
|
if(GetAnimationName(animation) != nil)
|
||||||
|
{
|
||||||
|
var length = GetAnimationLength(GetAnimationName(animation));
|
||||||
|
SetAnimationPosition(animation, Anim_Const(EffectVar(1, target, number)*length/200+length/2*EffectVar(2, target, number)));
|
||||||
|
}
|
||||||
|
}
|
||||||
var contact = GetContact(-1);
|
var contact = GetContact(-1);
|
||||||
if(contact)
|
if(contact)
|
||||||
{
|
{
|
||||||
|
@ -165,9 +175,14 @@ func FxIntClimbControlTimer(target, number)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LadderToLandscapeCoordinates(int x)
|
||||||
|
{
|
||||||
|
return (x+500)/1000; // round to the next thousand
|
||||||
|
}
|
||||||
|
|
||||||
func FxIntClimbControlStop(target, number)
|
func FxIntClimbControlStop(target, number)
|
||||||
{
|
{
|
||||||
SetDTRotation(0);
|
SetLadderRotation(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
func FxIntClimbControlControl(target, number, ctrl, x,y,strength, repeat, release)
|
func FxIntClimbControlControl(target, number, ctrl, x,y,strength, repeat, release)
|
||||||
|
@ -216,11 +231,11 @@ func FxIntClimbControlControl(target, number, ctrl, x,y,strength, repeat, releas
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
global func SetDTRotation (int r, int xoff, int yoff) {
|
func SetLadderRotation (int r, int xoff, int yoff) {
|
||||||
var fsin=Sin(r, 1000), fcos=Cos(r, 1000);
|
var fsin=Sin(r, 1000), fcos=Cos(r, 1000);
|
||||||
// set matrix values
|
// set matrix values
|
||||||
SetObjDrawTransform (
|
SetObjDrawTransform (
|
||||||
+fcos, +fsin, (1000-fcos)*xoff - fsin*yoff,
|
+fcos, +fsin, xoff, //(1000-fcos)*xoff - fsin*yoff,
|
||||||
-fsin, +fcos, (1000-fcos)*yoff + fsin*xoff,
|
-fsin, +fcos, yoff, //(1000-fcos)*yoff + fsin*xoff,
|
||||||
);
|
);
|
||||||
}
|
}
|
Loading…
Reference in New Issue