Weapon_Ammo_Type proto

Discussion in 'General Modification' started by WinstonShnozwick, Sep 9, 2019.

Remove all ads!
  1. WinstonShnozwick

    WinstonShnozwick Established Member

    Joined:
    Mar 2, 2011
    Messages:
    628
    Likes Received:
    23
    That's exactly the bugger that eluded me, you're a lifesaver, Darkstorm. Since that isn't in the main branch of temple+ right now, I could try to add it into my Psionics branch.

    Where would be an appropriate file to replace function and make this one in? Weapon.cpp.h?

    As an aside, I think that the vanilla throwing axe projectile proto is wrong. It uses the mesh ID for an arrow. Can anyone else confirm this is true on their end and I haven't just made a local modification? If true, then I suggest overwriting the throwing axe projectile proto in temple+ to point to a mesh id of the cleaver or something.
     
    Last edited: Sep 18, 2019
  2. WinstonShnozwick

    WinstonShnozwick Established Member

    Joined:
    Mar 2, 2011
    Messages:
    628
    Likes Received:
    23
    update:
    So I tried making a new file in templeplus called weapon_ammo_type_fixes.cpp, you can see the contents in the attachment to this post.
    I defined new enums for weapon types I wanted and updated places in code where the enums were being used. I defined the new projectile protoIDs to use as well. Two things came up, and it doesn't work currently.

    1) Even for base game projectiles, stuff like daggers and cleaver, when I try throwing them now, and I step into the replaced function, I'm getting values passed in way outside of the WeaponAmmoType enum. E.g. throwing a club (uses wat club, enum 5), the value passed in the function was 3338. Throwing a dagger (enum 4), I got 3335 passed in instead of 4. I was also getting mixed results in whether I was out of ammo or not with the new WAT I defined..

    2) In my weapon proto, setting the "weapon ammo type" field to a number, which I was expecting as the enum number, did not work and the weapon ammo type in game was initialized to 10000, so I had to do an obj_set_int on obj_f_weapon_ammo_type to reset it to the enum I wanted. So the proto parsing is doing something funky on that field and expecting strings that I have no idea where/how they are defined, like "throwing_axe" (which is related to enum 10, wat_throwing_axe).

    I am also unsure where/how thrown ammo types are defined to determine if the model is static (like a spear/javelin which just throws pointing forward) or moving (like a light mace or club which spin the weapon model as it arcs in the air).
     

    Attached Files:

  3. DarkStorm

    DarkStorm Established Member

    Joined:
    Oct 2, 2003
    Messages:
    514
    Likes Received:
    3
    Ah sorry, you took me too literally heh. The function I pasted is a replacement from my own code.

    The signature you're trying to replace is actually being passed an ObjHndl,and is defined in the .dll as such:
    Code:
    int __cdecl GetWeaponProjectileProto(ObjHndl obj)
    {
      return protoNumByAmmoType[GetInt32(obj, obj_f_weapon_ammo_type)];
    }
    However, I did look something up I suspected and I think this is still way harder to replace than initially thought :|
    The check whether a given weapon ammo type is a thrown weapon or not is actually inlined in a few places, meaning there's no easy way to replace it. One example is @ 0x1008E9CB.
     
  4. WinstonShnozwick

    WinstonShnozwick Established Member

    Joined:
    Mar 2, 2011
    Messages:
    628
    Likes Received:
    23
    Ah, good to know. I did suspect that weapon ammo types and thrown weapon definitions were scattered in multiple places in the dll based on what I was observing. I was getting no "throw weapon" radial option in one of my new WATs, a red circle with line through it on the arrow when aiming to throw with one of them, and "out of ammo" floating as well.
    Given that I can shelve the attempt for now and accept that throwing mind blades looks like garbage at the moment :) but I do believe that the throwing axe mesh ID is a vanilla defect that can be fixed?
     
  5. DarkStorm

    DarkStorm Established Member

    Joined:
    Oct 2, 2003
    Messages:
    514
    Likes Received:
    3
    Yes, that should be fixable with the hook you attached (if you change the signature of the function to the one I posted).
    I think the array of proto id's is only referenced in that one place.
     
  6. WinstonShnozwick

    WinstonShnozwick Established Member

    Joined:
    Mar 2, 2011
    Messages:
    628
    Likes Received:
    23
    I don't think the function needs to be replaced to fix the throwing axe mesh, since that just points to the projectile proto used. The problem is that the throwing axe projectile proto has the incorrect mesh id assigned in world builder (someone else confirm the same on their end?). See the attached images. I think a proto id overwriting the throwing axe projectile needs to be defined with everything kept the same but a different mesh id pointing to (cleaver mesh?)?

    Although now I'm looking at it, the trident (3013) also uses the same mesh id, but the behavior of the projectile (thrown straight like a spear) is different from the throwing axe projectile (thrown spinning). Must be something in the dll controlling this, which makes weapon ammo types even more complicated to fully understand.
     

    Attached Files:

  7. DarkStorm

    DarkStorm Established Member

    Joined:
    Oct 2, 2003
    Messages:
    514
    Likes Received:
    3
    I already have this fully reverse engineered in my current C# project so I'll look into it and get back to you. I remember reversing the function that does the spinning heh.
     
  8. DarkStorm

    DarkStorm Established Member

    Joined:
    Oct 2, 2003
    Messages:
    514
    Likes Received:
    3
    Alright, it's in 0x10013af0 (GoalUpdateMoveStraight), which handles animating the projectile object while it's moving.
    Most relevant part in red:
    upload_2019-9-14_0-27-52.png ,

    The function marked in red is @ 0x100643a0, and that's probably what you need to patch. It looks like this:
    upload_2019-9-14_0-28-36.png
     
Our Host!