Jump to content

[Help] Implementing Vehicles


Recommended Posts

  • Replies 604
  • Created
  • Last Reply

Top Posters In This Topic

anti sry for asking but you have a patch/git?

I'll post a patch file when it'll be good to work. Now it just couple of ideas which has been expressed in the code.

Important fix to my prev post.

@@ -98,11 +98,11 @@ const char TalentEntryfmt[]="niiiiiiiixxxxixxixxxxxx";
const char TalentTabEntryfmt[]="nxxxxxxxxxxxxxxxxxxxiiix";
const char TaxiNodesEntryfmt[]="nifffssssssssssssssssxii";
const char TaxiPathEntryfmt[]="niii";
const char TaxiPathNodeEntryfmt[]="diiifffiixx";
const char TotemCategoryEntryfmt[]="nxxxxxxxxxxxxxxxxxii";
-const char VehicleEntryfmt[]="niffffiiiiiiiifffffffffffffffssssfifixxx";
+const char VehicleEntryfmt[]="niffffiiiiiiiifffffffffffffffssssfifiixx";
const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiiixxxxxxxxxxxx";
const char WorldMapAreaEntryfmt[]="xinxffffixx";
const char WorldMapOverlayEntryfmt[]="nxiiiixxxxxxxxxxx";
const char WorldSafeLocsEntryfmt[]="nifffxxxxxxxxxxxxxxxxx";

Another bug in the movement handler

wowscrnshot121309175320.th.jpg

Link to comment
Share on other sites

But how? How to make patches from files, what merged with CONFLICT? Where I can found sources?

git clone git://github.com/Tasssadar/Valhalla-Project.git vehicle

cd vehicle

git checkout origin/vehicle

git checkout -b vehicle

git diff master vehicle > vehicle.patch

after that, you need fix patch by hands for fully appled.

Link to comment
Share on other sites

I have problems to compile the emulator after applying the command:

git pull git: //github.com/Tasssadar/Valhalla-roject.git vehicle

my mangos rev. 8993 sql

Error:

"12> Creating library .\\mangosd__Win32_Release\\mangosd.lib and object .\\mangosd__Win32_Release\\mangosd.exp

12>game.lib(SpellEffects.obj) : error LNK2019: unresolved external symbol "public: void __thiscall GameObject::DealSiegeDamage(unsigned int)" (?DealSiegeDamage@GameObject@@QAEXI@Z) referenced in function "public: void __thiscall Spell::EffectDamageBuilding(unsigned int)" (?EffectDamageBuilding@Spell@@QAEXI@Z)

12>..\\..\\bin\\Win32_Release\\mangosd.exe : fatal error LNK1120: 1 unresolved externals"

Link to comment
Share on other sites

I have implemented the power but I don't know how send info about energy to the client. May be with a SMSG_* or some thing else...

The Commit from my local repo:

--------------------------- src/game/DBCStructure.h ---------------------------
index 2e0ce90..a27acb4 100644
@@ -1663,7 +1663,7 @@ struct VehicleEntry
    uint32  m_uiLocomotionType;                             // 34
    float   m_msslTrgtImpactTexRadius;                      // 35
    uint32  m_uiSeatIndicatorType;                          // 36
-                                                            // 37, new in 3.1
+    uint32  m_powerType;                       // 37, new in 3.1
                                                            // 38, new in 3.1
                                                            // 39, new in 3.1
};

----------------------------- src/game/ObjectMgr.h -----------------------------
index d21bdd6..6dba638 100644
@@ -342,7 +342,7 @@ MANGOS_DLL_SPEC LanguageDesc const* GetLanguageDescByID(uint32 lang);

class PlayerDumpReader;
// vehicle system
-#define MAX_VEHICLE_SPELLS 10
+#define MAX_VEHICLE_SPELLS 6

struct VehicleDataStructure
{

----------------------------- src/game/Vehicle.cpp -----------------------------
index f80d26b..39fff88 100644
@@ -120,9 +121,41 @@ bool Vehicle::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, u
    {
        ((InstanceMap*)map)->GetInstanceData()->OnCreatureCreate(this);
    }
+    if(Creature *cre = dynamic_cast<Creature*>(this))
+    {
+        if(m_vehicleInfo->m_powerType == POWER_STEAM)
+        {
+            this->setPowerType(POWER_ENERGY);
+            this->SetMaxPower(POWER_ENERGY, 100);
->+            this->SetPower(POWER_ENERGY, 0);
->+            this->SetPower(POWER_ENERGY, 100);
+        }
+        else if(m_vehicleInfo->m_powerType == POWER_PYRITE)
+        {
+            this->setPowerType(POWER_ENERGY);
+            this->SetMaxPower(POWER_ENERGY, 50);
->+            this->SetPower(POWER_ENERGY, 0);
->+            this->SetPower(POWER_ENERGY, 50);
+        }
+        else
+        {
+            for (uint32 i = 0; i < MAX_VEHICLE_SPELLS; ++i)
+            {
+                if(!cre->m_spells[i])
+                    continue;

-    InstallAllAccessories();
+                SpellEntry const *spellInfo = sSpellStore.LookupEntry(cre->m_spells[i]);
+                if(!spellInfo)
+                    continue;

+                if(spellInfo->powerType == POWER_MANA)
+                    break;
+
+                if(spellInfo->powerType == POWER_ENERGY)
+                {
+                    this->setPowerType(POWER_ENERGY);
+                    this->SetMaxPower(POWER_ENERGY, 100);
->+                    this->SetPower(POWER_ENERGY, 0);
->+                    this->SetPower(POWER_ENERGY, 100);
+                    break;
+                }
+            }
+        }
+    }
    return true;
}


------------------------------ src/game/Vehicle.h ------------------------------
index fadb9ea..dc81125 100644
@@ -41,6 +41,11 @@ enum VehicleSeatFlags
    SEAT_VEHICLE_FULL   = 0x08                              // seat occupied by vehicle and that vehicle is full too
};

+enum PowerType
+{
+    POWER_STEAM     = 61,
+    POWER_PYRITE    = 41,
+};
#define MAX_SEAT 8

typedef std::map<int8, VehicleSeat> SeatMap;

And about 2nd problem:

We need smbd to implement changing of seats between base vehicle and the accessories.

Added

Whence we receives the information for CustomVehicleFLags?

Cool, good work! With my fixes (marked as "->") worked as expected. In client showed correct 100% energy and all spells do work.

Link to comment
Share on other sites

I have problems to compile the emulator after applying the command:

git pull git: //github.com/Tasssadar/Valhalla-roject.git vehicle

my mangos rev. 8993 sql

Error:

"12> Creating library .\\mangosd__Win32_Release\\mangosd.lib and object .\\mangosd__Win32_Release\\mangosd.exp

12>game.lib(SpellEffects.obj) : error LNK2019: unresolved external symbol "public: void __thiscall GameObject::DealSiegeDamage(unsigned int)" (?DealSiegeDamage@GameObject@@QAEXI@Z) referenced in function "public: void __thiscall Spell::EffectDamageBuilding(unsigned int)" (?EffectDamageBuilding@Spell@@QAEXI@Z)

12>..\\..\\bin\\Win32_Release\\mangosd.exe : fatal error LNK1120: 1 unresolved externals"

The function has missed.

diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index eada9cb..dc5402e 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -1332,3 +1332,15 @@ void GameObject::UpdateRotationFields(float rotation2 /*=0.0f*/, float rotation3
    SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rotation2);
    SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rotation3);
}
+
+void GameObject::DealSiegeDamage(uint32 damage)
+{
+    m_actualHealth -= damage;
+
+    // TODO : there are a lot of thinghts to do here
+    if(m_actualHealth < 0)
+    {
+        m_actualHealth = GetGOInfo()->destructibleBuilding.intactNumHits;
+        SetLootState(GO_JUST_DEACTIVATED);
+    }
+}
\\ No newline at end of file

added

I'd implemented regen system for vehicles.

There is patch for the Wojta's vehicles branch.

diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp
index d3fa42a..04c7e99 100644
--- a/src/game/Vehicle.cpp
+++ b/src/game/Vehicle.cpp
@@ -70,6 +70,7 @@ void Vehicle::Update(uint32 diff)
{
    Creature::Update(diff);
    InstallAllAccessories();
+
    if(despawn)
    {
        m_spawnduration -= diff;
@@ -77,6 +78,33 @@ void Vehicle::Update(uint32 diff)
            Dismiss();
        despawn = false;
    }
+
+    if(m_regenTimer <= diff)
+    {
+        Regenerate(getPowerType());
+        m_regenTimer = 4000;
+    }
+    else
+        m_regenTimer -= diff;
+}
+
+void Vehicle::Regenerate(Powers power)
+{
+    uint32 curValue = GetPower(power);
+    uint32 maxValue = GetMaxPower(power);
+
+    if (curValue >= maxValue)
+        return;
+
+    float addvalue = 0.0f;
+
+    if(m_vehicleInfo->m_powerType == POWER_STEAM)
+        addvalue = 20.0;
+    else 
+        if(m_vehicleInfo->m_powerType == POWER_PYRITE)
+            return;
+
+    ModifyPower(power, (int32)addvalue);
}

bool Vehicle::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehicleId, uint32 team, const CreatureData *data)
@@ -127,14 +155,12 @@ bool Vehicle::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, u
        {
            this->setPowerType(POWER_ENERGY);
            this->SetMaxPower(POWER_ENERGY, 100);
-            this->SetPower(POWER_ENERGY, 0);
            this->SetPower(POWER_ENERGY, 100);
        }
        else if(m_vehicleInfo->m_powerType == POWER_PYRITE)
        {
            this->setPowerType(POWER_ENERGY);
            this->SetMaxPower(POWER_ENERGY, 50);
-            this->SetPower(POWER_ENERGY, 0);
            this->SetPower(POWER_ENERGY, 50);
        }
        else
@@ -154,7 +180,6 @@ bool Vehicle::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, u
                {
                    this->setPowerType(POWER_ENERGY);
                    this->SetMaxPower(POWER_ENERGY, 100);
-                    this->SetPower(POWER_ENERGY, 0);
                    this->SetPower(POWER_ENERGY, 100);
                    break;
                }
diff --git a/src/game/Vehicle.h b/src/game/Vehicle.h
index c2e883e..7c17edc 100644
--- a/src/game/Vehicle.h
+++ b/src/game/Vehicle.h
@@ -66,6 +66,8 @@ class Vehicle : public Creature
        void setDeathState(DeathState s);                   // overwrite virtual Creature::setDeathState and Unit::setDeathState
        void Update(uint32 diff);                           // overwrite virtual Creature::Update and Unit::Update

+        void Regenerate(Powers power);
+
        uint32 GetVehicleId() { return m_vehicleId; }
        bool SetVehicleId(uint32 vehicleid);


DOWNLOAD*AS FILE!

Has the pyrite regen? Or it gets from some sources?

Link to comment
Share on other sites

Anti, over the last 2 days I keep getting this error on compile and don't know how to fix maybe you do,

Creating library .\\mangosd__Win32_Release\\mangosd.lib and object .\\mangosd__Win32_Release\\mangosd.exp

game.lib(SpellEffects.obj) : error LNK2019: unresolved external symbol "public: void __thiscall GameObject::DealSiegeDamage(unsigned int)" (?DealSiegeDamage@GameObject@@QAEXI@Z) referenced in function "public: void __thiscall Spell::EffectDamageBuilding(unsigned int)" (?EffectDamageBuilding@Spell@@QAEXI@Z)

..\\..\\bin\\Win32_Release\\mangosd.exe : fatal error LNK1120: 1 unresolved externals

Build log was saved at "file://c:\\MangosSRC\\win\\VC90\\mangosd__Win32_Release\\BuildLog.htm"

mangosd - 2 error(s), 0 warning(s)

------ Build started: Project: script, Configuration: Release Win32 ------

Compiling...

sc_default.cpp

system.cpp

ScriptMgr.cpp

Generating Code...

Linking...

Creating library .\\script__Win32_Release/mangosscript.lib and object .\\script__Win32_Release/mangosscript.exp

Embedding manifest...

Build log was saved at "file://c:\\MangosSRC\\win\\VC90\\script__Win32_Release\\BuildLog.htm"

script - 0 error(s), 0 warning(s)

========== Build: 12 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Thank you for the news in advance

