UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: DeletedUser on May 07, 2018, 02:52:10 am

Title: AI Weapons Trading!
Post by: DeletedUser on May 07, 2018, 02:52:10 am
Are there any scripts i could use that allow the player to trade weapons with AI Soldiers?

The only maps ive seen that allow weapon trading with AI is in UGX Cabin and AITest by nameless

If anyone has a script i could use, i would credit you in my map and would appreciate it!
Title: Re: AI Weapons Trading!
Post by: buttkicker845 on May 07, 2018, 12:12:17 pm
These functions will handle the weapon swap but you will need to do extra stuff to ensure that the player is actually trying to swap weapons with the AI

Code Snippet
Plaintext
/*
Sets the Ai's primary weapon to the weapon passed
<Required>: player- a player to swap weapons with the AI
<Required>: AI- an AI that will swap weapons with the Player
*/
doWeaponSwap( player, AI)
{
//save the weapons
AINewWeapon = player GetCurrentWeapon();
PlayerNewWeapon = ai.weapon;

//perform the swap
setAiWeapon(AINewWeapon);
swapPlayerCurrentWeapon(PlayerNewWeapon);
}

/*
Sets the Ai's primary weapon to the weapon passed
<Required>: self- an AI
<Required>: weapon - string representing the weapon that will be given to the Ai
*/
setAiWeapon( weapon )
{

self.primaryweapon = weapon;
self animscripts\init::initWeapon( weapon, "primary" );
self gun_switchto( weapon, "right" );
}


/*
Sets the player's primary weapon to the weapon passed
<Required>: self- a player
<Required>: weapon - string representing the weapon that will be given to the player
*/
swapPlayerCurrentWeapon(weapon)
{

oldWeapon = self GetCurrentWeapon();
self TakeWeapon(oldWeapon);
self GiveWeapon(weapon);
self SwitchToWeapon(weapon);
}


NOTE: I haven't tested this but it should work properly.
Title: Re: AI Weapons Trading!
Post by: Harry Bo21 on May 07, 2018, 02:32:52 pm
Not tracking ammo so this will create a glitch that always refills your gun

Not checking if the gun swapping is the gun he has already

If using my perks that will breakvthe inventory
Title: Re: AI Weapons Trading!
Post by: DeletedUser on May 07, 2018, 07:15:34 pm
Not tracking ammo so this will create a glitch that always refills your gun

Not checking if the gun swapping is the gun he has already

If using my perks that will breakvthe inventory
Oh im not using your perks..i was but i changed my mind...im not gonna be adding perks to my map

Also im fine with the refilling ammo on guns glitch


Double Post Merge: May 07, 2018, 07:29:05 pm
These functions will handle the weapon swap but you will need to do extra stuff to ensure that the player is actually trying to swap weapons with the AI

Code Snippet
Plaintext
/*
Sets the Ai's primary weapon to the weapon passed
<Required>: player- a player to swap weapons with the AI
<Required>: AI- an AI that will swap weapons with the Player
*/
doWeaponSwap( player, AI)
{
//save the weapons
AINewWeapon = player GetCurrentWeapon();
PlayerNewWeapon = ai.weapon;

//perform the swap
setAiWeapon(AINewWeapon);
swapPlayerCurrentWeapon(PlayerNewWeapon);
}

/*
Sets the Ai's primary weapon to the weapon passed
<Required>: self- an AI
<Required>: weapon - string representing the weapon that will be given to the Ai
*/
setAiWeapon( weapon )
{

self.primaryweapon = weapon;
self animscripts\init::initWeapon( weapon, "primary" );
self gun_switchto( weapon, "right" );
}


/*
Sets the player's primary weapon to the weapon passed
<Required>: self- a player
<Required>: weapon - string representing the weapon that will be given to the player
*/
swapPlayerCurrentWeapon(weapon)
{

oldWeapon = self GetCurrentWeapon();
self TakeWeapon(oldWeapon);
self GiveWeapon(weapon);
self SwitchToWeapon(weapon);
}


NOTE: I haven't tested this but it should work properly.
I am so lost on how to set this up Lmao. I'm not an expert on scripting
Title: Re: AI Weapons Trading!
Post by: buttkicker845 on May 08, 2018, 02:33:47 am
Not tracking ammo so this will create a glitch that always refills your gun

Not checking if the gun swapping is the gun he has already

If using my perks that will breakvthe inventory

The point was to give him the idea of how to do it, not write it line by line for him. There's a lot that it doesn't account for that it needs be checking.
Title: Re: AI Weapons Trading!
Post by: Harry Bo21 on May 08, 2018, 12:10:35 pm
The point was to give him the idea of how to do it, not write it line by line for him. There's a lot that it doesn't account for that it needs be checking.
and my “point” was highlighting what’s not handled for him

Problem?
Title: Re: AI Weapons Trading!
Post by: DeletedUser on May 08, 2018, 07:01:29 pm
and my “point” was highlighting what’s not handled for him

Problem?
Ok first of all...can we not argue...2nd of all...why cant i get a working script that someone can teach how to do it? I mean this is a help forum after so why are you just giving me scripts that i have no idea what to do with?
Title: Re: AI Weapons Trading!
Post by: Harry Bo21 on May 08, 2018, 09:22:34 pm
yes how dare you provide him with "most" of the answer and not just do the entire thing "for him"

how dare you
Title: Re: AI Weapons Trading!
Post by: DeletedUser on May 08, 2018, 10:12:53 pm
yes how dare you provide him with "most" of the answer and not just do the entire thing "for him"

how dare you
Ok...thats not what i meant...I don't need you're sarcasm. I can't making fucking scripts because i have no idea how to do so...and most importantly set the scripts up. All im asking is how to properly set it up so then i know how to do it in the future.
Title: Re: AI Weapons Trading!
Post by: TGMKTheII on May 08, 2018, 10:56:18 pm
Lets not start arguing back and forth like children. Thanks.