Fixing anim bugs, fixing car movement
This commit is contained in:
parent
582b9170db
commit
d7f4b0c773
21
ai.cpp
21
ai.cpp
@ -40,14 +40,21 @@ namespace OpenGTA {
|
|||||||
ped->m_control.setTurnRight(false);
|
ped->m_control.setTurnRight(false);
|
||||||
//INFO << ped->rot + a << std::endl;
|
//INFO << ped->rot + a << std::endl;
|
||||||
if (fabs(ped->rot - da) > 5) {
|
if (fabs(ped->rot - da) > 5) {
|
||||||
if (a > 0)
|
if (a > 0)
|
||||||
ped->m_control.setTurnLeft(true);
|
{
|
||||||
else
|
ped->m_control.setTurnLeft(true);
|
||||||
ped->m_control.setTurnRight(true);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ped->m_control.setTurnRight(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (fabs(ped->rot - da) < 120 && d > 0.19f)
|
if (fabs(ped->rot - da) < 120 && d > 0.25f)
|
||||||
ped->m_control.setMoveForward(true);
|
{
|
||||||
if (d <= 0.19f)
|
ped->m_control.setMoveForward(true);
|
||||||
|
}
|
||||||
|
//if (d <= 0.19f)
|
||||||
|
if (d <= 0.25f)
|
||||||
{
|
{
|
||||||
ped->m_control.setTurnLeft(false);
|
ped->m_control.setTurnLeft(false);
|
||||||
ped->m_control.setTurnRight(false);
|
ped->m_control.setTurnRight(false);
|
||||||
|
@ -223,9 +223,14 @@ activeWeapon = chooseWeapon;
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
/*
|
if (aimCarId == 0)
|
||||||
if (!(animId == 1u + activeWeapon*3))
|
{
|
||||||
switchToAnim(1 + activeWeapon*3);*/
|
|
||||||
|
if (!(animId == 1u + activeWeapon * 3))
|
||||||
|
{
|
||||||
|
switchToAnim(1 + activeWeapon * 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
if (!(animId == 2u + activeWeapon*3)) {
|
if (!(animId == 2u + activeWeapon*3)) {
|
||||||
@ -735,6 +740,12 @@ activeWeapon = chooseWeapon;
|
|||||||
//m_M.RotZ(rot+90);
|
//m_M.RotZ(rot+90);
|
||||||
CarSprite::update(ticks);
|
CarSprite::update(ticks);
|
||||||
|
|
||||||
|
if (lastUpdateAt == 0) //skip first frame
|
||||||
|
{
|
||||||
|
lastUpdateAt = ticks;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const float velocityRotateK = 100.0;
|
static const float velocityRotateK = 100.0;
|
||||||
@ -799,23 +810,35 @@ activeWeapon = chooseWeapon;
|
|||||||
|
|
||||||
tryMove(pos + moveDelta);
|
tryMove(pos + moveDelta);
|
||||||
|
|
||||||
/*
|
|
||||||
if (!inGroundContact) {
|
if (!inGroundContact) {
|
||||||
speedForces.y += 0.0005f *delta;
|
gravitySpeed += 0.0005f *delta;
|
||||||
pos.y -= speedForces.y;
|
pos.y -= gravitySpeed;
|
||||||
if (speedForces.y < 0.2f)
|
if (gravitySpeed < 0.2f)
|
||||||
INFO << "bridge step? height: " << pos.y << " speed: " << speedForces.y << std::endl;
|
INFO << "bridge step? height: " << pos.y << " speed: " << gravitySpeed << std::endl;
|
||||||
else
|
else
|
||||||
INFO << "FALLING " << pos.y << " speed " << speedForces.y << std::endl;
|
INFO << "FALLING " << pos.y << " speed " << gravitySpeed << std::endl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (speedForces.y > 0.1)
|
if (gravitySpeed > 0.1)
|
||||||
INFO << "impacting with speed: " << speedForces.y << std::endl;
|
INFO << "impacting with speed: " << gravitySpeed << std::endl;
|
||||||
speedForces.y = 0.0f;
|
gravitySpeed = 0.0f;
|
||||||
}*/
|
}
|
||||||
m_M = TranslateMatrix3D(pos);
|
m_M = TranslateMatrix3D(pos);
|
||||||
|
|
||||||
m_M.RotZ(rot);
|
m_M.RotZ(rot);
|
||||||
|
|
||||||
|
|
||||||
|
if (id() == OpenGTA::LocalPlayer::Instance().playerCarId)
|
||||||
|
{
|
||||||
|
OpenGL::Camera & cam = OpenGL::CameraHolder::Instance();
|
||||||
|
|
||||||
|
static const float camVelocityK = 300.0;
|
||||||
|
|
||||||
|
cam.getEye().y = 10 + velocity*camVelocityK;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//INFO << pos.x << " " << pos.y << " " << pos.z << std::endl;*/
|
//INFO << pos.x << " " << pos.y << " " << pos.z << std::endl;*/
|
||||||
lastUpdateAt = ticks;
|
lastUpdateAt = ticks;
|
||||||
@ -830,28 +853,25 @@ activeWeapon = chooseWeapon;
|
|||||||
OpenGTA::GraphicsBase & graphics = OpenGTA::StyleHolder::Instance().get();
|
OpenGTA::GraphicsBase & graphics = OpenGTA::StyleHolder::Instance().get();
|
||||||
|
|
||||||
|
|
||||||
int inGroundContact = 1;
|
|
||||||
|
|
||||||
//INFO << heightOverTerrain(nPos) << std::endl;
|
//INFO << heightOverTerrain(nPos) << std::endl;
|
||||||
|
|
||||||
/*
|
|
||||||
float hot = heightOverTerrain(nPos);
|
float hot = heightOverTerrain(nPos);
|
||||||
if (hot > 0.3f)
|
if (hot > 0.3f)
|
||||||
|
{
|
||||||
inGroundContact = 0;
|
inGroundContact = 0;
|
||||||
|
}
|
||||||
else if (hot < 0.0) {
|
else if (hot < 0.0) {
|
||||||
WARN << "gone below: " << hot << " at " << nPos.x << ", " << nPos.y << ", " << nPos.z << std::endl;
|
WARN << "gone below: " << hot << " at " << nPos.x << ", " << nPos.y << ", " << nPos.z << std::endl;
|
||||||
nPos.y -= (hot - 0.3f);
|
nPos.y -= (hot - 0.3f);
|
||||||
//nPos.y += 1;
|
|
||||||
//INFO << nPos.y << std::endl;
|
|
||||||
inGroundContact = 1;
|
inGroundContact = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
inGroundContact = 1;
|
inGroundContact = 1;
|
||||||
if (isDead)
|
|
||||||
nPos.y -= hot - 0.05f;
|
nPos.y -= hot - 0.1f;
|
||||||
else
|
}
|
||||||
nPos.y -= hot - 0.1f;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
if (y < map.getNumBlocksAtNew(PHYSFS_uint8(x), PHYSFS_uint8(z)) && y > 0.0f) {
|
if (y < map.getNumBlocksAtNew(PHYSFS_uint8(x), PHYSFS_uint8(z)) && y > 0.0f) {
|
||||||
@ -983,8 +1003,10 @@ activeWeapon = chooseWeapon;
|
|||||||
obj_blocked = true;
|
obj_blocked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((inGroundContact) && (obj_blocked == false))
|
if (/*(inGroundContact) && */(obj_blocked == false))
|
||||||
|
{
|
||||||
pos = nPos;
|
pos = nPos;
|
||||||
|
}
|
||||||
//else
|
//else
|
||||||
// inGroundContact = 0;
|
// inGroundContact = 0;
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ namespace OpenGTA {
|
|||||||
GraphicsBase::CarInfo & carInfo;
|
GraphicsBase::CarInfo & carInfo;
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
void update(Uint32 ticks);
|
void update(Uint32 ticks);
|
||||||
Uint32 lastUpdateAt;
|
Uint32 lastUpdateAt = 0;
|
||||||
void damageAt(const Vector3D & hit, uint32_t dmg);
|
void damageAt(const Vector3D & hit, uint32_t dmg);
|
||||||
void explode();
|
void explode();
|
||||||
|
|
||||||
@ -166,6 +166,8 @@ namespace OpenGTA {
|
|||||||
Vector3D moveDelta = Vector3D(0, 0, 0);
|
Vector3D moveDelta = Vector3D(0, 0, 0);
|
||||||
//Vector3D velocity = Vector3D(0, 0, 0);
|
//Vector3D velocity = Vector3D(0, 0, 0);
|
||||||
float velocity = 0;
|
float velocity = 0;
|
||||||
|
float gravitySpeed = 0;
|
||||||
|
int inGroundContact = 0;
|
||||||
private:
|
private:
|
||||||
void fixSpriteType();
|
void fixSpriteType();
|
||||||
int32_t hitPoints;
|
int32_t hitPoints;
|
||||||
|
@ -614,7 +614,7 @@ void create_car_at(const Vector3D v) {
|
|||||||
|
|
||||||
//Car(const Vector3D & _pos, float _rot, uint32_t id, uint8_t _type, int16_t _remap = -1);
|
//Car(const Vector3D & _pos, float _rot, uint32_t id, uint8_t _type, int16_t _remap = -1);
|
||||||
//OpenGTA::Car c2(Vector3D(7.25000000, 2.06562519, 90.2031250), 180, 999999, 18, 0);
|
//OpenGTA::Car c2(Vector3D(7.25000000, 2.06562519, 90.2031250), 180, 999999, 18, 0);
|
||||||
OpenGTA::Car c2(Vector3D(v.x, 2.06562519, v.z), 180, 999999, 18, 0);
|
OpenGTA::Car c2(Vector3D(v.x, v.y, v.z), 180, 999999, 18, 0);
|
||||||
|
|
||||||
OpenGTA::SpriteManagerHolder::Instance().add(c2);
|
OpenGTA::SpriteManagerHolder::Instance().add(c2);
|
||||||
}
|
}
|
||||||
@ -947,6 +947,7 @@ void handleKeyPress( SDL_Keysym *keysym ) {
|
|||||||
|
|
||||||
OpenGTA::Pedestrian & pped = OpenGTA::LocalPlayer::Instance().getPed();
|
OpenGTA::Pedestrian & pped = OpenGTA::LocalPlayer::Instance().getPed();
|
||||||
pped.aiMode = 0;
|
pped.aiMode = 0;
|
||||||
|
pped.aimCarId = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -957,6 +958,7 @@ void handleKeyPress( SDL_Keysym *keysym ) {
|
|||||||
{
|
{
|
||||||
OpenGTA::Pedestrian & pped = OpenGTA::LocalPlayer::Instance().getPed();
|
OpenGTA::Pedestrian & pped = OpenGTA::LocalPlayer::Instance().getPed();
|
||||||
pped.aiMode = 0;
|
pped.aiMode = 0;
|
||||||
|
pped.aimCarId = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -967,6 +969,7 @@ void handleKeyPress( SDL_Keysym *keysym ) {
|
|||||||
{
|
{
|
||||||
OpenGTA::Pedestrian & pped = OpenGTA::LocalPlayer::Instance().getPed();
|
OpenGTA::Pedestrian & pped = OpenGTA::LocalPlayer::Instance().getPed();
|
||||||
pped.aiMode = 0;
|
pped.aiMode = 0;
|
||||||
|
pped.aimCarId = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -977,6 +980,7 @@ void handleKeyPress( SDL_Keysym *keysym ) {
|
|||||||
{
|
{
|
||||||
OpenGTA::Pedestrian & pped = OpenGTA::LocalPlayer::Instance().getPed();
|
OpenGTA::Pedestrian & pped = OpenGTA::LocalPlayer::Instance().getPed();
|
||||||
pped.aiMode = 0;
|
pped.aiMode = 0;
|
||||||
|
pped.aimCarId = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user