by Orion » Sat Apr 28, 2012 5:54 am
Notice that multi_damage was turned into a dot float, which is a float that belongs to an entity, so 2 entities will not take the same damage, unless if the pellets are spread half and half for both entities. The Shotgun firing works like this:
First it resets the multi_damage value of every entity (that was the only way I found, but I might try yours) to zero. Then it goes to the while loop, and shoot the desired amout of pellets. TraceAttack() will add to multi_damage the amount of damage each pellet does, for the trace_ent it hits, if damageable. If a pellet misses, the trace_ent won't receive additional multi_damage from that pellet.
Then it finishes the while loop, and applies the multi damage to every entity with multi_damage > 0, and each entity will have their own multi_damage values. So I think it should work well even on MP, but I dunno what could happen it 2 shotguns from different players are fired EXACTLY at the same frame, but this is very hard to happen. I think if 2 players shoot with the SG at a single enemy, at the very same frame, that enemy will get a multi_damage of 96, if no pellet misses. 96 because if 2 shotguns are fired at the same frame, then ApplyMultiDamage() will be called twice, doubling the damage from EVERY shotgun. This is indeed a bug. Hard to happen, but it is. I still haven't discovered a better way to handle multi damage, but this one I found somewhat acceptable atm.