Announcement

Collapse
No announcement yet.

UAS2 Progress

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • UAS2 Progress

    Well, I know people are working on other things. But UAS is a bit more like my dinosaur-way of programming than this modern .NET/C# stuff people are heading towards. I've been trying to get some understanding of how things hang together, and it's a lot of fun, especially as I can now melee fight things. So I thought I would create one thread with changes and observations about UAS2 and the capture program, and perhaps these might be useful if anyone's still playing with it. I don't feel I've made enough progress to upload a whole new version.

    Firstly, the capture program has a number of bugs, at least the one I had. It has "vetors" instead of "vectors", and its bad way of building an insert line means that it often creates dud lines. Actually there's a dozen or more other problems with it, with the fields it captures

    But I've put this to one side. For one thing, it's generating too many records, and this slows down the server launch time. I've had to create a few scripts like ones to remove duplicates. I also created a file splitter on pcap files. The capture program already can deal with a whole folder, so this means instead of reading one file, and often skipping through and missing half the stuff, it deals with the individual thousands of packets, and this generates more data. One problem and this is me understanding things wrong is that you cannot run the capture program without then applying the SQL straight away. If you run two captures, the second one will have duplicate Linker numbers, which will screw up the database.

    One problem which was annoying me was that the inventory wasn't being saved. Yet there's code there to do it... it turns out the inventory is being saved, but not loaded back. Actually to be precise it's more the announcement back to the client of the inventory, it happens as far as I can see too early. I added a function to delete the inventory (an internal store of objects), and a delayed second calling of create inventory in WorldServer: thus#
    int DelayedInventory = 0; (at top)
    [Before switch ( m_bWorldState )]

    if (DelayedInventory > 0)
    {
    DelayedInventory--;
    if (DelayedInventory <= 0)
    {
    // erase the last botched attempt....
    m_pcAvatar->DeleteInventory();

    cMasterServer::CreateInventory( this ); //Send create packets for inventory contents
    }
    }
    switch ( m_bWorldState )
    {
    case 0: //First login
    ------------------
    and this is set up here
    if ( pcRecvPacket->GetFlags( ) == 0x400 ) //400 message acknowledged
    {
    m_bWorldState = 4;
    DelayedInventory = 3;
    cMasterServer::CreateInventory( this ); //Send create packets for inventory contents
    cMasterServer::SendLoginData( this ); //Send login data (uses CreateInventory information)

    ----------------

    and in avatar
    void cAvatar:eleteInventory()
    {
    while ( !m_lstInventory.empty( ) )
    {
    SAFEDELETE( m_lstInventory.front( ) )
    m_lstInventory.pop_front( );
    }
    return;
    }

    defined in avatar.h function prototype
    void DeleteInventory();

    -------------------------
    In TreasureGen.cpp there's a line needed for each CreateXXXXX( function) at the end
    something like
    cDatabase::AddToInventoryDB(who->m_pcAvatar->GetGUID(), aWand);

    or whatever the aXXXX is

    I made spawnitem take a name as a parameter, which makes it easier to spawn things

    I added a random distance to monster spawning. This was necessary as monsters attack now! MonsterServer needs quite a bit of work, but now a creature sees nearby enemies and goes for them. It also returns to base after. It's more or less right.

    Combat animation for melee wasn't working at all, and it was driving me nuts. In the end I went back to the earlier UAS1 and found it did work there, so I stole the "combat animation" code, and somehow that worked! But it's hardcoded for one attack. It needs to do low/medium/high. It's possible I mucked this up myself earlier. But I mention this in passing.

    Here's a question someone might know. I found a good many of the animations (by modifying !animation to default to the last number++ and working through) - the attack ones are 98-106 - but I didn't find ALL of them. In particular I can't find a stabbing animation, just more of a sweeping one. I'll make a list some time. For instance 106 is low kick.

    And another question: where are the female sounds? Ugh's and Arghs, etc?

    Looking at the way certain things are loaded - like monster spawns, NPCs, and permanent objects - I think it would be better to either load things up in a non-database way. Or a second program might do the load, and can just sit there in the background, and use shared-memory to supply whatever is needed. Oh and various hard-coded Maximum are too low once you start loading in captured objects.

    One big problem I can't get to the bottom of is a CLIENT crash that occurs once in a while. When it happens, the client restarted won't then connect to the server, so it's something the server has done to cause the client to crash. I might have to put some kind of a debug in that I can trap on demand in some way.

    The XP level code caused me to suddenly go from level 1 to level 126! I can't make sense of this line, so I fed in the XP table into a bit of code, it needs to be written properly, but it works now. Here's the line that was there - how was that ever supposed to work? 6 Xor 5? What's that all about?

    int level = floor( ( pow( (double)(9 * m_dwTotalXP + 6^5),(double)(1 / 5.0) ) - 6) + 1 );


    That's all for now. Will post again.


















  • #2

    Well it's been a week since my last post. I spent a lot of time trying to solve the crashing bug. In the end after messing around with the packet handling code, it seemed to go away. It also didn't seem to happen when I connected a second machine.


    I've realised a few problems that have created wrong data in the items database. The capture tool is writing to the wrong table for starters, and the fields are not all correct. I almost had some new boots working, imported from a capture file, they showed up in inventory and ground, but could not be equipped because all the flags were wrong.

    Incidentally, if anyone is playing with the databases as MySQL, I recommend heartily a free tool called Heidi, which is just incredibly better than MySQL toolbox, so easy to show and edit data.

    I added code to do the right combat animation according to low/medium/high. I also checked to see if you had no weapon, and switched to the unarmed kicks.

    I added code that reduces stamina, then realised there's code to do this, which is for some reason broken, another thing to look at!

    I added combat noises in a very limited way.

    I found code that was executed when a new landblock is entered. To this I added code that made creatures spawn. I got bored just spawning drudge robbers, so worked out creatures which were fully defined (some have bogus database models) and then made a list of them. So running around Dereth now spawns random creatures in your path, and they head for you and attack if they are in range.

    All in all, it made a kind of playable single player game: edited highlights:

    https://www.youtube.com/watch?v=i8Y-OoI2oRE

    Creatures death animation was not working, so I looked at that too, it almost drove me mad, but eventually it worked. Healing animation was broken too, or worked sometimes. In the end I copied some other animation in, and changed it to heal, and it worked.

    Player death causes all sorts of state problems that need sorting, so you need to go in and out of combat because the stance is wrong.


    I wanted to look at the portals.dat file. I found the ACDat explorer tool, or whatever it's called, only works with ToD portal.dat file. I spent a few days and built a new tool so I can see the data, and find if there was some kind of items repository that could be used to generate items. I think there kind of is - I found an area that had model/palette/texture IDs as one lump, but I can't quite find all the necessary information. I'll make this available somewhere, sometime. It works with the old-school portal.dat file, or the new one. So far it only displays and searches ID's. I found some very old tools with helped with this, in VB. They had a bug or two, and seemed very complicated for what is quite a simple file structure.

    A few brief words about portal.dat for those interested. For each object there is at least a set of files for 3D model, Textures, and Palettes. In the old portal.dat, these are respectively 0x01 files, 0x05 files and 0x04 files. To a large extent, the contents of these files match between old and new portal.dat files, notwithstanding the variations in how the dat files are stored. "Files" with the portal.dats have names which are this ID and an incrementing number, these are tied to an offset in the file, always on a 1K boundary, via a directory. Directories can have subdirectories of up to 61 entries.

    The Tod Portal.dat file does not seem to have the textures stored in the same way. I think these are stored indirectly, but still internally numbered the same, for the most part. So the 0x05 files are all very short in ToD.

    This week, once I've corrected the capture tool, or perhaps rewritten in it in part, I hope to be able to add loads of basic armour and other items. It needs some work because at the moment, it fills up with crazy stuff like housing junk, and random corpses!








    Comment

    • #3

      Great work!

      Comment

      Working...
      X