View difference between Paste ID: 1XprW8qu and ahh9Kru8
SHOW: | | - or go back to the newest paste.
1
diff --git a/aCis_gs/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonCreature.java b/aCis_gs/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonCreature.java
2
index 4919749..18711bf 100644
3
--- a/aCis_gs/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonCreature.java
4
+++ b/aCis_gs/java/net/sf/l2j/gameserver/handler/skillhandlers/SummonCreature.java
5
@@ -6,10 +6,12 @@
6
 import net.sf.l2j.gameserver.enums.skills.SkillType;
7
 import net.sf.l2j.gameserver.geoengine.GeoEngine;
8
 import net.sf.l2j.gameserver.handler.ISkillHandler;
9
+import net.sf.l2j.gameserver.idfactory.IdFactory;
10
 import net.sf.l2j.gameserver.model.World;
11
 import net.sf.l2j.gameserver.model.WorldObject;
12
 import net.sf.l2j.gameserver.model.actor.Creature;
13
 import net.sf.l2j.gameserver.model.actor.Player;
14
+import net.sf.l2j.gameserver.model.actor.instance.Agathion;
15
 import net.sf.l2j.gameserver.model.actor.instance.Pet;
16
 import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
17
 import net.sf.l2j.gameserver.model.holder.IntIntHolder;
18
@@ -40,10 +42,6 @@
19
 		if (checkedItem.getOwnerId() != player.getObjectId() || checkedItem.getLocation() != ItemLocation.INVENTORY)
20
 			return;
21
 		
22
-		// Owner has a pet listed in world.
23
-		if (World.getInstance().getPet(player.getObjectId()) != null)
24
-			return;
25
-		
26
 		// Check summon item validity.
27
 		final IntIntHolder summonItem = SummonItemData.getInstance().getSummonItem(checkedItem.getItemId());
28
 		if (summonItem == null)
29
@@ -54,6 +52,37 @@
30
 		if (npcTemplate == null)
31
 			return;
32
 		
33
+		if (npcTemplate.getType().equalsIgnoreCase("Agathion"))
34
+		{
35
+			if (player.getAgathion() != null)
36
+				player.getAgathion().unSummon(player);
37
+			
38
+			Agathion summon;
39
+			summon = new Agathion(IdFactory.getInstance().getNextId(), npcTemplate, player);
40
+//			summon.setInstanceId(player.getInstanceId());
41
+			player.setAgathion(summon);
42
+			
43
+			summon.setName(npcTemplate.getName());
44
+			summon.setTitle(player.getName());
45
+			summon.getStatus().setMaxHpMp();
46
+			summon.forceRunStance();
47
+			
48
+			final SpawnLocation spawnLoc = creature.getPosition().clone();
49
+			spawnLoc.addStrictOffset(40);
50
+			spawnLoc.setHeadingTo(creature.getPosition());
51
+			spawnLoc.set(GeoEngine.getInstance().getValidLocation(creature, spawnLoc));
52
+			
53
+			summon.spawnMe(spawnLoc);
54
+			summon.setInvul(true);
55
+			summon.getAI().setFollowStatus(true);
56
+			item.setAgathionItem(player);
57
+			return;
58
+		}
59
+		
60
+		// Owner has a pet listed in world.
61
+		if (World.getInstance().getPet(player.getObjectId()) != null)
62
+			return;
63
+		
64
 		// Add the pet instance to world.
65
 		final Pet pet = Pet.restore(checkedItem, npcTemplate, player);
66
 		if (pet == null)
67
diff --git a/aCis_gs/java/net/sf/l2j/gameserver/model/actor/Player.java b/aCis_gs/java/net/sf/l2j/gameserver/model/actor/Player.java
68
index f5a1be5..2ab98f4 100644
69
--- a/aCis_gs/java/net/sf/l2j/gameserver/model/actor/Player.java
70
+++ b/aCis_gs/java/net/sf/l2j/gameserver/model/actor/Player.java
71
@@ -108,6 +108,7 @@
72
 import net.sf.l2j.gameserver.model.actor.container.player.Request;
73
 import net.sf.l2j.gameserver.model.actor.container.player.ShortcutList;
74
 import net.sf.l2j.gameserver.model.actor.container.player.SubClass;
75
+import net.sf.l2j.gameserver.model.actor.instance.Agathion;
76
 import net.sf.l2j.gameserver.model.actor.instance.Door;
