Jump to content

Recommended Posts

Posted

Epidi dn to brika pouthena to kanw share, Protector npc to npc ayto apagoreyei to pvp i pk i kai ta dio analoga me to ti thelete eseis,se sigkekrimeno range kai bgazei kai ena minima tis epiloghs sas

 

[*]Ftiakste sto model.actor.instance ena L2ProtectorInstance

/* This program is free software; you can redistribute it and/or modify
2 	 * it under the terms of the GNU General Public License as published by
3 	 * the Free Software Foundation; either version 2, or (at your option)
4 	 * any later version.
5 	 *
6 	 * This program is distributed in the hope that it will be useful,
7 	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9 	 * GNU General Public License for more details.
10 	 *
11 	 * You should have received a copy of the GNU General Public License
12 	 * along with this program; if not, write to the Free Software
13 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
14 	 * 02111-1307, USA.
15 	 *
16 	 * http://www.gnu.org/copyleft/gpl.html
17 	 */
	package com.l2jrox.gameserver.model.actor.instance;

	import java.util.concurrent.ScheduledFuture;

	import com.l2jrox.Config;
	import com.l2jrox.gameserver.ThreadPoolManager;
	import com.l2jrox.gameserver.datatables.SkillTable;
	import com.l2jrox.gameserver.model.L2Character;
	import com.l2jrox.gameserver.model.L2Object;
import com.l2jrox.gameserver.model.L2Skill;
	import com.l2jrox.gameserver.network.serverpackets.CreatureSay;
	import com.l2jrox.gameserver.network.serverpackets.MagicSkillUse;
	import com.l2jrox.gameserver.templates.L2NpcTemplate;


	/**
	 * @author Ederik
 *
	 */
	public class L2ProtectorInstance extends L2NpcInstance
	{
	    private ScheduledFuture<?> _aiTask;

	    private class ProtectorAI implements Runnable
	    {
	        private L2ProtectorInstance _caster;

	        protected ProtectorAI(L2ProtectorInstance caster)
	        {
	            _caster = caster;
	        }

	        public void run()
	        {
	                /**
	             * For each known player in range, cast sleep if pvpFlag != 0 or Karma >0
	             * Skill use is just for buff animation
	             */
	                for (L2PcInstance player : getKnownList().getKnownPlayers().values())

	                {
	                        if ((player.getKarma() > 0 && Config.PROTECTOR_PLAYER_PK) || (player.getPvpFlag() != 0 && Config.PROTECTOR_PLAYER_PVP))
	                        {
	                                handleCast(player, Config.PROTECTOR_SKILLID, Config.PROTECTOR_SKILLLEVEL);
	                        }
	                }
        }

	        private boolean handleCast(L2PcInstance player, int skillId, int skillLevel)
	        {
	                if (player.isGM() || player.isDead() || !player.isVisible() || !isInsideRadius(player, getDistanceToWatchObject(player), false, false))
	                        return false;

	                L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLevel);

	            if (player.getFirstEffect(skill) == null)
	            {
	                int objId = _caster.getObjectId();
	                                skill.getEffects(_caster, player);
	                                broadcastPacket(new MagicSkillUse(_caster, player, skillId, skillLevel, Config.PROTECTOR_SKILLTIME, 0));
	                                broadcastPacket(new CreatureSay(objId,0,String.valueOf(getName()),Config.PROTECTOR_MESSAGE));

	                        return true;
	            }

	            return false;
	        }
	    }


	    public L2ProtectorInstance(int objectId, L2NpcTemplate template)
	    {
	        super(objectId, template);

	        if (_aiTask != null)
	                _aiTask.cancel(true);

	        _aiTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new ProtectorAI(this), 3000, 3000);
	    }

	    @Override
	        public void deleteMe()
	    {
	        if (_aiTask != null)
	        {
	                _aiTask.cancel(true);
	                _aiTask = null;
	        }

	        super.deleteMe();
	    }

	    @Override
	        public int getDistanceToWatchObject(L2Object object)
	    {
	        return Config.PROTECTOR_RADIUS_ACTION;
	    }

	    @Override
	        public boolean isAutoAttackable(L2Character attacker)
	    {
	        return false;
	    }
	}

 

 

