View Single Post
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 03-10-2020 , 00:19   Re: [TF2] Give Bots Weapons (06.11.2017)
Reply With Quote #83

I think this is what you are asking to see code for: If Bot rolls a Revolver, roll the dice again to see if the Bot gets a Revolver or Big Kill.

I'm just a hobby programmer, so I'm certainly no expert. However, if I was going to modify the code to do what you asked it would look like something like this:

PHP Code:
        case TFClass_Spy:
            {
                
int rnd GetRandomUInt(1,5);
                
TF2_RemoveWeaponSlot(client0);

                switch (
rnd)
                {
                case 
1:
                    {
                        
CreateWeapon(client"tf_weapon_revolver"616);  //The Ambassador
                    
}
                case 
2:
                    {
                        
CreateWeapon(client"tf_weapon_revolver"4606);  //The Enforcer
                    
}
                case 
3:
                    {
                        
CreateWeapon(client"tf_weapon_revolver"2246);  //L'Etranger
                    
}
                case 
4:
                    {
                        
int rnd2 GetRandomUInt(1,2);   //Roll for Revolver or Big Kill
                        
switch (rnd2)
                        {
                        case 
1:
                            {
                                
CreateWeapon(client"tf_weapon_revolver"246);  //Revolver
                            
}
                        case 
2:
                            {
                                
CreateWeapon(client"tf_weapon_revolver"1616);  //Big Kill
                            
}
                    }
                case 
5:
                    {
                        
CreateWeapon(client"tf_weapon_revolver"5256);  //The Diamondback
                    
}                    
                }
            } 
If Bot rolls a '4', (which would have been the Revolver), he immediately re-rolls to see if he still gets a Revolver (new roll of 1) or maybe a Big Kill (new roll of 2).

Is that what you wanted to see? You could also influence the outcome by adding more or less instances of the same weapon to the code. In the above code if the Bot rolls a '4' you have a 50% percent chance to get either a Revolver or a Big Kill. You can add more cases to change the percentage chance of getting a particular outcome.
PC Gamer is offline