Welcome to Open Carnage

A resource for Halo Custom Edition and MCC modding, with unique means of rewarding content creation and support. Have a wander to see why we're worth the time! - EST. 2012

Enclusion

Checking if plasma weapon is in hand & what is in the backpack

What is a good method of detecting if a plasma weapon is in hand. Also, how do I check if a weapon is in the backpack?

 

Is it possible to force a player to swap to the item in their backpack?

Edited by Enclusion

Share this post


Link to post
Share on other sites

Tiddy-bits:

When working on my weapon weights script I had to do what this post was originally asking for. Figured I'd respond to make sure anyone in the future can find the answer. Below shows how you can get the primary weapon, secondary weapon, and find some more information such as the tag.

function GetName(object)
    if object ~= 0 or object ~= nil then
        return read_string(read_dword(read_short(object) * 32 + 0x40440038))
    end
end

local player = get_dynamic_player(PlayerIndex)
local primary_weapon = get_object_memory(read_dword(player + 0x2F8 + 4*0))
local secondary_weapon = get_object_memory(read_dword(player + 0x2F8 + 4*1))

local primary_weapon_name = GetName(primary_weapon)
local secondary_weapon_name = GetName(secondary_weapon)

local primary_weapon_tag lookup_tag("weap", primary_weapon_name)
local secondary_weapon_tag lookup_tag("weap", secondary_weapon_name)

As for forcing a player to switch I haven't tried that yet but there are a probably a few ways you could do it. A non elegant way would be to simply save the primary and secondary weapon, destroy them, and reassign new weapons to the player in a reversed order. If someone knows a way to force a player to swap weapons without doing that please add it below.

 

Edit: I remembered the original reason I wanted this so i'll document that. Basically what I wanted to do was make it so that when you are using the infinite ammo script, the one that doesn't give you infinite grenades, it would automatically swap your weapons since the plasma ammo count won't update client side unless you do so. Swapping weapons probably isn't necessary just get the current weapon, check if it's a plasma weapon, and destroy it followed by replacing it with the same weapon.

Edited by Enclusion
Tucker933 likes this

Share this post


Link to post
Share on other sites
1 minute ago, chalwk77 said:

Make a call to InHand() and pass in Player Index ID [int] and Weapon Tag Name [string] as function arguments.
It's probably better to practise to check if the weapon id does not evaluate to 0 in the same function, but since I do this in GetTagName(), I skip this step.

Whoa, did you just make your first post after lurking for more than 6 years? Hahah I'd been wondering if that would ever happen.

Enclusion likes this

Oddly, this is familiar to you... as if from an old dream.  

splashdown.png

Guide to Balanced Gameplay

Share this post


Link to post
Share on other sites
2 hours ago, Tucker933 said:

Whoa, did you just make your first post after lurking for more than 6 years? Hahah I'd been wondering if that would ever happen.

You should check out their github. Tons of content, they do GREAT stuff.

aLTis likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.