Link to comment
Share on other sites

Add this to the bottom of your GameObject.cpp

void GameObject::DealSiegeDamage(uint32 damage)
{
   m_actualHealth -= damage;

   // TODO : there are a lot of thinghts to do here
   if(m_actualHealth < 0)
   {
       m_actualHealth = GetGOInfo()->destructibleBuilding.intactNumHits;
       SetLootState(GO_JUST_DEACTIVATED);
   }
}

Link to comment
Share on other sites

Anti, over the last 2 days I keep getting this error on compile and don't know how to fix maybe you do,

Creating library .\\mangosd__Win32_Release\\mangosd.lib and object .\\mangosd__Win32_Release\\mangosd.exp

game.lib(SpellEffects.obj) : error LNK2019: unresolved external symbol "public: void __thiscall GameObject::DealSiegeDamage(unsigned int)" (?DealSiegeDamage@GameObject@@QAEXI@Z) referenced in function "public: void __thiscall Spell::EffectDamageBuilding(unsigned int)" (?EffectDamageBuilding@Spell@@QAEXI@Z)

..\\..\\bin\\Win32_Release\\mangosd.exe : fatal error LNK1120: 1 unresolved externals

Build log was saved at "file://c:\\MangosSRC\\win\\VC90\\mangosd__Win32_Release\\BuildLog.htm"

mangosd - 2 error(s), 0 warning(s)

------ Build started: Project: script, Configuration: Release Win32 ------

Compiling...

sc_default.cpp

system.cpp

ScriptMgr.cpp

Generating Code...

Linking...

Creating library .\\script__Win32_Release/mangosscript.lib and object .\\script__Win32_Release/mangosscript.exp

Embedding manifest...

Build log was saved at "file://c:\\MangosSRC\\win\\VC90\\script__Win32_Release\\BuildLog.htm"

script - 0 error(s), 0 warning(s)

========== Build: 12 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Thank you for the news in advance

oh... Read 1st part of my prev post. I has already written fix.

Link to comment
Share on other sites

Yes, but he probably did a fetch from Wojta and he did not include this DealSiegeDamage function in his vehicles repo. ^_^

Unfortunately your wrong...sorry to break this to you but I did include all of that and as to the regen patch when I tried to apply I got hunk 1 line truncated : Failed, Hunk 2 patch doesn't apply: Failed so no regen patch and still get error, and yes my original pull was from Tasssadar's repo. :eek:

and Anti thank you again, Iknow your doing great work here I just wish this part was finnished and in the core so you could get things like multi clients logging in so that when I get a freind with only BC logging in they don't have to go out and buy Wrath just to play on me server. :D

Link to comment
Share on other sites

Unfortunately your wrong...sorry to break this to you but I did include all of that and as to the regen patch when I tried to apply I got hunk 1 line truncated : Failed, Hunk 2 patch doesn't apply: Failed so no regen patch and still get error, and yes my original pull was from Tasssadar's repo. :eek:

Hehe you misunderstood me. Or I was not clear ;) I meant that the vehicle repo from Tasssadar did not have that function ^_^ But nevermind ;)

and Anti thank you again, Iknow your doing great work here I just wish this part was finnished and in the core so you could get things like multi clients logging in so that when I get a freind with only BC logging in they don't have to go out and buy Wrath just to play on me server

That's true! Thanks Anti for you work so far! Good job!

Link to comment
Share on other sites

I have try it. Big thanks for developers.

But now "scripted" only 5 creatures and normally work only one - his id is the 28094 - orange tank.

Other creatures doesn't work - on dragon I can sit but dragon don't move.

About the guns - I can sit in, but after that I can't get out with guns - need to relogin for get out with guns.

About the tanks (not about the 28094) - attack functions doesn't work, any tank from the patch is aggressive for the player for default.

It is still damp patch...

Link to comment
Share on other sites

SESSION: opcode CMSG_CHANGE_SEATS_ON_CONTROLLED_VEHICLE (0x049B) have unprocessed tail data (read stop at 40 from 74)

I get this when I try to change seat in vehicle with accessory. Where is packet size defined? Where can I set to ignore this?

Why this appear? Packet is longer than expected? Unexpected data type in packet?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use