MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / MultiDoAdditionalDamage

Function MultiDoAdditionalDamage

Descent3/multi.cpp:5962–5984  ·  view source on GitHub ↗

Server is telling us to apply damage to a player

Source from the content-addressed store, hash-verified

5960
5961// Server is telling us to apply damage to a player
5962void MultiDoAdditionalDamage(uint8_t *data) {
5963 int count = 0;
5964
5965 MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_CLIENT);
5966
5967 // mprintf(0,"Got additional damage packet!\n");
5968
5969 SKIP_HEADER(data, &count);
5970
5971 uint8_t slot = MultiGetByte(data, &count);
5972 uint8_t type = MultiGetByte(data, &count);
5973 float amount = MultiGetFloat(data, &count);
5974
5975 if (amount < 0) // add to shields
5976 {
5977 Objects[Players[slot].objnum].shields += (-amount);
5978 if (Objects[Players[slot].objnum].shields > MAX_SHIELDS)
5979 Objects[Players[slot].objnum].shields = MAX_SHIELDS;
5980 } else // take damage
5981 {
5982 ApplyDamageToPlayer(&Objects[Players[slot].objnum], NULL, type, amount, 1);
5983 }
5984}
5985
5986// Asks the server for shields based on frametime "amount" x the type of shields requested
5987void MultiSendRequestShields(int type, float amount) {

Callers 1

MultiProcessDataFunction · 0.85

Calls 4

SKIP_HEADERFunction · 0.85
MultiGetByteFunction · 0.85
MultiGetFloatFunction · 0.85
ApplyDamageToPlayerFunction · 0.85

Tested by

no test coverage detected