speed is always set to 0 while climbing a ladder and position of clonk is subpixel precise (#190)

stable-5.1
Richard Gerum 2010-03-10 12:51:33 +01:00
parent 154e40cfed
commit 5fde6df839
3 changed files with 41 additions and 24 deletions

View File

@ -1667,5 +1667,7 @@ Build = {
SetProperty("PerspectiveR", 20000, def);
SetProperty("PerspectiveTheta", 20, def);
SetProperty("PerspectivePhi", 70, def);
_inherited(def);
}

View File

@ -129,12 +129,12 @@ public func OnLadderClimb(clonk, index)
public func GetLadderData(index, &startx, &starty, &endx, &endy, &angle)
{
startx = GetPartX(index);
starty = GetPartY(index);
startx = particles[index][0][0]*10;
starty = particles[index][0][1]*10;
if(index == 0)
{
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]);
return true;
}
@ -144,8 +144,8 @@ public func GetLadderData(index, &startx, &starty, &endx, &endy, &angle)
}
else
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);
endy = GetPartY(index-1);
endx = particles[index-1][0][0]*10;
endy = particles[index-1][0][1]*10;
return true;
}

View File

@ -10,8 +10,7 @@ local no_ladder_counter;
func GetTurnPhase() { return _inherited(...); }
func Initialize()
{
func Definition(def) {
// add action
SetProperty("Climb", {
Prototype = Action,
@ -25,13 +24,11 @@ func Initialize()
StartCall = "StartScale",
}, GetProperty("ActMap"));
// save old phasecall of jump
if(jump_startcall == nil)
{
jump_startcall = GetProperty("StartCall", GetProperty("Jump", GetProperty("ActMap")));
// and add new one
SetProperty("StartCall", "StartSearchLadder", GetProperty("Jump", GetProperty("ActMap")));
}
return _inherited(...);
var jump_startcall = GetProperty("StartCall", GetProperty("Jump", GetProperty("ActMap")));
// and add new one
SetProperty("StartCall", "StartSearchLadder", GetProperty("Jump", GetProperty("ActMap")));
SetProperty("StartCallLadderOverloaded", jump_startcall, GetProperty("Jump", GetProperty("ActMap")));
_inherited(def);
}
func StartScale()
@ -43,8 +40,8 @@ func StartScale()
func StartSearchLadder()
{
// call overwriten old phase call
if(jump_startcall != nil && jump_startcall != "StartSearchLadder")
Call(jump_startcall);
if(GetProperty("StartCallLadderOverloaded", GetProperty("Jump", GetProperty("ActMap"))))
Call(GetProperty("StartCallLadderOverloaded", GetProperty("Jump", GetProperty("ActMap"))));
if(!GetEffect("InSearchLadder", this))
{
AddEffect("IntSearchLadder", this, 1, 5, this);
@ -80,7 +77,7 @@ func FxIntClimbControlStart(target, number, tmp, ladder)
EffectVar(0, target, number) = ladder;
SetXDir(0); SetYDir(0);
SetComDir(COMD_Stop);
EffectVar(2, target, number) = 0; // angle
EffectVar(2, target, number) = 0; // odd or even segment?
}
func FxIntClimbControlTimer(target, number)
@ -94,6 +91,7 @@ func FxIntClimbControlTimer(target, number)
{
EffectVar(1, target, number) = 0;
EffectVar(0, target, number) = EffectVar(0, target, number)->GetNextLadder();
EffectVar(2, target, number) = !EffectVar(2, target, number);
}
if(EffectVar(0, target, number) == nil)
{
@ -118,6 +116,7 @@ func FxIntClimbControlTimer(target, number)
{
EffectVar(1, target, number) = 100;
EffectVar(0, target, number) = EffectVar(0, target, number)->GetPreviousLadder();
EffectVar(2, target, number) = !EffectVar(2, target, number);
}
if(EffectVar(0, target, number) == nil)
{
@ -135,15 +134,26 @@ func FxIntClimbControlTimer(target, number)
}
var 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 old_x = GetX(), old_y = GetY();
SetPosition(x, y);
SetDTRotation(-angle);//EffectVar(2, target, number));
SetPosition(LadderToLandscapeCoordinates(x), LadderToLandscapeCoordinates(y));
SetXDir(0); SetYDir(0);
SetLadderRotation(-angle, x-GetX()*1000, y-GetY()*1000);//EffectVar(2, target, number));
if(Stuck())
{
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);
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)
{
SetDTRotation(0);
SetLadderRotation(0);
}
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;
}
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);
// set matrix values
SetObjDrawTransform (
+fcos, +fsin, (1000-fcos)*xoff - fsin*yoff,
-fsin, +fcos, (1000-fcos)*yoff + fsin*xoff,
+fcos, +fsin, xoff, //(1000-fcos)*xoff - fsin*yoff,
-fsin, +fcos, yoff, //(1000-fcos)*yoff + fsin*xoff,
);
}