Npc crest

    
  1. Atsijungęs

    HmD

    Pranešimai: 0

    Sveiki forumieciai, gal kartais kas zinot kaip padaryt ar gal turit moda interludei, kur is gracia paimta ta funkcija kad npc butu su clan crestais to klano kuris valdo to regiono pili? Buciau labai dekingas uz bet kokia informacija apie sy dalyka.
    19 Kovo 2013 - 16:00 / #1
  2. 
  3. Atsijungęs

    Nimblex

    Pranešimai: 0

    Stai kodas, bet teks paciam adaptinti.

    Index: java/config/NPC.properties
    ===================================================================
    --- java/config/NPC.properties   (revision 4129)
    +++ java/config/NPC.properties   (working copy)
    @@ -46,6 +46,10 @@
     # Default: False 
     ShowNpcLevel = False
     
    +# Show clan, alliance crests for territory NPCs without quests
    +# Default: False
    +ShowCrestWithoutQuest = False
    +
     # Do you want mobs to drop Vitality resplenishing herbs?
     # Notes:
     #   Works only if EnableVitality = True
    Index: java/net/sf/l2j/gameserver/network/serverpackets/AbstractNpcInfo.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/network/serverpackets/AbstractNpcInfo.java   (revision 4129)
    +++ java/net/sf/l2j/gameserver/network/serverpackets/AbstractNpcInfo.java   (working copy)
    @@ -15,7 +15,10 @@
     package net.sf.l2j.gameserver.network.serverpackets;
     
     import net.sf.l2j.Config;
    +import net.sf.l2j.gameserver.datatables.ClanTable;
     import net.sf.l2j.gameserver.instancemanager.CursedWeaponsManager;
    +import net.sf.l2j.gameserver.instancemanager.TownManager;
    +import net.sf.l2j.gameserver.model.L2Clan;
     import net.sf.l2j.gameserver.model.L2Transformation;
     import net.sf.l2j.gameserver.model.actor.L2Character;
     import net.sf.l2j.gameserver.model.actor.L2Decoy;
    @@ -86,6 +89,10 @@
         public static class NpcInfo extends AbstractNpcInfo
         {
            private L2Npc _npc;
    +       private int _clanCrest = 0;
    +      private int _allyCrest = 0;
    +      private int _allyId = 0;
    +      private int _clanId = 0;
            
            public NpcInfo(L2Npc cha, L2Character attacker)
            {
    @@ -108,15 +115,29 @@
                   _title = cha.getTitle(); // On every subclass
     
                 if (Config.SHOW_NPC_LVL && _npc instanceof L2MonsterInstance)
    -           {
    -             String t = "Lv " + cha.getLevel() + (cha.getAggroRange() > 0 ? "*" : "");
    -             if (_title != null)
    -                t += " " + _title;
    -
    -             _title = t;
    -           }
    -       }
    +         {
    +            String t = "Lv " + cha.getLevel() + (cha.getAggroRange() > 0 ? "*" : "");
    +            if (_title != null)
    +               t += " " + _title;
    +            
    +            _title = t;
    +         }
            
    +       // npc crest of owning clan/ally of castle
    +      if (cha instanceof L2Npc && cha.isInsideZone(L2Character.ZONE_TOWN) && (Config.SHOW_CREST_WITHOUT_QUEST || cha.getCastle().getShowNpcCrest()) && cha.getCastle().getOwnerId() != 0)
    +      {
    +         int townId = TownManager.getTown(_x, _y, _z).getTownId();
    +         if (townId != 33 && townId != 22)
    +         {
    +            L2Clan clan = ClanTable.getInstance().getClan(cha.getCastle().getOwnerId());
    +            _clanCrest = clan.getCrestId();
    +            _clanId = clan.getClanId();
    +            _allyCrest = clan.getAllyCrestId();
    +            _allyId = clan.getAllyId();
    +         }
    +      }
    +   }
    +       
            @Override
           protected void writeImpl()
           {
    Index: java/net/sf/l2j/Config.java
    ===================================================================
    --- java/net/sf/l2j/Config.java   (revision 4129)
    +++ java/net/sf/l2j/Config.java   (working copy)
    @@ -629,6 +629,7 @@
        public static boolean DEEPBLUE_DROP_RULES;
        public static boolean DEEPBLUE_DROP_RULES_RAID;
        public static boolean SHOW_NPC_LVL;
    +   public static boolean SHOW_CREST_WITHOUT_QUEST;
        public static boolean GUARD_ATTACK_AGGRO_MOB;
        public static boolean ALLOW_WYVERN_UPGRADER;
        public static String PET_RENT_NPC;
    @@ -1669,6 +1670,7 @@
                    DEEPBLUE_DROP_RULES = Boolean.parseBoolean(NPC.getProperty("UseDeepBlueDropRules", "True"));
                    DEEPBLUE_DROP_RULES_RAID = Boolean.parseBoolean(NPC.getProperty("UseDeepBlueDropRulesRaid", "True"));
                    SHOW_NPC_LVL = Boolean.parseBoolean(NPC.getProperty("ShowNpcLevel", "False"));
    +               SHOW_CREST_WITHOUT_QUEST = Boolean.parseBoolean(NPC.getProperty("ShowCrestWithoutQuest", "False"));
                    ENABLE_DROP_VITALITY_HERBS = Boolean.parseBoolean(NPC.getProperty("EnableVitalityHerbs", "True"));
                    GUARD_ATTACK_AGGRO_MOB = Boolean.parseBoolean(NPC.getProperty("GuardAttackAggroMob", "False"));
                    ALLOW_WYVERN_UPGRADER = Boolean.parseBoolean(NPC.getProperty("AllowWyvernUpgrader", "False"));
    @@ -2270,6 +2272,7 @@
     
           else if (pName.equalsIgnoreCase("ShowServerNews")) SERVER_NEWS = Boolean.parseBoolean(pValue);
           else if (pName.equalsIgnoreCase("ShowNpcLevel")) SHOW_NPC_LVL = Boolean.parseBoolean(pValue);
    +      else if (pName.equalsIgnoreCase("ShowCrestWithoutQuest")) SHOW_CREST_WITHOUT_QUEST = Boolean.parseBoolean(pValue);
     
           else if (pName.equalsIgnoreCase("ForceInventoryUpdate")) FORCE_INVENTORY_UPDATE = Boolean.parseBoolean(pValue);
     
    Index: java/net/sf/l2j/gameserver/model/entity/Castle.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/model/entity/Castle.java   (revision 4129)
    +++ java/net/sf/l2j/gameserver/model/entity/Castle.java   (working copy)
    @@ -85,6 +85,7 @@
        private int _taxPercent = 0;
        private double _taxRate = 0;
        private long _treasury = 0;
    +   private boolean _showNpcCrest = false;
        private L2CastleZone _zone = null;
        private L2CastleTeleportZone _teleZone;
        private L2Clan _formerOwner = null;
    @@ -531,6 +532,7 @@
           }
           
           updateOwnerInDB(clan); // Update in database
    +      setShowNpcCrest(false);
           
           // if clan have fortress, remove it
           if (clan.getHasFort() > 0)
    @@ -707,6 +709,8 @@
                 
                 _taxPercent = rs.getInt("taxPercent");
                 _treasury = rs.getLong("treasury");
    +            
    +            _showNpcCrest = rs.getBoolean("showNpcCrest");
              }
              rs.close();
              statement.close();
    @@ -1129,6 +1133,20 @@
           return _treasury;
        }
        
    +   public final boolean getShowNpcCrest()
    +   {
    +      return _showNpcCrest;
    +   }
    +   
    +   public final void setShowNpcCrest(boolean showNpcCrest)
    +   {
    +      if (_showNpcCrest != showNpcCrest)
    +      {
    +         _showNpcCrest = showNpcCrest;
    +         updateShowNpcCrest();
    +      }
    +   }
    +   
        public List<SeedProduction> getSeedProduction(int period)
        {
           return (period == CastleManorManager.PERIOD_CURRENT ? _production : _productionNext);
    @@ -1579,6 +1597,36 @@
           }
        }
        
    +   public void updateShowNpcCrest()
    +   {
    +      Connection con = null;
    +      PreparedStatement statement;
    +      try
    +      {
    +         con = L2DatabaseFactory.getInstance().getConnection();
    +         
    +         statement = con.prepareStatement("UPDATE castle SET showNpcCrest = ? WHERE id = ?");
    +         statement.setString(1, String.valueOf(getShowNpcCrest()));
    +         statement.setInt(2, getCastleId());
    +         statement.execute();
    +         statement.close();
    +      }
    +      catch (Exception e)
    +      {
    +         _log.info("Error saving showNpcCrest for castle " + getName() + ": " + e.getMessage());
    +      }
    +      finally
    +      {
    +         try
    +         {
    +            con.close();
    +         }
    +         catch (Exception e)
    +         {
    +         }
    +      }
    +   }
    +   
        public FastList<L2Skill> getResidentialSkills()
        {
           return _residentialSkills;
    19 Kovo 2013 - 16:28 / #2
  4. 
  5. Atsijungęs

    HmD

    Pranešimai: 0

    Didelis dekui, o SQL dalies neturi?
    19 Kovo 2013 - 16:52 / #3
  6. 
  7. Atsijungęs

    Nimblex

    Pranešimai: 0

    Index: /trunk/Eclipse_Datapack/sql/castle.sql
    ===================================================================
    --- /trunk/Eclipse_Datapack/sql/castle.sql (revision 202)
    +++ /trunk/Eclipse_Datapack/sql/castle.sql (revision 206)
    @@ -7,4 +7,5 @@
       `regTimeOver` enum('true','false') DEFAULT 'true' NOT NULL,
       `regTimeEnd` DECIMAL(20,0) NOT NULL default 0,
    +  `showNpcCrest` enum('true','false') DEFAULT 'false' NOT NULL,
       PRIMARY KEY (`name`),
       KEY `id` (`id`)
    @@ -12,11 +13,11 @@
     
     INSERT IGNORE INTO `castle` VALUES
    -(1,'Gludio',0,0,0,'true',0),
    -(2,'Dion',0,0,0,'true',0),
    -(3,'Giran',0,0,0,'true',0),
    -(4,'Oren',0,0,0,'true',0),
    -(5,'Aden',0,0,0,'true',0),
    -(6,'Innadril',0,0,0,'true',0),
    -(7,'Goddard',0,0,0,'true',0),
    -(8,'Rune',0,0,0,'true',0),
    -(9,'Schuttgart',0,0,0,'true',0);
    +(1,'Gludio',0,0,0,'true',0,'false'),
    +(2,'Dion',0,0,0,'true',0,'false'),
    +(3,'Giran',0,0,0,'true',0,'false'),
    +(4,'Oren',0,0,0,'true',0,'false'),
    +(5,'Aden',0,0,0,'true',0,'false'),
    +(6,'Innadril',0,0,0,'true',0,'false'),
    +(7,'Goddard',0,0,0,'true',0,'false'),
    +(8,'Rune',0,0,0,'true',0,'false'),
    +(9,'Schuttgart',0,0,0,'true',0,'false');
    Paskutinį kartą redagavo: Nimblex 19 Kovo 2013 - 16:57
    19 Kovo 2013 - 16:55 / #4
  8. 
  9. Atsijungęs

    HmD

    Pranešimai: 0

    Dekui, viskas isirase puikiai, bet kazkodel nerodo cresto, jokiu error nemeta, gal kita varianta turi? :)
    19 Kovo 2013 - 18:16 / #5
  10. 
  11. Atsijungęs

    HmD

    Pranešimai: 0

    Susitvarkiau, veikia, dekui :)
    19 Kovo 2013 - 19:48 / #6
  12. 
  13. Atsijungęs

    Nimblex

    Pranešimai: 0

    Nera uz ka :)
    19 Kovo 2013 - 20:20 / #7