RLS chests now have names

This commit is contained in:
Mads Boddum
2018-02-18 18:39:55 +01:00
parent e018b04de6
commit 63b0cb50f2
2 changed files with 16 additions and 3 deletions
@@ -27,6 +27,7 @@
package com.projectswg.holocore.services.loot;
import com.projectswg.common.control.Service;
import com.projectswg.common.debug.Log;
import com.projectswg.common.network.packets.swg.zone.PlayClientEffectObjectMessage;
import com.projectswg.common.network.packets.swg.zone.PlayMusicMessage;
import com.projectswg.common.network.packets.swg.zone.object_controller.ShowLootBox;
@@ -91,11 +92,14 @@ final class RareLootService extends Service {
}
}
String chestIdForTemplate(String template) {
return template.replace("object/tangible/item/shared_", "").replace(".iff", "");
}
private void sendSuccessPackets(SWGObject chest, CreatureObject corpse, CreatureObject killer) {
ObjectCreatedIntent.broadcast(chest);
PlayClientEffectObjectMessage effect = new PlayClientEffectObjectMessage("appearance/pt_rare_chest.prt", "", corpse
.getObjectId(), "");
PlayClientEffectObjectMessage effect = new PlayClientEffectObjectMessage("appearance/pt_rare_chest.prt", "", corpse.getObjectId(), "");
PlayMusicMessage sound = new PlayMusicMessage(0, "sound/rare_loot_chest.snd", 1, false);
ShowLootBox box = new ShowLootBox(killer.getObjectId(), new long[] { chest.getObjectId() });
@@ -107,7 +111,7 @@ final class RareLootService extends Service {
CreatureObject corpse = cki.getCorpse();
CreatureObject killer = cki.getKiller();
if (!isPlayerEligible(corpse.isPlayer(), killer.isPlayer())) {
if (!isPlayerEligible(killer.isPlayer(), corpse.isPlayer())) {
return;
}
@@ -118,6 +122,7 @@ final class RareLootService extends Service {
int roll = random.nextInt(100) + 1; // Rolls from 0 to 99, then we add 1 and it becomes 1 to 100
if (!isDrop(roll)) {
Log.d("No RLS drop from %s with roll %d", corpse, roll);
return;
}
@@ -125,6 +130,9 @@ final class RareLootService extends Service {
SWGObject chest = ObjectCreator.createObjectFromTemplate(template);
SWGObject inventory = killer.getSlottedObject("inventory");
chest.setStf("loot_n", chestIdForTemplate(template) + "_n");
chest.setDetailStf("loot_n", chestIdForTemplate(template) + "_d"); // Not located in loot_d, for whatever reason...
switch (chest.moveToContainer(inventory)) {
case SUCCESS:
sendSuccessPackets(chest, corpse, killer);
@@ -66,4 +66,9 @@ public class TestRareLootService {
Assert.assertEquals("object/tangible/item/shared_rare_loot_chest_3.iff", rls.templateForDifficulty(CreatureDifficulty.BOSS));
}
@Test
public void testChestIdForTemplate() {
Assert.assertEquals("rare_loot_chest_1", rls.chestIdForTemplate("object/tangible/item/shared_rare_loot_chest_1.iff"));
}
}