77
 import net.sf.l2j.gameserver.model.actor.instance.FestivalMonster;
78
 import net.sf.l2j.gameserver.model.actor.instance.Folk;
79
@@ -368,6 +369,7 @@
80
 	private final QuestList _questList = new QuestList(this);
81
 	
82
 	private Summon _summon;
83
+	private Agathion aga;
84
 	private TamedBeast _tamedBeast;
85
 	
86
 	private int _partyRoom;
87
@@ -6282,6 +6284,9 @@
88
 			else if (_summon != null)
89
 				_summon.unSummon(this);
90
 			
91
+			if (getAgathion() != null)
92
+				aga.unSummon(this);
93
+			
94
 			// Stop all scheduled tasks.
95
 			stopChargeTask();
96
 			
97
@@ -7152,4 +7157,14 @@
98
 		setTarget(null);
99
 		sendPacket(ActionFailed.STATIC_PACKET);
100
 	}
101
+	
102
+	public void setAgathion(Agathion aga)
103
+	{
104
+		this.aga = aga;
105
+	}
106
+	
107
+	public Agathion getAgathion()
108
+	{
109
+		return aga;
110
+	}
111
 }
112
\ No newline at end of file
113
diff --git a/aCis_gs/java/net/sf/l2j/gameserver/model/actor/cast/PlayerCast.java b/aCis_gs/java/net/sf/l2j/gameserver/model/actor/cast/PlayerCast.java
114
index 28abb8c..55cc846 100644
115
--- a/aCis_gs/java/net/sf/l2j/gameserver/model/actor/cast/PlayerCast.java
116
+++ b/aCis_gs/java/net/sf/l2j/gameserver/model/actor/cast/PlayerCast.java
117
@@ -268,7 +268,7 @@
118
 		switch (skill.getSkillType())
