Cars available!
This commit is contained in:
parent
b4e5d2a104
commit
582b9170db
17
ai.cpp
Normal file → Executable file
17
ai.cpp
Normal file → Executable file
@ -5,6 +5,9 @@
|
||||
#include "cell_iterator.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
#include "spritemanager.h"
|
||||
|
||||
namespace OpenGTA {
|
||||
namespace AI {
|
||||
namespace Pedestrian {
|
||||
@ -44,8 +47,18 @@ namespace OpenGTA {
|
||||
}
|
||||
if (fabs(ped->rot - da) < 120 && d > 0.19f)
|
||||
ped->m_control.setMoveForward(true);
|
||||
if (d <= 0.19f)
|
||||
ped->aiMode = 0;
|
||||
if (d <= 0.19f)
|
||||
{
|
||||
ped->m_control.setTurnLeft(false);
|
||||
ped->m_control.setTurnRight(false);
|
||||
ped->aiMode = 0;
|
||||
|
||||
if (ped->aimCarId != 0)
|
||||
{
|
||||
OpenGTA::SpriteManagerHolder::Instance().getPedById(0xffffffff).getInCar();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
309
game_objects.cpp
309
game_objects.cpp
@ -31,6 +31,7 @@
|
||||
#include <functional>
|
||||
#include "log.h"
|
||||
|
||||
#include "gl_camera.h"
|
||||
|
||||
#define INT2FLOAT_WRLD(c) (float(c >> 6) + float(c % 64) / 64.0f)
|
||||
#define INT2F_DIV64(v) (float(v) / 64.0f)
|
||||
@ -192,9 +193,9 @@ namespace OpenGTA {
|
||||
|
||||
|
||||
//Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com
|
||||
/*if (aiMode) {
|
||||
if (aiMode) {
|
||||
AI::Pedestrian::moveto_shortrange(this);
|
||||
}*/
|
||||
}
|
||||
uint8_t chooseWeapon = m_control.getActiveWeapon();
|
||||
if (chooseWeapon != activeWeapon) {
|
||||
if (chooseWeapon == 0) {
|
||||
@ -222,8 +223,9 @@ activeWeapon = chooseWeapon;
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
/*
|
||||
if (!(animId == 1u + activeWeapon*3))
|
||||
switchToAnim(1 + activeWeapon*3);
|
||||
switchToAnim(1 + activeWeapon*3);*/
|
||||
break;
|
||||
case -1:
|
||||
if (!(animId == 2u + activeWeapon*3)) {
|
||||
@ -293,11 +295,6 @@ activeWeapon = chooseWeapon;
|
||||
SpriteManagerHolder::Instance().createProjectile(0, rot, pos, d1, ticks, pedId);
|
||||
lastWeaponTick = ticks;
|
||||
}
|
||||
/*
|
||||
if (m_control.statusChanged()) {
|
||||
INFO << "Ped-event id: " << pedId << " control: " << m_control.getRaw() <<
|
||||
" time: " << ticks << std::endl;
|
||||
}*/
|
||||
|
||||
//INFO << pos.x << " " << pos.y << " " << pos.z << std::endl;
|
||||
lastUpdateAt = ticks;
|
||||
@ -476,6 +473,46 @@ activeWeapon = chooseWeapon;
|
||||
isDead++;
|
||||
}
|
||||
|
||||
void Pedestrian::getInCar()
|
||||
{
|
||||
switchToAnim(OpenGTA::CONST_ANIM_CAR_ENTER);
|
||||
|
||||
anim.set(Util::Animation::PLAY_FORWARD, Util::Animation::FCALLBACK);
|
||||
|
||||
OpenGTA::SpriteManagerHolder::Instance().getCar(aimCarId).openDoor(0);
|
||||
|
||||
std::function<void()> cmd = [this]() {
|
||||
|
||||
using namespace OpenGTA;
|
||||
OpenGL::Camera & cam = OpenGL::CameraHolder::Instance();
|
||||
|
||||
auto& car = OpenGTA::SpriteManagerHolder::Instance().getCar(this->aimCarId);
|
||||
car.closeDoor(0);
|
||||
|
||||
/*
|
||||
cam.setVectors(cam.getEye(),
|
||||
Vector3D(cam.getEye() + Vector3D(1, -1, 1)), Vector3D(0, 1, 0));
|
||||
cam.setCamGravity(false);
|
||||
cam.releaseFollowMode();
|
||||
*/
|
||||
//GUI::remove_ingame_gui();
|
||||
|
||||
|
||||
OpenGTA::LocalPlayer::Instance().setCtrl(car.m_control);
|
||||
OpenGTA::SpriteManagerHolder::Instance().removePedById(0xffffffff);
|
||||
|
||||
cam.setVectors(Vector3D(car.pos.x, 10, car.pos.z), Vector3D(car.pos.x, 9.0f, car.pos.z), Vector3D(0, 0, -1));
|
||||
cam.setFollowMode(OpenGTA::SpriteManagerHolder::Instance().getCar(car.id()).pos);
|
||||
cam.setCamGravity(true);
|
||||
|
||||
OpenGTA::LocalPlayer::Instance().playerCarId = car.id();
|
||||
|
||||
};
|
||||
|
||||
anim.setCallback(cmd);
|
||||
|
||||
}
|
||||
|
||||
void Pedestrian::getShot(uint32_t shooterId, uint32_t dmg, bool front) {
|
||||
isDead = 1;
|
||||
switchToAnim(45);
|
||||
@ -630,7 +667,7 @@ activeWeapon = chooseWeapon;
|
||||
}
|
||||
}
|
||||
|
||||
Car::Car(Vector3D & _pos, float _rot, uint32_t id, uint8_t _type, int16_t _remap) :
|
||||
Car::Car(const Vector3D & _pos, float _rot, uint32_t id, uint8_t _type, int16_t _remap) :
|
||||
GameObject_common(_pos, _rot),
|
||||
CarSprite(0, -1, GraphicsBase::SpriteNumbers::CAR), OBox(),
|
||||
carInfo(*StyleHolder::Instance().get().findCarByModel(_type)) {
|
||||
@ -697,6 +734,260 @@ activeWeapon = chooseWeapon;
|
||||
//m_M = TranslateMatrix3D(pos);
|
||||
//m_M.RotZ(rot+90);
|
||||
CarSprite::update(ticks);
|
||||
|
||||
|
||||
|
||||
static const float velocityRotateK = 100.0;
|
||||
|
||||
|
||||
Uint32 delta = ticks - lastUpdateAt;
|
||||
//INFO << "delta = " << delta << " t: " << ticks << " lt: " << lastUpdateAt << std::endl;
|
||||
moveDelta = Vector3D(0, 0, 0);
|
||||
|
||||
|
||||
switch(m_control.getTurn()) {
|
||||
case -1:
|
||||
rot -= 0.2f * delta * velocity * velocityRotateK;
|
||||
break;
|
||||
case 1:
|
||||
rot += 0.2f * delta * velocity * velocityRotateK;
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
if (rot >= 360.0f)
|
||||
rot -= 360.0f;
|
||||
if (rot < 0.0f)
|
||||
rot += 360.0f;
|
||||
|
||||
static const float accelerationK = 0.00002;
|
||||
|
||||
static const float slowK = 0.1;
|
||||
|
||||
|
||||
|
||||
switch(m_control.getMove()) {
|
||||
case -1:
|
||||
velocity -= accelerationK * delta;
|
||||
/*
|
||||
velocity += accelerationK * delta;
|
||||
velocity += -slowK * velocity;
|
||||
moveDelta.x -= sin(rot * M_PI / 180.0f) * velocity * delta;
|
||||
moveDelta.z -= cos(rot * M_PI / 180.0f) * velocity * delta;*/
|
||||
break;
|
||||
case 1:
|
||||
velocity += accelerationK * delta;
|
||||
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
|
||||
auto oldVelocity = velocity;
|
||||
|
||||
velocity += -slowK * velocity;
|
||||
|
||||
if (oldVelocity*velocity < 0)
|
||||
{
|
||||
velocity = 0;
|
||||
}
|
||||
|
||||
moveDelta.x += sin(rot * M_PI / 180.0f) * velocity * delta;
|
||||
moveDelta.z += cos(rot * M_PI / 180.0f) * velocity * delta;
|
||||
|
||||
tryMove(pos + moveDelta);
|
||||
|
||||
/*
|
||||
if (!inGroundContact) {
|
||||
speedForces.y += 0.0005f *delta;
|
||||
pos.y -= speedForces.y;
|
||||
if (speedForces.y < 0.2f)
|
||||
INFO << "bridge step? height: " << pos.y << " speed: " << speedForces.y << std::endl;
|
||||
else
|
||||
INFO << "FALLING " << pos.y << " speed " << speedForces.y << std::endl;
|
||||
}
|
||||
else {
|
||||
if (speedForces.y > 0.1)
|
||||
INFO << "impacting with speed: " << speedForces.y << std::endl;
|
||||
speedForces.y = 0.0f;
|
||||
}*/
|
||||
m_M = TranslateMatrix3D(pos);
|
||||
|
||||
m_M.RotZ(rot);
|
||||
|
||||
//INFO << pos.x << " " << pos.y << " " << pos.z << std::endl;*/
|
||||
lastUpdateAt = ticks;
|
||||
}
|
||||
|
||||
void Car::tryMove(Vector3D nPos) {
|
||||
float x, y, z;
|
||||
x = floor(nPos.x);
|
||||
y = floor(nPos.y);
|
||||
z = floor(nPos.z);
|
||||
OpenGTA::Map & map = OpenGTA::MapHolder::Instance().get();
|
||||
OpenGTA::GraphicsBase & graphics = OpenGTA::StyleHolder::Instance().get();
|
||||
|
||||
|
||||
int inGroundContact = 1;
|
||||
|
||||
//INFO << heightOverTerrain(nPos) << std::endl;
|
||||
|
||||
/*
|
||||
float hot = heightOverTerrain(nPos);
|
||||
if (hot > 0.3f)
|
||||
inGroundContact = 0;
|
||||
else if (hot < 0.0) {
|
||||
WARN << "gone below: " << hot << " at " << nPos.x << ", " << nPos.y << ", " << nPos.z << std::endl;
|
||||
nPos.y -= (hot - 0.3f);
|
||||
//nPos.y += 1;
|
||||
//INFO << nPos.y << std::endl;
|
||||
inGroundContact = 1;
|
||||
}
|
||||
else {
|
||||
inGroundContact = 1;
|
||||
if (isDead)
|
||||
nPos.y -= hot - 0.05f;
|
||||
else
|
||||
nPos.y -= hot - 0.1f;
|
||||
}*/
|
||||
|
||||
|
||||
if (y < map.getNumBlocksAtNew(PHYSFS_uint8(x), PHYSFS_uint8(z)) && y > 0.0f) {
|
||||
OpenGTA::Map::BlockInfo * block = map.getBlockAtNew(PHYSFS_uint8(x), PHYSFS_uint8(z), PHYSFS_uint8(y));
|
||||
assert(block);
|
||||
if (block->left && graphics.isBlockingSide(block->left)) {
|
||||
if (block->isFlat()) {
|
||||
if (x - pos.x < 0 && x - pos.x > -0.2f) {
|
||||
nPos.x = (nPos.x < pos.x) ? pos.x : nPos.x;
|
||||
}
|
||||
else if (x - pos.x > 0 && x - pos.x < 0.2f)
|
||||
{
|
||||
nPos.x = pos.x;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
#ifdef DEBUG_OLD_PED_BLOCK
|
||||
INFO << "xblock left: " << x - pos.x << " tex: " << int(block->left) << std::endl;
|
||||
#endif
|
||||
if (x - pos.x > 0 && x - pos.x < 0.2f)
|
||||
nPos.x = pos.x;
|
||||
else if (x - pos.x < 0 && x - pos.x > -0.2f)
|
||||
nPos.x = (nPos.x < pos.x) ? pos.x : nPos.x;
|
||||
}
|
||||
}
|
||||
if (block->right && block->isFlat() == false) {
|
||||
#ifdef DEBUG_OLD_PED_BLOCK
|
||||
INFO << "xblock right: " << pos.x - x - 1 << " tex: " << int(block->right) << std::endl;
|
||||
#endif
|
||||
if (pos.x - x - 1 > 0 && pos.x - x - 1 < 0.2f) {
|
||||
nPos.x = pos.x;
|
||||
}
|
||||
else if (pos.x - x - 1 < 0 && pos.x - x - 1 > -0.2f)
|
||||
nPos.x = (nPos.x > pos.x) ? pos.x : nPos.x;
|
||||
}
|
||||
if (block->top && graphics.isBlockingSide(block->top)) {
|
||||
if (block->isFlat()) {
|
||||
#ifdef DEBUG_OLD_PED_BLOCK
|
||||
INFO << "zblock top: " << z - pos.z << " tex: " << int(block->top) << std::endl;
|
||||
#endif
|
||||
if (z - pos.z > 0 && z - pos.z < 0.2f)
|
||||
nPos.z = pos.z;
|
||||
else if (z - pos.z < 0 && z - pos.z > -0.2f)
|
||||
nPos.z = (nPos.z < pos.z) ? pos.z : nPos.z;
|
||||
}
|
||||
else {
|
||||
#ifdef DEBUG_OLD_PED_BLOCK
|
||||
INFO << "zblock top: " << z - pos.z << " tex: " << int(block->top) << std::endl;
|
||||
#endif
|
||||
if (z - pos.z > 0 && z - pos.z < 0.2f)
|
||||
nPos.z = pos.z;
|
||||
else if (z - pos.z < 0 && z - pos.z > -0.2f)
|
||||
nPos.z = (nPos.z < pos.z) ? pos.z : nPos.z;
|
||||
}
|
||||
}
|
||||
if (block->bottom && block->isFlat() == false) {
|
||||
#ifdef DEBUG_OLD_PED_BLOCK
|
||||
INFO << "zblock bottom: " << pos.z - z - 1 << " tex: " << int(block->bottom) << std::endl;
|
||||
#endif
|
||||
if (pos.z - z - 1 > 0 && pos.z - z - 1 < 0.2f) {
|
||||
nPos.z = pos.z;
|
||||
}
|
||||
else if (pos.z - z - 1 < 0 && pos.z - z - 1 > -0.2f)
|
||||
nPos.z = (nPos.z > pos.z) ? pos.z : nPos.z;
|
||||
}
|
||||
if (x >= 1 && y < map.getNumBlocksAtNew(PHYSFS_uint8(x - 1), PHYSFS_uint8(z))) {
|
||||
block = map.getBlockAtNew(PHYSFS_uint8(x - 1), PHYSFS_uint8(z), PHYSFS_uint8(y));
|
||||
if (block->right && block->isFlat() == false) {
|
||||
#ifdef DEBUG_OLD_PED_BLOCK
|
||||
INFO << "xblock right: " << pos.x - x << " tex: " << int(block->right) << std::endl;
|
||||
#endif
|
||||
if (pos.x - x < 0.2f) {
|
||||
nPos.x = (nPos.x < pos.x ? pos.x : nPos.x);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (x < 255 && y < map.getNumBlocksAtNew(PHYSFS_uint8(x + 1), PHYSFS_uint8(z))) {
|
||||
block = map.getBlockAtNew(PHYSFS_uint8(x + 1), PHYSFS_uint8(z), PHYSFS_uint8(y));
|
||||
if (block->left && graphics.isBlockingSide(block->left)) {
|
||||
#ifdef DEBUG_OLD_PED_BLOCK
|
||||
INFO << "xblock left: " << x + 1 - pos.x << " tex: " << int(block->left) << std::endl;
|
||||
#endif
|
||||
if (block->isFlat()) {
|
||||
if (x + 1 - pos.x > 0 && x + 1 - pos.x < 0.2f)
|
||||
nPos.x = (nPos.x < pos.x ? nPos.x : pos.x);
|
||||
}
|
||||
else {
|
||||
if (x + 1 - pos.x < 0.2f)
|
||||
nPos.x = (nPos.x < pos.x ? nPos.x : pos.x);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (z >= 1 && y < map.getNumBlocksAtNew(PHYSFS_uint8(x), PHYSFS_uint8(z - 1))) {
|
||||
block = map.getBlockAtNew(PHYSFS_uint8(x), PHYSFS_uint8(z - 1), PHYSFS_uint8(y));
|
||||
if (block->bottom && block->isFlat() == false) {
|
||||
#ifdef DEBUG_OLD_PED_BLOCK
|
||||
INFO << "zblock bottom: " << pos.z - z << " tex: " << int(block->bottom) << std::endl;
|
||||
#endif
|
||||
if (pos.z - z < 0.2f) {
|
||||
nPos.z = (nPos.z < pos.z ? pos.z : nPos.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (z < 255 && y < map.getNumBlocksAtNew(PHYSFS_uint8(x), PHYSFS_uint8(z + 1))) {
|
||||
block = map.getBlockAtNew(PHYSFS_uint8(x), PHYSFS_uint8(z + 1), PHYSFS_uint8(y));
|
||||
if (block->top && graphics.isBlockingSide(block->top)) {
|
||||
#ifdef DEBUG_OLD_PED_BLOCK
|
||||
INFO << "zblock top: " << z + 1 - pos.z << " tex: " << int(block->top) << std::endl;
|
||||
#endif
|
||||
if (block->isFlat()) {
|
||||
if (z + 1 - pos.z > 0 && z + 1 - pos.z < 0.2f)
|
||||
nPos.z = (nPos.z < pos.z ? nPos.z : pos.z);
|
||||
}
|
||||
else {
|
||||
if (z + 1 - pos.z < 0.2f)
|
||||
nPos.z = (nPos.z < pos.z ? nPos.z : pos.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (inGroundContact)
|
||||
// pos = nPos;
|
||||
}
|
||||
bool obj_blocked = false;
|
||||
std::list<Car> & list = SpriteManagerHolder::Instance().getList<Car>();
|
||||
for (std::list<Car>::iterator i = list.begin(); i != list.end(); i++) {
|
||||
if (isBoxInBox(*i)) {
|
||||
if (Util::distance(pos, i->pos) > Util::distance(nPos, i->pos))
|
||||
obj_blocked = true;
|
||||
}
|
||||
}
|
||||
if ((inGroundContact) && (obj_blocked == false))
|
||||
pos = nPos;
|
||||
//else
|
||||
// inGroundContact = 0;
|
||||
|
||||
}
|
||||
|
||||
void Car::damageAt(const Vector3D & hit, uint32_t dmg) {
|
||||
|
@ -94,11 +94,12 @@ namespace OpenGTA {
|
||||
uint8_t isDead;
|
||||
void getShot(uint32_t shooterId, uint32_t dmg, bool front = true);
|
||||
void die();
|
||||
void getInCar();
|
||||
typedef std::map<uint8_t, uint32_t> InventoryMap;
|
||||
InventoryMap inventory;
|
||||
uint8_t activeWeapon;
|
||||
uint32_t * activeAmmo;
|
||||
uint32_t aiMode;
|
||||
uint32_t aiMode = 0;
|
||||
static uint32_t fistAmmo;
|
||||
struct AiData {
|
||||
AiData() : id1(0), id2(0), pos1() {}
|
||||
@ -109,6 +110,9 @@ namespace OpenGTA {
|
||||
};
|
||||
AiData aiData;
|
||||
Vector3D moveDelta;
|
||||
|
||||
//Xperimental -- Vladislav Khorev vladislav.khorev@fishrungames.com
|
||||
uint32_t aimCarId = 0;
|
||||
};
|
||||
|
||||
class CarSprite {
|
||||
@ -144,7 +148,7 @@ namespace OpenGTA {
|
||||
public:
|
||||
Car(const Car & o);
|
||||
Car(OpenGTA::Map::ObjectPosition&, uint32_t id);
|
||||
Car(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);
|
||||
uint32_t carId;
|
||||
inline uint32_t id() const { return carId; }
|
||||
GraphicsBase::CarInfo & carInfo;
|
||||
@ -153,9 +157,20 @@ namespace OpenGTA {
|
||||
Uint32 lastUpdateAt;
|
||||
void damageAt(const Vector3D & hit, uint32_t dmg);
|
||||
void explode();
|
||||
|
||||
|
||||
void tryMove(Vector3D nPos);
|
||||
|
||||
PedController m_control;
|
||||
|
||||
Vector3D moveDelta = Vector3D(0, 0, 0);
|
||||
//Vector3D velocity = Vector3D(0, 0, 0);
|
||||
float velocity = 0;
|
||||
private:
|
||||
void fixSpriteType();
|
||||
int32_t hitPoints;
|
||||
|
||||
|
||||
};
|
||||
|
||||
class SpriteObject : public GameObject_common, public Sprite, public OBox {
|
||||
|
4
localplayer.cpp
Normal file → Executable file
4
localplayer.cpp
Normal file → Executable file
@ -6,6 +6,10 @@ namespace OpenGTA {
|
||||
return SpriteManagerHolder::Instance().getPed(playerId);
|
||||
}
|
||||
|
||||
Car & PlayerController::getCar() {
|
||||
return SpriteManagerHolder::Instance().getCar(playerCarId);
|
||||
}
|
||||
|
||||
bool PlayerController::up(const uint32_t & key) {
|
||||
if (!pc_ptr)
|
||||
return false;
|
||||
|
@ -34,6 +34,7 @@ namespace OpenGTA {
|
||||
void disableCtrl(bool soft);
|
||||
void enableCtrl();
|
||||
Pedestrian & getPed();
|
||||
Car& getCar();
|
||||
int32_t getNumLives() { return numLives; }
|
||||
int32_t getWantedLevel() { return wantedLevel; }
|
||||
uint32_t getCash() { return cash; }
|
||||
@ -43,6 +44,9 @@ namespace OpenGTA {
|
||||
void addCash(uint32_t v) { cash += v; }
|
||||
void setWanted(int32_t v) { wantedLevel = v; }
|
||||
void addWanted(uint32_t v) { wantedLevel += v; if (wantedLevel > 5) wantedLevel = 5; }
|
||||
|
||||
|
||||
uint32_t playerCarId = 0;
|
||||
private:
|
||||
uint32_t playerId;
|
||||
uint32_t cash;
|
||||
@ -50,6 +54,8 @@ namespace OpenGTA {
|
||||
uint32_t modifier;
|
||||
int32_t numLives;
|
||||
PedController * pc_ptr;
|
||||
|
||||
|
||||
};
|
||||
|
||||
typedef Loki::SingletonHolder<PlayerController> LocalPlayer;
|
||||
|
@ -35,13 +35,13 @@ namespace OpenGTA {
|
||||
|
||||
registerAnimation(0, SpriteObject::Animation(0, 0)); // dummy
|
||||
|
||||
registerAnimation(1, SpriteObject::Animation(98, 0)); // standing still
|
||||
registerAnimation(2, SpriteObject::Animation(0, 7, 0.001f)); // walking
|
||||
registerAnimation(3, SpriteObject::Animation(8, 7, 0.0015f)); // running
|
||||
registerAnimation(CONST_ANIM_STANDING_STILL, SpriteObject::Animation(98, 0)); // standing still
|
||||
registerAnimation(CONST_ANIM_WALKING, SpriteObject::Animation(0, 7, 0.001f)); // walking
|
||||
registerAnimation(CONST_ANIM_RUNNING, SpriteObject::Animation(8, 7, 0.0015f)); // running
|
||||
|
||||
// registerAnimation(3, SpriteObject::Animation(16, 0)); // sitting in car
|
||||
// registerAnimation(4, SpriteObject::Animation(17, 7)); // car-exit
|
||||
// registerAnimation(5, SpriteObject::Animation(25, 7)); // car-enter
|
||||
registerAnimation(CONST_ANIM_SITTING_IN_CAR, SpriteObject::Animation(16, 0)); // sitting in car
|
||||
registerAnimation(CONST_ANIM_CAR_EXIT, SpriteObject::Animation(17, 7)); // car-exit
|
||||
registerAnimation(CONST_ANIM_CAR_ENTER, SpriteObject::Animation(25, 7)); // car-enter
|
||||
//registerAnimation(3, SpriteObject::Animation(107, 7, 0.002f));
|
||||
//registerAnimation(4, SpriteObject::Animation(99, 7, 0.001f));
|
||||
//registerAnimation(5, SpriteObject::Animation(28, 7));
|
||||
|
@ -34,6 +34,61 @@
|
||||
|
||||
namespace OpenGTA {
|
||||
|
||||
|
||||
constexpr Uint32 CONST_ANIM_STANDING_STILL = 1;
|
||||
|
||||
constexpr Uint32 CONST_ANIM_WALKING = 2;
|
||||
|
||||
constexpr Uint32 CONST_ANIM_RUNNING = 3;
|
||||
|
||||
constexpr Uint32 CONST_ANIM_SITTING_IN_CAR = 30;
|
||||
|
||||
constexpr Uint32 CONST_ANIM_CAR_EXIT = 31;
|
||||
|
||||
constexpr Uint32 CONST_ANIM_CAR_ENTER = 32;
|
||||
|
||||
/*
|
||||
registerAnimation(0, SpriteObject::Animation(0, 0)); // dummy
|
||||
|
||||
registerAnimation(1, SpriteObject::Animation(98, 0)); // standing still
|
||||
registerAnimation(2, SpriteObject::Animation(0, 7, 0.001f)); // walking
|
||||
registerAnimation(3, SpriteObject::Animation(8, 7, 0.0015f)); // running
|
||||
|
||||
// registerAnimation(3, SpriteObject::Animation(16, 0)); // sitting in car
|
||||
// registerAnimation(4, SpriteObject::Animation(17, 7)); // car-exit
|
||||
// registerAnimation(5, SpriteObject::Animation(25, 7)); // car-enter
|
||||
//registerAnimation(3, SpriteObject::Animation(107, 7, 0.002f));
|
||||
//registerAnimation(4, SpriteObject::Animation(99, 7, 0.001f));
|
||||
//registerAnimation(5, SpriteObject::Animation(28, 7));
|
||||
// registerAnimation(6, SpriteObject::Animation(38, 2)); // falling
|
||||
//registerAnimation(7, SpriteObject::Animation(41, 0)); // sliding under
|
||||
//registerAnimation(9, SpriteObject::Animation(44, 0)); // death-back pose
|
||||
//registerAnimation(11, SpriteObject::Animation(47, 1)); // swimming
|
||||
//registerAnimation(12, SpriteObject::Animation(98, 0)); // standing still
|
||||
|
||||
registerAnimation(4, SpriteObject::Animation(89, 0)); // standing, gun
|
||||
registerAnimation(5, SpriteObject::Animation(99, 7, 0.001f)); // walking, gun
|
||||
registerAnimation(6, SpriteObject::Animation(107, 7, 0.002f)); // running, gun
|
||||
|
||||
registerAnimation(7, SpriteObject::Animation(134, 0)); //standing, flamethrower
|
||||
registerAnimation(8, SpriteObject::Animation(118, 7, 0.001f)); // walking, flamethrower
|
||||
registerAnimation(9, SpriteObject::Animation(126, 7, 0.002f)); // running, flamethrower
|
||||
|
||||
registerAnimation(10, SpriteObject::Animation(152, 0)); //standing, uzi
|
||||
registerAnimation(11, SpriteObject::Animation(136, 7, 0.001f)); // walking, uzi
|
||||
registerAnimation(12, SpriteObject::Animation(144, 7, 0.002f)); // running, uzi
|
||||
|
||||
registerAnimation(13, SpriteObject::Animation(170, 0)); //standing, rocket-launcher
|
||||
registerAnimation(14, SpriteObject::Animation(154, 7, 0.001f)); // walking, rocket-launcher
|
||||
registerAnimation(15, SpriteObject::Animation(162, 7, 0.002f)); // running, rocket-launcher
|
||||
|
||||
|
||||
|
||||
registerAnimation(42, SpriteObject::Animation(42, 1)); // death pose; maybe just 1?
|
||||
registerAnimation(45, SpriteObject::Animation(45, 1)); // shot-in-front
|
||||
|
||||
registerAnimation(46, SpriteObject::Animation(354, 12));*/
|
||||
|
||||
#if 0
|
||||
class SpriteManager {
|
||||
public:
|
||||
@ -113,12 +168,24 @@ namespace OpenGTA {
|
||||
template <typename T> T & add(const T & t) {
|
||||
return AbstractContainer<T>::doAdd(t);
|
||||
}
|
||||
|
||||
template <typename T> T & addPed(const T & t) {
|
||||
return this->add(t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T> size_t getNum() {
|
||||
return AbstractContainer<T>::objs.size();
|
||||
}
|
||||
inline Pedestrian & getPed(uint32_t id) {
|
||||
return AbstractContainer<Pedestrian>::doGet(id);
|
||||
}
|
||||
|
||||
inline Pedestrian & getPedById(uint32_t id) {
|
||||
return this->getPed(id);
|
||||
}
|
||||
|
||||
inline Car & getCar(uint32_t id) {
|
||||
return AbstractContainer<Car>::doGet(id);
|
||||
}
|
||||
@ -137,6 +204,11 @@ namespace OpenGTA {
|
||||
inline void removePed(uint32_t id) {
|
||||
AbstractContainer<Pedestrian>::doRemove(id);
|
||||
}
|
||||
|
||||
inline void removePedById(uint32_t id) {
|
||||
this->removePed(id);
|
||||
}
|
||||
|
||||
inline void removeCar(uint32_t id) {
|
||||
AbstractContainer<Car>::doRemove(id);
|
||||
}
|
||||
|
87
viewer.cpp
87
viewer.cpp
@ -53,11 +53,9 @@
|
||||
#include "ai.h"
|
||||
|
||||
|
||||
#include <SDL_keycode.h>
|
||||
|
||||
#define getPedById getPed
|
||||
#define removePedById removePed
|
||||
#define addPed add
|
||||
|
||||
#include <SDL_keycode.h>
|
||||
|
||||
SDL_Window* screen;
|
||||
extern int global_EC;
|
||||
@ -599,6 +597,28 @@ void create_ped_at(const Vector3D v) {
|
||||
//OpenGTA::SpriteManagerHolder::Instance().getPedById(0xffffffff).giveItem(1, 255);
|
||||
}
|
||||
|
||||
|
||||
void updateAnim() {
|
||||
|
||||
OpenGTA::SpriteManagerHolder::Instance().getPedById(0xffffffff).switchToAnim(OpenGTA::CONST_ANIM_CAR_ENTER);
|
||||
}
|
||||
|
||||
void create_car_at(const Vector3D v) {
|
||||
|
||||
|
||||
//OpenGTA::Car& cx = OpenGTA::SpriteManagerHolder::Instance().getCar(2909);
|
||||
|
||||
//OpenGTA::Car c(cx);
|
||||
|
||||
//c.pos.x -= 1.0;
|
||||
|
||||
//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(v.x, 2.06562519, v.z), 180, 999999, 18, 0);
|
||||
|
||||
OpenGTA::SpriteManagerHolder::Instance().add(c2);
|
||||
}
|
||||
|
||||
void explode_ped() {
|
||||
try {
|
||||
OpenGTA::Pedestrian & ped = OpenGTA::SpriteManagerHolder::Instance().getPedById(0xffffffff);
|
||||
@ -754,9 +774,11 @@ void car_toggle() {
|
||||
p_door_global.y += 0.2f;
|
||||
std::cout << p_door_global.x << ", " << p_door_global.y << ", " << p_door_global.z << std::endl;
|
||||
test_dot = p_door_global;
|
||||
//pped.aiMode = 1;
|
||||
//pped.aiData.pos1 = p_door_global;
|
||||
OpenGTA::AI::Pedestrian::walk_pavement(&pped);
|
||||
pped.aiMode = 1;
|
||||
pped.aiData.pos1 = p_door_global;
|
||||
|
||||
pped.aimCarId = j->carId;
|
||||
//OpenGTA::AI::Pedestrian::walk_pavement(&pped);
|
||||
|
||||
}
|
||||
|
||||
@ -819,7 +841,6 @@ void handleKeyPress( SDL_Keysym *keysym ) {
|
||||
case SDLK_F4:
|
||||
follow_toggle = (follow_toggle ? 0 : 1);
|
||||
if (follow_toggle) {
|
||||
//SDL_EnableKeyRepeat( 0, SDL_DEFAULT_REPEAT_INTERVAL );
|
||||
city->setViewMode(false);
|
||||
Vector3D p(cam.getEye());
|
||||
create_ped_at(p);
|
||||
@ -842,8 +863,14 @@ void handleKeyPress( SDL_Keysym *keysym ) {
|
||||
car_toggle();
|
||||
break;
|
||||
case SDLK_F5:
|
||||
draw_arrows = (draw_arrows ? 0 : 1);
|
||||
city->setDrawHeadingArrows(draw_arrows);
|
||||
//draw_arrows = (draw_arrows ? 0 : 1);
|
||||
//city->setDrawHeadingArrows(draw_arrows);
|
||||
{
|
||||
Vector3D px(cam.getEye());
|
||||
create_car_at(px);
|
||||
|
||||
//updateAnim();
|
||||
}
|
||||
break;
|
||||
case SDLK_F6:
|
||||
draw_mapmode();
|
||||
@ -912,16 +939,46 @@ void handleKeyPress( SDL_Keysym *keysym ) {
|
||||
cam.setSpeed(-0.2f);
|
||||
break;
|
||||
case 'j':
|
||||
OpenGTA::LocalPlayer::Instance().getCtrl().setTurnLeft();
|
||||
break;
|
||||
{
|
||||
OpenGTA::LocalPlayer::Instance().getCtrl().setTurnLeft();
|
||||
|
||||
if (OpenGTA::LocalPlayer::Instance().playerCarId == 0)
|
||||
{
|
||||
|
||||
OpenGTA::Pedestrian & pped = OpenGTA::LocalPlayer::Instance().getPed();
|
||||
pped.aiMode = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
OpenGTA::LocalPlayer::Instance().getCtrl().setTurnRight();
|
||||
{
|
||||
OpenGTA::LocalPlayer::Instance().getCtrl().setTurnRight();
|
||||
if (OpenGTA::LocalPlayer::Instance().playerCarId == 0)
|
||||
{
|
||||
OpenGTA::Pedestrian & pped = OpenGTA::LocalPlayer::Instance().getPed();
|
||||
pped.aiMode = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
OpenGTA::LocalPlayer::Instance().getCtrl().setMoveForward();
|
||||
{
|
||||
OpenGTA::LocalPlayer::Instance().getCtrl().setMoveForward();
|
||||
if (OpenGTA::LocalPlayer::Instance().playerCarId == 0)
|
||||
{
|
||||
OpenGTA::Pedestrian & pped = OpenGTA::LocalPlayer::Instance().getPed();
|
||||
pped.aiMode = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'k':
|
||||
OpenGTA::LocalPlayer::Instance().getCtrl().setMoveBack();
|
||||
{
|
||||
OpenGTA::LocalPlayer::Instance().getCtrl().setMoveBack();
|
||||
if (OpenGTA::LocalPlayer::Instance().playerCarId == 0)
|
||||
{
|
||||
OpenGTA::Pedestrian & pped = OpenGTA::LocalPlayer::Instance().getPed();
|
||||
pped.aiMode = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
//FIXME: simply ignored on windows for now
|
||||
|
Loading…
Reference in New Issue
Block a user