Npcs and mobs climb in stairs too

feature/colissions-stairs
Nuno 3 years ago
parent 8ea4ff53cb
commit f0b74071ad

@ -1676,7 +1676,7 @@ void CMoveContainer::reaction (const CCollisionOTInfo& first)
CVectorD first_pos = dynInfo->getFirstPrimitive()->getFinalPosition(dynInfo->getFirstWorldImage());
CVectorD second_pos = dynInfo->getSecondPrimitive()->getFinalPosition(dynInfo->getSecondWorldImage());
nlinfo("P = %f, C = %f, H = %f, D = %f", first_pos.z, second_pos.z, dynInfo->getSecondPrimitive()->getHeight(), second_pos.z-first_pos.z);
dynInfo->getFirstPrimitive()->setZOffset(second_pos.z+dynInfo->getSecondPrimitive()->getHeight()-1.0f);
dynInfo->getFirstPrimitive()->setZOffset(second_pos.z+dynInfo->getSecondPrimitive()->getHeight()-10.0f);
}
}
if (dynInfo->isExit())

@ -426,7 +426,7 @@ void CCharacterCL::computePrimitive()
// Initialize the primitive.
if (_Sheet)
{
initPrimitive(_Sheet->ColRadius*getScale(), _Sheet->ColHeight*getScale(), _Sheet->ColLength, _Sheet->ColWidth, UMovePrimitive::DoNothing, UMovePrimitive::NotATrigger, MaskColNpc, MaskColNone, _Sheet->ClipRadius, _Sheet->ClipHeight);
initPrimitive(_Sheet->ColRadius*getScale(), _Sheet->ColHeight*getScale(), _Sheet->ColLength, _Sheet->ColWidth, UMovePrimitive::DoNothing, (UMovePrimitive::TTrigger)(UMovePrimitive::OverlapTrigger | UMovePrimitive::EnterTrigger), MaskColNpc, MaskColDoor, _Sheet->ClipRadius, _Sheet->ClipHeight);
}
else
{
@ -976,7 +976,7 @@ bool CCharacterCL::build(const CEntitySheet *sheet) // virtual
_CustomScalePos *= getScale();
// Create PACS Primitive.
initPrimitive(_Sheet->ColRadius*getScale(), _Sheet->ColHeight*getScale(), _Sheet->ColLength, _Sheet->ColWidth, UMovePrimitive::DoNothing, UMovePrimitive::NotATrigger, MaskColNpc, MaskColNone, _Sheet->ClipRadius, _Sheet->ClipHeight);
initPrimitive(_Sheet->ColRadius*getScale(), _Sheet->ColHeight*getScale(), _Sheet->ColLength, _Sheet->ColWidth, UMovePrimitive::DoNothing, (UMovePrimitive::TTrigger)(UMovePrimitive::OverlapTrigger | UMovePrimitive::EnterTrigger), MaskColNpc, MaskColDoor, _Sheet->ClipRadius, _Sheet->ClipHeight);
// Compute the element to be able to snap the entity to the ground.
computeCollisionEntity();
@ -6678,7 +6678,7 @@ ADD_METHOD(void CCharacterCL::updatePos(const TTime &currentTimeInMs, CEntityCL
updatePosCombatFloat(frameTimeRemaining, target);
}
// Compute the average speed to the destination.
// double spd =
// double spd =
computeSpeed();
@ -8232,14 +8232,14 @@ float CCharacterCL::getSheetScale() const // virtual
// getColRadius :
// Return the entity collision radius. (return 0.5 if there is any problem).
//---------------------------------------------------
float CCharacterCL::getSheetColRadius() const
float CCharacterCL::getSheetColRadius() const
{
if(!_Sheet)
if(!_Sheet)
return 0.5f;
else
return _Sheet->ColRadius;
}
//---------------------------------------------------
// getScale :
@ -8358,7 +8358,7 @@ std::string CCharacterCL::shapeFromItem(const CItemSheet &itemSheet) const
sheet = itemSheet.getShape();
return sheet;
}// shapeFromItem //
@ -9146,7 +9146,7 @@ void CCharacterCL::setAuraFX(uint index, const CAnimationFX *sheet)
bi.DelayBeforeStart = 11.5f;
_AttachedFXListToStart.push_front(bi);
}
else
else
{
CAttachedFX::TSmartPtr fx = new CAttachedFX;
fx->create(*this, bi, CAttachedFX::CTargeterInfo());

@ -945,6 +945,8 @@ bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const
float height = primitive->getHeight();
CVector size = CVector(width, depth, height);
if (primitive->getTriggerType() == UMovePrimitive::OverlapStairsTrigger)
size.z -= 10.0f;
float v;
if (getRelativeFloatFromString(values[i], v))
{
@ -954,6 +956,8 @@ bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const
{
updateVector(param, size, v, false);
}
if (primitive->getTriggerType() == UMovePrimitive::OverlapStairsTrigger)
size.z += 10.0f;
primitive->setSize(size.x, size.y);
primitive->setHeight(size.z);
}
@ -1028,12 +1032,12 @@ bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const
{
bool active;
fromString(values[i], active);
primitive->setObstacle(active);
primitive->setObstacle(!active);
if (active)
{
primitive->setReactionType(UMovePrimitive::DoNothing);
primitive->setTriggerType(UMovePrimitive::OverlapStairsTrigger);
primitive->setGlobalPosition(instance.getPos()+CVector(0, 0, 0.5f), dynamicWI);
primitive->setGlobalPosition(instance.getPos(), dynamicWI);
}
else
{

@ -3080,9 +3080,9 @@ void displayPACSPrimitive()
// Static collision
if (prim->getTriggerType() == UMovePrimitive::OverlapStairsTrigger)
{
line.Color0 = CRGBA::Blue;
line.Color0 = CRGBA::Green;
isStairs = true;
position.z -= 1.0f;
position.z -= 10.0f;
}
else if (prim->getReactionType() == UMovePrimitive::DoNothing)
{

Loading…
Cancel
Save