119
 		{
120
 			case SUMMON:
121
-				if (!((L2SkillSummon) skill).isCubic())
122
+				if (!((L2SkillSummon) skill).isAgathion() && !((L2SkillSummon) skill).isCubic())
123
 				{
124
 					if (_actor.getSummon() != null || _actor.isMounted())
125
 					{
126
diff --git a/aCis_gs/java/net/sf/l2j/gameserver/model/actor/instance/Agathion.java b/aCis_gs/java/net/sf/l2j/gameserver/model/actor/instance/Agathion.java
127
new file mode 100644
128
index 0000000..a818256
129
--- /dev/null
130
+++ b/aCis_gs/java/net/sf/l2j/gameserver/model/actor/instance/Agathion.java
131
@@ -0,0 +1,132 @@
132
+package net.sf.l2j.gameserver.model.actor.instance;
133
+
134
+import java.util.concurrent.Future;
135
+
136
+import net.sf.l2j.commons.pool.ThreadPool;
137
+import net.sf.l2j.commons.random.Rnd;
138
+
139
+import net.sf.l2j.gameserver.model.actor.Npc;
140
+import net.sf.l2j.gameserver.model.actor.Player;
141
+import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
142
+import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
143
+import net.sf.l2j.gameserver.model.location.Location;
144
+import net.sf.l2j.gameserver.network.serverpackets.PetDelete;
145
+
146
+/**
147
+ * @author maxi5
148
+ */
149
+public class Agathion extends Npc
150
+{
151
+	private Player owner;
152
+	private Future<?> _followTask;
153
+	
154
+	private ItemInstance item;
155
+	
156
+	public Agathion(int objectId, NpcTemplate template, Player owner)
157
+	{
158
+		super(objectId, template);
159
+		
160
+		// Set the magical circle animation.
161
+		setShowSummonAnimation(true);
162
+		
163
+		// Set the Player owner.
164
+		this.owner = owner;
165
+	}
166
+	
167
+	@Override
168
+	public void onSpawn()
169
+	{
170
+		disableCoreAi(true);
171
+		setSpawnLocation(getPosition());
172
+		followToOwner();
173
+		super.onSpawn();
174
+	}
175
+	
176
+	public void unSummon(Player owner)
177
+	{
178
+		// Abort attack, cast and move.
179
+		abortAll(true);
180
+		
181
+		if (item != null)
182
+			item.setAgathion(owner, false);
183
+		
184
+		owner.sendPacket(new PetDelete(2, getObjectId()));
185
+		owner.setAgathion(null);
186
+		
187
+		if (owner.getSummon() != null)
188
+			owner.getSummon().sendInfo(owner);
189
+		owner.broadcastUserInfo();
190
+		
191
+		if (_followTask != null)
192
+			_followTask.cancel(true);
193
+		
194
+		decayMe();
195
+		deleteMe();
196
+		
197
+		super.deleteMe();
198
+	}
199
+	
200
+	public void followToOwner()
201
+	{
202
+		if (owner == null)
203
+			return;
204
+		setTarget(owner);
205
+		
206
+		if (_followTask == null)
207
+			_followTask = ThreadPool.scheduleAtFixedRate(new Follow(this), 1000, 1000);
208
+		
209
+		getPosition().setHeading(owner.getHeading());
210
+		int rnd = Rnd.get(-15, +15);
211
+		Location toMoveLoc = new Location(owner.getX(), owner.getY(), owner.getZ());
212
+		
213
+		if (!isIn2DRadius(owner, 2000))
214
+		{
215
+			teleportTo(owner.getPosition().clone(), rnd);
216
+			return;
217
+		}
218
+		if (!isIn2DRadius(owner, 50) && !isMoving())
219
+		{
220
+			getMove().maybeMoveToLocation(toMoveLoc, rnd, true, false);
221
+			return;
222
+		}
223
+		if (isIn2DRadius(owner, 30))
224
+		{
225
+			getMove().stop();
226
+			getAI().thinkIdle();
227
+			return;
228
+		}
229
+		getMove().maybeMoveToLocation(toMoveLoc, rnd, true, false);
230
+	}
231
+	
232
+	@Override
233
+	public boolean isInMyTerritory()
234
+	{
235
+		return false;
236
+	}
237
+	
238
+	private static class Follow implements Runnable
239
+	{
240
+		private final Agathion agathion;
241
+		
242
+		protected Follow(Agathion aga)
243
+		{
244
+			agathion = aga;
245
+		}
246
+		
247
+		@Override
248
+		public void run()
249
+		{
250
+			agathion.followToOwner();
251
+		}
252
+	}
253
+	
254
+	public void setAgathionItem(ItemInstance item)
255
+	{
256
+		this.item = item;
257
+	}
258
+	
259
+	public Player getOwner()
260
+	{
261
+		return owner;
262
+	}
263
+}
264
\ No newline at end of file
265
diff --git a/aCis_gs/java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java b/aCis_gs/java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java
266
index 652df79..7cb112f 100644
267
--- a/aCis_gs/java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java
268
+++ b/aCis_gs/java/net/sf/l2j/gameserver/model/item/instance/ItemInstance.java
269
@@ -5,6 +5,7 @@
270
 import java.sql.ResultSet;
271
 import java.sql.SQLException;
272
 import java.util.List;
273
+import java.util.concurrent.Future;
274
 import java.util.concurrent.ScheduledFuture;
275
 
276
 import net.sf.l2j.commons.pool.ConnectionPool;
277
@@ -74,6 +75,8 @@
278
 	private boolean _destroyProtected;
279
 	
280
 	private ScheduledFuture<?> _dropProtection;
281
+	private boolean isAgathion;
282
+	private Future<?> _protectedTask;
283
 	
284
 	public ItemInstance(int objectId, int itemId)
285
 	{
286
@@ -501,7 +504,7 @@
287
 	 */
288
 	public boolean isDropable()
289
 	{
290
-		return !isAugmented() && _item.isDropable();
291
+		return isAgathion || !isAugmented() && _item.isDropable();
292
 	}
293
 	
294
 	/**
295
@@ -509,7 +512,7 @@
296
 	 */
297
 	public boolean isDestroyable()
298
 	{
299
-		return !isQuestItem() && _item.isDestroyable();
300
+		return isAgathion || !isQuestItem() && _item.isDestroyable();
301
 	}
302
 	
303
 	/**
304
@@ -517,7 +520,7 @@
305
 	 */
306
 	public boolean isTradable()
307
 	{
308
-		return !isAugmented() && _item.isTradable();
309
+		return isAgathion || !isAugmented() && _item.isTradable();
310
 	}
311
 	
312
 	/**
313
@@ -534,7 +537,7 @@
314
 	 */
315
 	public boolean isDepositable(boolean isPrivateWarehouse)
316
 	{
317
-		return !(isEquipped() || !_item.isDepositable()) && (isPrivateWarehouse || (isTradable() && !isShadowItem()));
318
+		return !(isEquipped() || isAgathion || !_item.isDepositable()) && (isPrivateWarehouse || (isTradable() && !isShadowItem()));
319
 	}
320
 	
321
 	/**
322
@@ -944,4 +947,47 @@
323
 	{
324
 		_shotsMask = 0;
325
 	}
326
+	
327
+	public void setAgathion(Player player, boolean isAgathion)
328
+	{
329
+		this.isAgathion = isAgathion;
330
+	}
331
+	
332
+	public void checkProtected(Player player)
333
+	{
334
+		if (_protectedTask != null)
335
+			_protectedTask.cancel(true);
336
+		_protectedTask = ThreadPool.schedule(new Protected(player), 5500);
337
+	}
338
+
339
+	public boolean isAgathion()
340
+	{
341
+		return isAgathion;
342
+	}
343
+	
344
+	public void setAgathionItem(Player player)
345
+	{
346
+		player.getAgathion().setAgathionItem(this);
347
+	}	
348
+
349
+	private class Protected implements Runnable
350
+	{
351
+		private final Player player;
352
+		
353
+		protected Protected(Player player)
354
+		{
355
+			this.player = player;
356
+		}
357
+		
358
+		@Override
359
+		public void run()
360
+		{
361
+			if (player.getAgathion() != null)
362
+				isAgathion = true;
363
+			else 
364
+				isAgathion = false;
365
+			if (_protectedTask != null)
366
+				_protectedTask.cancel(true);
367
+		}
368
+	}
369
 }
370
\ No newline at end of file
371
diff --git a/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/Action.java b/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/Action.java
372
index 1652483..7af1464 100644
373
--- a/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/Action.java
374
+++ b/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/Action.java
375
@@ -4,6 +4,7 @@
376
 import net.sf.l2j.gameserver.model.World;
377
 import net.sf.l2j.gameserver.model.WorldObject;
378
 import net.sf.l2j.gameserver.model.actor.Player;
379
+import net.sf.l2j.gameserver.model.actor.instance.Agathion;
380
 import net.sf.l2j.gameserver.network.SystemMessageId;
381
 import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
382
 
383
@@ -57,6 +58,12 @@
384
 			return;
385
 		}
386
 		
387
+		if (target instanceof Agathion)
388
+		{
389
+			player.sendPacket(ActionFailed.STATIC_PACKET);
390
+			return;
391
+		}
392
+		
393
 		target.onAction(player, false, _isShiftAction);
394
 	}
395
 	
396
diff --git a/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java b/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java
397
index 5bbd7e8..e091a24 100644
398
--- a/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java
399
+++ b/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/AttackRequest.java
400
@@ -3,6 +3,7 @@
401
 import net.sf.l2j.gameserver.model.World;
402
 import net.sf.l2j.gameserver.model.WorldObject;
403
 import net.sf.l2j.gameserver.model.actor.Player;
404
+import net.sf.l2j.gameserver.model.actor.instance.Agathion;
405
 import net.sf.l2j.gameserver.network.SystemMessageId;
406
 import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
407
 
408
@@ -54,6 +55,12 @@
409
 			return;
410
 		}
411
 		
412
+		if (target instanceof Agathion)
413
+		{
414
+			player.sendPacket(ActionFailed.STATIC_PACKET);
415
+			return;
416
+		}
417
+		
418
 		// (player.getTarget() == target) -> This happens when you control + click a target without having had it selected beforehand. Behaves as the Action packet and will NOT trigger an attack.
419
 		target.onAction(player, (player.getTarget() == target), _isShiftAction);
420
 	}
421
diff --git a/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java b/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java
422
index 5f3a046..d37be72 100644
423
--- a/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java
424
+++ b/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/RequestDestroyItem.java
425
@@ -57,6 +57,12 @@
426
 			return;
427
 		}
428
 		
429
+		if (itemToRemove.isAgathion())
430
+		{
431
+			player.sendPacket(SystemMessageId.CANNOT_DISCARD_THIS_ITEM);
432
+			return;
433
+		}
434
+		
435
 		if (itemToRemove.isEquipped() && (!itemToRemove.isStackable() || (itemToRemove.isStackable() && _count >= itemToRemove.getCount())))
436
 			player.useEquippableItem(itemToRemove, false);
437
 		
438
diff --git a/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/RequestDropItem.java b/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/RequestDropItem.java
439
index 8ff3f5c..6b443f0 100644
440
--- a/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/RequestDropItem.java
441
+++ b/aCis_gs/java/net/sf/l2j/gameserver/network/clientpackets/RequestDropItem.java
442
@@ -46,7 +46,7 @@
443
 		if (item.isQuestItem())
444
 			return;
445
 		
446
-		if (_count > item.getCount())
447
+		if (_count > item.getCount() || item.isAgathion())
448
 		{
449
 			player.sendPacket(SystemMessageId.CANNOT_DISCARD_THIS_ITEM);
450
 			return;
451
diff --git a/aCis_gs/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillSummon.java b/aCis_gs/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillSummon.java
452
index 438f224..2fba8f4 100644
453
--- a/aCis_gs/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillSummon.java
454
+++ b/aCis_gs/java/net/sf/l2j/gameserver/skills/l2skills/L2SkillSummon.java
455
@@ -12,6 +12,7 @@
456
 import net.sf.l2j.gameserver.model.actor.Creature;
457
 import net.sf.l2j.gameserver.model.actor.Player;
458
 import net.sf.l2j.gameserver.model.actor.Summon;
459
+import net.sf.l2j.gameserver.model.actor.instance.Agathion;
460
 import net.sf.l2j.gameserver.model.actor.instance.Servitor;
461
 import net.sf.l2j.gameserver.model.actor.instance.SiegeSummon;
462
 import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
463
@@ -24,6 +25,7 @@
464
 	private final int _npcId;
465
 	private final float _expPenalty;
466
 	private final boolean _isCubic;
467
+	private final boolean _isAgathion;
468
 	
469
 	private final int _activationTime;
470
 	private final int _activationChance;
471
@@ -47,6 +49,7 @@
472
 		_npcId = set.getInteger("npcId", 0); // default for undescribed skills
473
 		_expPenalty = set.getFloat("expPenalty", 0.f);
474
 		_isCubic = set.getBool("isCubic", false);
475
+		_isAgathion = set.getBool("isAgathion", false);
476
 		
477
 		_activationTime = set.getInteger("activationtime", 8);
478
 		_activationChance = set.getInteger("activationchance", 30);
479
@@ -82,7 +85,7 @@
480
 				if (player.isInObserverMode())
481
 					return false;
482
 				
483
-				if (player.getSummon() != null)
484
+				if (!_isAgathion && player.getSummon() != null)
485
 				{
486
 					player.sendPacket(SystemMessageId.SUMMON_ONLY_ONE);
487
 					return false;
488
@@ -140,6 +143,37 @@
489
 		}
490
 		else
491
 		{
492
+			if (_isAgathion)
493
+			{
494
+				NpcTemplate summonTemplate = NpcData.getInstance().getTemplate(_npcId);
495
+
496
+				if (summonTemplate == null)
497
+				{
498
+					LOGGER.warn("Couldn't properly spawn with id {} ; the template is missing.", _npcId);
499
+					return;
500
+				}
501
+				if (player.getAgathion() != null)
502
+					player.getAgathion().unSummon(player);
503
+				Agathion summon;
504
+				summon = new Agathion(IdFactory.getInstance().getNextId(), summonTemplate, player);
505
+				//summon.setInstanceId(player.getInstanceId());
506
+				player.setAgathion(summon);
507
+				
508
+				summon.setName(summonTemplate.getName());
509
+				summon.setTitle(player.getName());
510
+				summon.getStatus().setMaxHpMp();
511
+				summon.forceRunStance();
512
+				
513
+				final SpawnLocation spawnLoc = player.getPosition().clone();
514
+				spawnLoc.addStrictOffset(30);
515
+				spawnLoc.setHeadingTo(player.getPosition());
516
+				spawnLoc.set(GeoEngine.getInstance().getValidLocation(player, spawnLoc));
517
+				
518
+				summon.spawnMe(spawnLoc);
519
+				summon.setInvul(true);
520
+				summon.getAI().setFollowStatus(true);
521
+				return;
522
+			}
523
 			if (player.getSummon() != null || player.isMounted())
524
 				return;
525
 			
526
@@ -184,6 +218,11 @@
527
 		return _isCubic;
528
 	}
529
 	
530
+	public final boolean isAgathion()
531
+	{
532
+		return _isAgathion;
533
+	}
534
+	
535
 	public final int getTotalLifeTime()
536
 	{
537
 		return _summonTotalLifeTime;
538