C++ Mounts add variables

zxmatzx

Well-Known Member
Joined
Dec 1, 2010
Messages
85
Reaction score
22
Hello,
Im working on a advanced mount system, and need to add some new properties to mounts. My knowledge in C++ is almost none. I know what i can do(logic), but don't know how to do. I was looking some files(mounts.cpp, mounts.h, player.cpp, game.cpp) and following the mounts data logic trying to understand how it works.
I found a function that return the infos from xml, im needing only to add new variables to my .xml file, but i know, if the Mounts::loadFromXml()(in mounts.cpp), don't assign values to the new variables i can't access it from the function.
This is the function that i found: Game.GetMounts().

I need some help to add those new variables to loadFromXml(), Game.GetMounts().

What i know i need to do:
Add new variables in struct Mount in Mounts.h to recive the values from loadFromXml()
Change loadFromXml() to read the new values in .xml file and assign to new variables
Change Game.GetMounts() to read new variables and return too.

But i don't know how to do in C++.
Is possible put a lua-like table? Like:
XML:
<mount id="1" clientid="368" name="Widow Queen" speed="20" premium="yes" properties="maxLevel = 10, xpGainRate = 2.0, speedModifier = 2" />
I think this way, i don't need to make changes if i need to add new properties.
If it doesn't work, i now the variables that i need(names and value types).

I know i can use Game.GetMounts(), get mountId from it, make a table and use the id to get mount info in Lua, but im trying to do this with C++. Im already reading/learning C++, i think this will be very helpfull.
Thanks for atention.

--EDIT
I realized that I will have to modify the toggleMount function in player.cpp too, because when level up the mounts, they would have their speeds changed, and would not use the speed base as the function does. Maybe something like:
C++:
if (currentMount->speed != 0) {
newSpeed = currentMount->speed + (currrentMount->speedModifier(new propertie in .xml) * mountLevel) //Sorry for this, idk how to declare and sum variables in C++
            g_game.changeSpeed(this, newSpeed);
}
mountLevel variable = Player Storage Value, maybe a table like:
Lua:
--                    [mountId] = Storage Number
mount_level_storages = {
                        [1] = 1000,
                        [2] = 1001,
                        [3] = 1003,
                       }
In lua? In C++? Where would be better? Lua i guess...

bump

bump
I think i can do this, maybe with some orientation, i will try start code this today, any help will be nice.
 
Last edited:
Top