Noticias:

Debes de estar registrado para poder ver el contenido indicado. Registrate o Conectate

Menú Principal

Blessing of Protection

Iniciado por Swarlog, Ago 12, 2022, 02:26 AM

Tema anterior - Siguiente tema

Swarlog

Se trata de un sistema que viene en el L2 de proteccion a personajes de bajo nivel, con este script no podran pegar a un nuevo usuarios si su diferencia de nivel es superior a 10 niveles. De este modo, se evitan abusos en servidores de bajo rate. Valido hasta personajes de nivel 39 e inferior y sin el segundo cambio de clase, pero si entienes el código podras editarlo a tu gusto sin problemas.

CitarDATA:

Index: data/html/default/30601.htm
===================================================================
--- data/html/default/30601.htm (revision 3440)
+++ data/html/default/30601.htm (working copy)
@@ -2,7 +2,7 @@
 Can I help you with anything? Eh? Well, then, what would you like to know?<br>
 <a action="bypass -h npc_%objectId%_Chat 1">Ask for advice.</a><br>
 NPC location guide. [not done yet]<br>
-Receive blessing of protection. [not done yet]<br>
+<a action="bypass -h npc_%objectId%_Link default/BlessingOfProtection.htm">Receive blessing of protection.</a><br>
 <a action="bypass -h npc_%objectId%_Chat 12">Ask about the Newbie Travel Token.</a><br>
 <a action="bypass -h npc_%objectId%_Quest 1104_NewbieTravelToken">Teleport using the Newbie Travel Token.</a><br>
 <a action="bypass -h npc_%objectId%_SupportMagic">Receive help from beneficial magic.</a><br>
Index: data/html/default/30598.htm
===================================================================
--- data/html/default/30598.htm (revision 3440)
+++ data/html/default/30598.htm (working copy)
@@ -2,7 +2,7 @@
 If you need advice, ask me at any time! I will give you what help I can.<br>
 <a action="bypass -h npc_%objectId%_Chat 1">Ask for advice.</a><br>
 NPC location guide. [not done yet]<br>
-Receive blessing of protection. [not done yet]<br>
+<a action="bypass -h npc_%objectId%_Link default/BlessingOfProtection.htm">Receive blessing of protection.</a><br>
 <a action="bypass -h npc_%objectId%_Chat 12">Ask about the Newbie Travel Token.</a><br>
 <a action="bypass -h npc_%objectId%_Quest 1104_NewbieTravelToken">Teleport using the Newbie Travel Token.</a><br>
 <a action="bypass -h npc_%objectId%_SupportMagic">Receive help from beneficial magic.</a><br>
Index: data/html/default/30602.htm
===================================================================
--- data/html/default/30602.htm (revision 3440)
+++ data/html/default/30602.htm (working copy)
@@ -1,8 +1,8 @@
 <html><body>Newbie Guide:<br>
 You wish to grow strong and powerful, Eh? Then listen carefully; I will advice you!<br>
 <a action="bypass -h npc_%objectId%_Chat 1">Ask for advice.</a><br>
-NPC location guide. [not done yet]<br>
-Receive blessing of protection. [not done yet]<br>
+<a action="bypass -h npc_%objectId%_Link help/newbielocator/orc.htm">NPC location guide.</a><br>
+<a action="bypass -h npc_%objectId%_Link default/BlessingOfProtection.htm">Receive blessing of protection.</a><br>
 <a action="bypass -h npc_%objectId%_Chat 12">Ask about the Newbie Travel Token.</a><br>
 <a action="bypass -h npc_%objectId%_Quest 1104_NewbieTravelToken">Teleport using the Newbie Travel Token.</a><br>
 <a action="bypass -h npc_%objectId%_SupportMagic">Receive help from beneficial magic.</a><br>
Index: data/html/default/30599.htm
===================================================================
--- data/html/default/30599.htm (revision 3440)
+++ data/html/default/30599.htm (working copy)
@@ -2,7 +2,7 @@
 Don't hesitate to tell me if you require assistance. I can teach you about a number of useful things.<br>
 <a action="bypass -h npc_%objectId%_Chat 1">Ask for advice.</a><br>
 NPC location guide. [not done yet]<br>
-Receive blessing of protection. [not done yet]<br>
+<a action="bypass -h npc_%objectId%_Link default/BlessingOfProtection.htm">Receive blessing of protection.</a><br>
 <a action="bypass -h npc_%objectId%_Chat 12">Ask about the Newbie Travel Token.</a><br>
 <a action="bypass -h npc_%objectId%_Quest 1104_NewbieTravelToken">Teleport using the Newbie Travel Token.</a><br>
 <a action="bypass -h npc_%objectId%_SupportMagic">Receive help from beneficial magic.</a><br>
Index: data/html/default/BlessingOfProtection.htm
===================================================================
--- data/html/default/BlessingOfProtection.htm  (revision 0)
+++ data/html/default/BlessingOfProtection.htm  (revision 0)
@@ -0,0 +1,6 @@
+<html><body>Novice Guide:<br>
+The protection blessing is a special protection given to character under level 39 who not made the second transfer.<br>
+While a character has this blessing, he or she cannot either inflict or receive damage when in combat with chaotic character 10 or more levels higher than they are. The protection does not apply to the battle field, however.<br>
+Would you like to receive the protection?<br>
+<a action="bypass -h npc_%objectId%_GiveBlessing">Receive the protection blessing.</a>
+</body></html>
\ No newline at end of file
Index: data/html/default/31076.htm
===================================================================
--- data/html/default/31076.htm (revision 3440)
+++ data/html/default/31076.htm (working copy)
@@ -2,6 +2,7 @@
 Good day, friend. I now live peacefully here on this island, but once I was a well-known adventure. Why, I ventured into the deepest part of Dragon Valley with Sir Cedric, brother of Roien.<br>
 Today, my time is spent guiding novices, If you have any questions, please come and ask me. I will teach you as much as I can.<br>
 <a action="bypass -h npc_%objectId%_Chat 1">Ask for advice</a><br>
+<a action="bypass -h npc_%objectId%_Link default/BlessingOfProtection.htm">Receive blessing of protection.</a><br>
 <a action="bypass -h npc_%objectId%_SupportMagic">"Give me some support magic."</a><br>
 <a action="bypass -h npc_%objectId%_Chat 12">"Tell me about novice characters."</a>
 </body></html>
\ No newline at end of file
Index: data/html/default/30600.htm
===================================================================
--- data/html/default/30600.htm (revision 3440)
+++ data/html/default/30600.htm (working copy)
@@ -2,7 +2,7 @@
 If you need advice, do not hesitate to ask me! I will help you as much as I can.<br>
 <a action="bypass -h npc_%objectId%_Chat 1">Ask for advice.</a><br>
 NPC location guide. [not done yet]<br>
-Receive blessing of protection. [not done yet]<br>
+<a action="bypass -h npc_%objectId%_Link default/BlessingOfProtection.htm">Receive blessing of protection.</a><br>
 <a action="bypass -h npc_%objectId%_Chat 12">Ask about the Newbie Travel Token.</a><br>
 <a action="bypass -h npc_%objectId%_Quest 1104_NewbieTravelToken">Teleport using the Newbie Travel Token.</a><br>
 <a action="bypass -h npc_%objectId%_SupportMagic">Receive help from beneficial magic.</a><br>
Index: data/html/default/31077.htm
===================================================================
--- data/html/default/31077.htm (revision 3440)
+++ data/html/default/31077.htm (working copy)
@@ -2,6 +2,7 @@
 Good day, friend. I now live peacefully here on this island, but once I was a well-known adventure. Why, I ventured into the deepest part of Dragon Valley with Sir Cedric, brother of Roien.<br>
 Today, my time is spent guiding novices, If you have any questions, please come and ask me. I will teach you as much as I can.<br>
 <a action="bypass -h npc_%objectId%_Chat 1">Ask for advice</a><br>
+<a action="bypass -h npc_%objectId%_Link default/BlessingOfProtection.htm">Receive blessing of protection.</a><br>
 <a action="bypass -h npc_%objectId%_SupportMagic">"Give me some support magic."</a><br>
 <a action="bypass -h npc_%objectId%_Chat 12">"Tell me about novice characters."</a
 ></body></html>
\ No newline at end of file
Index: data/stats/skills/5100-5199.xml
===================================================================
--- data/stats/skills/5100-5199.xml     (revision 3472)
+++ data/stats/skills/5100-5199.xml     (working copy)
@@ -1196,16 +1197,19 @@
 </skill>
 <skill id="5182" levels="1" name="Blessing of Protection">
 <!--
-  Needs to be finished.
-  Target is set to TARGET_NONE, skillType to NOTDONE for server compatability.
   Description(s):
       Keeps you safe from an attack by a chaotic character who is more than 10 levels apart from you.
 -->
