Moving Horses to a Table
Instead of letting the source hard code everything about handling horses, I think it is about time to move them into their own table. I have looked into this a little bit, but don't have anything solid yet. I just wanted to get the idea out there.
I will look into what needs to change to get them to load from tables. I think a format like this should work for a table: Code:
Table Name: horse_types I am not sure how mount size is set currently yet, so I think a field for each race to set the mount size on a per race basis should work unless there is a better way. Last, I think that a notes field might be useful so you can put "Spell: 2866 Tan Ornate Chain" or whatever you want in there. That would just make things easier to keep track of. I will try to start figuring out the code for this soon, but any help/input is appreciated :) |
Probably should set the size based the size of the client summoning it.
Good idea though. |
Ya, I know the idea has been tossed around for a while, but no real effort put into doing it that I have seen. Doesn't seem like it would be too hard. I am not exactly sure what to do yet, but I figure looking at pets might give us a good start.
I think the idea to have it set size based on the client is a good one. But, I figured it would be good to allow them to be set manually per race as well. Just incase someone wanted to use a global model as a custom mount (if any actually fit closely). Maybe setting the table size settings to 0 would let the server use the race size to automatically set a size for the mount, but anything over 0 would be used to set the size manually. It would be similar to using a rule, if that is possible. The only thing I am unsure about for setting size manually is what happens if the character shrinks/grows? Would the mount be able to scale properly with that? Maybe some extra code would be needed for shrink/grow and other #size changes. |
Here is what I have so far for SQL for a table. Haven't made a table myself yet, so lemme know if something looks wrong. I also included 1 example line for a fast white horse. Once this code is done, I will try to go through and create a full table for it to match what the current source code already does for all mounts.
Code:
DROP TABLE IF EXISTS `horses`; I also just made a struct for this, but am not exactly sure if this is completely right or not yet. zonedb.h Code:
struct Horses_Struct { horse.cpp Code:
const NPCType *Horse::BuildHorseType(int16 spell_id) { |
Yeah still not liking the sizes part, we know how to grab the current size even after shrunk or grown. I doubt people would really make much use of the sizes part too.
I'll look at the code and comment more when I've had more sleep though. |
Ya, I don't think sizes would be required for any of the normal Horse/Drogmar/Mechboar mounts, but what if someone wanted to use a Tiger, Chokidai, Basilisk, or Alligator as a mount? Or, maybe even a boat as a mount for water or something. I am sure they would need a way to size them to players, since they aren't scaled that way by design.
It isn't required that we have the option to use other races as mounts, but I don't think it would be a bad option to have. I was mostly wanting to make it a table to allow custom speeds and the use of the mechboar mount model. I wouldn't mind seeing how well a Tiger (or whatever) might look as a mount though. |
I think I have everything working now. I tried messing with custom mounts and they won't work. I think the client blocks them from being used. But, the mechboars do work :)
In horse.cpp add these lines: Code:
#include "../common/packet_functions.h" Also, replace the whole Horse::BuildHorseType section with this: Code:
const NPCType *Horse::BuildHorseType(int16 spell_id) { Here is the dump of my semi-completed table (should match everthing that was previously in the code, and also include all mount filenames up to live): Code:
DROP TABLE IF EXISTS `horses`; |
It looks like we will need to change this as well:
effects.cpp Code:
void EntityList::AEAttack(Mob *attacker, float dist, int Hand, int count) { Code:
&& curmob->GetRace() != 216 && curmob->GetRace() != 472 /* dont attack horses */ |
There are still 2 issues holding me back from being able to get this added to SVN. The first issue is that the 0.75 speed mounts don't move at all. It almost seems like it is setting the speed to 0 for some reason. It worked fine for the old way horses were done, but doesn't seem to work in the new way.
The second issue is that if you #cast the spell, the mount summons almost instantly, but if you try to use the actual bridles, it delays the spell for a while. The mount does still cast, but it takes probably 5 or 10 seconds after the spell finishes casting before the mount actually gets summoned. I am not sure what is causing this extra cast time yet. It almost seems like the displayed cast time and actual cast time settings for the bridles are not the same times. But, checking the items show that they are. If anyone wants to check this out and/or maybe give a little help, it would be appreciated. I think this is mostly done. Other than those 2 issues, the rest seems to work great. |
Why did you not just store mountspeed as a float? Why do this extra work when you could just do:
Code:
npc_type->runspeed = atof(row[3]) Code:
npc_type->runspeed = mountspeed / 100; Also there's no reason to assign temp variables to hold the information from db as you don't do anything else with it, you're plugging it straight into the NPCType. Waste of time and memory however small it may be. |
Thanks KLS. I originally had it set as a float and it was still having the same problem for some reason, which is why I tried changing it to just be an int16. I will set it all back as a float again and rewrite the code like you suggested since it doesn't need variables. Maybe I was just missing something when I set it as a float before.
That should resolve that issue hopefully. Then, I will just need to figure out why clickie items for horses seem to have some long extra delay. Editing the code in the post above, but I will need to test it later tonight before I know if it helped or not. EDIT: LMAO, I just figured out why the float I set before wasn't working. It is because I was using atoi and not atof. I didn't really know what they meant until I looked at your suggestion again and noticed you had atof. I thought about it a sec and realized that the last letter must mean float, as apposed to int from the last letter of atoi. LOL, I really should start reading up on how to code in C++ instead of just learning from examples like that :P Any clue why the bridles would have such a delayed casting? Maybe it is just an issue with my test server. I will have to try some other item clickies and see what happens. |
Nothing I see there should cause delayed casting. Maybe if the mysql server was so lagged that it took a long time per query but odds are you'd notice other things too in that case. Like startup or looting lag.
|
Since I am trying it on my test server, it may be some other custom code I am have been trying on it that is causing the extra cast time for mounts from clickies. When I use #cast, it works instantly, so it shouldn't be database delay.
If I get this tested and confirm that it all works perfectly, does anyone have any issues with me adding this to the SVN? I will add the required SQL as well, which will include the full mount table. The only mounts that work in Titanium are Horses, Drogmors and Mechboars, so all of the other ones in the table are mostly just placeholders for later expansions. I put in some global races other than horses for the mounts that can't be used in Titanium. They don't work as mounts, but they don't have models anyway, so I don't think it will be an issue. Also, I seem to remember certain mounts being slightly faster than the fastest purchasable ones. I thought the knights' AA mount was one of the fastest, but maybe it is the same speed as the ornate ones. At least these will be really easy to change and tweak with the new table :) Thanks again for the insight, KLS. One more thing done on the list :D |
I have no problem with it being added assuming you fix what I told ya!
|
I already edited the changes you suggested into the code post above. I will test it out later and verify that it all works as intended. Lemme know if you see anything wrong still with the code above.
|
All times are GMT -4. The time now is 11:28 AM. |
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.