Page 1 of 1

weapon addon_flags and how too...

Posted: 02 Aug 2017, 01:23
by sLoPpYdOtBiGhOlE
Hi again,

Using a script in CoC 1.4.22 how do I

Q1. Distinguish the scope type that is attached to a weapon?
Using stpk_utils the weapon addon_flags has 1 for scope, but how do I tell which scope type is attached?

Q2. Once I determine what attachments a weapon has, how do I remove the attachments from the weapon?
I did try finding the mechanic script as an example (since attachment are removed when you upgrade a weapon),
but had no success finding what I was looking for.

I'm assuming more then anything once again..
But after using printf to dump weapon data for all weapons in my inventory I gather the addon_flags works as:
1 = Scope
2 = Grenade launcher
4 = Silencer

It's easy enough for silencer (generic for all) and grenade laucher check the weapon ini to look up what a weapon uses.
But the scope bit got me stumped as there are multiple scopes for some weapons where should I be checking to find which one is used?.

I'm thinking of adding a remove all attachments feature to my little unload all weapons addon.

Off topic:
After the initial map bugs are sorted in CoC 1.5 I'll update to it.
I can't afford repeats of latge amounts of data as I only have access to prepaid mobile data where 3GB = $30 AU.
What I get for living in a backwards rural area, but I wouldn't have it any other way :)

Re: weapon addon_flags and how too...

Posted: 02 Aug 2017, 02:23
by Alundaio
it is a bitmask

2^0 -- bit 0 (1)
2^1 -- bit 1 (2)
2^2 -- bit 2 (4)

Code: Select all

if (,data.addon_flags) == 2) then
     printf("has GL")

Re: weapon addon_flags and how too...

Posted: 02 Aug 2017, 02:33
by sLoPpYdOtBiGhOlE
Thank you for taking the time.
I understood it's a bitmask, but it still doesn't tell me the type of scope the weapon is using.

The weapon ini has 4 scopes listed that a weapon can use.
How do I check which scope is attached to the weapon?

Also I notice never seems to return anything, doesn't error but the bit is never met.
Where bit_and (listed in lua_help.script namespaces) works fine.

Re: weapon addon_flags and how too...

Posted: 02 Aug 2017, 19:45
by Alundaio
Not even the engine knows which scope. Try putting night vision scope on weapon, leave it in a stash, then come back later, it will just be a normal scope again. There is no way to get this information.

Re: weapon addon_flags and how too...

Posted: 03 Aug 2017, 02:51
by sLoPpYdOtBiGhOlE
I was curious as to why that happens (detection scope attached to weapon, leave weapon in chest and it turns in to a standard scope).

But I must be missing something (well a lot actually).
When I have a red scope attached to my weapon and I detach it, it detaches as a red scope.

When I aim with a red scope it offers target detection..
How do scripts or engine check when aiming what should be offered, eg: night vision, target detection, zoom amount?
To offer different attributes for each scope then there has to be some way to distinguish which scope a weapon is using.

Is the dxr_scopes.script that ships with CoC no longer valid?