-  <set name="target" val="TARGET_NONE"/>
-  <set name="skillType" val="NOTDONE"/>
-  <set name="operateType" val="OP_PASSIVE"/>
-  <set name="castRange" val="-1"/>
+  <set name="power" val="0.0"/>
+  <set name="target" val="TARGET_ONE"/>
+  <set name="skillTime" val="0"/>
+  <set name="skillType" val="BUFF"/>
+  <set name="operateType" val="OP_ACTIVE"/>
+  <set name="buffDuration" val="3600000"/>
+  <set name="castRange" val="400"/>
+  <set name="effectRange" val="900"/>
   <for>
+     <effect count="1" name="ProtectionBlessing" time="3600" val="0"/>
   </for>
 </skill>
 <skill id="5183" levels="1" name="Production: Dimensional Shock">

CitarCORE:

Index: java/net/sf/l2j/gameserver/ai/L2CharacterAI.java
===================================================================
--- java/net/sf/l2j/gameserver/ai/L2CharacterAI.java   (revision 1283)
+++ java/net/sf/l2j/gameserver/ai/L2CharacterAI.java   (working copy)
@@ -55,6 +55,7 @@
  */
 public class L2CharacterAI extends AbstractAI
 {
+   private static final int ZONE_PVP = 1;
     @Override
    protected void onEvtAttacked(L2Character attacker)
     {
@@ -195,6 +196,16 @@
             return;
         }
 
+        if (target instanceof L2PcInstance && _actor instanceof L2PcInstance)
+        {
+           if (((L2PcInstance) _actor).getKarma() > 0 && (_actor.getLevel() - target.getLevel()) >=10 && ((L2PlayableInstance) target).getProtectionBlessing() && !(target.isInsideZone(ZONE_PVP)))
+           {
+              //If attacker have karma and have level >= 10 than his target and target have Newbie Protection Buff,
+              clientActionFailed();
+              return;
+           }
+        }
+       
         // Check if the Intention is already AI_INTENTION_ATTACK
         if (getIntention() == AI_INTENTION_ATTACK)
         {
@@ -264,6 +275,16 @@
             return;
         }
 
+        if (target instanceof L2PcInstance && _actor instanceof L2PcInstance)
+        {
+           if (( (L2PcInstance) _actor).getKarma() > 0 && (_actor.getLevel() - ( (L2PcInstance) target).getLevel()) >=10 && ( (L2PlayableInstance) target).getProtectionBlessing() && !(( (L2Character) target).isInsideZone(ZONE_PVP)))
+           {
+              //If attacker have karma and have level >= 10 than his target and target have Newbie Protection Buff,
+              clientActionFailed();
+              return;
+           }
+        }
+       
         // Set the AI cast target
         setCastTarget((L2Character) target);
 
Index: java/net/sf/l2j/gameserver/handler/skillhandlers/Disablers.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/skillhandlers/Disablers.java     (revision 1266)
+++ java/net/sf/l2j/gameserver/handler/skillhandlers/Disablers.java     (working copy)
@@ -457,7 +457,7 @@
                           int maxfive = 5;
                           for (L2Effect e : effects)
                           {
-                             if (e.getSkill().getId() != 4082 && e.getSkill().getId() != 4215 &&
+                             if (e.getSkill().getId() != 4082 && e.getSkill().getId() != 4215 && e.getSkill().getId() != 5182 &&
                                    e.getSkill().getId() != 4515 && e.getSkill().getId() != 110 && e.getSkill().getId() != 111) // Cannot cancel skills 4082, 4215, 4515
                              {
                                 if(e.getSkill().getSkillType() != SkillType.BUFF) //sleep, slow, surrenders etc
Index: java/net/sf/l2j/gameserver/model/L2Effect.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2Effect.java      (revision 1266)
+++ java/net/sf/l2j/gameserver/model/L2Effect.java      (working copy)
@@ -81,7 +81,8 @@
         PETRIFICATION,
         BLUFF,
         BATTLE_FORCE,
-        SPELL_FORCE
+        SPELL_FORCE,
+        PROTECTION_BLESSING
     }
 
     private static final Func[] _emptyFunctionSet = new Func[0];
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java  (revision 1240)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java  (working copy)
@@ -966,6 +966,10 @@
             {
                 makeSupportMagic(player);
             }
+            else if (command.startsWith("GiveBlessing"))
+            {
+               giveBlessingSupport(player);
+            }
             else if (command.startsWith("multisell"))
             {
                 L2Multisell.getInstance().SeparateAndSend(Integer.parseInt(command.substring(9).trim()), player, false, getCastle().getTaxRate());
@@ -1036,7 +1040,30 @@
         }
     }
     
-    /**
+    public void giveBlessingSupport(L2PcInstance player)
+       {
+       if (player == null)
+          return;
+
+       // Prevent a cursed weapon weilder of being buffed
+       if (player.isCursedWeaponEquiped())
+          return;
+
+       int player_level = player.getLevel();
+        // Select the player
+        setTarget(player);
+        // If the player is too high level, display a message and return
+        if (player_level > 39 || !player.isNewbie())
+        {
+            String content = "<html><body>Newbie Guide:<br>Only a <font color=\"LEVEL\">novice character of level 39 or less</font> can receive my support magic.<br>Your novice character is the first one that you created and raised in this world.</body></html>";
+            insertObjectIdAndShowChatWindow(player, content);
+            return;
+        }
+        L2Skill skill = SkillTable.getInstance().getInfo(5182,1);
+        doCast(skill);
+       }
+
+       /**
      * Return null (regular NPCs don't have weapons instancies).<BR><BR>
      */
     @Override
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PlayableInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PlayableInstance.java     (revision 1240)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PlayableInstance.java     (working copy)
@@ -39,6 +39,7 @@
 {
 
        private boolean _isNoblesseBlessed = false; // for Noblesse Blessing skill, restores buffs after death
+       private boolean _ProtectionBlessing = false; // for Newbie Protection Blessing skill, keeps you safe from an attack by a chaotic character >= 10 levels apart from you
        /**
         * Constructor of L2PlayableInstance (use L2Character constructor).<BR><BR>
         *
@@ -178,4 +179,30 @@
     
        public abstract boolean destroyItemByItemId(String process, int itemId, int count, L2Object reference, boolean sendMessage);
        public abstract boolean destroyItem(String process, int objectId, int count, L2Object reference, boolean sendMessage);
+
+    // for Newbie Protection Blessing skill, keeps you safe from an attack by a chaotic character >= 10 levels apart from you
+    public final boolean getProtectionBlessing() { return _ProtectionBlessing; }
+    public final void setProtectionBlessing(boolean value) { _ProtectionBlessing = value; }
+       /**
+        *
+        */
+       public void startProtectionBlessing()
+       {
+       setProtectionBlessing(true);
+       updateAbnormalEffect();
+    }
+
+       /**
+        * @param blessing
+        */
+       public void stopProtectionBlessing(L2Effect effect)
+       {
+       if (effect == null)
+          stopEffects(L2Effect.EffectType.PROTECTION_BLESSING);
+       else
+          removeEffect(effect);
+             
+       setProtectionBlessing(false);
+       updateAbnormalEffect();
+    }
 }
Index: java/net/sf/l2j/gameserver/skills/effects/EffectProtectionBlessing.java
===================================================================
--- java/net/sf/l2j/gameserver/skills/effects/EffectProtectionBlessing.java     (revision 0)
+++ java/net/sf/l2j/gameserver/skills/effects/EffectProtectionBlessing.java     (revision 0)
@@ -0,0 +1,61 @@
+/* This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, *fork*., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+package net.sf.l2j.gameserver.skills.effects;
+
+import net.sf.l2j.gameserver.model.L2Effect;
+import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;
+import net.sf.l2j.gameserver.skills.Env;
+
+/**
+ * @author kerberos_20
+ *
+ */
+public class EffectProtectionBlessing extends L2Effect
+{
+       public EffectProtectionBlessing(Env env, EffectTemplate template)
+       {
+              super(env, template);
+       }
+
+       @Override
+       public EffectType getEffectType()
+       {
+              return EffectType.PROTECTION_BLESSING;
+       }
+       
+       /** Notify started */
+       @Override
+       public void onStart() {
+              if (getEffected() instanceof L2PlayableInstance)
+                     ((L2PlayableInstance)getEffected()).startProtectionBlessing();
+       }
+       
+       /** Notify exited */
+       @Override
+       public void onExit() {
+              if (getEffected() instanceof L2PlayableInstance)
+                     ((L2PlayableInstance)getEffected()).stopProtectionBlessing (this);
+       }
+       
+    @Override
+       public boolean onActionTime()
+    {
+       // just stop this effect
+       return false;
+    }
+}
\ No newline at end of file