Physical: Float speed and acceleration is now an Action property

Günther Brammer 2010-12-12 00:05:42 +01:00
parent 434c45d00c
commit d31371cb95
18 changed files with 52 additions and 44 deletions

View File

@ -57,6 +57,8 @@ Fall = {
Prototype = Action,
Name = "Fall",
Procedure = DFA_FLIGHT,
Speed = 200,
Accel = 16,
Directions = 1,
FlipDir = 0,
Length = 1,
@ -99,4 +101,4 @@ Float = {
Hgt = 25,
NextAction = "FLOAT",
},
}, def);}
}, def);}

View File

@ -26,4 +26,3 @@ IncompleteActivity=1
[Physical]
Energy=40000
Breath=50000
Float=200

View File

@ -97,6 +97,8 @@ Fly = {
Prototype = Action,
Name = "Fly",
Procedure = DFA_FLOAT,
Speed = 200,
Accel = 16,
Directions = 2,
FlipDir = 1,
Length = 1,
@ -113,6 +115,8 @@ Flutter = {
Prototype = Action,
Name = "Flutter",
Procedure = DFA_FLOAT,
Speed = 200,
Accel = 16,
Directions = 2,
FlipDir = 1,
Length = 11,

View File

@ -264,6 +264,8 @@ Jump = {
Prototype = Action,
Name = "Jump",
Procedure = DFA_FLIGHT,
Speed = 200,
Accel = 16,
Directions = 2,
FlipDir = 1,
Length = 17,
@ -297,6 +299,8 @@ Lunge = {
Prototype = Action,
Name = "Lunge",
Procedure = DFA_FLIGHT,
Speed = 200,
Accel = 16,
Directions = 2,
FlipDir = 1,
Length = 22,

View File

@ -1869,6 +1869,8 @@ Tumble = {
Prototype = Action,
Name = "Tumble",
Procedure = DFA_FLIGHT,
Speed = 200,
Accel = 16,
Directions = 2,
Length = 1,
Delay = 0,
@ -1958,6 +1960,8 @@ Jump = {
Prototype = Action,
Name = "Jump",
Procedure = DFA_FLIGHT,
Speed = 200,
Accel = 16,
Directions = 2,
Length = 1,
Delay = 0,
@ -1974,6 +1978,8 @@ Dive = {
Prototype = Action,
Name = "Dive",
Procedure = DFA_FLIGHT,
Speed = 200,
Accel = 16,
Directions = 2,
Length = 8,
Delay = 4,

View File

@ -6,5 +6,3 @@ Width=10
Height=10
Offset=-5,-5
[Physical]
Float=1000

View File

@ -39,12 +39,14 @@ func UpdateTransferZone()
}
local ActMap = {
Fly = {
Prototype = Action,
Name = "Fly",
Procedure = DFA_FLOAT,
NextAction = "Hold"
},
Fly = {
Prototype = Action,
Name = "Fly",
Procedure = DFA_FLOAT,
Speed = 1000,
Accel = 16,
NextAction = "Hold"
},
};
local Name = "Cloud";

View File

@ -17,5 +17,3 @@ Components=Cloud=1
Oversize=1
StretchGrowth=1
[Physical]
Float=20

View File

@ -157,6 +157,8 @@ Fly = {
Prototype = Action,
Name = "Fly",
Procedure = DFA_FLOAT,
Speed = 20,
Accel = 16,
X = 0,
Y = 0,
Wdt = 512,

View File

@ -10,5 +10,3 @@ VertexY=0
VertexFriction=100
BorderBound=7
[Physical]
Float=100000

View File

@ -20,8 +20,8 @@ public func Set(int iWidth, int iLength, object pSht)
{
pShot = pSht;
w = 1000*iWidth/this["ActMap"]["Travel"]["Wdt"];
l = 1000*iLength/this["ActMap"]["Travel"]["Hgt"];
w = 1000*iWidth/ActMap.Travel.Wdt;
l = 1000*iLength/ActMap.Travel.Hgt;
var iXDir = pShot->GetXDir(1000);
var iYDir = pShot->GetYDir(1000);
@ -76,7 +76,7 @@ public func Hit()
public func Remove() {
SetXDir();
SetYDir();
l = Min(l,1000*Distance(x,y,GetX(),GetY())/this["ActMap"]["Travel"]["Hgt"]);
l = Min(l,1000*Distance(x,y,GetX(),GetY())/ActMap.Travel.Hgt);
fRemove = true;
pShot = nil;
}
@ -84,7 +84,7 @@ public func Remove() {
public func DrawTransform() {
var distance = Distance(x,y,GetX(),GetY());
var relative_length = 1000*distance/this["ActMap"]["Travel"]["Hgt"];
var relative_length = 1000*distance/ActMap.Travel.Hgt;
// skip because nothing has to be transformed
if(!fRemove && l < relative_length) return;
@ -97,7 +97,7 @@ public func DrawTransform() {
var fsin = -Sin(r, 1000), fcos = Cos(r, 1000);
var xoff = -(this["ActMap"]["Travel"]["Wdt"]*w/1000)/2;
var xoff = -(ActMap.Travel.Wdt*w/1000)/2;
var yoff = 0;
var width = +fcos*w/1000, height = +fcos*h/1000;
@ -119,6 +119,8 @@ Travel = {
Prototype = Action,
Name = "Travel",
Procedure = DFA_FLOAT,
Speed = 100000,
Accel = 16,
NextAction = "Travel",
Length = 1,
Delay = 1,

View File

@ -50,6 +50,8 @@ Fall = {
Prototype = Action,
Name = "Fall",
Procedure = DFA_FLIGHT,
Speed = 200,
Accel = 16,
Directions = 1,
FlipDir = 0,
Length = 1,
@ -92,4 +94,4 @@ Float = {
Hgt = 25,
NextAction = "FLOAT",
},
}, def);}
}, def);}

View File

@ -31,7 +31,6 @@ const int CornerRange=AttachRange+2;
#define GravAccel (::Landscape.Gravity)
extern const C4Real FloatAccel;
extern const C4Real HitSpeed1,HitSpeed2,HitSpeed3,HitSpeed4;
extern const C4Real FloatFriction;
extern const C4Real RotateAccel;

View File

@ -389,7 +389,7 @@ void C4Command::MoveTo()
{
C4Real dx = itofix(Tx._getInt()) - cObj->fix_x, dy = itofix(Ty) - cObj->fix_y;
// normalize
C4Real dScale = C4REAL100(cObj->GetPhysical()->Float) / Max(Abs(dx), Abs(dy));
C4Real dScale = C4REAL100(cObj->GetAction()->GetPropertyInt(P_Speed)) / Max(Abs(dx), Abs(dy));
dx *= dScale; dy *= dScale;
// difference to momentum
dx -= cObj->xdir; dy -= cObj->ydir;

View File

@ -173,7 +173,6 @@ struct C4PhysInfoNameMap_t { const char *szName; C4PhysicalInfo::Offset off; } C
{ "Jump", &C4PhysicalInfo::Jump },
{ "Throw", &C4PhysicalInfo::Throw },
{ "Magic", &C4PhysicalInfo::Magic },
{ "Float", &C4PhysicalInfo::Float },
{ "CanScale", &C4PhysicalInfo::CanScale },
{ "CanHangle", &C4PhysicalInfo::CanHangle },
{ "CanDig", &C4PhysicalInfo::CanDig },

View File

@ -52,7 +52,6 @@ public:
int32_t CanFly;
int32_t CorrosionResist;
int32_t BreatheWater;
int32_t Float;
public:
void Default();
void PromotionUpdate(int32_t iRank, bool fUpdateTrainablePhysicals=false, class C4Def *pTrainDef=NULL);

View File

@ -36,7 +36,6 @@ const C4Real FFriction=C4REAL100(30);
const C4Real FixFullCircle=itofix(360),FixHalfCircle=FixFullCircle/2;
const C4Real FloatFriction=C4REAL100(2);
const C4Real RotateAccel=C4REAL100(20);
const C4Real FloatAccel=C4REAL100(16);
const C4Real HitSpeed1=C4REAL100(150); // Hit Event
const C4Real HitSpeed2=itofix(2); // Cross Check Hit
const C4Real HitSpeed3=itofix(6); // Scale disable, kneel

View File

@ -3477,7 +3477,7 @@ void GrabLost(C4Object *cObj)
}
}
void DoGravity(C4Object *cobj, bool fFloatFriction=true);
static void DoGravity(C4Object *cobj);
void C4Object::NoAttachAction()
{
@ -3828,20 +3828,17 @@ bool DoBridge(C4Object *clk)
return true;
}
void DoGravity(C4Object *cobj, bool fFloatFriction)
static void DoGravity(C4Object *cobj)
{
// Floatation in liquids
if (cobj->InLiquid && cobj->Def->Float)
{
cobj->ydir-=FloatAccel;
if (cobj->ydir<FloatAccel*-10) cobj->ydir=FloatAccel*-10;
if (fFloatFriction)
{
if (cobj->xdir<-FloatFriction) cobj->xdir+=FloatFriction;
if (cobj->xdir>+FloatFriction) cobj->xdir-=FloatFriction;
if (cobj->rdir<-FloatFriction) cobj->rdir+=FloatFriction;
if (cobj->rdir>+FloatFriction) cobj->rdir-=FloatFriction;
}
cobj->ydir-=GravAccel * C4REAL100(80);
if (cobj->ydir<C4REAL100(-160)) cobj->ydir=C4REAL100(-160);
if (cobj->xdir<-FloatFriction) cobj->xdir+=FloatFriction;
if (cobj->xdir>+FloatFriction) cobj->xdir-=FloatFriction;
if (cobj->rdir<-FloatFriction) cobj->rdir+=FloatFriction;
if (cobj->rdir>+FloatFriction) cobj->rdir-=FloatFriction;
if (!GBackLiquid(cobj->GetX(),cobj->GetY()-1+ cobj->Def->Float*cobj->GetCon()/FullCon -1 ))
if (cobj->ydir<0) cobj->ydir=0;
}
@ -4082,9 +4079,8 @@ void C4Object::ExecAction()
SetCommand(C4CMD_Exit);
}
lLimit = itofix(2);
lFloatAccel = Max(Min(lLimit+xdir,FloatAccel),itofix(0));
rFloatAccel = Max(Min(lLimit-xdir,FloatAccel),itofix(0));
lFloatAccel = Max(Min(lLimit+xdir,accel),itofix(0));
rFloatAccel = Max(Min(lLimit-xdir,accel),itofix(0));
switch (Action.ComDir)
{
@ -4416,11 +4412,10 @@ void C4Object::ExecAction()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case DFA_FLOAT:
// Float speed
lLimit=C4REAL100(pPhysical->Float);
xlFloatAccel = Max(Min(lLimit+xdir,FloatAccel),itofix(0));
xrFloatAccel = Max(Min(lLimit-xdir,FloatAccel),itofix(0));
yuFloatAccel = Max(Min(lLimit+ydir,FloatAccel),itofix(0));
ydFloatAccel = Max(Min(lLimit-ydir,FloatAccel),itofix(0));
xlFloatAccel = Max(Min(lLimit+xdir,accel),itofix(0));
xrFloatAccel = Max(Min(lLimit-xdir,accel),itofix(0));
yuFloatAccel = Max(Min(lLimit+ydir,accel),itofix(0));
ydFloatAccel = Max(Min(lLimit-ydir,accel),itofix(0));
// ComDir changes xdir/ydir
switch (Action.ComDir)