Add Cake #81
|
@ -11,63 +11,53 @@ static const char *monster_names[] = {"Zombie", "Creeper", "Skeleton", "Spider",
|
|||
static std::string get_death_message(Player *player, Entity *cause, bool was_shot = false) {
|
||||
// Prepare Death Message
|
||||
std::string message = player->username;
|
||||
|
||||
// The cause
|
||||
if (cause) {
|
||||
// Entity cause
|
||||
int type_id = cause->vtable->getEntityTypeId(cause);
|
||||
int aux = cause->vtable->getAuxData(cause);
|
||||
if (cause->vtable->isPlayer(cause)) {
|
||||
// Another player
|
||||
bool is_player = cause->vtable->isPlayer(cause);
|
||||
if (cause->vtable->getCreatureBaseType(cause) != 0 || is_player) {
|
||||
// Killed by a creature
|
||||
if (was_shot) {
|
||||
message += " was shot by ";
|
||||
} else {
|
||||
message += " was killed by ";
|
||||
}
|
||||
message += ((Player *) cause)->username;
|
||||
} else if (cause->vtable->getCreatureBaseType(cause) == 1) {
|
||||
// Killed by a monster
|
||||
if (was_shot) {
|
||||
message += " was shot by a ";
|
||||
} else {
|
||||
message += " was killed by a ";
|
||||
}
|
||||
if (32 <= type_id && type_id <= 36) {
|
||||
if (is_player) {
|
||||
// Killed by a player
|
||||
message += ((Player *) cause)->username;
|
||||
} else if (32 <= type_id && type_id <= 36) {
|
||||
// Normal monster
|
||||
message += "a ";
|
||||
message += monster_names[type_id - 32];
|
||||
} else {
|
||||
// Unknown monster
|
||||
message += "Mysterious Beast";
|
||||
// Unknown creature
|
||||
message += "a Mysterious Beast";
|
||||
}
|
||||
return message;
|
||||
} else if (aux) {
|
||||
// Throwable with owner
|
||||
// Killed by a throwable with owner
|
||||
Level *level = player->level;
|
||||
Entity *shooter = Level_getEntity(level, aux);
|
||||
return get_death_message(player, shooter, true);
|
||||
} else if (80 <= type_id || type_id <= 82) {
|
||||
// Throwable without owner
|
||||
message += " was shot under mysterious circumstances";
|
||||
} else if (type_id == 65) {
|
||||
bigjango13 marked this conversation as resolved
|
||||
// TNT
|
||||
message += " was blown apart";
|
||||
// Blown up by TNT
|
||||
return message + " was blown apart";
|
||||
} else if (cause->vtable->isHangingEntity(cause)) {
|
||||
// Painting?
|
||||
message += " admired too much art";
|
||||
} else {
|
||||
if (was_shot) {
|
||||
message += " was shot under mysterious circumstances";
|
||||
} else {
|
||||
message += " was killed under mysterious circumstances";
|
||||
}
|
||||
return message + " admired too much art";
|
||||
bigjango13 marked this conversation as resolved
Outdated
TheBrokenRail
commented
A lot of these death messages are duplicated. Is there any chance these could be consolidated into fewer if statements? A lot of these death messages are duplicated. Is there any chance these could be consolidated into fewer if statements?
bigjango13
commented
Done 👍 Done 👍
|
||||
}
|
||||
}
|
||||
|
||||
if (was_shot) {
|
||||
// Throwable with invalid owner
|
||||
return message + " was shot under mysterious circumstances";
|
||||
TheBrokenRail
commented
When would this ever happen? When would this ever happen?
bigjango13
commented
No idea, I thought it might be useful in case the paintings ever try to take over. No idea, I thought it might be useful in case the paintings ever try to take over.
|
||||
} else if (cause) {
|
||||
// Unknown entity
|
||||
return message + " was killed";
|
||||
} else {
|
||||
// Non-entity cause
|
||||
if (was_shot) {
|
||||
// Throwable with invalid owner
|
||||
message += " was shot under mysterious circumstances";
|
||||
} else {
|
||||
// Anything else
|
||||
message += " has died";
|
||||
}
|
||||
// Anything else
|
||||
return message + " has died";
|
||||
}
|
||||
|
||||
// Return
|
||||
|
|
Loading…
Reference in New Issue
Shouldn't this check if this was an arrow? What if another entity has aux data?
That's intended, only throwables have aux values:
So if I egg you to death, it still says that I'm the one who did it.