A Project for Chronicle 4 based on L2JServer.


    [Share] Disable/Enable player attack NPCs in Towns.

    Share
    avatar
    mystogan64

    Posts : 51
    Join date : 2013-10-04

    [Share] Disable/Enable player attack NPCs in Towns.

    Post  mystogan64 on 17th October 2013, 13:53

    Hello , today's share is a config that will allow admin enable or disable the option that will allow players to attack Npcs in towns.

    net.sf.l2j.Config.java
    Code:

     public static boolean ENABLE_MODIFY_SKILL_DURATION;
    + // Disable-Enable Attack npc in towns.
    + public static boolean DISABLE_ATTACK_NPC_TYPE;
    + public static String ALLOWED_NPC_TYPES;
    + public static FastList<String> LIST_ALLOWED_NPC_TYPES = new FastList<String>();

     ENABLE_MODIFY_SKILL_DURATION = Boolean.parseBoolean(customSettings.getProperty("EnableModifySkillDuration", "False"));
    + DISABLE_ATTACK_NPC_TYPE = Boolean.parseBoolean(customSettings.getProperty("DisableAttackToNpcs", "False"));
    + ALLOWED_NPC_TYPES = customSettings.getProperty("AllowedNPCTypes");
    + LIST_ALLOWED_NPC_TYPES = new FastList<String>();
    + for (String npc_type : ALLOWED_NPC_TYPES.split(","))
    + {
    + LIST_ALLOWED_NPC_TYPES.add(npc_type);
    + }
    gameserver/config/custom.properties
    Code:

    +# If True ActiveChar will not be able to Attack the Listed Npc Types.
    +DisableAttackToNpcs = True
    +
    +# List of NPC's that allow casting skills on them
    +# Any other type will not allow casting
    +AllowedNPCTypes = L2GrandBoss,L2Chest,L2FestivalMonster,L2Minion,L2Monster,L2Pet,L2RaidBoss,L2SiegeGuard,L2SiegeNpc,L2ControlTower,L2Artefact,L2PenaltyMonster,L2FeedableBeast,L2SiegeFlag,L2RiftInvader,L2Guard,L2GuardNoHTML
    net.sf.l2j.gameserver.model.L2Character.java
    Code:

    if (this instanceof L2PcInstance)
     
    {
     if (getPet() != null)
     {
     if (target == getPet())
     {
     sendPacket(new ActionFailed());
     return;
     }
     }
    + if ((target instanceof L2NpcInstance) && Config.DISABLE_ATTACK_NPC_TYPE)
    + {
    + String mobtype = ((L2NpcInstance) target).getTemplate().type;
    + if (!Config.LIST_ALLOWED_NPC_TYPES.contains(mobtype))
    + {
    + sendPacket(new SystemMessage(SystemMessage.CANT_SEE_TARGET));
    + sendPacket(new ActionFailed());
    + return;
    + }
    + }


    if (target == null)
     {
     getAI().notifyEvent(CtrlEvent.EVT_CANCEL);
     return;
     }
     
    setLastSkillCast(skill);
    + if ((target instanceof L2NpcInstance) && Config.DISABLE_ATTACK_NPC_TYPE)
    + {
    + String mobtype = ((L2NpcInstance) target).getTemplate().type;
    + if (!Config.LIST_ALLOWED_NPC_TYPES.contains(mobtype))
    + {
    + sendPacket(new SystemMessage(SystemMessage.CANT_SEE_TARGET));
    + sendPacket(new ActionFailed());
    + return;
    + }
    + }


    public boolean isInsidePeaceZone(L2Object attacker, L2Object target)
     {
     if (target == null)
     {
     return false;
     }
    + if ((target instanceof L2NpcInstance) && Config.DISABLE_ATTACK_NPC_TYPE)
    + {
    + String mobtype = ((L2NpcInstance) target).getTemplate().type;
    + if (!Config.LIST_ALLOWED_NPC_TYPES.contains(mobtype))
    + {
    + sendPacket(new SystemMessage(SystemMessage.CANT_SEE_TARGET));
    + sendPacket(new ActionFailed());
    + return false;
    + }
    + }
    avatar
    jamaica

    Posts : 135
    Join date : 2013-02-24
    Age : 28
    Location : Romania

    Re: [Share] Disable/Enable player attack NPCs in Towns.

    Post  jamaica on 17th October 2013, 14:28

    this should be commited....keep it up....it seems only we two both bring features here xD
    avatar
    Karakan

    Posts : 428
    Join date : 2013-10-04

    Re: [Share] Disable/Enable player attack NPCs in Towns.

    Post  Karakan on 17th October 2013, 17:30

    Dwarves used to delevel by atking npcs in towns Wink

    Should be commited as a custom feature

    Sponsored content

    Re: [Share] Disable/Enable player attack NPCs in Towns.

    Post  Sponsored content


      Current date/time is 19th November 2017, 14:02