My program doesn't have bugs. It just develops random features.
Legacy:How UT Weapons Work/Switching To Another Weapon
Switching weapons consists of two parts
- putting down the old weapon
- bringing up the new weapon
Putting Down The Old Weapon
- The pawn's PendingWeapon property is set to the new weapon.
- If the pawn's Weapon and PendingWeapon are already the same switching is aborted and nothing happens.
- If the pawn doesn't currently have a selected Weapon, PendingWeapon is brought up. Otherwise the current weapon's PutDown function is called. This function can in some cases abort the weapon change by returning False. (e.g. SwitchWeapon function)
Bringing Up The New Weapon
This part of the weapon change starts with the Pawn (UT).ChangedWeapon function. This function acts differently depending on whether Weapon and PendingWeapon are the same or not:
When the pawn has no weapon selected and no weapon to switch to (Weapon == PendingWeapon == None) then the SwitchToBestWeapon function is called. Otherwise if Weapon and PendingWeapon are the same and in DownWeapon state, the weapon's BringUp function is called.
When Weapon and PendingWeapon are different and PendingWeapon is None it will be set to Weapon. Then the pawn's PlayWeaponSwitch function is called to play an animation for changing the weapon. When the PendingWeapon's mass is greater than 20 and the pawn caries a decoration, the DropDecoration function is called. Afterwards Weapon is set to PendingWeapon.
Then (in all cases) the selected weapon's SetDefaultDisplayProperties function is called and the pawn's inventory receives a ChangedWeapon call. The ChangedWeapon function of each item should call the ChangedWeapon function of the next item in the pawn's inventory chain. In case Weapon and PendingWeapon were different the weapon's RaiseUp function is called.
ChangedWeapon always returns with PendingWeapon set to None.