[*]meta pate sto net.sf.l2j.config kai prostheste ta parakatw....

 

public static boolean PROTECTOR_PLAYER_PK;
  public static boolean PROTECTOR_PLAYER_PVP;
  public static int PROTECTOR_RADIUS_ACTION;
  public static int PROTECTOR_SKILLID;
  public static int PROTECTOR_SKILLLEVEL;
  public static int PROTECTOR_SKILLTIME;
  public static String PROTECTOR_MESSAGE;

PROTECTOR_PLAYER_PK = Boolean.parseBoolean(L2jModsSettings.getProperty("ProtectorPlayerPK", "false"));
		      PROTECTOR_PLAYER_PVP = Boolean.parseBoolean(L2jModsSettings.getProperty("ProtectorPlayerPVP", "false"));
		      PROTECTOR_RADIUS_ACTION = Integer.parseInt(L2jModsSettings.getProperty("ProtectorRadiusAction", "500"));
		      PROTECTOR_SKILLID = Integer.parseInt(L2jModsSettings.getProperty("ProtectorSkillId", "1069"));
		      PROTECTOR_SKILLLEVEL = Integer.parseInt(L2jModsSettings.getProperty("ProtectorSkillLevel", "42"));
		      PROTECTOR_SKILLTIME = Integer.parseInt(L2jModsSettings.getProperty("ProtectorSkillTime", "800"));
		      PROTECTOR_MESSAGE = L2jModsSettings.getProperty("ProtectorMessage", "Protector, not spawnkilling here, go read the rules !!!");

  [*] Meta prostheste tis parakatw rithtmiseis sto mods.properties

# --------------------
# Protector Npc Config
# --------------------
# Enable Protector npc action to player with karma or/and pvpFlag
# default = true

ProtectorPlayerPK  = true
ProtectorPlayerPVP = true

# Skill use by protector for player
# defaut protector use sleep level 42 time 800 check on radius 500

ProtectorRadiusAction = 1500
ProtectorSkillId      = 1069
ProtectorSkillLevel   = 42
ProtectorSkillTime    = 800

# Protector message

ProtectorMessage = "No  killing here, go read the rules !!!"

 

 

[*]Telos peraste ayto to npc sthn database sas

 

(50017, 31854, 'Protector', '1', 'PVP/PK Manager', '1', 'NPC.a_maidA_FHuman', '8.00', '20.50', '80', 'female', 'L2Protector', '40', '99999', '9999', null, null, '40', '43', '30', '21', '20', '10', '0', '0', '1314', '470', '10000', '382', '278', '0', '3000', '0', '0', '0', '55', '132', null, '0', '0', '0', 'LAST_HIT')

 

 

[*]kante spawn to npc ingame kai eiste etimoi!

Posted

afto edo    * meta pate sto net.sf.l2j.config kai prostheste ta parakatw....

 

Code:

 

public static boolean PROTECTOR_PLAYER_PK;

  public static boolean PROTECTOR_PLAYER_PVP;

  public static int PROTECTOR_RADIUS_ACTION;

  public static int PROTECTOR_SKILLID;

  public static int PROTECTOR_SKILLLEVEL;

  public static int PROTECTOR_SKILLTIME;

  public static String PROTECTOR_MESSAGE; kai ta alla episis pes kato apo pou ta pername gia na gini ena kalos guide fix

Posted

afto edo    * meta pate sto net.sf.l2j.config kai prostheste ta parakatw....

 

Code:

 

public static boolean PROTECTOR_PLAYER_PK;

  public static boolean PROTECTOR_PLAYER_PVP;

  public static int PROTECTOR_RADIUS_ACTION;

  public static int PROTECTOR_SKILLID;

  public static int PROTECTOR_SKILLLEVEL;

  public static int PROTECTOR_SKILLTIME;

  public static String PROTECTOR_MESSAGE; kai ta alla episis pes kato apo pou ta pername gia na gini ena kalos guide fix

 

kai ekeina gia to config einai.... Eyxaristw pedes a ksexasa credits l2jnet

  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...