UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: DeletedUser on August 21, 2016, 09:22:31 pm

Title: [Black ops 1] [Help] waittill left hand weapon fired?
Post by: DeletedUser on August 21, 2016, 09:22:31 pm
so im trying to script the RayGun MK 3 but i cant seem to figure out how to detemine which weapon you fired (left or right hand) since GetCurrentWeapon() always returns the right hand and "weapon_fired" notify doesnt give the weapon fired

i mean ive tested with the left hand side of MK 3 being executed when i shoot the m1911 and it works fine but i just cant get it to work from firing the MK 3 left hand :(

ive tried to make my own notify but again for somereason it only works on right hand weapon, left hand never gets notified (right hand only ever gets print out)

Code Snippet
Plaintext
// <player> thread dualwield_weapon_fired_notify_think(<weapon>);
// <player> thread dualwield_weapon_fired_notify_think("m1911_upgraded_zm");
// <player> thread dualwield_weapon_fired_notify_think("m1911lh_upgraded_zm");

dualwield_weapon_fired_notify_think(weapon)
{
self endon("disconnect");

ammo = 0;

max_clip = WeaponClipSize(weapon);
max_stock = WeaponMaxAmmo(weapon);

for(;;)
{
wait .05;

if(!self HasWeapon(weapon))
{
while(!self HasWeapon(weapon))
{
wait .05;
}

ammo = self GetWeaponAmmoClip(weapon) + self GetWeaponAmmoStock(weapon); // reset ammo since it should be a new instance of the weapon (just bought / obtained)

continue;
}

result = self waittill_any_return("weapon_fired", "reload_start");

clip = self GetWeaponAmmoClip(weapon);
stock = self GetWeaponAmmoStock(weapon);

if(result == "reload_start")
{
str_result = self waittill_any_return("reload", "weapon_change");

if(str_result == "weapon_change")
continue;

ammo = max_clip + max_stock; // FIXME: maybe this should be max_clip + stock (max + current)
}
else
{
test_ammo = clip + stock;

if(ammo < test_ammo)
{
ammo = test_ammo;

self notify("dualwield_weapon_fired", weapon);
IPrintLn(weapon);
}
}
}
}
Title: Re: [Black ops 1] [Help] waittill left hand weapon fired?
Post by: lilrifa on August 21, 2016, 10:27:04 pm
I would set it up as a projectile weapon, and write the script revolving around that concept.
Title: Re: [Black ops 1] [Help] waittill left hand weapon fired?
Post by: MakeCents on August 22, 2016, 01:13:20 am
How are you firing the left weapon, ads? Why not look for that and check the right side gun. I assume you can only have a certain gun in right and left hands?

ps, didn't notice it said bo1, oops
Title: Re: [Black ops 1] [Help] waittill left hand weapon fired?
Post by: DeletedUser on August 22, 2016, 01:57:33 pm
How are you firing the left weapon, ads? Why not look for that and check the right side gun. I assume you can only have a certain gun in right and left hands?

ps, didn't notice it said bo1, oops

after a good nights rest and reading what MakeCents said i dawned on me how simple this is, just a normal waittill weapon fired but check if ADS button is pressed and now it works perfectly

Code if you want to know the BTS but its very simple
Code Snippet
Plaintext
dualwield_weapon_fired_notify_think(weapon, weapon_upgraded, lh_weapon, lh_weapon_upgraded)
{
self endon("disconnect");

for(;;)
{
self waittill("weapon_fired");

current_weapon = self GetCurrentWeapon();

if(current_weapon == weapon || current_weapon == weapon_upgraded)
{
if(self ADSButtonPressed())
{
if(current_weapon == weapon_upgraded)
self notify("dualwield_weapon_fired", lh_weapon_upgraded);
else
self notify("dualwield_weapon_fired", lh_weapon);
}
else
self notify("dualwield_weapon_fired", current_weapon); // use current weapon so you know if its upgraded or not
}
}
}

Marked MakeCents as best answer but this is also part of the answer