Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: isTouching()

  1. #1
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts

    isUseTouching()

    I have made a method for detecting if a player is touching a weapon/turret/bombsite. Basically in any situation where the "Press (F) to use" dialog shows up.

    Use example:
    PHP Code:
    if ( player isUseTouching() ) ... 
    Install

    Open gsc.cpp, CTRL + F and search for "resetNextReliableTime". Then add the following on a new line;
    PHP Code:
    {"isusetouching"         gsc_player_isusetouching      0}, 
    Open gsc_player.hpp, CTRL + F and search for "void gsc_player_resetNextReliableTime(int id);". Then add the following on a new line;
    PHP Code:
    void gsc_player_isusetouching(int id); 
    Open gsc_player.cpp, CTRL + F and search for "// entity functions". Then add the following on a new line;
    PHP Code:
    void gsc_player_isusetouching(int id) {
        
    #if COD_VERSION == COD2_1_0
            
    int info_use_offset 0x0811F004;
        
    #elif COD_VERSION == COD2_1_2
            
    int info_use_offset 0x08121338;
        
    #elif COD_VERSION == COD2_1_3
            
    int info_use_offset 0x08121494;
        
    #endif
        
        
    int entity gentities id gentities_size;
        
    int base[2050];
        
    int res 0;
        
        
    int (*isUseHover)(int a1void *d);
        *(
    int *)&isUseHover info_use_offset;
        
        
    res isUseHover(entitybase);
        
    stackPushInt(res);

    Compile your version and you are done.
    Last edited by filthy_freak_; 15th June 2015 at 15:28. Reason: isTouching() to isUseTouching()

  2. The Following 2 Users Say Thank You to filthy_freak_ For This Useful Post:

    kung foo man (15th June 2015),serthy (15th June 2015)

  3. #2
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    It should not be called isTouching() because there is already a built-in function with that name to determine if you are within a trigger range. Call it something else please.

  4. The Following User Says Thank You to Tally For This Useful Post:

    filthy_freak_ (15th June 2015)

  5. #3
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Quote Originally Posted by Tally View Post
    It should not be called isTouching() because there is already a built-in function with that name to determine if you are within a trigger range. Call it something else please.
    Yup was just about to edit before seeing this.

  6. #4
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    So if i'm understanding this right and from looking at the used function.

    You are checking if the player is touching any triggers that is range.
    The difference between 'isTouching' and this new function is that the default 'isTouching' requires you to specify the entity that you want to check.
    PHP Code:
    self isTouching(entity)
    self isUseTouching() 
    The function that you are using is called 'G_TouchTriggers'.
    If i'm right it should return which entity you are triggering at the moment.

    So maybe call the function: 'player getActiveTouchTrigger() or player getCurrentTouchTrigger()' (in case it does return an entity).

    Edit: it doesn't return a entity. But it does notify the entities that someone triggers them.
    Last edited by Mitch; 15th June 2015 at 18:25.

  7. The Following User Says Thank You to Mitch For This Useful Post:

    kung foo man (15th June 2015)

  8. #5
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Honestly I didn't even know there was a isTouching() function until after I posted this thread. Made the above method so that my sprint does not clash with stock weapon pickups. You can also block bots from picking up weapons/using turrets with a little tweaking.

  9. #6
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by filthy_freak_ View Post
    Honestly I didn't even know there was a isTouching() function until after I posted this thread. Made the above method so that my sprint does not clash with stock weapon pickups. You can also block bots from picking up weapons/using turrets with a little tweaking.
    Wouldn't it be more effective and useful to hook the call/function that is responsible for picking up weapons?
    Then with a libcod function you can set if the player is allowed to pickup weapons or not.

    Like this
    PHP Code:
    player enableWeaponPickup();
    player disableWeaponPickup(); 
    Last edited by Mitch; 16th June 2015 at 13:35. Reason: added function example (suggestion) and added '?'.

  10. #7
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Maybe dumb question, but how to compile it?

  11. #8
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by Ni3ls View Post
    Maybe dumb question, but how to compile it?
    https://github.com/kungfooman/libcod...ster/README.md

    See: Working with the source / Compiling:

  12. The Following User Says Thank You to Mitch For This Useful Post:

    Ni3ls (16th June 2015)

  13. #9
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Quote Originally Posted by Mitch View Post
    Wouldn't it be more effective and useful to hook the call/function that is responsible for picking up weapons?
    Then with a libcod function you can set if the player is allowed to pickup weapons or not.

    Like this
    PHP Code:
    player enableWeaponPickup();
    player disableWeaponPickup(); 
    I don't have the knowledge to do this yet. I'm still earning about C++ and libcod.

  14. #10
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by filthy_freak_ View Post
    I don't have the knowledge to do this yet. I'm still earning about C++ and libcod.
    This is the information that i found so far.

    PHP Code:
    Touch_Item_Auto 8105C80 (1.3), 81037F0 (1.0
    It calls:
    PHP Code:
    Touch_Item(item_weaponplayermessage 1
    Item_weapon and player are probably gentities.
    So the function gentityaddress_to_num in gsc_player.cpp will probably give you a number between 0 and 63.

    The function is called from:
    PHP Code:
    8187F64 (1.3), 8167AE4 (1.0)
    8187F8C (1.3), 8167B0C (1.0)
    8187FB4 (1.3), 8167B34 (1.0
    These addresses are pointers to a function like closer or download.
    Now you can try and replace these pointers with your own function and return to the original function.
    Before return to the function you can add a message to see which of the addresses you need.

    These commits might help:
    Replacing a function: https://github.com/M-itch/libcod/com...9ef0a8cb70d2c1
    Client number: https://github.com/M-itch/libcod/com...1e2387aadc42ff
    Last edited by Mitch; 17th June 2015 at 14:04. Reason: added commits for examples

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •