Garden Watchman AI.
Contributed by gigilo1968.
This commit is contained in:
		
							
								
								
									
										105
									
								
								L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/areas/GardenOfGenesis/GardenWatchman.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/ai/areas/GardenOfGenesis/GardenWatchman.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,105 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the L2J Mobius project.
 | 
			
		||||
 * 
 | 
			
		||||
 * 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
package ai.areas.GardenOfGenesis;
 | 
			
		||||
 | 
			
		||||
import com.l2jmobius.gameserver.geoengine.GeoEngine;
 | 
			
		||||
import com.l2jmobius.gameserver.model.L2World;
 | 
			
		||||
import com.l2jmobius.gameserver.model.actor.L2Character;
 | 
			
		||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
 | 
			
		||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
 | 
			
		||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
 | 
			
		||||
 | 
			
		||||
import ai.AbstractNpcAI;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Garden Watchman AI
 | 
			
		||||
 * @author Gigi
 | 
			
		||||
 * @date 2018-08-26 - [12:27:45]
 | 
			
		||||
 */
 | 
			
		||||
public class GardenWatchman extends AbstractNpcAI
 | 
			
		||||
{
 | 
			
		||||
	// NPCs
 | 
			
		||||
	private static final int GARDEN_WATCHMAN = 22952;
 | 
			
		||||
	private static final int GENESIS_TRAP_1 = 18985;
 | 
			
		||||
	private static final int GENESIS_TRAP_2 = 18986;
 | 
			
		||||
	// Skills
 | 
			
		||||
	private static final SkillHolder TRAP_SETUP = new SkillHolder(14418, 1);
 | 
			
		||||
	private static final SkillHolder HARMFUL_TRAP_1 = new SkillHolder(14075, 1);
 | 
			
		||||
	private static final SkillHolder HARMFUL_TRAP_2 = new SkillHolder(14076, 1);
 | 
			
		||||
	
 | 
			
		||||
	public GardenWatchman()
 | 
			
		||||
	{
 | 
			
		||||
		addSpawnId(GARDEN_WATCHMAN);
 | 
			
		||||
		addSeeCreatureId(GENESIS_TRAP_1, GENESIS_TRAP_2);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
 | 
			
		||||
	{
 | 
			
		||||
		switch (event)
 | 
			
		||||
		{
 | 
			
		||||
			case "SPAWN_TRAP":
 | 
			
		||||
			{
 | 
			
		||||
				if (!npc.isInCombat())
 | 
			
		||||
				{
 | 
			
		||||
					npc.doCast(TRAP_SETUP.getSkill());
 | 
			
		||||
					final L2Npc trap = addSpawn((getRandom(10) < 5) ? GENESIS_TRAP_1 : GENESIS_TRAP_2, npc, true, 90000, false);
 | 
			
		||||
					trap.setDisplayEffect(1);
 | 
			
		||||
					startQuestTimer("SPAWN_TRAP", getRandom(50000, 100000), npc, null);
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
			case "DEBUFF":
 | 
			
		||||
			{
 | 
			
		||||
				L2World.getInstance().forEachVisibleObjectInRange(npc, L2PcInstance.class, 100, nearby ->
 | 
			
		||||
				{
 | 
			
		||||
					if ((npc != null) && npc.isScriptValue(0) && nearby.isPlayer() && GeoEngine.getInstance().canSeeTarget(npc, nearby))
 | 
			
		||||
					{
 | 
			
		||||
						npc.setScriptValue(1);
 | 
			
		||||
						npc.setTarget(nearby);
 | 
			
		||||
						npc.doCast((getRandom(10) < 5) ? HARMFUL_TRAP_1.getSkill() : HARMFUL_TRAP_2.getSkill());
 | 
			
		||||
						npc.deleteMe();
 | 
			
		||||
					}
 | 
			
		||||
				});
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return super.onAdvEvent(event, npc, player);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String onSpawn(L2Npc npc)
 | 
			
		||||
	{
 | 
			
		||||
		startQuestTimer("SPAWN_TRAP", 50000, npc, null);
 | 
			
		||||
		return super.onSpawn(npc);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String onSeeCreature(L2Npc npc, L2Character creature, boolean isSummon)
 | 
			
		||||
	{
 | 
			
		||||
		if (creature.isPlayer())
 | 
			
		||||
		{
 | 
			
		||||
			startQuestTimer("DEBUFF", 3000, npc, null, true);
 | 
			
		||||
		}
 | 
			
		||||
		return super.onSeeCreature(npc, creature, isSummon);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public static void main(String[] args)
 | 
			
		||||
	{
 | 
			
		||||
		new GardenWatchman();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -3379,7 +3379,7 @@
 | 
			
		||||
			<defence physical="607.972112" magical="667.3314" />
 | 
			
		||||
			<abnormalResist physical="10" magical="10" />
 | 
			
		||||
		</stats>
 | 
			
		||||
		<status attackable="false" targetable="false" showName="false" undying="true" />
 | 
			
		||||
		<status attackable="false" targetable="false" showName="false" canMove="false" undying="true" />
 | 
			
		||||
		<skill_list>
 | 
			
		||||
			<skill id="14075" level="1" /> <!-- Harmful Trap -->
 | 
			
		||||
			<skill id="4416" level="2" /> <!-- Magic Creatures -->
 | 
			
		||||
@@ -3413,7 +3413,7 @@
 | 
			
		||||
			<defence physical="607.972112" magical="667.3314" />
 | 
			
		||||
			<abnormalResist physical="10" magical="10" />
 | 
			
		||||
		</stats>
 | 
			
		||||
		<status attackable="false" targetable="false" showName="false" undying="true" />
 | 
			
		||||
		<status attackable="false" targetable="false" showName="false" canMove="false" undying="true" />
 | 
			
		||||
		<skill_list>
 | 
			
		||||
			<skill id="14076" level="1" /> <!-- Harmful Trap -->
 | 
			
		||||
			<skill id="4416" level="2" /> <!-- Magic Creatures -->
 | 
			
		||||
@@ -3440,7 +3440,7 @@
 | 
			
		||||
			<defence physical="379.98257" magical="278.05475" />
 | 
			
		||||
			<abnormalResist physical="10" magical="10" />
 | 
			
		||||
		</stats>
 | 
			
		||||
		<status attackable="false" targetable="false" />
 | 
			
		||||
		<status attackable="false" targetable="false" talkable="false" canMove="false" />
 | 
			
		||||
		<skill_list>
 | 
			
		||||
			<skill id="4416" level="2" /> <!-- Magic Creatures -->
 | 
			
		||||
			<skill id="4415" level="3" /> <!-- One-handed Sword -->
 | 
			
		||||
@@ -3466,7 +3466,7 @@
 | 
			
		||||
			<defence physical="379.98257" magical="278.05475" />
 | 
			
		||||
			<abnormalResist physical="10" magical="10" />
 | 
			
		||||
		</stats>
 | 
			
		||||
		<status attackable="false" targetable="false" />
 | 
			
		||||
		<status attackable="false" targetable="false" talkable="false" canMove="false" />
 | 
			
		||||
		<skill_list>
 | 
			
		||||
			<skill id="4416" level="2" /> <!-- Magic Creatures -->
 | 
			
		||||
			<skill id="4415" level="3" /> <!-- One-handed Sword -->
 | 
			
		||||
 
 | 
			
		||||
@@ -2801,9 +2801,8 @@
 | 
			
		||||
		<abnormalTime>180</abnormalTime>
 | 
			
		||||
		<affectRange>100</affectRange>
 | 
			
		||||
		<isDebuff>true</isDebuff>
 | 
			
		||||
		<targetType>SELF</targetType>
 | 
			
		||||
		<affectScope>POINT_BLANK</affectScope>
 | 
			
		||||
		<affectObject>NOT_FRIEND</affectObject>
 | 
			
		||||
		<targetType>TARGET</targetType>
 | 
			
		||||
		<affectScope>SINGLE</affectScope>
 | 
			
		||||
		<effects>
 | 
			
		||||
			<effect name="Speed">
 | 
			
		||||
				<amount>-20</amount>
 | 
			
		||||
@@ -2829,9 +2828,8 @@
 | 
			
		||||
		<abnormalTime>180</abnormalTime>
 | 
			
		||||
		<affectRange>100</affectRange>
 | 
			
		||||
		<isDebuff>true</isDebuff>
 | 
			
		||||
		<targetType>SELF</targetType>
 | 
			
		||||
		<affectScope>POINT_BLANK</affectScope>
 | 
			
		||||
		<affectObject>NOT_FRIEND</affectObject>
 | 
			
		||||
		<targetType>TARGET</targetType>
 | 
			
		||||
		<affectScope>SINGLE</affectScope>
 | 
			
		||||
		<effects>
 | 
			
		||||
			<effect name="PhysicalAttackSpeed">
 | 
			
		||||
				<amount>-15</amount>
 | 
			
		||||
 
 | 
			
		||||
@@ -476,7 +476,7 @@
 | 
			
		||||
		<rideState>NONE</rideState>
 | 
			
		||||
		<magicCriticalRate>-5</magicCriticalRate>
 | 
			
		||||
		<hitCancelTime>0</hitCancelTime>
 | 
			
		||||
		<magicLvl>95</magicLvl>
 | 
			
		||||
		<magicLvl>90</magicLvl>
 | 
			
		||||
		<hitTime>2000</hitTime>
 | 
			
		||||
		<targetType>SELF</targetType>
 | 
			
		||||
		<affectScope>SINGLE</affectScope>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user