Operators not working / Logical Weirdness

Discuss programming in the QuakeC language.
Post Reply
SusanMDK
Posts: 601
Joined: Fri Aug 05, 2005 2:35 pm
Location: In The Sun

Operators not working / Logical Weirdness

Post by SusanMDK »

I have some weapon that can have two different ammo types loaded in it. Then I run into some kind of logical weirdness. My logic says "the code that doesn't work" works, but it doesn't work...

This code is about picking up the Weapon or letting it stay on the ground.

Logic Explanation:
It lets player to pick up the Weapon always if player has less than two of the kind. When player has two Weapons, then it's not useful to let player pickup a third, if it doesn't give player anything.

First check which ammo type the Weapon is giving. If player don't have enough ammo in the pockets, then pick it up. Otherwise it's needed to check which type ammo of player's Weapons are loaded and are they full. Both incorrect, don't pickup. Both full, don't pickup.

Then comes the weirdness in the logic. It is not enough to check, if one of the Weapons has the correct type loaded and it's not full. But I also need to check if the Weapons have incorrect type and not full, if I didn't do this check, then player would pickup a weapon and not get anything.

The code in pastebin with weird linings
zbang!
Post Reply