Ticket #3176: livestock_attack_notification_r16544.diff

File livestock_attack_notification_r16544.diff, 2.1 KB (added by fcxSanya, 9 years ago)

In this patch a different "Your livestock have been attacked by %(attacker)s!" notification is displayed if the attacked entity has the ResourceSupply component

  • binaries/data/mods/public/gui/session/messages.js

     
    119119        addChatMessage({
    120120            "type": "attack",
    121121            "player": player,
    122             "attacker": notification.attacker
     122            "attacker": notification.attacker,
     123            "target": notification.target
    123124        });
    124125    },
    125126    "dialog": function(notification, player)
     
    509510            return;
    510511
    511512        [username, playerColor] = getUsernameAndColor(msg.attacker);
    512         formatted = sprintf(translate("You have been attacked by %(attacker)s!"), { attacker: "[color=\"" + playerColor + "\"]" + username + "[/color]" });
     513        var targetEntState = GetExtendedEntityState(msg.target);
     514        if (targetEntState.resourceSupply)
     515            var message = translate("Your livestock have been attacked by %(attacker)s!");
     516        else
     517            var message = translate("You have been attacked by %(attacker)s!");
     518        formatted = sprintf(message, { attacker: "[color=\"" + playerColor + "\"]" + username + "[/color]" });
    513519        break;
    514520    case "message":
    515521        // May have been hidden by the 'team' command.
  • binaries/data/mods/public/simulation/components/AttackDetection.js

     
    7878    this.AddSuppression(event);
    7979    Engine.PostMessage(this.entity, MT_AttackDetected, { "player": cmpPlayer.GetPlayerID(), "event": event });
    8080    var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
    81     cmpGuiInterface.PushNotification({"type": "attack", "players": [cmpPlayer.GetPlayerID()], "attacker": cmpAttackerOwnership.GetOwner() });
     81    cmpGuiInterface.PushNotification({"type": "attack", "players": [cmpPlayer.GetPlayerID()], "attacker": cmpAttackerOwnership.GetOwner(), "target": target });
    8282    PlaySound("attacked", target);
    8383};
    8484