[question] Ядро (event: тыквы\squash)
9 ответов190 просмотровСейчас просматривают: 1
· 28.04.2009, 20:18
Сборка: L2DOT Interlude (исходники)
Краткое изложение СУТИ проблемы: суть в том что я очень хочу добавить эвент: тыквы\Squash, есть исходный код из Rellebion.
Nectar.java
Раскрывающийся текст
Код
package events.TheFallHarvest;
import l2r.extensions.scripts.ScriptFile;
import l2r.gameserver.cache.Msg;
import l2r.gameserver.handler.IItemHandler;
import l2r.gameserver.handler.ItemHandler;
import l2r.gameserver.model.L2Character;
import l2r.gameserver.model.L2Playable;
import l2r.gameserver.model.L2Player;
import l2r.gameserver.model.L2Skill;
import l2r.gameserver.model.instances.L2ItemInstance;
import l2r.gameserver.tables.SkillTable;
public class Nectar implements IItemHandler, ScriptFile
{
private static short[] _itemIds = { 6391 };
public void useItem(L2Playable playable, L2ItemInstance item)
{
L2Player player = (L2Player) playable;
L2Character target = (L2Character) player.getTarget();
if(!(target instanceof SquashInstance))
{
player.sendPacket(Msg.INCORRECT_TARGET);
return;
}
L2Skill skill = SkillTable.getInstance().getInfo(2005, 1);
if(skill != null) // && skill.checkCondition(player, target, true, false, true))
player.getAI().Cast(skill, target);
}
public short[] getItemIds()
{
return _itemIds;
}
public void onLoad()
{
ItemHandler.getInstance().registerItemHandler(this);
}
public void onReload()
{}
public void onShutdown()
{}
}
import l2r.extensions.scripts.ScriptFile;
import l2r.gameserver.cache.Msg;
import l2r.gameserver.handler.IItemHandler;
import l2r.gameserver.handler.ItemHandler;
import l2r.gameserver.model.L2Character;
import l2r.gameserver.model.L2Playable;
import l2r.gameserver.model.L2Player;
import l2r.gameserver.model.L2Skill;
import l2r.gameserver.model.instances.L2ItemInstance;
import l2r.gameserver.tables.SkillTable;
public class Nectar implements IItemHandler, ScriptFile
{
private static short[] _itemIds = { 6391 };
public void useItem(L2Playable playable, L2ItemInstance item)
{
L2Player player = (L2Player) playable;
L2Character target = (L2Character) player.getTarget();
if(!(target instanceof SquashInstance))
{
player.sendPacket(Msg.INCORRECT_TARGET);
return;
}
L2Skill skill = SkillTable.getInstance().getInfo(2005, 1);
if(skill != null) // && skill.checkCondition(player, target, true, false, true))
player.getAI().Cast(skill, target);
}
public short[] getItemIds()
{
return _itemIds;
}
public void onLoad()
{
ItemHandler.getInstance().registerItemHandler(this);
}
public void onReload()
{}
public void onShutdown()
{}
}
Seed.java
Раскрывающийся текст
Код
package events.TheFallHarvest;
import l2r.extensions.scripts.ScriptFile;
import l2r.gameserver.ThreadPoolManager;
import l2r.gameserver.handler.IItemHandler;
import l2r.gameserver.handler.ItemHandler;
import l2r.gameserver.idfactory.IdFactory;
import l2r.gameserver.model.L2Object;
import l2r.gameserver.model.L2Playable;
import l2r.gameserver.model.L2Player;
import l2r.gameserver.model.L2Spawn;
import l2r.gameserver.model.instances.L2ItemInstance;
import l2r.gameserver.model.instances.L2NpcInstance;
import l2r.gameserver.serverpackets.SystemMessage;
import l2r.gameserver.tables.NpcTable;
import l2r.gameserver.templates.L2NpcTemplate;
public class Seed implements IItemHandler, ScriptFile
{
public class DeSpawnScheduleTimerTask implements Runnable
{
L2Spawn spawnedPlant = null;
public DeSpawnScheduleTimerTask(L2Spawn spawn)
{
spawnedPlant = spawn;
}
public void run()
{
try
{
spawnedPlant.getLastSpawn().decayMe();
spawnedPlant.getLastSpawn().deleteMe();
}
catch(Throwable t)
{}
}
}
private static short[] _itemIds = { 6389, // small seed
6390 // large seed
};
private static int[] _npcIds = { 12774, // Young Pumpkin
12777 // Large Young Pumpkin
};
public void useItem(L2Playable playable, L2ItemInstance item)
{
L2Player activeChar = (L2Player) playable;
L2NpcTemplate template = null;
int itemId = item.getItemId();
for(int i = 0; i < _itemIds.length; i++)
if(_itemIds[i] == itemId)
{
template = NpcTable.getTemplate(_npcIds[i]);
break;
}
if(template == null)
return;
L2Object target = activeChar.getTarget();
if(target == null)
target = activeChar;
try
{
L2Spawn spawn = new L2Spawn(template);
spawn.setConstructor(SquashInstance.class.getConstructors()[0]);
spawn.setId(IdFactory.getInstance().getNextId());
spawn.setLoc(activeChar.getLoc());
L2NpcInstance npc = spawn.doSpawn(true);
npc.setAI(new SquashAI(npc));
npc.stopHpMpRegeneration();
((SquashInstance) npc).setSpawner(activeChar);
ThreadPoolManager.getInstance().scheduleGeneral(new DeSpawnScheduleTimerTask(spawn), 180000);
activeChar.getInventory().destroyItem(item.getObjectId(), 1, false);
}
catch(Exception e)
{
activeChar.sendPacket(new SystemMessage(SystemMessage.TARGET_CAN_NOT_BE_FOUND));
}
}
public short[] getItemIds()
{
return _itemIds;
}
public void onLoad()
{
ItemHandler.getInstance().registerItemHandler(this);
}
public void onReload()
{}
public void onShutdown()
{}
}
import l2r.extensions.scripts.ScriptFile;
import l2r.gameserver.ThreadPoolManager;
import l2r.gameserver.handler.IItemHandler;
import l2r.gameserver.handler.ItemHandler;
import l2r.gameserver.idfactory.IdFactory;
import l2r.gameserver.model.L2Object;
import l2r.gameserver.model.L2Playable;
import l2r.gameserver.model.L2Player;
import l2r.gameserver.model.L2Spawn;
import l2r.gameserver.model.instances.L2ItemInstance;
import l2r.gameserver.model.instances.L2NpcInstance;
import l2r.gameserver.serverpackets.SystemMessage;
import l2r.gameserver.tables.NpcTable;
import l2r.gameserver.templates.L2NpcTemplate;
public class Seed implements IItemHandler, ScriptFile
{
public class DeSpawnScheduleTimerTask implements Runnable
{
L2Spawn spawnedPlant = null;
public DeSpawnScheduleTimerTask(L2Spawn spawn)
{
spawnedPlant = spawn;
}
public void run()
{
try
{
spawnedPlant.getLastSpawn().decayMe();
spawnedPlant.getLastSpawn().deleteMe();
}
catch(Throwable t)
{}
}
}
private static short[] _itemIds = { 6389, // small seed
6390 // large seed
};
private static int[] _npcIds = { 12774, // Young Pumpkin
12777 // Large Young Pumpkin
};
public void useItem(L2Playable playable, L2ItemInstance item)
{
L2Player activeChar = (L2Player) playable;
L2NpcTemplate template = null;
int itemId = item.getItemId();
for(int i = 0; i < _itemIds.length; i++)
if(_itemIds[i] == itemId)
{
template = NpcTable.getTemplate(_npcIds[i]);
break;
}
if(template == null)
return;
L2Object target = activeChar.getTarget();
if(target == null)
target = activeChar;
try
{
L2Spawn spawn = new L2Spawn(template);
spawn.setConstructor(SquashInstance.class.getConstructors()[0]);
spawn.setId(IdFactory.getInstance().getNextId());
spawn.setLoc(activeChar.getLoc());
L2NpcInstance npc = spawn.doSpawn(true);
npc.setAI(new SquashAI(npc));
npc.stopHpMpRegeneration();
((SquashInstance) npc).setSpawner(activeChar);
ThreadPoolManager.getInstance().scheduleGeneral(new DeSpawnScheduleTimerTask(spawn), 180000);
activeChar.getInventory().destroyItem(item.getObjectId(), 1, false);
}
catch(Exception e)
{
activeChar.sendPacket(new SystemMessage(SystemMessage.TARGET_CAN_NOT_BE_FOUND));
}
}
public short[] getItemIds()
{
return _itemIds;
}
public void onLoad()
{
ItemHandler.getInstance().registerItemHandler(this);
}
public void onReload()
{}
public void onShutdown()
{}
}
SquashAI.java
Раскрывающийся текст
Код
package events.TheFallHarvest;
import static l2r.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
import java.util.concurrent.ScheduledFuture;
import l2r.extensions.scripts.Functions;
import l2r.gameserver.ThreadPoolManager;
import l2r.gameserver.ai.Fighter;
import l2r.gameserver.model.L2Character;
import l2r.gameserver.model.L2DropData;
import l2r.gameserver.model.L2Skill;
import l2r.gameserver.model.L2Spawn;
import l2r.gameserver.model.base.ItemToDrop;
import l2r.gameserver.model.instances.L2ItemInstance;
import l2r.gameserver.model.instances.L2NpcInstance;
import l2r.gameserver.serverpackets.Die;
import l2r.gameserver.serverpackets.MagicSkillUse;
import l2r.gameserver.tables.ItemTable;
import l2r.gameserver.tables.NpcTable;
import l2r.util.Rnd;
public class SquashAI extends Fighter
{
public class PolimorphTask implements Runnable
{
public void run()
{
L2Spawn spawn = null;
try
{
spawn = new L2Spawn(NpcTable.getTemplate(_npcId));
spawn.setConstructor(SquashInstance.class.getConstructors()[0]);
spawn.setLoc(_thisActor.getLoc());
L2NpcInstance npc = spawn.doSpawn(true);
npc.setAI(new SquashAI(npc));
npc.stopHpMpRegeneration();
((SquashInstance) npc).setSpawner(((SquashInstance) _thisActor).getSpawner());
}
catch(Exception e)
{
e.printStackTrace();
}
_timeToUnspawn = Long.MAX_VALUE;
stopAITask();
_thisActor.deleteMe();
}
}
protected static final L2DropData[] _dropList = new L2DropData[] { new L2DropData(1539, 1, 5, 15000, 1), // Greater Healing Potion
new L2DropData(1374, 1, 3, 15000, 1), // Greater Haste Potion
new L2DropData(4411, 1, 1, 5000, 1), // Echo Crystal - Theme of Journey
new L2DropData(4412, 1, 1, 5000, 1), // Echo Crystal - Theme of Battle
new L2DropData(4413, 1, 1, 5000, 1), // Echo Crystal - Theme of Love
new L2DropData(4414, 1, 1, 5000, 1), // Echo Crystal - Theme of Solitude
new L2DropData(4415, 1, 1, 5000, 1), // Echo Crystal - Theme of the Feast
new L2DropData(4416, 1, 1, 5000, 1), // Echo Crystal - Theme of Celebration
new L2DropData(4417, 1, 1, 5000, 1), // Echo Crystal - Theme of Comedy
new L2DropData(5010, 1, 1, 5000, 1), // Echo Crystal - Theme of Victory
new L2DropData(1458, 10, 30, 13846, 1), // Crystal: D-Grade 1.3%
new L2DropData(1459, 10, 30, 3000, 1), // Crystal: C-Grade 0.3%
new L2DropData(1460, 10, 30, 1000, 1), // Crystal: B-Grade 0.1%
new L2DropData(1461, 10, 30, 600, 1), // Crystal: A-Grade 0.06%
new L2DropData(1462, 10, 30, 360, 1), // Crystal: S-Grade 0.036%
new L2DropData(4161, 1, 1, 5000, 1), // Recipe: Blue Wolf Tunic
new L2DropData(4182, 1, 1, 5000, 1), // Recipe: Great Sword
new L2DropData(4174, 1, 1, 5000, 1), // Recipe: Zubei's Boots
new L2DropData(4166, 1, 1, 5000, 1), // Recipe: Doom Helmet
new L2DropData(8660, 1, 1, 1000, 1), // Demon Horns 0.1%
new L2DropData(8661, 1, 1, 1000, 1), // Mask of Spirits 0.1%
new L2DropData(4393, 1, 1, 300, 1), // Calculator 0.03%
new L2DropData(7836, 1, 1, 200, 1), // Santa's Hat 0.02%
new L2DropData(5590, 1, 1, 200, 1), // Squeaking Shoes 0.02%
new L2DropData(7058, 1, 1, 50, 1), // Chrono Darbuka 0.005%
new L2DropData(8350, 1, 1, 50, 1), // Chrono Maracas 0.005%
new L2DropData(5133, 1, 1, 50, 1), // Chrono Unitus 0.005%
new L2DropData(5817, 1, 1, 50, 1), // Chrono Campana 0.005%
new L2DropData(9140, 1, 1, 30, 1), // Salvation Bow 0.003%
// Призрачные аксессуары - шанс 0.01%
new L2DropData(9177, 1, 1, 100, 1), // Teddy Bear Hat - Blessed Resurrection Effect
new L2DropData(9178, 1, 1, 100, 1), // Piggy Hat - Blessed Resurrection Effect
new L2DropData(9179, 1, 1, 100, 1), // Jester Hat - Blessed Resurrection Effect
new L2DropData(9180, 1, 1, 100, 1), // Wizard's Hat - Blessed Resurrection Effect
new L2DropData(9181, 1, 1, 100, 1), // Dapper Cap - Blessed Resurrection Effect
new L2DropData(9182, 1, 1, 100, 1), // Romantic Chapeau - Blessed Resurrection Effect
new L2DropData(9183, 1, 1, 100, 1), // Iron Circlet - Blessed Resurrection Effect
new L2DropData(9184, 1, 1, 100, 1), // Teddy Bear Hat - Blessed Escape Effect
new L2DropData(9185, 1, 1, 100, 1), // Piggy Hat - Blessed Escape Effect
new L2DropData(9186, 1, 1, 100, 1), // Jester Hat - Blessed Escape Effect
new L2DropData(9187, 1, 1, 100, 1), // Wizard's Hat - Blessed Escape Effect
new L2DropData(9188, 1, 1, 100, 1), // Dapper Cap - Blessed Escape Effect
new L2DropData(9189, 1, 1, 100, 1), // Romantic Chapeau - Blessed Escape Effect
new L2DropData(9190, 1, 1, 100, 1), // Iron Circlet - Blessed Escape Effect
new L2DropData(9191, 1, 1, 100, 1), // Teddy Bear Hat - Big Head
new L2DropData(9192, 1, 1, 100, 1), // Piggy Hat - Big Head
new L2DropData(9193, 1, 1, 100, 1), // Jester Hat - Big Head
new L2DropData(9194, 1, 1, 100, 1), // Wizard Hat - Big Head
new L2DropData(9195, 1, 1, 100, 1), // Dapper Hat - Big Head
new L2DropData(9196, 1, 1, 100, 1), // Romantic Chapeau - Big Head
new L2DropData(9197, 1, 1, 100, 1), // Iron Circlet - Big Head
new L2DropData(9198, 1, 1, 100, 1), // Teddy Bear Hat - Firework
new L2DropData(9199, 1, 1, 100, 1), // Piggy Hat - Firework
new L2DropData(9200, 1, 1, 100, 1), // Jester Hat - Firework
new L2DropData(9201, 1, 1, 100, 1), // Wizard's Hat - Firework
new L2DropData(9202, 1, 1, 100, 1), // Dapper Hat - Firework
new L2DropData(9203, 1, 1, 100, 1), // Romantic Chapeau - Firework
new L2DropData(9204, 1, 1, 100, 1), // Iron Circlet - Firework
new L2DropData(9146, 1, 3, 5000, 1), // Scroll of Guidance 0.5%
new L2DropData(9147, 1, 3, 5000, 1), // Scroll of Death Whisper 0.5%
new L2DropData(9148, 1, 3, 5000, 1), // Scroll of Focus 0.5%
new L2DropData(9149, 1, 3, 5000, 1), // Scroll of Acumen 0.5%
new L2DropData(9150, 1, 3, 5000, 1), // Scroll of Haste 0.5%
new L2DropData(9151, 1, 3, 5000, 1), // Scroll of Agility 0.5%
new L2DropData(9152, 1, 3, 5000, 1), // Scroll of Empower 0.5%
new L2DropData(9153, 1, 3, 5000, 1), // Scroll of Might 0.5%
new L2DropData(9154, 1, 3, 5000, 1), // Scroll of Wind Walk 0.5%
new L2DropData(9155, 1, 3, 5000, 1), // Scroll of Shield 0.5%
new L2DropData(9156, 1, 3, 2000, 1), // BSoE 0.2%
new L2DropData(9157, 1, 3, 1000, 1), // BRES 0.1%
new L2DropData(955, 1, 1, 400, 1), // EWD 0.04%
new L2DropData(956, 1, 1, 2000, 1), // EAD 0.2%
new L2DropData(951, 1, 1, 300, 1), // EWC 0.03%
new L2DropData(952, 1, 1, 1500, 1), // EAC 0.15%
new L2DropData(947, 1, 1, 200, 1), // EWB 0.02%
new L2DropData(948, 1, 1, 1000, 1), // EAB 0.1%
new L2DropData(729, 1, 1, 100, 1), // EWA 0.01%
new L2DropData(730, 1, 1, 500, 1), // EAA 0.05%
new L2DropData(959, 1, 1, 50, 1), // EWS 0.005%
new L2DropData(960, 1, 1, 300, 1), // EAS 0.03%
};
public final static int Young_Squash = 12774;
public final static int High_Quality_Squash = 12775;
public final static int Low_Quality_Squash = 12776;
public final static int Large_Young_Squash = 12777;
public final static int High_Quality_Large_Squash = 12778;
public final static int Low_Quality_Large_Squash = 12779;
public final static int King_Squash = 13016;
public final static int Emperor_Squash = 13017;
public final static int Squash_Level_up = 4513;
public final static int Squash_Poisoned = 4514;
private String[] textOnSpawn = new String[] {
"scripts.events.TheFallHarvest.SquashAI.textOnSpawn.0",
"scripts.events.TheFallHarvest.SquashAI.textOnSpawn.1",
"scripts.events.TheFallHarvest.SquashAI.textOnSpawn.2" };
private String[] textOnAttack = new String[] {
"Bites rat-a-tat... to change... body...!",
"Ha ha, grew up! Completely on all!",
"Cannot to aim all? Had a look all to flow out...",
"Is that also calculated hit? Look for person which has the strength!",
"Don't waste your time!",
"Ha, this sound is really pleasant to hear?",
"I eat your attack to grow!",
"Time to hit again! Come again!",
"Only useful music can open big pumpkin... It can not be opened with weapon!" };
private String[] textTooFast = new String[] {
"heh heh,looks well hit!",
"yo yo? Your skill is mediocre?",
"Time to hit again! Come again!",
"I eat your attack to grow!",
"Make an effort... to get down like this, I walked...",
"What is this kind of degree to want to open me? Really is indulges in fantasy!",
"Good fighting method. Evidently flies away the fly also can overcome.",
"Strives to excel strength oh! But waste your time..." };
private String[] textSuccess0 = new String[] {
"The lovely pumpkin young fruit start to glisten when taken to the threshing ground! From now on will be able to grow healthy and strong!",
"Oh, Haven't seen for a long time?",
"Suddenly, thought as soon as to see my beautiful appearance?",
"Well! This is something! Is the nectar?",
"Refuels! Drink 5 bottles to be able to grow into the big pumpkin oh!" };
private String[] textFail0 = new String[] {
"If I drink nectar, I can grow up faster!",
"Come, believe me, sprinkle a nectar! I can certainly turn the big pumpkin!!!",
"Take nectar to come, pumpkin nectar!" };
private String[] textSuccess1 = new String[] {
"Wish the big pumpkin!",
"completely became the recreation area! Really good!",
"Guessed I am mature or am rotten?",
"Nectar is just the best! Ha! Ha! Ha!" };
private String[] textFail1 = new String[] {
"oh! Randomly missed! Too quickly sprinkles the nectar?",
"If I die like this, you only could get young pumpkin...",
"Cultivate a bit faster! The good speech becomes the big pumpkin, the young pumpkin is not good!",
"The such small pumpkin you all must eat? Bring the nectar, I can be bigger!" };
private String[] textSuccess2 = new String[] {
"Young pumpkin wishing! Has how already grown up?",
"Already grew up! Quickly sneaked off...",
"Graciousness, is very good. Come again to see, now felt more and more well" };
private String[] textFail2 = new String[] {
"Hey! Was not there! Here is! Here! Not because I can not properly care? Small!",
"Wow, stops? Like this got down to have to thank",
"Hungry for a nectar oh...",
"Do you want the big pumpkin? But I like young pumpkin..." };
private String[] textSuccess3 = new String[] {
"Big pumpkin wishing! Ask, to sober!",
"Rumble rumble... it's really tasty! Hasn't it?",
"Cultivating me just to eat? Good, is casual your... not to give the manna on the suicide!" };
private String[] textFail3 = new String[] {
"Isn't it the water you add? What flavor?",
"Master, rescue my... I don't have the nectar flavor, I must die..." };
private String[] textSuccess4 = new String[] {
"is very good, does extremely well! Knew what next step should make?",
"If you catch me, I give you 10 million adena!!! Agree?" };
private String[] textFail4 = new String[] { "Hungry for a nectar oh...", "If I drink nectar, I can grow up faster!" };
private int _npcId;
private int _nectar;
private int _tryCount;
private long _lastNectarUse;
private long _timeToUnspawn;
@SuppressWarnings("unchecked")
private ScheduledFuture _polimorphTask;
private static int NECTAR_REUSE = 3000;
public SquashAI(L2Character actor)
{
super(actor);
_npcId = _thisActor.getNpcId();
Functions.npcShoutCustomMessage(_thisActor, textOnSpawn[Rnd.get(textOnSpawn.length)], null);
_timeToUnspawn = System.currentTimeMillis() + 120000;
}
@Override
protected boolean thinkActive()
{
if(System.currentTimeMillis() > _timeToUnspawn)
{
_timeToUnspawn = Long.MAX_VALUE;
if(_polimorphTask != null)
{
_polimorphTask.cancel(true);
_polimorphTask = null;
}
stopAITask();
_thisActor.deleteMe();
}
return false;
}
@Override
protected void onEvtSeeSpell(L2Skill skill, L2Character caster)
{
if(skill.getId() != 2005)
return;
switch(_tryCount)
{
case 0:
_tryCount++;
_lastNectarUse = System.currentTimeMillis();
if(Rnd.chance(50))
{
_nectar++;
Functions.npcShout(_thisActor, textSuccess0[Rnd.get(textSuccess0.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Level_up, 1, NECTAR_REUSE, 0));
}
else
{
Functions.npcShout(_thisActor, textFail0[Rnd.get(textFail0.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
}
break;
case 1:
if(System.currentTimeMillis() - _lastNectarUse < NECTAR_REUSE)
{
Functions.npcShout(_thisActor, textTooFast[Rnd.get(textTooFast.length)]);
return;
}
_tryCount++;
_lastNectarUse = System.currentTimeMillis();
if(Rnd.chance(50))
{
_nectar++;
Functions.npcShout(_thisActor, textSuccess1[Rnd.get(textSuccess1.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Level_up, 1, NECTAR_REUSE, 0));
}
else
{
Functions.npcShout(_thisActor, textFail1[Rnd.get(textFail1.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
}
break;
case 2:
if(System.currentTimeMillis() - _lastNectarUse < NECTAR_REUSE)
{
Functions.npcShout(_thisActor, textTooFast[Rnd.get(textTooFast.length)]);
return;
}
_tryCount++;
_lastNectarUse = System.currentTimeMillis();
if(Rnd.chance(50))
{
_nectar++;
Functions.npcShout(_thisActor, textSuccess2[Rnd.get(textSuccess2.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Level_up, 1, NECTAR_REUSE, 0));
}
else
{
Functions.npcShout(_thisActor, textFail2[Rnd.get(textFail2.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
}
break;
case 3:
if(System.currentTimeMillis() - _lastNectarUse < NECTAR_REUSE)
{
Functions.npcShout(_thisActor, textTooFast[Rnd.get(textTooFast.length)]);
return;
}
_tryCount++;
_lastNectarUse = System.currentTimeMillis();
if(Rnd.chance(50))
{
_nectar++;
Functions.npcShout(_thisActor, textSuccess3[Rnd.get(textSuccess3.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Level_up, 1, NECTAR_REUSE, 0));
}
else
{
Functions.npcShout(_thisActor, textFail3[Rnd.get(textFail3.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
}
break;
case 4:
if(System.currentTimeMillis() - _lastNectarUse < NECTAR_REUSE)
{
Functions.npcShout(_thisActor, textTooFast[Rnd.get(textTooFast.length)]);
return;
}
_tryCount++;
_lastNectarUse = System.currentTimeMillis();
if(Rnd.chance(50))
{
_nectar++;
Functions.npcShout(_thisActor, textSuccess4[Rnd.get(textSuccess4.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Level_up, 1, NECTAR_REUSE, 0));
}
else
{
Functions.npcShout(_thisActor, textFail4[Rnd.get(textFail4.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
}
if(_npcId == Young_Squash)
{
if(_nectar < 3)
_npcId = Low_Quality_Squash;
else if(_nectar == 5)
_npcId = King_Squash;
else
_npcId = High_Quality_Squash;
}
else if(_npcId == Large_Young_Squash)
if(_nectar < 3)
_npcId = Low_Quality_Large_Squash;
else if(_nectar == 5)
_npcId = Emperor_Squash;
else
_npcId = High_Quality_Large_Squash;
_polimorphTask = ThreadPoolManager.getInstance().scheduleGeneral(new PolimorphTask(), NECTAR_REUSE);
break;
}
}
@Override
protected void onEvtAttacked(L2Character attacker, int damage)
{
if(Rnd.chance(10))
Functions.npcShout(_thisActor, textOnAttack[Rnd.get(textOnAttack.length)]);
}
@Override
protected void onEvtDead()
{
int dropMod = 1;
switch(_npcId)
{
case Low_Quality_Squash:
dropMod = 1;
Functions.npcShout(_thisActor, "The pampkin opens!!!");
Functions.npcShout(_thisActor, "ya yo! Opens! Good thing many...");
break;
case High_Quality_Squash:
dropMod = 2;
Functions.npcShout(_thisActor, "The pampkin opens!!!");
Functions.npcShout(_thisActor, "ya yo! Opens! Good thing many...");
break;
case Low_Quality_Large_Squash:
dropMod = 2;
Functions.npcShout(_thisActor, "The pampkin opens!!!");
Functions.npcShout(_thisActor, "ya yo! Opens! Good thing many...");
break;
case High_Quality_Large_Squash:
dropMod = 4;
Functions.npcShout(_thisActor, "The pampkin opens!!!");
Functions.npcShout(_thisActor, "ya yo! Opens! Good thing many...");
break;
case King_Squash:
dropMod = 4;
Functions.npcShout(_thisActor, "The pampkin opens!!!");
Functions.npcShout(_thisActor, "ya yo! Opens! Good thing many...");
break;
case Emperor_Squash:
dropMod = 8;
Functions.npcShout(_thisActor, "The pampkin opens!!!");
Functions.npcShout(_thisActor, "ya yo! Opens! Good thing many...");
break;
default:
dropMod = 0;
Functions.npcShout(_thisActor, "Ouch, if I had died like this, you could obtain nothing!");
Functions.npcShout(_thisActor, "The news about my death shouldn't spread, oh!");
break;
}
_actor.breakAttack();
_actor.broadcastPacket(new Die(_actor));
_intention = AI_INTENTION_IDLE;
if(dropMod > 0)
for(L2DropData d : _dropList)
{
ItemToDrop itd = d.roll(null, dropMod * 1.5);
if(itd != null)
{
L2ItemInstance item = ItemTable.getInstance().createItem(itd.itemId, 0, 0, "TheFallHarvest");
item.setCount(itd.count);
item.dropToTheGround(((SquashInstance) _thisActor).getSpawner(), (L2NpcInstance) _actor);
}
}
}
@Override
protected boolean randomAnimation()
{
return false;
}
@Override
protected boolean randomWalk()
{
return false;
}
}
import static l2r.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
import java.util.concurrent.ScheduledFuture;
import l2r.extensions.scripts.Functions;
import l2r.gameserver.ThreadPoolManager;
import l2r.gameserver.ai.Fighter;
import l2r.gameserver.model.L2Character;
import l2r.gameserver.model.L2DropData;
import l2r.gameserver.model.L2Skill;
import l2r.gameserver.model.L2Spawn;
import l2r.gameserver.model.base.ItemToDrop;
import l2r.gameserver.model.instances.L2ItemInstance;
import l2r.gameserver.model.instances.L2NpcInstance;
import l2r.gameserver.serverpackets.Die;
import l2r.gameserver.serverpackets.MagicSkillUse;
import l2r.gameserver.tables.ItemTable;
import l2r.gameserver.tables.NpcTable;
import l2r.util.Rnd;
public class SquashAI extends Fighter
{
public class PolimorphTask implements Runnable
{
public void run()
{
L2Spawn spawn = null;
try
{
spawn = new L2Spawn(NpcTable.getTemplate(_npcId));
spawn.setConstructor(SquashInstance.class.getConstructors()[0]);
spawn.setLoc(_thisActor.getLoc());
L2NpcInstance npc = spawn.doSpawn(true);
npc.setAI(new SquashAI(npc));
npc.stopHpMpRegeneration();
((SquashInstance) npc).setSpawner(((SquashInstance) _thisActor).getSpawner());
}
catch(Exception e)
{
e.printStackTrace();
}
_timeToUnspawn = Long.MAX_VALUE;
stopAITask();
_thisActor.deleteMe();
}
}
protected static final L2DropData[] _dropList = new L2DropData[] { new L2DropData(1539, 1, 5, 15000, 1), // Greater Healing Potion
new L2DropData(1374, 1, 3, 15000, 1), // Greater Haste Potion
new L2DropData(4411, 1, 1, 5000, 1), // Echo Crystal - Theme of Journey
new L2DropData(4412, 1, 1, 5000, 1), // Echo Crystal - Theme of Battle
new L2DropData(4413, 1, 1, 5000, 1), // Echo Crystal - Theme of Love
new L2DropData(4414, 1, 1, 5000, 1), // Echo Crystal - Theme of Solitude
new L2DropData(4415, 1, 1, 5000, 1), // Echo Crystal - Theme of the Feast
new L2DropData(4416, 1, 1, 5000, 1), // Echo Crystal - Theme of Celebration
new L2DropData(4417, 1, 1, 5000, 1), // Echo Crystal - Theme of Comedy
new L2DropData(5010, 1, 1, 5000, 1), // Echo Crystal - Theme of Victory
new L2DropData(1458, 10, 30, 13846, 1), // Crystal: D-Grade 1.3%
new L2DropData(1459, 10, 30, 3000, 1), // Crystal: C-Grade 0.3%
new L2DropData(1460, 10, 30, 1000, 1), // Crystal: B-Grade 0.1%
new L2DropData(1461, 10, 30, 600, 1), // Crystal: A-Grade 0.06%
new L2DropData(1462, 10, 30, 360, 1), // Crystal: S-Grade 0.036%
new L2DropData(4161, 1, 1, 5000, 1), // Recipe: Blue Wolf Tunic
new L2DropData(4182, 1, 1, 5000, 1), // Recipe: Great Sword
new L2DropData(4174, 1, 1, 5000, 1), // Recipe: Zubei's Boots
new L2DropData(4166, 1, 1, 5000, 1), // Recipe: Doom Helmet
new L2DropData(8660, 1, 1, 1000, 1), // Demon Horns 0.1%
new L2DropData(8661, 1, 1, 1000, 1), // Mask of Spirits 0.1%
new L2DropData(4393, 1, 1, 300, 1), // Calculator 0.03%
new L2DropData(7836, 1, 1, 200, 1), // Santa's Hat 0.02%
new L2DropData(5590, 1, 1, 200, 1), // Squeaking Shoes 0.02%
new L2DropData(7058, 1, 1, 50, 1), // Chrono Darbuka 0.005%
new L2DropData(8350, 1, 1, 50, 1), // Chrono Maracas 0.005%
new L2DropData(5133, 1, 1, 50, 1), // Chrono Unitus 0.005%
new L2DropData(5817, 1, 1, 50, 1), // Chrono Campana 0.005%
new L2DropData(9140, 1, 1, 30, 1), // Salvation Bow 0.003%
// Призрачные аксессуары - шанс 0.01%
new L2DropData(9177, 1, 1, 100, 1), // Teddy Bear Hat - Blessed Resurrection Effect
new L2DropData(9178, 1, 1, 100, 1), // Piggy Hat - Blessed Resurrection Effect
new L2DropData(9179, 1, 1, 100, 1), // Jester Hat - Blessed Resurrection Effect
new L2DropData(9180, 1, 1, 100, 1), // Wizard's Hat - Blessed Resurrection Effect
new L2DropData(9181, 1, 1, 100, 1), // Dapper Cap - Blessed Resurrection Effect
new L2DropData(9182, 1, 1, 100, 1), // Romantic Chapeau - Blessed Resurrection Effect
new L2DropData(9183, 1, 1, 100, 1), // Iron Circlet - Blessed Resurrection Effect
new L2DropData(9184, 1, 1, 100, 1), // Teddy Bear Hat - Blessed Escape Effect
new L2DropData(9185, 1, 1, 100, 1), // Piggy Hat - Blessed Escape Effect
new L2DropData(9186, 1, 1, 100, 1), // Jester Hat - Blessed Escape Effect
new L2DropData(9187, 1, 1, 100, 1), // Wizard's Hat - Blessed Escape Effect
new L2DropData(9188, 1, 1, 100, 1), // Dapper Cap - Blessed Escape Effect
new L2DropData(9189, 1, 1, 100, 1), // Romantic Chapeau - Blessed Escape Effect
new L2DropData(9190, 1, 1, 100, 1), // Iron Circlet - Blessed Escape Effect
new L2DropData(9191, 1, 1, 100, 1), // Teddy Bear Hat - Big Head
new L2DropData(9192, 1, 1, 100, 1), // Piggy Hat - Big Head
new L2DropData(9193, 1, 1, 100, 1), // Jester Hat - Big Head
new L2DropData(9194, 1, 1, 100, 1), // Wizard Hat - Big Head
new L2DropData(9195, 1, 1, 100, 1), // Dapper Hat - Big Head
new L2DropData(9196, 1, 1, 100, 1), // Romantic Chapeau - Big Head
new L2DropData(9197, 1, 1, 100, 1), // Iron Circlet - Big Head
new L2DropData(9198, 1, 1, 100, 1), // Teddy Bear Hat - Firework
new L2DropData(9199, 1, 1, 100, 1), // Piggy Hat - Firework
new L2DropData(9200, 1, 1, 100, 1), // Jester Hat - Firework
new L2DropData(9201, 1, 1, 100, 1), // Wizard's Hat - Firework
new L2DropData(9202, 1, 1, 100, 1), // Dapper Hat - Firework
new L2DropData(9203, 1, 1, 100, 1), // Romantic Chapeau - Firework
new L2DropData(9204, 1, 1, 100, 1), // Iron Circlet - Firework
new L2DropData(9146, 1, 3, 5000, 1), // Scroll of Guidance 0.5%
new L2DropData(9147, 1, 3, 5000, 1), // Scroll of Death Whisper 0.5%
new L2DropData(9148, 1, 3, 5000, 1), // Scroll of Focus 0.5%
new L2DropData(9149, 1, 3, 5000, 1), // Scroll of Acumen 0.5%
new L2DropData(9150, 1, 3, 5000, 1), // Scroll of Haste 0.5%
new L2DropData(9151, 1, 3, 5000, 1), // Scroll of Agility 0.5%
new L2DropData(9152, 1, 3, 5000, 1), // Scroll of Empower 0.5%
new L2DropData(9153, 1, 3, 5000, 1), // Scroll of Might 0.5%
new L2DropData(9154, 1, 3, 5000, 1), // Scroll of Wind Walk 0.5%
new L2DropData(9155, 1, 3, 5000, 1), // Scroll of Shield 0.5%
new L2DropData(9156, 1, 3, 2000, 1), // BSoE 0.2%
new L2DropData(9157, 1, 3, 1000, 1), // BRES 0.1%
new L2DropData(955, 1, 1, 400, 1), // EWD 0.04%
new L2DropData(956, 1, 1, 2000, 1), // EAD 0.2%
new L2DropData(951, 1, 1, 300, 1), // EWC 0.03%
new L2DropData(952, 1, 1, 1500, 1), // EAC 0.15%
new L2DropData(947, 1, 1, 200, 1), // EWB 0.02%
new L2DropData(948, 1, 1, 1000, 1), // EAB 0.1%
new L2DropData(729, 1, 1, 100, 1), // EWA 0.01%
new L2DropData(730, 1, 1, 500, 1), // EAA 0.05%
new L2DropData(959, 1, 1, 50, 1), // EWS 0.005%
new L2DropData(960, 1, 1, 300, 1), // EAS 0.03%
};
public final static int Young_Squash = 12774;
public final static int High_Quality_Squash = 12775;
public final static int Low_Quality_Squash = 12776;
public final static int Large_Young_Squash = 12777;
public final static int High_Quality_Large_Squash = 12778;
public final static int Low_Quality_Large_Squash = 12779;
public final static int King_Squash = 13016;
public final static int Emperor_Squash = 13017;
public final static int Squash_Level_up = 4513;
public final static int Squash_Poisoned = 4514;
private String[] textOnSpawn = new String[] {
"scripts.events.TheFallHarvest.SquashAI.textOnSpawn.0",
"scripts.events.TheFallHarvest.SquashAI.textOnSpawn.1",
"scripts.events.TheFallHarvest.SquashAI.textOnSpawn.2" };
private String[] textOnAttack = new String[] {
"Bites rat-a-tat... to change... body...!",
"Ha ha, grew up! Completely on all!",
"Cannot to aim all? Had a look all to flow out...",
"Is that also calculated hit? Look for person which has the strength!",
"Don't waste your time!",
"Ha, this sound is really pleasant to hear?",
"I eat your attack to grow!",
"Time to hit again! Come again!",
"Only useful music can open big pumpkin... It can not be opened with weapon!" };
private String[] textTooFast = new String[] {
"heh heh,looks well hit!",
"yo yo? Your skill is mediocre?",
"Time to hit again! Come again!",
"I eat your attack to grow!",
"Make an effort... to get down like this, I walked...",
"What is this kind of degree to want to open me? Really is indulges in fantasy!",
"Good fighting method. Evidently flies away the fly also can overcome.",
"Strives to excel strength oh! But waste your time..." };
private String[] textSuccess0 = new String[] {
"The lovely pumpkin young fruit start to glisten when taken to the threshing ground! From now on will be able to grow healthy and strong!",
"Oh, Haven't seen for a long time?",
"Suddenly, thought as soon as to see my beautiful appearance?",
"Well! This is something! Is the nectar?",
"Refuels! Drink 5 bottles to be able to grow into the big pumpkin oh!" };
private String[] textFail0 = new String[] {
"If I drink nectar, I can grow up faster!",
"Come, believe me, sprinkle a nectar! I can certainly turn the big pumpkin!!!",
"Take nectar to come, pumpkin nectar!" };
private String[] textSuccess1 = new String[] {
"Wish the big pumpkin!",
"completely became the recreation area! Really good!",
"Guessed I am mature or am rotten?",
"Nectar is just the best! Ha! Ha! Ha!" };
private String[] textFail1 = new String[] {
"oh! Randomly missed! Too quickly sprinkles the nectar?",
"If I die like this, you only could get young pumpkin...",
"Cultivate a bit faster! The good speech becomes the big pumpkin, the young pumpkin is not good!",
"The such small pumpkin you all must eat? Bring the nectar, I can be bigger!" };
private String[] textSuccess2 = new String[] {
"Young pumpkin wishing! Has how already grown up?",
"Already grew up! Quickly sneaked off...",
"Graciousness, is very good. Come again to see, now felt more and more well" };
private String[] textFail2 = new String[] {
"Hey! Was not there! Here is! Here! Not because I can not properly care? Small!",
"Wow, stops? Like this got down to have to thank",
"Hungry for a nectar oh...",
"Do you want the big pumpkin? But I like young pumpkin..." };
private String[] textSuccess3 = new String[] {
"Big pumpkin wishing! Ask, to sober!",
"Rumble rumble... it's really tasty! Hasn't it?",
"Cultivating me just to eat? Good, is casual your... not to give the manna on the suicide!" };
private String[] textFail3 = new String[] {
"Isn't it the water you add? What flavor?",
"Master, rescue my... I don't have the nectar flavor, I must die..." };
private String[] textSuccess4 = new String[] {
"is very good, does extremely well! Knew what next step should make?",
"If you catch me, I give you 10 million adena!!! Agree?" };
private String[] textFail4 = new String[] { "Hungry for a nectar oh...", "If I drink nectar, I can grow up faster!" };
private int _npcId;
private int _nectar;
private int _tryCount;
private long _lastNectarUse;
private long _timeToUnspawn;
@SuppressWarnings("unchecked")
private ScheduledFuture _polimorphTask;
private static int NECTAR_REUSE = 3000;
public SquashAI(L2Character actor)
{
super(actor);
_npcId = _thisActor.getNpcId();
Functions.npcShoutCustomMessage(_thisActor, textOnSpawn[Rnd.get(textOnSpawn.length)], null);
_timeToUnspawn = System.currentTimeMillis() + 120000;
}
@Override
protected boolean thinkActive()
{
if(System.currentTimeMillis() > _timeToUnspawn)
{
_timeToUnspawn = Long.MAX_VALUE;
if(_polimorphTask != null)
{
_polimorphTask.cancel(true);
_polimorphTask = null;
}
stopAITask();
_thisActor.deleteMe();
}
return false;
}
@Override
protected void onEvtSeeSpell(L2Skill skill, L2Character caster)
{
if(skill.getId() != 2005)
return;
switch(_tryCount)
{
case 0:
_tryCount++;
_lastNectarUse = System.currentTimeMillis();
if(Rnd.chance(50))
{
_nectar++;
Functions.npcShout(_thisActor, textSuccess0[Rnd.get(textSuccess0.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Level_up, 1, NECTAR_REUSE, 0));
}
else
{
Functions.npcShout(_thisActor, textFail0[Rnd.get(textFail0.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
}
break;
case 1:
if(System.currentTimeMillis() - _lastNectarUse < NECTAR_REUSE)
{
Functions.npcShout(_thisActor, textTooFast[Rnd.get(textTooFast.length)]);
return;
}
_tryCount++;
_lastNectarUse = System.currentTimeMillis();
if(Rnd.chance(50))
{
_nectar++;
Functions.npcShout(_thisActor, textSuccess1[Rnd.get(textSuccess1.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Level_up, 1, NECTAR_REUSE, 0));
}
else
{
Functions.npcShout(_thisActor, textFail1[Rnd.get(textFail1.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
}
break;
case 2:
if(System.currentTimeMillis() - _lastNectarUse < NECTAR_REUSE)
{
Functions.npcShout(_thisActor, textTooFast[Rnd.get(textTooFast.length)]);
return;
}
_tryCount++;
_lastNectarUse = System.currentTimeMillis();
if(Rnd.chance(50))
{
_nectar++;
Functions.npcShout(_thisActor, textSuccess2[Rnd.get(textSuccess2.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Level_up, 1, NECTAR_REUSE, 0));
}
else
{
Functions.npcShout(_thisActor, textFail2[Rnd.get(textFail2.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
}
break;
case 3:
if(System.currentTimeMillis() - _lastNectarUse < NECTAR_REUSE)
{
Functions.npcShout(_thisActor, textTooFast[Rnd.get(textTooFast.length)]);
return;
}
_tryCount++;
_lastNectarUse = System.currentTimeMillis();
if(Rnd.chance(50))
{
_nectar++;
Functions.npcShout(_thisActor, textSuccess3[Rnd.get(textSuccess3.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Level_up, 1, NECTAR_REUSE, 0));
}
else
{
Functions.npcShout(_thisActor, textFail3[Rnd.get(textFail3.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
}
break;
case 4:
if(System.currentTimeMillis() - _lastNectarUse < NECTAR_REUSE)
{
Functions.npcShout(_thisActor, textTooFast[Rnd.get(textTooFast.length)]);
return;
}
_tryCount++;
_lastNectarUse = System.currentTimeMillis();
if(Rnd.chance(50))
{
_nectar++;
Functions.npcShout(_thisActor, textSuccess4[Rnd.get(textSuccess4.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Level_up, 1, NECTAR_REUSE, 0));
}
else
{
Functions.npcShout(_thisActor, textFail4[Rnd.get(textFail4.length)]);
_thisActor.broadcastPacket(new MagicSkillUse(_thisActor, _thisActor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
}
if(_npcId == Young_Squash)
{
if(_nectar < 3)
_npcId = Low_Quality_Squash;
else if(_nectar == 5)
_npcId = King_Squash;
else
_npcId = High_Quality_Squash;
}
else if(_npcId == Large_Young_Squash)
if(_nectar < 3)
_npcId = Low_Quality_Large_Squash;
else if(_nectar == 5)
_npcId = Emperor_Squash;
else
_npcId = High_Quality_Large_Squash;
_polimorphTask = ThreadPoolManager.getInstance().scheduleGeneral(new PolimorphTask(), NECTAR_REUSE);
break;
}
}
@Override
protected void onEvtAttacked(L2Character attacker, int damage)
{
if(Rnd.chance(10))
Functions.npcShout(_thisActor, textOnAttack[Rnd.get(textOnAttack.length)]);
}
@Override
protected void onEvtDead()
{
int dropMod = 1;
switch(_npcId)
{
case Low_Quality_Squash:
dropMod = 1;
Functions.npcShout(_thisActor, "The pampkin opens!!!");
Functions.npcShout(_thisActor, "ya yo! Opens! Good thing many...");
break;
case High_Quality_Squash:
dropMod = 2;
Functions.npcShout(_thisActor, "The pampkin opens!!!");
Functions.npcShout(_thisActor, "ya yo! Opens! Good thing many...");
break;
case Low_Quality_Large_Squash:
dropMod = 2;
Functions.npcShout(_thisActor, "The pampkin opens!!!");
Functions.npcShout(_thisActor, "ya yo! Opens! Good thing many...");
break;
case High_Quality_Large_Squash:
dropMod = 4;
Functions.npcShout(_thisActor, "The pampkin opens!!!");
Functions.npcShout(_thisActor, "ya yo! Opens! Good thing many...");
break;
case King_Squash:
dropMod = 4;
Functions.npcShout(_thisActor, "The pampkin opens!!!");
Functions.npcShout(_thisActor, "ya yo! Opens! Good thing many...");
break;
case Emperor_Squash:
dropMod = 8;
Functions.npcShout(_thisActor, "The pampkin opens!!!");
Functions.npcShout(_thisActor, "ya yo! Opens! Good thing many...");
break;
default:
dropMod = 0;
Functions.npcShout(_thisActor, "Ouch, if I had died like this, you could obtain nothing!");
Functions.npcShout(_thisActor, "The news about my death shouldn't spread, oh!");
break;
}
_actor.breakAttack();
_actor.broadcastPacket(new Die(_actor));
_intention = AI_INTENTION_IDLE;
if(dropMod > 0)
for(L2DropData d : _dropList)
{
ItemToDrop itd = d.roll(null, dropMod * 1.5);
if(itd != null)
{
L2ItemInstance item = ItemTable.getInstance().createItem(itd.itemId, 0, 0, "TheFallHarvest");
item.setCount(itd.count);
item.dropToTheGround(((SquashInstance) _thisActor).getSpawner(), (L2NpcInstance) _actor);
}
}
}
@Override
protected boolean randomAnimation()
{
return false;
}
@Override
protected boolean randomWalk()
{
return false;
}
}
SquashInstance.java
Раскрывающийся текст
Код
package events.TheFallHarvest;
import l2r.gameserver.model.L2Character;
import l2r.gameserver.model.L2Player;
import l2r.gameserver.model.instances.L2MonsterInstance;
import l2r.gameserver.templates.L2NpcTemplate;
public class SquashInstance extends L2MonsterInstance
{
public final static int Young_Squash = 12774;
public final static int High_Quality_Squash = 12775;
public final static int Low_Quality_Squash = 12776;
public final static int Large_Young_Squash = 12777;
public final static int High_Quality_Large_Squash = 12778;
public final static int Low_Quality_Large_Squash = 12779;
public final static int King_Squash = 13016;
public final static int Emperor_Squash = 13017;
private L2Player _spawner;
public SquashInstance(int objectId, L2NpcTemplate template)
{
super(objectId, template);
_spawner = null;
}
public void setSpawner(L2Player spawner)
{
_spawner = spawner;
}
public L2Player getSpawner()
{
return _spawner;
}
@Override
public void reduceCurrentHp(double i, L2Character attacker, boolean awake, boolean standUp, boolean directHp)
{
if(attacker.getActiveWeaponInstance() == null)
return;
int weaponId = attacker.getActiveWeaponInstance().getItemId();
if(getNpcId() == Low_Quality_Large_Squash || getNpcId() == High_Quality_Large_Squash || getNpcId() == Emperor_Squash)
// Разрешенное оружие для больших тыкв:
// 4202 Chrono Cithara
// 5133 Chrono Unitus
// 5817 Chrono Campana
// 7058 Chrono Darbuka
// 8350 Chrono Maracas
if(weaponId != 4202 && weaponId != 5133 && weaponId != 5817 && weaponId != 7058 && weaponId != 8350)
return;
i = 1;
super.reduceCurrentHp(i, attacker, awake, standUp, directHp);
}
@Override
protected synchronized void startHpMpRegeneration()
{}
}
import l2r.gameserver.model.L2Character;
import l2r.gameserver.model.L2Player;
import l2r.gameserver.model.instances.L2MonsterInstance;
import l2r.gameserver.templates.L2NpcTemplate;
public class SquashInstance extends L2MonsterInstance
{
public final static int Young_Squash = 12774;
public final static int High_Quality_Squash = 12775;
public final static int Low_Quality_Squash = 12776;
public final static int Large_Young_Squash = 12777;
public final static int High_Quality_Large_Squash = 12778;
public final static int Low_Quality_Large_Squash = 12779;
public final static int King_Squash = 13016;
public final static int Emperor_Squash = 13017;
private L2Player _spawner;
public SquashInstance(int objectId, L2NpcTemplate template)
{
super(objectId, template);
_spawner = null;
}
public void setSpawner(L2Player spawner)
{
_spawner = spawner;
}
public L2Player getSpawner()
{
return _spawner;
}
@Override
public void reduceCurrentHp(double i, L2Character attacker, boolean awake, boolean standUp, boolean directHp)
{
if(attacker.getActiveWeaponInstance() == null)
return;
int weaponId = attacker.getActiveWeaponInstance().getItemId();
if(getNpcId() == Low_Quality_Large_Squash || getNpcId() == High_Quality_Large_Squash || getNpcId() == Emperor_Squash)
// Разрешенное оружие для больших тыкв:
// 4202 Chrono Cithara
// 5133 Chrono Unitus
// 5817 Chrono Campana
// 7058 Chrono Darbuka
// 8350 Chrono Maracas
if(weaponId != 4202 && weaponId != 5133 && weaponId != 5817 && weaponId != 7058 && weaponId != 8350)
return;
i = 1;
super.reduceCurrentHp(i, attacker, awake, standUp, directHp);
}
@Override
protected synchronized void startHpMpRegeneration()
{}
}
TheFallHarvest.java
Раскрывающийся текст
Код
package events.TheFallHarvest;
import l2r.Config;
import l2r.extensions.scripts.Functions;
import l2r.extensions.scripts.ScriptFile;
import l2r.gameserver.Announcements;
import l2r.gameserver.instancemanager.ServerVariables;
import l2r.gameserver.model.L2Character;
import l2r.gameserver.model.L2Object;
import l2r.gameserver.model.L2Player;
import l2r.gameserver.model.L2Spawn;
import l2r.gameserver.model.instances.L2ItemInstance;
import l2r.gameserver.model.instances.L2NpcInstance;
import l2r.gameserver.serverpackets.SystemMessage;
import l2r.gameserver.tables.ItemTable;
import l2r.gameserver.tables.NpcTable;
import l2r.gameserver.templates.L2NpcTemplate;
import l2r.util.Files;
import l2r.util.Rnd;
import java.util.ArrayList;
public class TheFallHarvest extends Functions implements ScriptFile
{
public static L2Object self;
public static L2NpcInstance npc;
private static int EVENT_MANAGER_ID = 31255;
private static ArrayList<L2Spawn> _spawns = new ArrayList<L2Spawn>();
private static boolean _active = false;
public void onLoad()
{
if(isActive())
{
_active = true;
spawnEventManagers();
System.out.println("Loaded Event: The Fall Harvest [state: activated]");
}
else
System.out.println("Loaded Event: The Fall Harvest [state: deactivated]");
}
/**
* Читает статус эвента из базы.
* @return
*/
private static boolean isActive()
{
return ServerVariables.getString("TheFallHarvest", "off").equalsIgnoreCase("on");
}
/**
* Запускает эвент
*/
public void startEvent()
{
L2Player player = (L2Player) self;
if(!player.getPlayerAccess().IsEventGm)
return;
if(!isActive())
{
ServerVariables.set("TheFallHarvest", "on");
spawnEventManagers();
System.out.println("Event 'The Fall Harvest' started.");
Announcements.getInstance().announceByCustomMessage("scripts.events.TheFallHarvest.AnnounceEventStarted", null);
}
else
player.sendMessage("Event 'The Fall Harvest' already started.");
_active = true;
show(Files.read("data/html/admin/events.htm", player), player);
}
/**
* Останавливает эвент
*/
public void stopEvent()
{
L2Player player = (L2Player) self;
if(!player.getPlayerAccess().IsEventGm)
return;
if(isActive())
{
ServerVariables.unset("TheFallHarvest");
unSpawnEventManagers();
System.out.println("Event 'The Fall Harvest' stopped.");
Announcements.getInstance().announceByCustomMessage("scripts.events.TheFallHarvest.AnnounceEventStoped", null);
}
else
player.sendMessage("Event 'The Fall Harvest' not started.");
_active = false;
show(Files.read("data/html/admin/events.htm", player), player);
}
/**
* Спавнит эвент менеджеров
*/
private void spawnEventManagers()
{
final int EVENT_MANAGERS[][] = {
{ 81921, 148921, -3467, 16384 },
{ 146405, 28360, -2269, 49648 },
{ 19319, 144919, -3103, 31135 },
{ -82805, 149890, -3129, 33202 },
{ -12347, 122549, -3104, 32603 },
{ 110642, 220165, -3655, 61898 },
{ 116619, 75463, -2721, 20881 },
{ 85513, 16014, -3668, 23681 },
{ 81999, 53793, -1496, 61621 },
{ 148159, -55484, -2734, 44315 },
{ 44185, -48502, -797, 27479 },
{ 86899, -143229, -1293, 22021 } };
L2NpcTemplate template = NpcTable.getTemplate(EVENT_MANAGER_ID);
for(int[] element : EVENT_MANAGERS)
try
{
L2Spawn sp = new L2Spawn(template);
sp.setLocx(element[0]);
sp.setLocy(element[1]);
sp.setLocz(element[2]);
sp.setAmount(1);
sp.setHeading(element[3]);
sp.setRespawnDelay(0);
sp.init();
_spawns.add(sp);
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
}
/**
* Удаляет спавн эвент менеджеров
*/
private void unSpawnEventManagers()
{
for(L2Spawn sp : _spawns)
{
sp.stopRespawn();
sp.getLastSpawn().deleteMe();
}
_spawns.clear();
}
public void onReload()
{
unSpawnEventManagers();
}
public void onShutdown()
{
unSpawnEventManagers();
}
/**
* Обработчик смерти мобов, управляющий эвентовым дропом
*/
public static void onDie(L2Character cha, L2Character killer)
{
if(_active && cha.isMonster && !cha.isRaid && killer != null && killer.getPlayer() != null && Rnd.get(1000) <= Config.TFH_POLLEN_CHANCE * killer.getPlayer().getRateItems() * Config.RATE_DROP_ITEMS && Math.abs(cha.getLevel() - killer.getLevel()) < 10)
{
L2ItemInstance item = ItemTable.getInstance().createItem(6391, killer.getPlayer().getObjectId(), 0, "TheFallHarvest");
((L2NpcInstance) cha).dropItem(killer.getPlayer(), item);
}
}
/**
* Обмен эвентовых вещей, где var - номер группы обмена.<br>
* <li>Группа 0: 1 Pollen на 1 Squash Seed
* <li>Группа 1: 50 Pollen на 1 Large Squash Seed
* <li>Группа 2: 10 Pollen на 1 Chrono Darbuka
*/
public static void exchange(String[] var)
{
final int price_id[] = { 6391, 6391, 6391 };
final int price_count[] = { 1, 50, 10 };
final int goodds_id[] = { 6389, 6390, 7058 };
final int goodds_count[] = { 1, 1, 1 };
int grp = Integer.parseInt(var[0]);
if(grp > price_id.length || grp < 0)
return;
L2Player player = (L2Player) self;
if(!player.isQuestContinuationPossible())
return;
if(player.isActionsDisabled() || player.isSitting() || player.getLastNpc().getDistance(player) > 300)
return;
if(getItemCount(player, price_id[grp]) < price_count[grp])
{
player.sendPacket(new SystemMessage(SystemMessage.YOU_DO_NOT_HAVE_ENOUGH_REQUIRED_ITEMS));
return;
}
removeItem(player, price_id[grp], price_count[grp]);
addItem(player, goodds_id[grp], goodds_count[grp]);
}
public static void OnPlayerEnter(L2Player player)
{
if(_active)
Announcements.getInstance().announceToPlayerByCustomMessage(player, "scripts.events.TheFallHarvest.AnnounceEventStarted", null);
}
}
import l2r.Config;
import l2r.extensions.scripts.Functions;
import l2r.extensions.scripts.ScriptFile;
import l2r.gameserver.Announcements;
import l2r.gameserver.instancemanager.ServerVariables;
import l2r.gameserver.model.L2Character;
import l2r.gameserver.model.L2Object;
import l2r.gameserver.model.L2Player;
import l2r.gameserver.model.L2Spawn;
import l2r.gameserver.model.instances.L2ItemInstance;
import l2r.gameserver.model.instances.L2NpcInstance;
import l2r.gameserver.serverpackets.SystemMessage;
import l2r.gameserver.tables.ItemTable;
import l2r.gameserver.tables.NpcTable;
import l2r.gameserver.templates.L2NpcTemplate;
import l2r.util.Files;
import l2r.util.Rnd;
import java.util.ArrayList;
public class TheFallHarvest extends Functions implements ScriptFile
{
public static L2Object self;
public static L2NpcInstance npc;
private static int EVENT_MANAGER_ID = 31255;
private static ArrayList<L2Spawn> _spawns = new ArrayList<L2Spawn>();
private static boolean _active = false;
public void onLoad()
{
if(isActive())
{
_active = true;
spawnEventManagers();
System.out.println("Loaded Event: The Fall Harvest [state: activated]");
}
else
System.out.println("Loaded Event: The Fall Harvest [state: deactivated]");
}
/**
* Читает статус эвента из базы.
* @return
*/
private static boolean isActive()
{
return ServerVariables.getString("TheFallHarvest", "off").equalsIgnoreCase("on");
}
/**
* Запускает эвент
*/
public void startEvent()
{
L2Player player = (L2Player) self;
if(!player.getPlayerAccess().IsEventGm)
return;
if(!isActive())
{
ServerVariables.set("TheFallHarvest", "on");
spawnEventManagers();
System.out.println("Event 'The Fall Harvest' started.");
Announcements.getInstance().announceByCustomMessage("scripts.events.TheFallHarvest.AnnounceEventStarted", null);
}
else
player.sendMessage("Event 'The Fall Harvest' already started.");
_active = true;
show(Files.read("data/html/admin/events.htm", player), player);
}
/**
* Останавливает эвент
*/
public void stopEvent()
{
L2Player player = (L2Player) self;
if(!player.getPlayerAccess().IsEventGm)
return;
if(isActive())
{
ServerVariables.unset("TheFallHarvest");
unSpawnEventManagers();
System.out.println("Event 'The Fall Harvest' stopped.");
Announcements.getInstance().announceByCustomMessage("scripts.events.TheFallHarvest.AnnounceEventStoped", null);
}
else
player.sendMessage("Event 'The Fall Harvest' not started.");
_active = false;
show(Files.read("data/html/admin/events.htm", player), player);
}
/**
* Спавнит эвент менеджеров
*/
private void spawnEventManagers()
{
final int EVENT_MANAGERS[][] = {
{ 81921, 148921, -3467, 16384 },
{ 146405, 28360, -2269, 49648 },
{ 19319, 144919, -3103, 31135 },
{ -82805, 149890, -3129, 33202 },
{ -12347, 122549, -3104, 32603 },
{ 110642, 220165, -3655, 61898 },
{ 116619, 75463, -2721, 20881 },
{ 85513, 16014, -3668, 23681 },
{ 81999, 53793, -1496, 61621 },
{ 148159, -55484, -2734, 44315 },
{ 44185, -48502, -797, 27479 },
{ 86899, -143229, -1293, 22021 } };
L2NpcTemplate template = NpcTable.getTemplate(EVENT_MANAGER_ID);
for(int[] element : EVENT_MANAGERS)
try
{
L2Spawn sp = new L2Spawn(template);
sp.setLocx(element[0]);
sp.setLocy(element[1]);
sp.setLocz(element[2]);
sp.setAmount(1);
sp.setHeading(element[3]);
sp.setRespawnDelay(0);
sp.init();
_spawns.add(sp);
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
}
/**
* Удаляет спавн эвент менеджеров
*/
private void unSpawnEventManagers()
{
for(L2Spawn sp : _spawns)
{
sp.stopRespawn();
sp.getLastSpawn().deleteMe();
}
_spawns.clear();
}
public void onReload()
{
unSpawnEventManagers();
}
public void onShutdown()
{
unSpawnEventManagers();
}
/**
* Обработчик смерти мобов, управляющий эвентовым дропом
*/
public static void onDie(L2Character cha, L2Character killer)
{
if(_active && cha.isMonster && !cha.isRaid && killer != null && killer.getPlayer() != null && Rnd.get(1000) <= Config.TFH_POLLEN_CHANCE * killer.getPlayer().getRateItems() * Config.RATE_DROP_ITEMS && Math.abs(cha.getLevel() - killer.getLevel()) < 10)
{
L2ItemInstance item = ItemTable.getInstance().createItem(6391, killer.getPlayer().getObjectId(), 0, "TheFallHarvest");
((L2NpcInstance) cha).dropItem(killer.getPlayer(), item);
}
}
/**
* Обмен эвентовых вещей, где var - номер группы обмена.<br>
* <li>Группа 0: 1 Pollen на 1 Squash Seed
* <li>Группа 1: 50 Pollen на 1 Large Squash Seed
* <li>Группа 2: 10 Pollen на 1 Chrono Darbuka
*/
public static void exchange(String[] var)
{
final int price_id[] = { 6391, 6391, 6391 };
final int price_count[] = { 1, 50, 10 };
final int goodds_id[] = { 6389, 6390, 7058 };
final int goodds_count[] = { 1, 1, 1 };
int grp = Integer.parseInt(var[0]);
if(grp > price_id.length || grp < 0)
return;
L2Player player = (L2Player) self;
if(!player.isQuestContinuationPossible())
return;
if(player.isActionsDisabled() || player.isSitting() || player.getLastNpc().getDistance(player) > 300)
return;
if(getItemCount(player, price_id[grp]) < price_count[grp])
{
player.sendPacket(new SystemMessage(SystemMessage.YOU_DO_NOT_HAVE_ENOUGH_REQUIRED_ITEMS));
return;
}
removeItem(player, price_id[grp], price_count[grp]);
addItem(player, goodds_id[grp], goodds_count[grp]);
}
public static void OnPlayerEnter(L2Player player)
{
if(_active)
Announcements.getInstance().announceToPlayerByCustomMessage(player, "scripts.events.TheFallHarvest.AnnounceEventStarted", null);
}
}
Объясните примерно, что и куда запихивать?
Вопрос: как и какие мне склеить файлики relebion c мои l2dot?
Мои соображения по этому поводу: нету соображений....((
подпись она и в Африке подпись!
0
· 28.04.2009, 20:20
помоему у тебя
TheFallHarvest.java
SquashInstance.java
SquashAI.java
Seed.java
Nectar.java
Настроен для ПТС, а у тебя Java
0
· 28.04.2009, 20:47
3BE3DA: помоему у тебя
TheFallHarvest.java
SquashInstance.java
SquashAI.java
Seed.java
Nectar.java
Настроен для ПТС, а у тебя Java
что ты херню городиш как блин у него можыт быть настроеный птс если у него ява если ты не знаеш то и не пишы!!!!
0
· 29.04.2009, 03:28
lsd: что ты херню городиш как блин у него можыт быть настроеный птс если у него ява если ты не знаеш то и не пишы!!!!
Отжог....
1. Учи Русский
2. Настроить можно на что угодно и как угодно,вопрос только 1,как это потом будет работать....
0
· 29.04.2009, 08:58
3BE3DA: помоему у тебя
TheFallHarvest.java
SquashInstance.java
SquashAI.java
Seed.java
Nectar.java
Настроен для ПТС, а у тебя Java
ну если в pts паке ты найдёшь файлики *.java...Это раз
второе то что помоему у Rellebion PTS сборок нету...хотя я мб и ошибаюсь)))
RangerV3: Отжог....
1. Учи Русский
2. Настроить можно на что угодно и как угодно,вопрос только 1,как это потом будет работать....
Ну а вообще по теме может кто помоч??? или так only flyd???
подпись она и в Африке подпись!
0
· 29.04.2009, 11:01
Ща ченить попробую сделать.
Кста, в ла2базе реализованы тыквы? имхо легче вытащить из нее )
ппц у ребов структура изменена, никуя непонятно )
0
· 29.04.2009, 12:23
St1ng3r: Ща ченить попробую сделать.
Кста, в ла2базе реализованы тыквы? имхо легче вытащить из нее )
ппц у ребов структура изменена, никуя непонятно )
К сожалению в la2base нету! =(
подпись она и в Африке подпись!
0
· 29.04.2009, 12:49
Цитата
помоему у тебя
TheFallHarvest.java
SquashInstance.java
SquashAI.java
Seed.java
Nectar.java
Настроен для ПТС, а у тебя Java
TheFallHarvest.java
SquashInstance.java
SquashAI.java
Seed.java
Nectar.java
Настроен для ПТС, а у тебя Java
меня ето убило особено настроено под ПТС то что Ява ето уже ПТС :).......... собствено автрору иногда не все исходники можно перетащить из одной сборки в другую так как структура будет иной
0
Войдите или зарегистрируйтесь чтобы ответить






