Physical: Remove unused Can* values, instead rely on action availability

Günther Brammer 2010-12-12 01:09:29 +01:00
parent d31371cb95
commit 086e3e9e10
8 changed files with 38 additions and 123 deletions

View File

@ -35,4 +35,4 @@ Energy=50000
Breath=50000
Jump=35000
Throw=50000
CanDig=1

View File

@ -31,9 +31,4 @@ Energy=50000
Breath=100000
Jump=40000
Throw=50000
CanDig=1
CanConstruct=1
CanChop=1
CanScale=1
CanHangle=1

View File

@ -16,13 +16,6 @@ public func ControlUse(object clonk, int ix, int iy)
// Stop clonk
clonk->SetComDir(COMD_Stop);
// Is the clonk able to build?
if (clonk && !clonk->GetPhysical("CanConstruct", PHYS_Current) && CheckCanUse(clonk)==true)
{
PlayerMessage(clonk->GetController(), "$TxtCantConstruct$", clonk->GetName());
return 1;
}
if(clonk->GetAction()=="Build") //Stop building
{
clonk->Message("Cancelling building");

View File

@ -124,16 +124,6 @@ void AdjustMoveToTarget(int32_t &rX, int32_t &rY, bool fFreeMove, int32_t iShape
}
bool FreeMoveTo(C4Object *cObj)
{
// Floating: we accept any move-to target
if (cObj->GetProcedure()==DFA_FLOAT) return true;
// Can fly: we accept any move-to target
if (cObj->GetPhysical()->CanFly) return true;
// Assume we're walking: move-to targets are adjusted
return false;
}
bool AdjustSolidOffset(int32_t &rX, int32_t &rY, int32_t iXOff, int32_t iYOff)
{
// In solid: fail
@ -733,9 +723,6 @@ void C4Command::Chop()
DWORD ocf;
// No target: fail
if (!Target) { Finish(); return; }
// Can not chop: fail
if (!cObj->GetPhysical()->CanChop)
{ Finish(); return; }
// Target not chopable: done (assume was successfully chopped)
if (!(Target->OCF & OCF_Chop))
{ Finish(true); return; }
@ -771,12 +758,6 @@ void C4Command::Build()
// No target: cancel
if (!Target)
{ Finish(); return; }
// Lost the ability to build? Fail.
if (cObj->GetPhysical() && !cObj->GetPhysical()->CanConstruct)
{
Finish(false, FormatString(LoadResStr("IDS_TEXT_CANTBUILD"), cObj->GetName()).getData());
return;
}
// Target complete: Command fulfilled
if (Target->GetCon()>=FullCon)
{
@ -1514,7 +1495,7 @@ bool C4Command::InitEvaluation()
if (Target) { Tx+=Target->GetX(); Ty+=Target->GetY(); Target=NULL; }
// Adjust coordinates
int32_t iTx = Tx._getInt();
if (~Data.getInt() & C4CMD_MoveTo_NoPosAdjust) AdjustMoveToTarget(iTx,Ty,FreeMoveTo(cObj),cObj->Shape.Hgt);
if (~Data.getInt() & C4CMD_MoveTo_NoPosAdjust) AdjustMoveToTarget(iTx,Ty,true,cObj->Shape.Hgt);
Tx.SetInt(iTx);
return true;
}
@ -1523,7 +1504,7 @@ bool C4Command::InitEvaluation()
{
// Adjust coordinates
int32_t iTx = Tx._getInt();
AdjustMoveToTarget(iTx,Ty,FreeMoveTo(cObj),cObj->Shape.Hgt);
AdjustMoveToTarget(iTx,Ty,true,cObj->Shape.Hgt);
Tx.SetInt(iTx);
return true;
}
@ -1567,12 +1548,6 @@ void C4Command::Clear()
void C4Command::Construct()
{
// Only those who can
if (cObj->GetPhysical() && !cObj->GetPhysical()->CanConstruct)
{
Finish(false, FormatString(LoadResStr("IDS_TEXT_CANTBUILD"), cObj->GetName()).getData());
return;
}
// No target type to construct: fail
if (!Data)
{
@ -1674,8 +1649,6 @@ void C4Command::Construct()
bool C4Command::FlightControl() // Called by DFA_WALK, DFA_FLIGHT
{
// Objects with CanFly physical only
if (!cObj->GetPhysical()->CanFly) return false;
// Crew members or pathfinder objects only
if (!((cObj->OCF & OCF_CrewMember) || cObj->Def->Pathfinder)) return false;
@ -1700,7 +1673,7 @@ bool C4Command::FlightControl() // Called by DFA_WALK, DFA_FLIGHT
if (iTopFree>=15)
{
// Take off
cObj->SetActionByName("Fly"); // This is a little primitive... we should have a ObjectActionFly or maybe a command for this...
return cObj->SetActionByName("Fly"); // This is a little primitive... we should have a ObjectActionFly or maybe a command for this...
}
}

View File

@ -173,13 +173,6 @@ struct C4PhysInfoNameMap_t { const char *szName; C4PhysicalInfo::Offset off; } C
{ "Jump", &C4PhysicalInfo::Jump },
{ "Throw", &C4PhysicalInfo::Throw },
{ "Magic", &C4PhysicalInfo::Magic },
{ "CanScale", &C4PhysicalInfo::CanScale },
{ "CanHangle", &C4PhysicalInfo::CanHangle },
{ "CanDig", &C4PhysicalInfo::CanDig },
{ "CanConstruct", &C4PhysicalInfo::CanConstruct },
{ "CanChop", &C4PhysicalInfo::CanChop },
{ "CanSwimDig", &C4PhysicalInfo::CanSwimDig },
{ "CanFly", &C4PhysicalInfo::CanFly },
{ "CorrosionResist", &C4PhysicalInfo::CorrosionResist },
{ "BreatheWater", &C4PhysicalInfo::BreatheWater },
{ NULL, NULL }

View File

@ -43,13 +43,6 @@ public:
int32_t Jump;
int32_t Throw;
int32_t Magic;
int32_t CanScale;
int32_t CanHangle;
int32_t CanDig;
int32_t CanConstruct;
int32_t CanChop;
int32_t CanSwimDig;
int32_t CanFly;
int32_t CorrosionResist;
int32_t BreatheWater;
public:

View File

@ -1742,18 +1742,12 @@ bool C4Object::Build(int32_t iLevel, C4Object *pBuilder)
}
// Do con (mass- and builder-relative)
int32_t iBuildSpeed=100; C4PhysicalInfo *pPhys;
if (pBuilder) if ((pPhys=pBuilder->GetPhysical()))
{
iBuildSpeed=pPhys->CanConstruct;
if (!iBuildSpeed)
{
// shouldn't even have gotten here. Looks like the Clonk lost the ability to build recently
return false;
}
if (iBuildSpeed<=1) iBuildSpeed=100;
}
DoCon(iLevel*iBuildSpeed*150/Def->Mass, false, fNeedMaterial);
int32_t iBuildSpeed=100*150;
if (pBuilder && pBuilder->GetAction())
{
iBuildSpeed=pBuilder->GetAction()->GetPropertyInt(P_Speed);
}
DoCon(iLevel*iBuildSpeed/Def->Mass, false, fNeedMaterial);
// TurnTo
if (Def->BuildTurnTo!=C4ID::None)
@ -3586,14 +3580,10 @@ void C4Object::ContactAction()
// Scale: Try hangle, else stop if going upward
if (ComDirLike(Action.ComDir, COMD_Up))
{
if (pPhysical->CanHangle)
{
iDir=DIR_Left;
if (Action.Dir==DIR_Left) { iDir=DIR_Right; }
ObjectActionHangle(this,iDir); return;
}
else
Action.ComDir=COMD_Stop;
iDir=DIR_Left;
if (Action.Dir==DIR_Left) { iDir=DIR_Right; }
if (ObjectActionHangle(this,iDir)) return;
Action.ComDir=COMD_Stop;
}
break;
case DFA_FLIGHT:
@ -3601,8 +3591,7 @@ void C4Object::ContactAction()
// High Speed Flight: Tumble
if ((OCF & OCF_HitSpeed3) || fDisabled)
{ ObjectActionTumble(this,Action.Dir,Fix0,Fix0); break; }
if (pPhysical->CanHangle)
{ ObjectActionHangle(this,Action.Dir); return; }
if (ObjectActionHangle(this,Action.Dir)) return;
break;
case DFA_DIG:
// Dig: Stop
@ -3622,15 +3611,13 @@ void C4Object::ContactAction()
if ((OCF & OCF_HitSpeed3) || fDisabled)
{ ObjectActionTumble(this,DIR_Left,C4REAL100(+150),Fix0); break; }
// Else
else if (pPhysical->CanScale)
{ ObjectActionScale(this,DIR_Left); return; }
else if (ObjectActionScale(this,DIR_Left)) return;
break;
case DFA_WALK:
// Walk: Try scale, else stop
if (ComDirLike(Action.ComDir, COMD_Left))
{
if (pPhysical->CanScale)
{ ObjectActionScale(this,DIR_Left); return; }
if (ObjectActionScale(this,DIR_Left)) return;
// Else stop
Action.ComDir=COMD_Stop;
}
@ -3644,16 +3631,14 @@ void C4Object::ContactAction()
case DFA_SWIM:
// Try scale
if (ComDirLike(Action.ComDir, COMD_Left))
if (pPhysical->CanScale)
{ ObjectActionScale(this,DIR_Left); return; }
if (ObjectActionScale(this,DIR_Left)) return;
// Try corner scale out
if (ObjectActionCornerScale(this)) return;
return;
case DFA_HANGLE:
// Hangle: Try scale, else stop
if (pPhysical->CanScale)
if (ObjectActionScale(this,DIR_Left))
return;
if (ObjectActionScale(this,DIR_Left))
return;
Action.ComDir=COMD_Stop;
return;
case DFA_DIG:
@ -3673,15 +3658,13 @@ void C4Object::ContactAction()
if ((OCF & OCF_HitSpeed3) || fDisabled)
{ ObjectActionTumble(this,DIR_Right,C4REAL100(-150),Fix0); break; }
// Else Scale
else if (pPhysical->CanScale)
{ ObjectActionScale(this,DIR_Right); return; }
else if (ObjectActionScale(this,DIR_Right)) return;
break;
case DFA_WALK:
// Walk: Try scale, else stop
if (ComDirLike(Action.ComDir, COMD_Right))
{
if (pPhysical->CanScale)
{ ObjectActionScale(this,DIR_Right); return; }
if (ObjectActionScale(this,DIR_Right)) return;
Action.ComDir=COMD_Stop;
}
// Heading away from solid
@ -3694,17 +3677,15 @@ void C4Object::ContactAction()
case DFA_SWIM:
// Try scale
if (ComDirLike(Action.ComDir, COMD_Right))
if (pPhysical->CanScale)
{ ObjectActionScale(this,DIR_Right); return; }
if (ObjectActionScale(this,DIR_Right)) return;
// Try corner scale out
if (ObjectActionCornerScale(this)) return;
// Skip to enable walk out
return;
case DFA_HANGLE:
// Hangle: Try scale, else stop
if (pPhysical->CanScale)
if (ObjectActionScale(this,DIR_Right))
return;
if (ObjectActionScale(this,DIR_Right))
return;
Action.ComDir=COMD_Stop;
return;
case DFA_DIG:

View File

@ -369,7 +369,7 @@ bool ObjectComUp(C4Object *cObj) // by DFA_WALK or DFA_SWIM
bool ObjectComDig(C4Object *cObj) // by DFA_WALK
{
C4PhysicalInfo *phys=cObj->GetPhysical();
if (!phys->CanDig || !ObjectActionDig(cObj))
if (!ObjectActionDig(cObj))
{
GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_NODIG"),cObj->GetName()).getData(),cObj);
return false;
@ -399,12 +399,6 @@ bool ObjectComLineConstruction(C4Object *cObj)
ObjectActionStand(cObj);
// Check physical
if (!cObj->GetPhysical()->CanConstruct)
{
GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_NOLINECONSTRUCT"),cObj->GetName()).getData(),cObj); return false;
}
// - - - - - - - - - - - - - - - - - - Line pickup - - - - - - - - - - - - - - - - -
// Check for linekit
@ -564,23 +558,21 @@ void ObjectComDigDouble(C4Object *cObj) // "Activation" by DFA_WALK, DFA_DIG, DF
// Chop
ocf=OCF_Chop;
if (phys->CanChop)
if (cObj->GetProcedure()!=DFA_SWIM)
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
if (ocf & OCF_Chop)
{
PlayerObjectCommand(cObj->Owner,C4CMD_Chop,pTarget);
return;
}
if (cObj->GetProcedure()!=DFA_SWIM)
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
if (ocf & OCF_Chop)
{
PlayerObjectCommand(cObj->Owner,C4CMD_Chop,pTarget);
return;
}
// Line construction pick up
ocf=OCF_LineConstruct;
if (phys->CanConstruct)
if (!cObj->Contents.GetObject())
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
if (ocf & OCF_LineConstruct)
if (ObjectComLineConstruction(cObj))
return;
if (!cObj->Contents.GetObject())
if ((pTarget=::Objects.AtObject(cObj->GetX(),cObj->GetY(),ocf,cObj)))
if (ocf & OCF_LineConstruct)
if (ObjectComLineConstruction(cObj))
return;
// Own activation call
if (!! cObj->Call(PSF_Activate, &C4AulParSet(C4VObj(cObj)))) return;
@ -690,11 +682,6 @@ bool ObjectComDrop(C4Object *cObj, C4Object *pThing)
bool ObjectComChop(C4Object *cObj, C4Object *pTarget)
{
if (!pTarget) return false;
if (!cObj->GetPhysical()->CanChop)
{
GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_NOCHOP"),cObj->GetName()).getData(),cObj);
return false;
}
if (cObj->GetProcedure()!=DFA_WALK) return false;
return ObjectActionChop(cObj,pTarget);
}