mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-14 04:13:14 -04:00
Merge branch 'master' of https://github.com/ProjectSWGCore/NGECore2
Conflicts: src/main/NGECore.java
This commit is contained in:
@@ -178,7 +178,6 @@ public class BuffService implements INetworkDispatch {
|
||||
|
||||
// I'm not sure if all aura effects follow the same rules, so this is simply restricted to officer aura's atm
|
||||
ScheduledFuture<?> task = scheduler.scheduleAtFixedRate(new Runnable() {
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
public void run() {
|
||||
if (buffer == null || buffer.getClient() == null)
|
||||
|
||||
@@ -124,7 +124,7 @@ public class ConversationService implements INetworkDispatch {
|
||||
|
||||
conversationHandlers.put(player, handler);
|
||||
|
||||
NpcConversationOptions convoOptions = new NpcConversationOptions(player.getObjectID(), npc.getObjectID());
|
||||
NpcConversationOptions convoOptions = new NpcConversationOptions(player.getObjectID());
|
||||
options.forEach(convoOptions::addOption);
|
||||
ObjControllerMessage objController = new ObjControllerMessage(0x0B, convoOptions);
|
||||
player.getClient().getSession().write(objController.serialize());
|
||||
|
||||
@@ -38,6 +38,7 @@ import resources.common.Opcodes;
|
||||
import resources.common.SpawnPoint;
|
||||
import resources.objects.building.BuildingObject;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.deed.Harvester_Deed;
|
||||
import resources.objects.player.PlayerObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import resources.objects.tool.SurveyTool;
|
||||
@@ -67,7 +68,7 @@ public class DevService implements INetworkDispatch {
|
||||
public void sendCharacterBuilderSUI(CreatureObject creature, int childMenu)
|
||||
{
|
||||
Map<Long, String> suiOptions = new HashMap<Long, String>();
|
||||
|
||||
|
||||
switch(childMenu)
|
||||
{
|
||||
case 0: // Root
|
||||
@@ -84,7 +85,9 @@ public class DevService implements INetworkDispatch {
|
||||
suiOptions.put((long) 21, "Weapons");
|
||||
suiOptions.put((long) 22, "Misc Items");
|
||||
suiOptions.put((long) 23, "Jedi Items");
|
||||
suiOptions.put((long) 26, "Installations");
|
||||
suiOptions.put((long) 110, "Survey Devices");
|
||||
if(creature.getClient().isGM()) suiOptions.put((long) 120, "House Deeds");
|
||||
break;
|
||||
case 3: // [Items] Weapons
|
||||
suiOptions.put((long) 30, "Jedi Weapons");
|
||||
@@ -121,6 +124,10 @@ public class DevService implements INetworkDispatch {
|
||||
suiOptions.put((long) 91, "(Dark) Jedi Robe");
|
||||
suiOptions.put((long) 92, "Belt of Master Bodo Baas");
|
||||
break;
|
||||
case 10: // [Items] Jedi Items
|
||||
suiOptions.put((long) 111, "Harvesters");
|
||||
suiOptions.put((long) 112, "Energy resources");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@@ -186,6 +193,9 @@ public class DevService implements INetworkDispatch {
|
||||
case 25: // Tools
|
||||
sendCharacterBuilderSUI(player, 15);
|
||||
return;
|
||||
case 26: // Installations
|
||||
sendCharacterBuilderSUI(player, 10);
|
||||
return;
|
||||
|
||||
// [Items] Weapons
|
||||
case 30: // Jedi Weapons
|
||||
@@ -990,8 +1000,201 @@ public class DevService implements INetworkDispatch {
|
||||
SurveyTool solarSurveyTool = (SurveyTool) core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_solar.iff", planet);
|
||||
solarSurveyTool.setCustomName("Solar Survey Device");
|
||||
inventory.add(solarSurveyTool);
|
||||
return;
|
||||
case 111:
|
||||
// Minerals
|
||||
String templateString="object/tangible/deed/harvester_deed/shared_harvester_ore_s1_deed.iff";
|
||||
Harvester_Deed deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(27344);
|
||||
deed1.setBER(5);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_ore_s2_deed.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(27344);
|
||||
deed1.setBER(11);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_ore_heavy_deed.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(135400);
|
||||
deed1.setBER(14);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_ore_deed_elite.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(250000);
|
||||
deed1.setBER(44);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
|
||||
// Chemicals
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_liquid_deed.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(27344);
|
||||
deed1.setBER(5);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_liquid_deed_medium.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(27344);
|
||||
deed1.setBER(11);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_liquid_deed_heavy.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(135400);
|
||||
deed1.setBER(14);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_liquid_deed_elite.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(250000);
|
||||
deed1.setBER(44);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
|
||||
// Flora
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_flora_deed.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(27344);
|
||||
deed1.setBER(5);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_flora_deed_medium.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(27344);
|
||||
deed1.setBER(11);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_flora_deed_heavy.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(135400);
|
||||
deed1.setBER(14);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_flora_deed_elite.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(250000);
|
||||
deed1.setBER(44);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
|
||||
// Gas
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_gas_deed.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(27344);
|
||||
deed1.setBER(5);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_gas_deed_medium.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(27344);
|
||||
deed1.setBER(11);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_gas_deed_heavy.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(135400);
|
||||
deed1.setBER(14);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_gas_deed_elite.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(250000);
|
||||
deed1.setBER(44);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
|
||||
// Water
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_moisture_deed.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(27344);
|
||||
deed1.setBER(5);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_moisture_deed_medium.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(27344);
|
||||
deed1.setBER(11);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_moisture_deed_heavy.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(135400);
|
||||
deed1.setBER(14);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/harvester_deed/shared_harvester_moisture_deed_elite.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(250000);
|
||||
deed1.setBER(44);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
|
||||
// Generators
|
||||
templateString="object/tangible/deed/generator_deed/shared_generator_fusion_deed.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(250000);
|
||||
deed1.setBER(19);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/generator_deed/shared_generator_wind_deed.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(250000);
|
||||
deed1.setBER(10);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/generator_deed/shared_generator_solar_deed.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(250000);
|
||||
deed1.setBER(15);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
// templateString="object/tangible/deed/generator_deed/shared_generator_photo_bio_deed.iff";
|
||||
// deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
// deed1.setOutputHopperCapacity(250000);
|
||||
// deed1.setBER(19);
|
||||
// inventory.add(deed1);
|
||||
|
||||
templateString="object/tangible/deed/generator_deed/shared_generator_geothermal_deed.iff";
|
||||
deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet);
|
||||
deed1.setOutputHopperCapacity(250000);
|
||||
deed1.setBER(15);
|
||||
deed1.setAttributes();
|
||||
inventory.add(deed1);
|
||||
|
||||
break;
|
||||
case 112:
|
||||
core.resourceService.spawnSpecificResourceContainer("Radioactive", player, 100000);
|
||||
break;
|
||||
case 120:
|
||||
SWGObject houseDeed = core.objectService.createObject("object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff", planet);
|
||||
inventory.add(houseDeed);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,10 +2,8 @@ package services;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -19,25 +17,18 @@ import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import protocol.swg.OkMessage;
|
||||
import protocol.swg.PlayClientEffectObjectMessage;
|
||||
import protocol.swg.objectControllerObjects.BuffBuilderChangeMessage;
|
||||
import protocol.swg.objectControllerObjects.BuffBuilderEndMessage;
|
||||
import protocol.swg.objectControllerObjects.BuffBuilderStartMessage;
|
||||
import protocol.swg.objectControllerObjects.ImageDesignMessage;
|
||||
import resources.common.BuffBuilder;
|
||||
import resources.common.Console;
|
||||
import resources.common.IDAttribute;
|
||||
import resources.common.MathUtilities;
|
||||
import resources.common.ObjControllerOpcodes;
|
||||
import resources.common.Performance;
|
||||
import resources.common.PerformanceEffect;
|
||||
import resources.common.RGB;
|
||||
import resources.common.StringUtilities;
|
||||
import resources.datatables.Posture;
|
||||
import resources.objects.Buff;
|
||||
import resources.objects.BuffItem;
|
||||
import resources.objects.SWGList;
|
||||
import resources.objects.SkillMod;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.player.PlayerObject;
|
||||
@@ -45,7 +36,6 @@ import resources.objects.tangible.TangibleObject;
|
||||
import resources.visitors.IDManagerVisitor;
|
||||
import services.sui.SUIService.InputBoxType;
|
||||
import services.sui.SUIWindow;
|
||||
import services.sui.SUIWindow.SUICallback;
|
||||
import services.sui.SUIWindow.Trigger;
|
||||
import engine.clientdata.ClientFileManager;
|
||||
import engine.clientdata.visitors.DatatableVisitor;
|
||||
|
||||
@@ -35,7 +35,6 @@ import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.python.antlr.ast.Str;
|
||||
import org.python.core.Py;
|
||||
import org.python.core.PyObject;
|
||||
|
||||
@@ -46,9 +45,7 @@ import engine.resources.objects.SWGObject;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
import resources.objects.player.PlayerObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import services.equipment.BonusSetTemplate;
|
||||
import services.spawn.MobileTemplate;
|
||||
|
||||
public class EquipmentService implements INetworkDispatch {
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.util.Map;
|
||||
import resources.objects.Buff;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.group.GroupObject;
|
||||
import services.chat.ChatRoom;
|
||||
import main.NGECore;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.objects.SWGObject;
|
||||
|
||||
@@ -36,7 +36,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import resources.objects.building.BuildingObject;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.group.GroupObject;
|
||||
import services.object.ObjectService;
|
||||
import main.NGECore;
|
||||
|
||||
import engine.clientdata.ClientFileManager;
|
||||
|
||||
@@ -0,0 +1,521 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package services;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.DirectoryStream.Filter;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.attribute.BasicFileAttributeView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.group.GroupObject;
|
||||
import resources.objects.loot.LootGroup;
|
||||
import resources.objects.loot.LootRollSession;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import main.NGECore;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
|
||||
/**
|
||||
* @author Charon
|
||||
*/
|
||||
|
||||
public class LootService implements INetworkDispatch {
|
||||
|
||||
private NGECore core;
|
||||
|
||||
public LootService(NGECore core) {
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertOpcodes(Map<Integer, INetworkRemoteEvent> swgOpcodes, Map<Integer, INetworkRemoteEvent> objControllerOpcodes) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
|
||||
}
|
||||
|
||||
public void handleLootRequest(CreatureObject requester, TangibleObject lootedObject) {
|
||||
|
||||
GroupObject group = (GroupObject) core.objectService.getObject(requester.getGroupId());
|
||||
|
||||
if (lootedObject.isLooted() || lootedObject.isLootLock() || (group == null && !lootedObject.getKiller().equals(requester)) || (group != null && !group.getMemberList().contains(lootedObject.getKiller())))
|
||||
return;
|
||||
|
||||
lootedObject.setLootLock(true);
|
||||
|
||||
if (requester.getCustomName().contains("Kun")){
|
||||
requester.setCashCredits(requester.getCashCredits()+1);
|
||||
requester.sendSystemMessage("You looted 1 credit.", (byte)1);
|
||||
lootedObject.setLooted(true);
|
||||
return;
|
||||
}
|
||||
|
||||
LootRollSession lootRollSession = new LootRollSession(requester,lootedObject);
|
||||
|
||||
handleCreditDrop(requester,lootedObject);
|
||||
|
||||
lootSituationAssessment(requester,lootedObject,lootRollSession);
|
||||
|
||||
CreatureObject lootedCreature = (CreatureObject) lootedObject;
|
||||
|
||||
//TreeSet<TreeMap<String,Integer>> lootSpec = lootedObject.getLootSpecification();
|
||||
List<LootGroup> lootGroups = lootedCreature.getLootGroups();
|
||||
System.out.println("lootGroups size " + lootGroups.size());
|
||||
Iterator<LootGroup> iterator = lootGroups.iterator();
|
||||
|
||||
while (iterator.hasNext()){
|
||||
LootGroup lootGroup = iterator.next();
|
||||
int groupChance = lootGroup.getLootGroupChance();
|
||||
int lootGroupRoll = new Random().nextInt(100);
|
||||
if (lootGroupRoll <= groupChance){
|
||||
System.out.println("this lootGroup will drop something");
|
||||
handleLootGroup(lootGroup,lootRollSession); //this lootGroup will drop something e.g. {kraytpearl_range,krayt_tissue_rare}
|
||||
}
|
||||
}
|
||||
|
||||
// Rare Loot System Stage (Is in place for all looted creatures)
|
||||
if (lootRollSession.isAllowRareLoot()){
|
||||
int randomRareLoot = new Random().nextInt(100);
|
||||
int chanceRequirement = 1;
|
||||
if (lootRollSession.isIncreasedRLSChance())
|
||||
chanceRequirement+=3; // RLS chance is at 4% for groupsize >= 4
|
||||
if (randomRareLoot <= chanceRequirement){
|
||||
handleRareLootChest(lootRollSession);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ********** Phase 1 complete, loot items determined **********
|
||||
// stored in the lootSession
|
||||
|
||||
// Distribute the loot drops according to group loot rules
|
||||
// For now just spawn items into requester's inventory
|
||||
|
||||
if (lootRollSession.getErrorMessages().size()>0){
|
||||
for (String msg : lootRollSession.getErrorMessages()){
|
||||
// ToDo: Show this for each group member later!
|
||||
requester.sendSystemMessage(msg,(byte) 1);
|
||||
lootedObject.setLootLock(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SWGObject requesterInventory = requester.getSlottedObject("inventory");
|
||||
|
||||
for (TangibleObject droppedItem : lootRollSession.getDroppedItems()){
|
||||
|
||||
requesterInventory.add(droppedItem);
|
||||
if (droppedItem.getAttachment("LootItemName").toString().contains("Loot Chest")){
|
||||
requester.playEffectObject("clienteffect/level_granted.cef", "");
|
||||
}
|
||||
}
|
||||
|
||||
lootedObject.setLooted(true);
|
||||
|
||||
|
||||
// ToDo: Group loot settings etc. actual loot chance was lootgroupchance*lootchance
|
||||
}
|
||||
|
||||
|
||||
private void handleLootGroup(LootGroup lootGroup,LootRollSession lootRollSession){
|
||||
|
||||
int[] lootPoolChances = lootGroup.getLootPoolChances();
|
||||
String[] lootPoolNames = lootGroup.getLootPoolNames();
|
||||
if (lootPoolChances==null || lootPoolNames==null){
|
||||
System.err.println("Lootpools are null!");
|
||||
return;
|
||||
}
|
||||
if (lootPoolChances.length==0 || lootPoolNames.length==0){
|
||||
System.err.println("No Lootpools in Lootgroup!");
|
||||
return;
|
||||
}
|
||||
|
||||
int randomItemFromGroup = new Random().nextInt(100);
|
||||
int remainder = 0; // [10,20,30,34,5,1]
|
||||
|
||||
for(int i=0;i<lootPoolChances.length;i++) {
|
||||
remainder += lootPoolChances[i];
|
||||
if (randomItemFromGroup <= remainder){
|
||||
System.out.println("this loot pool will drop something"); // e.g. kraytpearl_range
|
||||
handleLootPool(lootPoolNames[i],lootRollSession); // This loot pool will drop something
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleLootPool(String poolName,LootRollSession lootRollSession){
|
||||
|
||||
// Fetch the loot pool data from the poolName.py script
|
||||
String path = "scripts/loot/lootPools/"+poolName.toLowerCase();
|
||||
Vector<String> itemNames = (Vector<String>)core.scriptService.fetchStringVector(path,"itemNames");
|
||||
|
||||
for (String s : itemNames){
|
||||
System.out.println("template: " + s);
|
||||
}
|
||||
|
||||
Vector<Integer> itemChances = (Vector<Integer>)core.scriptService.fetchIntegerVector(path,"itemChances");
|
||||
|
||||
int randomItemFromPool = new Random().nextInt(100);
|
||||
int remainder = 0; // [10,20,30,34,5,1]
|
||||
|
||||
for (int i=0;i<itemNames.size();i++){
|
||||
remainder += itemChances.get(i);
|
||||
if (randomItemFromPool<=remainder){
|
||||
// this element has been chosen e.g. kraytpearl_flawless
|
||||
handleLootPoolItems(itemNames.get(i), lootRollSession);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class DirectoriesFilter implements Filter<Path> {
|
||||
@Override
|
||||
public boolean accept(Path entry) throws IOException {
|
||||
return Files.isDirectory(entry);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleLootPoolItems(String itemName,LootRollSession lootRollSession){
|
||||
|
||||
List<String> subfolders = new ArrayList<String>(); // Consider all sub-folders
|
||||
try (DirectoryStream<Path> ds = Files.newDirectoryStream(FileSystems.getDefault().getPath("scripts/loot/lootItems/"), new DirectoriesFilter())) {
|
||||
for (Path p : ds) {
|
||||
subfolders.add(p.getFileName().toString());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
lootRollSession.addErrorMessage("File system check caused an error. Please contact Charon about this issue.");
|
||||
return;
|
||||
}
|
||||
|
||||
String itemPath = "scripts/loot/lootItems/"+itemName.toLowerCase()+".py";
|
||||
File file = new File(itemPath);
|
||||
if (!file.isFile()){
|
||||
for (String subfolderName : subfolders){
|
||||
itemPath = "scripts/loot/lootItems/"+ subfolderName +"/"+itemName.toLowerCase()+".py";
|
||||
File subfile = new File(itemPath);
|
||||
if (subfile.isFile())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
File checkfile = new File(itemPath);
|
||||
if (!checkfile.isFile()){
|
||||
String errorMessage = "Loot item '" + itemName + "' not found in file system. Please contact Charon about this issue.";
|
||||
lootRollSession.addErrorMessage(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
itemPath = itemPath.substring(0, itemPath.length()-3); // remove the file type
|
||||
|
||||
String customName = "";
|
||||
String itemTemplate = "";
|
||||
int stackCount = 1;
|
||||
Vector<String> customizationAttributes = null;
|
||||
Vector<Integer> customizationValues = null;
|
||||
|
||||
if(core.scriptService.getMethod(itemPath,"","itemTemplate")==null){
|
||||
String errorMessage = "Loot item '" + itemName + "' has no template function assigned in its script. Please contact Charon about this issue.";
|
||||
lootRollSession.addErrorMessage(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
itemTemplate = (String)core.scriptService.fetchString(itemPath,"itemTemplate");
|
||||
|
||||
// only consider the following variables, if they are in the python-script file
|
||||
if(core.scriptService.getMethod(itemPath,"","customItemName")!=null)
|
||||
customName = (String)core.scriptService.fetchString(itemPath,"customItemName");
|
||||
|
||||
if(core.scriptService.getMethod(itemPath,"","customItemStackCount")!=null)
|
||||
stackCount = (Integer)core.scriptService.fetchInteger(itemPath,"customItemStackCount");
|
||||
|
||||
if(core.scriptService.getMethod(itemPath,"","customizationAttributes")!=null)
|
||||
customizationAttributes = (Vector<String>)core.scriptService.fetchStringVector(itemPath,"customizationAttributes");
|
||||
|
||||
if(core.scriptService.getMethod(itemPath,"","customizationValues")!=null)
|
||||
customizationValues = (Vector<Integer>)core.scriptService.fetchIntegerVector(itemPath,"customizationValues");
|
||||
|
||||
System.out.println("itemTemplate " + itemTemplate);
|
||||
|
||||
TangibleObject droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet());
|
||||
|
||||
droppedItem.setAttachment("LootItemName", itemName);
|
||||
handleCustomDropName(droppedItem,customName);
|
||||
handleStats(droppedItem);
|
||||
setCustomization(droppedItem, itemName);
|
||||
handleSpecialItems(droppedItem,itemName);
|
||||
|
||||
lootRollSession.addDroppedItem(droppedItem);
|
||||
}
|
||||
|
||||
private void handleCustomDropName(TangibleObject droppedItem,String customName) {
|
||||
// String customItemName = droppedItem.getCustomName();
|
||||
// if (customName.charAt(0) == '@' || customName.contains("_n:")) {
|
||||
// if (customName!=null) {
|
||||
// customName = ""; // Look the name up in some tre table
|
||||
// }
|
||||
// }
|
||||
droppedItem.setCustomName(customName);
|
||||
}
|
||||
|
||||
private TangibleObject createDroppedItem(String template,Planet planet){
|
||||
TangibleObject droppedItem = (TangibleObject) core.objectService.createObject(template, planet);
|
||||
System.out.println("droppedItem " + droppedItem);
|
||||
return droppedItem;
|
||||
}
|
||||
|
||||
private void handleRareLootChest(LootRollSession lootRollSession){
|
||||
|
||||
TangibleObject droppedItem = null;
|
||||
|
||||
int legendaryRoll = new Random().nextInt(100);
|
||||
int exceptionalRoll = new Random().nextInt(100);
|
||||
int chancemodifier = 0;
|
||||
if (lootRollSession.isIncreasedRLSChance())
|
||||
chancemodifier += 15;
|
||||
|
||||
if (legendaryRoll<2+chancemodifier){
|
||||
String itemTemplate="object/tangible/item/shared_rare_loot_chest_3.iff";
|
||||
droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet());
|
||||
String itemName = "Legendary Loot Chest";
|
||||
droppedItem.setStfFilename("loot_n");
|
||||
droppedItem.setStfName("rare_loot_chest_3_n");
|
||||
droppedItem.setDetailFilename("loot_n");
|
||||
droppedItem.setDetailName("rare_loot_chest_3_d");
|
||||
droppedItem.setAttachment("LootItemName", itemName);
|
||||
droppedItem.getAttributes().put("@obj_attr_n:rare_loot_category", "\\#D1F56F Rare Item \\#FFFFFF ");
|
||||
fillLegendaryChest(droppedItem);
|
||||
|
||||
} else if (exceptionalRoll<10+chancemodifier){
|
||||
String itemTemplate="object/tangible/item/shared_rare_loot_chest_2.iff";
|
||||
droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet());
|
||||
String itemName = "Exceptional Loot Chest";
|
||||
droppedItem.setStfFilename("loot_n");
|
||||
droppedItem.setStfName("rare_loot_chest_2_n");
|
||||
droppedItem.setDetailFilename("loot_n");
|
||||
droppedItem.setDetailName("rare_loot_chest_2_d");
|
||||
droppedItem.setAttachment("LootItemName", itemName);
|
||||
droppedItem.getAttributes().put("@obj_attr_n:rare_loot_category", "\\#D1F56F Rare Item \\#FFFFFF ");
|
||||
fillExceptionalChest(droppedItem);
|
||||
} else {
|
||||
String itemTemplate="object/tangible/item/shared_rare_loot_chest_1.iff";
|
||||
droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet());
|
||||
String itemName = "Rare Loot Chest";
|
||||
droppedItem.setStfFilename("loot_n");
|
||||
droppedItem.setStfName("rare_loot_chest_1_n");
|
||||
droppedItem.setDetailFilename("loot_n");
|
||||
droppedItem.setDetailName("rare_loot_chest_1_d");
|
||||
droppedItem.setAttachment("LootItemName", itemName);
|
||||
droppedItem.getAttributes().put("@obj_attr_n:rare_loot_category", "\\#D1F56F Rare Item \\#FFFFFF ");
|
||||
fillRareChest(droppedItem);
|
||||
}
|
||||
|
||||
lootRollSession.addDroppedItem(droppedItem);
|
||||
}
|
||||
|
||||
private void fillLegendaryChest(TangibleObject droppedItem){
|
||||
|
||||
}
|
||||
|
||||
private void fillExceptionalChest(TangibleObject droppedItem){
|
||||
|
||||
}
|
||||
|
||||
private void fillRareChest(TangibleObject droppedItem){
|
||||
|
||||
}
|
||||
|
||||
private void setCustomization(TangibleObject droppedItem,String itemName) {
|
||||
|
||||
// Example color crystal
|
||||
if (itemName.contains("colorcrystal")) {
|
||||
System.out.println("colorcrystal");
|
||||
droppedItem.setCustomizationVariable("/private/index_color_1", (byte) new Random().nextInt(11));
|
||||
}
|
||||
|
||||
// Example power crystal
|
||||
if (itemName.contains("powercrystal")) {
|
||||
System.out.println("powercrystal");
|
||||
droppedItem.setCustomizationVariable("/private/index_color_1", (byte) 0x21); // 0x1F
|
||||
}
|
||||
|
||||
// More general
|
||||
// String path = "scripts/loot/lootItems/"+droppedItem.getCustomName().toLowerCase();
|
||||
// Vector<String> customizationPaths = (Vector<String>)core.scriptService.fetchStringVector(path,"itemCustomizationPaths");
|
||||
// Vector<Integer> customizationValues = (Vector<Integer>)core.scriptService.fetchIntegerVector(path,"itemCustomizationValues");
|
||||
// for (int i=0;i<customizationPaths.size();i++){
|
||||
// String attributePath = customizationPaths.get(i);
|
||||
// int attributeValue = customizationValues.get(i);
|
||||
// droppedItem.setCustomizationVariable(attributePath, (byte)attributeValue);
|
||||
// }
|
||||
}
|
||||
|
||||
private void handleSpecialItems(TangibleObject droppedItem,String itemName) {
|
||||
if (itemName.contains("kraytpearl")){
|
||||
handleKraytPearl(droppedItem);
|
||||
}
|
||||
if (itemName.contains("powercrystal")){
|
||||
handlePowerCrystal(droppedItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleStats(TangibleObject droppedItem) {
|
||||
// ToDo: Min,Max for weapons , Dots on weapons etc.
|
||||
// This must be considered for the python scripts as well
|
||||
// So basically every item needs to have loot-related data in their py scripts as well
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void handleCreditDrop(CreatureObject requester,TangibleObject lootedObject){
|
||||
int lootedCredits = 0;
|
||||
// Credit drop is depending on the CL of the looted CreatureObject
|
||||
// or if explicitely assigned in the .py script
|
||||
if (lootedObject instanceof CreatureObject){
|
||||
CreatureObject lootedCreature = (CreatureObject) lootedObject;
|
||||
int creatureCL = lootedCreature.getLevel();
|
||||
creatureCL = 90;
|
||||
int maximalCredits = (int)Math.floor(4*creatureCL + creatureCL*creatureCL*4/100);
|
||||
int minimalCredits = (int)Math.floor(creatureCL*2 + maximalCredits/2);
|
||||
int spanOfCredits = maximalCredits - minimalCredits;
|
||||
lootedCredits = minimalCredits + new Random().nextInt(spanOfCredits);
|
||||
requester.setCashCredits(requester.getCashCredits()+lootedCredits);
|
||||
requester.sendSystemMessage("You looted " + lootedCredits + " credits.", (byte)1);
|
||||
}
|
||||
|
||||
if (lootedObject instanceof TangibleObject){
|
||||
// This is for chests etc.
|
||||
// Check the py script
|
||||
}
|
||||
}
|
||||
|
||||
private void lootSituationAssessment(CreatureObject requester,TangibleObject lootedObject, LootRollSession lootRollSession){
|
||||
|
||||
// reserved for possible necessities
|
||||
}
|
||||
|
||||
// ************* Special items ************
|
||||
private void handleKraytPearl(TangibleObject droppedItem) {
|
||||
|
||||
String itemName = (String)droppedItem.getAttachment("LootItemName");
|
||||
String qualityString = "";
|
||||
switch (itemName) {
|
||||
case "kraytpearl_cracked":
|
||||
droppedItem.setStfFilename("static_item_n");
|
||||
droppedItem.setStfName("item_junk_imitation_pearl_01_02");
|
||||
droppedItem.setDetailFilename("static_item_d");
|
||||
droppedItem.setDetailName("item_junk_imitation_pearl_01_02");
|
||||
return;
|
||||
case "kraytpearl_scratched":
|
||||
droppedItem.setStfFilename("static_item_n");
|
||||
droppedItem.setStfName("item_junk_imitation_pearl_01_01");
|
||||
droppedItem.setDetailFilename("static_item_d");
|
||||
droppedItem.setDetailName("item_junk_imitation_pearl_01_01");
|
||||
return;
|
||||
case "kraytpearl_poor":
|
||||
qualityString="Poor";
|
||||
break;
|
||||
case "kraytpearl_fair":
|
||||
qualityString="Fair";
|
||||
break;
|
||||
case "kraytpearl_good":
|
||||
qualityString="Good";
|
||||
break;
|
||||
case "kraytpearl_quality":
|
||||
qualityString="Quality";
|
||||
break;
|
||||
case "kraytpearl_select":
|
||||
qualityString="Select";
|
||||
break;
|
||||
case "kraytpearl_premium":
|
||||
qualityString="Premium";
|
||||
break;
|
||||
case "kraytpearl_flawless":
|
||||
qualityString="Flawless";
|
||||
break;
|
||||
default:
|
||||
qualityString="Undetermined";
|
||||
break;
|
||||
}
|
||||
droppedItem.getAttributes().put("@obj_attr_n:condition", "100/100");
|
||||
droppedItem.getAttributes().put("@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF ");
|
||||
droppedItem.getAttributes().put("@obj_attr_n:crystal_quality", qualityString);
|
||||
droppedItem.setAttachment("radial_filename", "tunable");
|
||||
}
|
||||
|
||||
private void handlePowerCrystal(TangibleObject droppedItem) {
|
||||
|
||||
String itemName = (String)droppedItem.getAttachment("LootItemName");
|
||||
String qualityString = "";
|
||||
switch (itemName) {
|
||||
|
||||
case "powercrystal_poor":
|
||||
qualityString="Poor";
|
||||
break;
|
||||
case "powercrystal_fair":
|
||||
qualityString="Fair";
|
||||
break;
|
||||
case "powercrystal_good":
|
||||
qualityString="Good";
|
||||
break;
|
||||
case "powercrystal_quality":
|
||||
qualityString="Quality";
|
||||
break;
|
||||
case "powercrystal_select":
|
||||
qualityString="Select";
|
||||
break;
|
||||
case "powercrystal_premium":
|
||||
qualityString="Premium";
|
||||
break;
|
||||
case "powercrystal_flawless":
|
||||
qualityString="Flawless";
|
||||
break;
|
||||
case "powercrystal_perfect":
|
||||
qualityString="Perfect";
|
||||
break;
|
||||
default:
|
||||
qualityString="Undetermined";
|
||||
break;
|
||||
}
|
||||
droppedItem.getAttributes().put("@obj_attr_n:condition", "100/100");
|
||||
droppedItem.getAttributes().put("@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF ");
|
||||
droppedItem.getAttributes().put("@obj_attr_n:crystal_quality", qualityString);
|
||||
droppedItem.setAttachment("radial_filename", "tunable");
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ package services;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import main.NGECore;
|
||||
@@ -44,7 +43,6 @@ import engine.clientdata.visitors.DatatableVisitor;
|
||||
import engine.clients.Client;
|
||||
import engine.resources.container.Traverser;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
******************************************************************************/
|
||||
package services;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.python.core.Py;
|
||||
import org.python.core.PyObject;
|
||||
import org.python.util.PythonInterpreter;
|
||||
@@ -107,4 +110,34 @@ public class ScriptService {
|
||||
return func;
|
||||
}
|
||||
|
||||
public String fetchString(String path, String method) {
|
||||
PyObject result = core.scriptService.callScript(path, "", method);
|
||||
return ((PyObject)result).asString();
|
||||
}
|
||||
|
||||
public int fetchInteger(String path, String method) {
|
||||
PyObject result = core.scriptService.callScript(path, "", method);
|
||||
return ((PyObject)result).asInt();
|
||||
}
|
||||
|
||||
public Vector<String> fetchStringVector(String path, String method) {
|
||||
Vector<String> vector = new Vector<String>();
|
||||
PyObject result = core.scriptService.callScript(path, "", method);
|
||||
Iterable<PyObject> comp = (Iterable<PyObject>)result.asIterable();
|
||||
for (Iterator<PyObject> temp = comp.iterator(); temp.hasNext();){
|
||||
vector.add(temp.next().asString());
|
||||
}
|
||||
return vector;
|
||||
}
|
||||
|
||||
public Vector<Integer> fetchIntegerVector(String path, String method) {
|
||||
Vector<Integer> vector = new Vector<Integer>();
|
||||
PyObject result = core.scriptService.callScript(path, "", method);
|
||||
Iterable<PyObject> comp = (Iterable<PyObject>)result.asIterable();
|
||||
for (Iterator<PyObject> temp = comp.iterator(); temp.hasNext();){
|
||||
vector.add(temp.next().asInt());
|
||||
}
|
||||
return vector;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,15 +60,15 @@ import engine.resources.scene.Quaternion;
|
||||
import engine.resources.scene.quadtree.QuadTree;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
import protocol.swg.ChatFriendsListUpdate;
|
||||
import protocol.swg.ChatOnChangeFriendStatus;
|
||||
import protocol.swg.ChatOnGetFriendsList;
|
||||
import protocol.swg.CmdStartScene;
|
||||
import protocol.swg.HeartBeatMessage;
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import protocol.swg.OpenedContainerMessage;
|
||||
import protocol.swg.UpdateTransformMessage;
|
||||
import protocol.swg.UpdateTransformWithParentMessage;
|
||||
import protocol.swg.chat.ChatFriendsListUpdate;
|
||||
import protocol.swg.chat.ChatOnChangeFriendStatus;
|
||||
import protocol.swg.chat.ChatOnGetFriendsList;
|
||||
import protocol.swg.objectControllerObjects.DataTransform;
|
||||
import protocol.swg.objectControllerObjects.DataTransformWithParent;
|
||||
import protocol.swg.objectControllerObjects.TargetUpdate;
|
||||
@@ -809,7 +809,9 @@ public class SimulationService implements INetworkDispatch {
|
||||
PlayerObject ghost = (PlayerObject) object.getSlottedObject("ghost");
|
||||
|
||||
core.weatherService.sendWeather(object);
|
||||
|
||||
|
||||
//core.chatService.joinChatRoom(object.getCustomName().toLowerCase(), "SWG." + core.getGalaxyName() + "." + object.getPlanet().getName());
|
||||
|
||||
if (!object.hasSkill(ghost.getProfessionWheelPosition())) {
|
||||
object.showFlyText("cbt_spam", "skill_up", (float) 2.5, new RGB(154, 205, 50), 0);
|
||||
object.playEffectObject("clienteffect/skill_granted.cef", "");
|
||||
@@ -886,6 +888,24 @@ public class SimulationService implements INetworkDispatch {
|
||||
|
||||
}
|
||||
|
||||
public void transform(TangibleObject obj, Point3D position)
|
||||
{
|
||||
Point3D oldPosition = obj.getPosition();
|
||||
Point3D newPosition = new Point3D(oldPosition.x + position.x, oldPosition.y + position.y, oldPosition.z + position.z);
|
||||
|
||||
teleport(obj, newPosition, obj.getOrientation(), obj.getParentId());
|
||||
}
|
||||
|
||||
public void transform(SWGObject obj, float rotation, Point3D axis)
|
||||
{
|
||||
rotation *= (Math.PI / 180);
|
||||
|
||||
Quaternion oldRotation = obj.getOrientation();
|
||||
Quaternion newRotation = resources.common.MathUtilities.rotateQuaternion(oldRotation, rotation, axis);
|
||||
|
||||
teleport(obj, obj.getPosition(), newRotation, obj.getParentId());
|
||||
}
|
||||
|
||||
public void teleport(SWGObject obj, Point3D position, Quaternion orientation, long cellId) {
|
||||
|
||||
if(cellId == 0) {
|
||||
@@ -900,6 +920,9 @@ public class SimulationService implements INetworkDispatch {
|
||||
DataTransformWithParent dataTransform = new DataTransformWithParent(new Point3D(position.x, position.y, position.z), orientation, obj.getMovementCounter(), obj.getObjectID(), cellId);
|
||||
ObjControllerMessage objController = new ObjControllerMessage(0x1B, dataTransform);
|
||||
obj.notifyObservers(objController, true);
|
||||
|
||||
obj.setPosition(position);
|
||||
obj.setOrientation(orientation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
package services;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Observable;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -31,27 +30,19 @@ import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import protocol.swg.PlayClientEffectLocMessage;
|
||||
import protocol.swg.SceneCreateObjectByCrc;
|
||||
import protocol.swg.SceneEndBaselines;
|
||||
import protocol.swg.SurveyMapUpdateMessage;
|
||||
import protocol.swg.UpdateContainmentMessage;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.player.PlayerObject;
|
||||
import resources.objects.resource.GalacticResource;
|
||||
import resources.objects.resource.ResourceConcentration;
|
||||
import resources.objects.resource.ResourceContainerObject;
|
||||
import resources.objects.resource.ResourceRoot;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import resources.objects.tool.SurveyTool;
|
||||
import resources.objects.waypoint.WaypointObject;
|
||||
import services.sui.SUIWindow;
|
||||
import services.sui.SUIWindow.SUICallback;
|
||||
import services.sui.SUIWindow.Trigger;
|
||||
import main.NGECore;
|
||||
import engine.resources.common.CRC;
|
||||
import engine.resources.container.Traverser;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
|
||||
@@ -479,7 +470,6 @@ public class SurveyService implements INetworkDispatch {
|
||||
returnList.add("List.lstList:SelectedRow");
|
||||
|
||||
window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
|
||||
int index = Integer.parseInt(returnList.get(0));
|
||||
@@ -627,7 +617,6 @@ public class SurveyService implements INetworkDispatch {
|
||||
final SurveyTool outerSurveyTool = (SurveyTool)target;
|
||||
|
||||
window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
|
||||
CreatureObject crafter = (CreatureObject)owner;
|
||||
@@ -673,14 +662,12 @@ public class SurveyService implements INetworkDispatch {
|
||||
final SurveyTool outerSurveyTool = (SurveyTool)target;
|
||||
|
||||
window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
|
||||
((CreatureObject)owner).sendSystemMessage("Rad confirmed", (byte) 0);
|
||||
}
|
||||
});
|
||||
window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
|
||||
((CreatureObject)owner).sendSystemMessage("Rad declined", (byte) 0);
|
||||
|
||||
@@ -24,22 +24,16 @@ package services;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import resources.common.FileUtilities;
|
||||
import resources.common.collidables.CollidableCircle;
|
||||
import resources.objects.building.BuildingObject;
|
||||
import resources.objects.cell.CellObject;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
|
||||
import engine.clientdata.ClientFileManager;
|
||||
import engine.clientdata.visitors.DatatableVisitor;
|
||||
import engine.resources.config.Config;
|
||||
import engine.resources.container.Traverser;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
@@ -181,6 +175,12 @@ public class TerrainService {
|
||||
core.mapService.addPlanet(planet);
|
||||
noBuildAreas.put(planet, new ArrayList<CollidableCircle>());
|
||||
loadClientRegions(planet);
|
||||
|
||||
core.chatService.createChatRoom("", name, "system", true);
|
||||
core.chatService.createChatRoom("public chat for this planet, cannot create rooms here", name + ".Planet", "SYSTEM", true);
|
||||
core.chatService.createChatRoom("system messages for this planet, cannot create rooms here", name + ".system", "SYSTEM", true);
|
||||
|
||||
System.out.println("Created chat rooms for " + name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
package services.ai;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -42,7 +41,6 @@ import services.ai.states.AttackState;
|
||||
import services.ai.states.DeathState;
|
||||
import services.ai.states.IdleState;
|
||||
import services.ai.states.RetreatState;
|
||||
import services.ai.states.SpawnState;
|
||||
import services.combat.CombatEvents.DamageTaken;
|
||||
import services.spawn.MobileTemplate;
|
||||
|
||||
|
||||
@@ -26,14 +26,11 @@ import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
|
||||
import resources.objects.cell.CellObject;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.group.GroupObject;
|
||||
import resources.objects.player.PlayerObject;
|
||||
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ public class DeathState extends AIState {
|
||||
@Override
|
||||
public byte onEnter(AIActor actor) {
|
||||
NGECore.getInstance().aiService.awardExperience(actor);
|
||||
actor.getCreature().setAttachment("radial_filename", "npc/corpse");
|
||||
actor.scheduleDespawn();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
******************************************************************************/
|
||||
package services.ai.states;
|
||||
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import services.ai.AIActor;
|
||||
import services.ai.states.AIState.StateResult;
|
||||
|
||||
public class RetreatState extends AIState {
|
||||
|
||||
|
||||
@@ -21,16 +21,12 @@
|
||||
******************************************************************************/
|
||||
package services.chat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import resources.objects.creature.CreatureObject;
|
||||
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.PrimaryKey;
|
||||
import com.sleepycat.persist.model.Relationship;
|
||||
import com.sleepycat.persist.model.SecondaryKey;
|
||||
|
||||
@Entity
|
||||
public class ChatRoom {
|
||||
@@ -40,13 +36,11 @@ public class ChatRoom {
|
||||
private int roomId;
|
||||
private String roomAddress; // name
|
||||
|
||||
private Vector<CreatureObject> moderatorList = new Vector<CreatureObject>();
|
||||
private Vector<CreatureObject> banList = new Vector<CreatureObject>();
|
||||
private Vector<String> moderatorList = new Vector<String>();
|
||||
private Vector<String> banList = new Vector<String>();
|
||||
@NotPersistent
|
||||
private Vector<CreatureObject> userList = new Vector<CreatureObject>(); // current users
|
||||
private Vector<String> userList = new Vector<String>(); // current users
|
||||
|
||||
@NotPersistent
|
||||
private int requestId; // not-persistent
|
||||
private boolean moderatorsOnly;
|
||||
private boolean privateRoom;
|
||||
private boolean visible;
|
||||
@@ -55,9 +49,9 @@ public class ChatRoom {
|
||||
public String getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
|
||||
public void setCreator(String creator) {
|
||||
this.creator = creator;
|
||||
this.creator = creator.toLowerCase();
|
||||
}
|
||||
|
||||
public String getRoomAddress() {
|
||||
@@ -76,30 +70,14 @@ public class ChatRoom {
|
||||
this.roomId = roomId;
|
||||
}
|
||||
|
||||
public Vector<CreatureObject> getModeratorList() {
|
||||
public Vector<String> getModeratorList() {
|
||||
return moderatorList;
|
||||
}
|
||||
|
||||
public void setModeratorList(Vector<CreatureObject> moderatorList) {
|
||||
this.moderatorList = moderatorList;
|
||||
}
|
||||
|
||||
public Vector<CreatureObject> getUserList() {
|
||||
public Vector<String> getUserList() {
|
||||
return userList;
|
||||
}
|
||||
|
||||
public void setUserList(Vector<CreatureObject> userList) {
|
||||
this.userList = userList;
|
||||
}
|
||||
|
||||
public int getRequestId() {
|
||||
return requestId;
|
||||
}
|
||||
|
||||
public void setRequestId(int requestId) {
|
||||
this.requestId = requestId;
|
||||
}
|
||||
|
||||
public boolean isModeratorsOnly() {
|
||||
return moderatorsOnly;
|
||||
}
|
||||
@@ -121,17 +99,13 @@ public class ChatRoom {
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
this.owner = owner.toLowerCase();
|
||||
}
|
||||
|
||||
public Vector<CreatureObject> getBanList() {
|
||||
public Vector<String> getBanList() {
|
||||
return banList;
|
||||
}
|
||||
|
||||
public void setBanList(Vector<CreatureObject> banList) {
|
||||
this.banList = banList;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
@@ -147,4 +121,28 @@ public class ChatRoom {
|
||||
public void setVisible(boolean visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
public void addUser(String user) {
|
||||
userList.add(user.toLowerCase());
|
||||
}
|
||||
|
||||
public void addModerator(String moderator) {
|
||||
moderatorList.add(moderator.toLowerCase());
|
||||
}
|
||||
|
||||
public void banUser(String user) {
|
||||
banList.add(user.toLowerCase());
|
||||
}
|
||||
|
||||
public boolean hasUser(String user) {
|
||||
return userList.contains(user.toLowerCase());
|
||||
}
|
||||
|
||||
public boolean hasModerator(String moderator) {
|
||||
return moderatorList.contains(moderator.toLowerCase());
|
||||
}
|
||||
|
||||
public boolean hasBan(String user) {
|
||||
return banList.contains(user.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ package services.chat;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
@@ -34,14 +35,13 @@ import org.apache.mina.core.session.IoSession;
|
||||
|
||||
import com.sleepycat.je.Transaction;
|
||||
import com.sleepycat.persist.EntityCursor;
|
||||
import com.sleepycat.persist.PrimaryIndex;
|
||||
import com.sleepycat.persist.SecondaryIndex;
|
||||
|
||||
import engine.clients.Client;
|
||||
import engine.resources.config.Config;
|
||||
import engine.resources.config.DefaultConfig;
|
||||
import engine.resources.database.ObjectDatabase;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
@@ -49,25 +49,28 @@ import resources.common.*;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.player.PlayerObject;
|
||||
import protocol.swg.AddIgnoreMessage;
|
||||
import protocol.swg.ChatEnterRoomById;
|
||||
import protocol.swg.ChatOnChangeFriendStatus;
|
||||
import protocol.swg.ChatDeletePersistentMessage;
|
||||
import protocol.swg.ChatFriendsListUpdate;
|
||||
import protocol.swg.ChatInstantMessageToCharacter;
|
||||
import protocol.swg.ChatInstantMessagetoClient;
|
||||
import protocol.swg.ChatOnAddFriend;
|
||||
import protocol.swg.ChatOnEnteredRoom;
|
||||
import protocol.swg.ChatOnSendInstantMessage;
|
||||
import protocol.swg.ChatOnSendPersistentMessage;
|
||||
import protocol.swg.ChatOnSendRoomMessage;
|
||||
import protocol.swg.ChatPersistentMessageToClient;
|
||||
import protocol.swg.ChatPersistentMessageToServer;
|
||||
import protocol.swg.ChatRequestPersistentMessage;
|
||||
import protocol.swg.ChatRoomList;
|
||||
import protocol.swg.ChatRoomMessage;
|
||||
import protocol.swg.ChatSendToRoom;
|
||||
import protocol.swg.ChatSystemMessage;
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import protocol.swg.chat.ChatCreateRoom;
|
||||
import protocol.swg.chat.ChatDeletePersistentMessage;
|
||||
import protocol.swg.chat.ChatEnterRoomById;
|
||||
import protocol.swg.chat.ChatFriendsListUpdate;
|
||||
import protocol.swg.chat.ChatInstantMessageToCharacter;
|
||||
import protocol.swg.chat.ChatInstantMessagetoClient;
|
||||
import protocol.swg.chat.ChatOnAddFriend;
|
||||
import protocol.swg.chat.ChatOnChangeFriendStatus;
|
||||
import protocol.swg.chat.ChatOnCreateRoom;
|
||||
import protocol.swg.chat.ChatOnEnteredRoom;
|
||||
import protocol.swg.chat.ChatOnSendInstantMessage;
|
||||
import protocol.swg.chat.ChatOnSendPersistentMessage;
|
||||
import protocol.swg.chat.ChatOnSendRoomMessage;
|
||||
import protocol.swg.chat.ChatPersistentMessageToClient;
|
||||
import protocol.swg.chat.ChatPersistentMessageToServer;
|
||||
import protocol.swg.chat.ChatRequestPersistentMessage;
|
||||
import protocol.swg.chat.ChatRoomList;
|
||||
import protocol.swg.chat.ChatRoomMessage;
|
||||
import protocol.swg.chat.ChatSendToRoom;
|
||||
import protocol.swg.chat.ChatServerStatus;
|
||||
import protocol.swg.chat.ChatSystemMessage;
|
||||
import protocol.swg.objectControllerObjects.PlayerEmote;
|
||||
import protocol.swg.objectControllerObjects.SpatialChat;
|
||||
import main.NGECore;
|
||||
@@ -362,23 +365,65 @@ public class ChatService implements INetworkDispatch {
|
||||
return;
|
||||
|
||||
ChatRoomList listMessage = new ChatRoomList(chatRooms);
|
||||
|
||||
client.getSession().write(listMessage.serialize());
|
||||
|
||||
//System.out.println("Sent the room request responses.");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
swgOpcodes.put(Opcodes.ChatCreateRoom, (session, data) -> {
|
||||
//System.out.println("CREATE:");
|
||||
//StringUtilities.printBytes(data.array());
|
||||
/*data.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
Client client = core.getClient(session);
|
||||
|
||||
if(client == null)
|
||||
return;
|
||||
|
||||
SWGObject obj = client.getParent();
|
||||
|
||||
if (obj == null)
|
||||
return;
|
||||
|
||||
CreatureObject creo = (CreatureObject) obj;
|
||||
|
||||
ChatCreateRoom sentPacket = new ChatCreateRoom();
|
||||
sentPacket.deserialize(data);
|
||||
|
||||
ChatRoom room = createChatRoom(sentPacket.getTitle(), sentPacket.getAddress(), creo.getCustomName().toLowerCase(), true, false);
|
||||
|
||||
if (room != null) {
|
||||
room.setPrivateRoom(sentPacket.isPrivacy());
|
||||
room.setModeratorsOnly(sentPacket.isModeratorOnly());
|
||||
room.addUser(creo.getCustomName());
|
||||
room.addModerator(creo.getCustomName());
|
||||
ChatOnCreateRoom response = new ChatOnCreateRoom(room, 0, sentPacket.getRequest());
|
||||
session.write(response.serialize());
|
||||
}
|
||||
|
||||
System.out.println("Created room.");*/
|
||||
|
||||
});
|
||||
|
||||
swgOpcodes.put(Opcodes.ChatQueryRoom, (session, data) -> {
|
||||
//System.out.println("QUERY: ");
|
||||
data.order(ByteOrder.LITTLE_ENDIAN);
|
||||
//StringUtilities.printBytes(data.array());
|
||||
Client client = core.getClient(session);
|
||||
|
||||
if(client == null)
|
||||
return;
|
||||
|
||||
SWGObject obj = client.getParent();
|
||||
|
||||
if (obj == null)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
swgOpcodes.put(Opcodes.ChatSendToRoom, (session, data) -> {
|
||||
//System.out.println("send to room!");
|
||||
Client client = core.getClient(session);
|
||||
|
||||
if(client == null)
|
||||
@@ -408,13 +453,14 @@ public class ChatService implements INetworkDispatch {
|
||||
|
||||
if (obj == null)
|
||||
return;
|
||||
|
||||
data.order(ByteOrder.LITTLE_ENDIAN);
|
||||
data.position(0);
|
||||
ChatEnterRoomById sentPacket = new ChatEnterRoomById();
|
||||
sentPacket.deserialize(data);
|
||||
|
||||
joinChatRoom((CreatureObject) obj, sentPacket.getRoomId());
|
||||
joinChatRoom(obj.getCustomName(), sentPacket.getRoomId());
|
||||
|
||||
//System.out.println("Entering room...");
|
||||
//System.out.println("Entering room... " + sentPacket.getRoomId());
|
||||
|
||||
});
|
||||
}
|
||||
@@ -684,8 +730,22 @@ public class ChatService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
private void loadChatRooms() {
|
||||
ChatRoom system = createChatRoom("Waves Dungeon", "ProjectSWGTest.Dungeon", "Waverunner", true);
|
||||
chatRooms.put(system.getRoomId(), system);
|
||||
|
||||
/*
|
||||
* Battlefields channel format:
|
||||
* SWG.serverName.battlefield.bfMapName
|
||||
*
|
||||
* TODO: Research other channel address formats
|
||||
*/
|
||||
|
||||
createChatRoom("", "SWG", "system", true);
|
||||
createChatRoom("", "SWG." + core.getGalaxyName(), "system", true);
|
||||
|
||||
createChatRoom("", "system", "system", true); // galaxy system messages
|
||||
createChatRoom("", "Auction", "system", true);
|
||||
|
||||
//createChatRoom("Bounty Hunter chat for this galaxy", "BountyHunter", "SYSTEM", true);
|
||||
//createChatRoom("Commando chat for this galaxy", "Commando", "SYSTEM", true);
|
||||
|
||||
EntityCursor<ChatRoom> cursor = chatRoomsODB.getCursor(Integer.class, ChatRoom.class);
|
||||
cursor.forEach(room -> {
|
||||
@@ -694,20 +754,23 @@ public class ChatService implements INetworkDispatch {
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
public ChatRoom createChatRoom(String roomName, String address, String creator, boolean showInList) {
|
||||
return createChatRoom(roomName, address, creator, showInList, false);
|
||||
public ChatRoom createChatRoom(String roomName, String address, String creator, boolean isPublic) {
|
||||
return createChatRoom(roomName, address, creator, isPublic, false);
|
||||
}
|
||||
public ChatRoom createChatRoom(String roomName, String address, String creator, boolean showInList, boolean store) {
|
||||
public ChatRoom createChatRoom(String roomName, String address, String creator, boolean isPublic, boolean store) {
|
||||
|
||||
if (creator.contains(" "))
|
||||
creator = creator.split(" ")[0];
|
||||
|
||||
|
||||
ChatRoom room = new ChatRoom();
|
||||
room.setDescription(roomName);
|
||||
room.setRoomAddress("SWG." + core.getGalaxyName() + "." + address);
|
||||
room.setCreator(creator);
|
||||
room.setOwner(creator);
|
||||
room.setVisible(showInList);
|
||||
if (!address.startsWith("SWG"))
|
||||
room.setRoomAddress("SWG." + core.getGalaxyName() + "." + address);
|
||||
else
|
||||
room.setRoomAddress(address);
|
||||
room.setCreator(creator.toLowerCase());
|
||||
room.setOwner(creator.toLowerCase());
|
||||
room.setVisible(isPublic);
|
||||
room.setRoomId(generateChatRoomId());
|
||||
|
||||
chatRooms.put(room.getRoomId(), room);
|
||||
@@ -721,26 +784,45 @@ public class ChatService implements INetworkDispatch {
|
||||
return room;
|
||||
}
|
||||
|
||||
public void joinChatRoom(CreatureObject player, int roomId) {
|
||||
public boolean joinChatRoom(String user, String roomAddress) {
|
||||
chatRooms.forEach((k, v) -> {
|
||||
if (v.getRoomAddress().equals(roomAddress)) {
|
||||
joinChatRoom(user, k, true);
|
||||
return;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
public boolean joinChatRoom(String user, int roomId, boolean resendList) {
|
||||
|
||||
String playerName = player.getCustomName().toLowerCase();
|
||||
|
||||
if (playerName.contains(" "))
|
||||
playerName = playerName.split(" ")[0];
|
||||
if (user.contains(" "))
|
||||
user = user.split(" ")[0];
|
||||
|
||||
ChatRoom room = getChatRoom(roomId);
|
||||
if (room == null)
|
||||
return;
|
||||
|
||||
ChatOnEnteredRoom enterRoom = new ChatOnEnteredRoom(playerName, 0, roomId, true);
|
||||
|
||||
if (!room.getUserList().contains(player))
|
||||
room.getUserList().add(player);
|
||||
|
||||
room.getUserList().stream().forEach(user -> user.getClient().getSession().write(enterRoom.serialize()));
|
||||
return false;
|
||||
|
||||
if (!room.hasUser(user.toLowerCase())) {
|
||||
room.addUser(user.toLowerCase());
|
||||
|
||||
if (!room.isVisible() || resendList) {
|
||||
CreatureObject creo = (CreatureObject) getObjectByFirstName(user);
|
||||
if (creo != null) {
|
||||
ChatRoomList listMessage = new ChatRoomList(room);
|
||||
creo.getClient().getSession().write(listMessage.serialize());
|
||||
}
|
||||
}
|
||||
ChatOnEnteredRoom enterRoom = new ChatOnEnteredRoom(user, 0, roomId, true);
|
||||
getObjectByFirstName(user).getClient().getSession().write(enterRoom.serialize());
|
||||
//System.out.println("Sent message for room " + room.getRoomAddress());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean joinChatRoom(String user, int roomId) {
|
||||
return joinChatRoom(user, roomId, false);
|
||||
}
|
||||
public void leaveChatRoom(CreatureObject player, int roomId) {
|
||||
|
||||
String playerName = player.getCustomName().toLowerCase();
|
||||
@@ -773,11 +855,8 @@ public class ChatService implements INetworkDispatch {
|
||||
sender.getClient().getSession().write(onSend.serialize());
|
||||
|
||||
ChatRoomMessage roomMessage = new ChatRoomMessage(roomId, senderName, message);
|
||||
Vector<CreatureObject> users = room.getUserList();
|
||||
Vector<String> users = room.getUserList();
|
||||
|
||||
for (CreatureObject user : users) {
|
||||
user.getClient().getSession().write(roomMessage.serialize());
|
||||
}
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<Integer, ChatRoom> getChatRooms() {
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
******************************************************************************/
|
||||
package services.combat;
|
||||
|
||||
import services.command.CombatCommand;
|
||||
import main.NGECore;
|
||||
|
||||
public class CombatCommands {
|
||||
|
||||
@@ -36,7 +36,6 @@ import org.apache.mina.core.session.IoSession;
|
||||
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import protocol.swg.PlayClientEffectLocMessage;
|
||||
import protocol.swg.UpdatePVPStatusMessage;
|
||||
import protocol.swg.objectControllerObjects.CombatAction;
|
||||
import protocol.swg.objectControllerObjects.CombatSpam;
|
||||
import protocol.swg.objectControllerObjects.CommandEnqueueRemove;
|
||||
@@ -52,6 +51,7 @@ import resources.objects.waypoint.WaypointObject;
|
||||
import resources.objects.weapon.WeaponObject;
|
||||
import services.ai.AIActor;
|
||||
import services.combat.CombatEvents.DamageTaken;
|
||||
import services.command.BaseSWGCommand;
|
||||
import services.command.CombatCommand;
|
||||
import services.sui.SUIService.MessageBoxType;
|
||||
import services.sui.SUIWindow;
|
||||
@@ -191,7 +191,9 @@ public class CombatService implements INetworkDispatch {
|
||||
{
|
||||
defender.removeDefender(creature);
|
||||
creature.removeDefender(defender);
|
||||
}
|
||||
}
|
||||
|
||||
if(((CreatureObject) target).getPlayerObject() == null) target.setKiller(attacker);
|
||||
}
|
||||
}
|
||||
else if(target instanceof TangibleObject)
|
||||
@@ -400,7 +402,7 @@ public class CombatService implements INetworkDispatch {
|
||||
|
||||
}
|
||||
|
||||
private void sendCombatPackets(CreatureObject attacker, TangibleObject target, WeaponObject weapon, CombatCommand command, int actionCounter, float damage, int armorAbsorbed, int hitType) {
|
||||
private void sendCombatPackets(CreatureObject attacker, TangibleObject target, WeaponObject weapon, BaseSWGCommand command, int actionCounter, float damage, int armorAbsorbed, int hitType) {
|
||||
|
||||
String animationStr = command.getRandomAnimation(weapon);
|
||||
CombatAction combatAction = new CombatAction(CRC.StringtoCRC(animationStr), attacker.getObjectID(), weapon.getObjectID(), target.getObjectID(), command.getCommandCRC());
|
||||
@@ -429,7 +431,7 @@ public class CombatService implements INetworkDispatch {
|
||||
|
||||
}
|
||||
|
||||
private void sendHealPackets(CreatureObject attacker, CreatureObject target, WeaponObject weapon, CombatCommand command, int actionCounter) {
|
||||
private void sendHealPackets(CreatureObject attacker, CreatureObject target, WeaponObject weapon, BaseSWGCommand command, int actionCounter) {
|
||||
|
||||
CombatAction combatAction = new CombatAction(CRC.StringtoCRC(command.getDefaultAnimations()[0]), attacker.getObjectID(), weapon.getObjectID(), target.getObjectID(), command.getCommandCRC());
|
||||
ObjControllerMessage objController = new ObjControllerMessage(0x1B, combatAction);
|
||||
@@ -820,7 +822,6 @@ public class CombatService implements INetworkDispatch {
|
||||
target.getEventBus().publish(event);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void doDrainHeal(CreatureObject receiver, int drainAmount) {
|
||||
synchronized(receiver.getMutex()) {
|
||||
receiver.setHealth(receiver.getHealth() + drainAmount);
|
||||
|
||||
@@ -27,6 +27,9 @@ import engine.resources.common.CRC;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import resources.objects.weapon.WeaponObject;
|
||||
|
||||
public class BaseSWGCommand implements Cloneable {
|
||||
|
||||
@@ -34,7 +37,6 @@ public class BaseSWGCommand implements Cloneable {
|
||||
private String clientEffectSelf;
|
||||
private String clientEffectTarget;
|
||||
private int commandCRC;
|
||||
private boolean isGmCommand = false;
|
||||
private String characterAbility;
|
||||
private int target;
|
||||
private int targetType;
|
||||
@@ -55,6 +57,21 @@ public class BaseSWGCommand implements Cloneable {
|
||||
private Byte[] invalidPostures;
|
||||
private Long[] invalidStates;
|
||||
|
||||
private String[] defaultAnimations = new String[]{};
|
||||
private String[] oneHandedAnimations = new String[]{};
|
||||
private String[] twoHandedAnimations = new String[]{};
|
||||
private String[] polearmAnimations = new String[]{};
|
||||
private String[] unarmedAnimations = new String[]{};
|
||||
private String[] pistolAnimations = new String[]{};
|
||||
private String[] carbineAnimations = new String[]{};
|
||||
private String[] lightRifleAnimations = new String[]{};
|
||||
private String[] rifleAnimations = new String[]{};
|
||||
private String[] heavyWpnAnimations = new String[]{};
|
||||
private String[] oneHandedLSAnimations = new String[]{};
|
||||
private String[] twoHandedLSAnimations = new String[]{};
|
||||
private String[] polearmLSAnimations = new String[]{};
|
||||
private String[] thrownAnimations = new String[]{};
|
||||
|
||||
public BaseSWGCommand(String commandName) {
|
||||
setCommandName(commandName);
|
||||
setCommandCRC(CRC.StringtoCRC(commandName));
|
||||
@@ -222,10 +239,6 @@ public class BaseSWGCommand implements Cloneable {
|
||||
return (godLevel > 0);
|
||||
}
|
||||
|
||||
public void setGmCommand(boolean isGmCommand) {
|
||||
this.isGmCommand = isGmCommand;
|
||||
}
|
||||
|
||||
public String getCharacterAbility() {
|
||||
return characterAbility;
|
||||
}
|
||||
@@ -362,4 +375,169 @@ public class BaseSWGCommand implements Cloneable {
|
||||
this.warmupTime = warmupTime;
|
||||
}
|
||||
|
||||
public String[] getDefaultAnimations() {
|
||||
return defaultAnimations;
|
||||
}
|
||||
|
||||
public void setDefaultAnimations(String[] defaultAnimations) {
|
||||
this.defaultAnimations = defaultAnimations;
|
||||
}
|
||||
|
||||
public String[] getOneHandedAnimations() {
|
||||
return oneHandedAnimations;
|
||||
}
|
||||
|
||||
public void setOneHandedAnimations(String[] oneHandedAnimations) {
|
||||
this.oneHandedAnimations = oneHandedAnimations;
|
||||
}
|
||||
|
||||
public String[] getTwoHandedAnimations() {
|
||||
return twoHandedAnimations;
|
||||
}
|
||||
|
||||
public void setTwoHandedAnimations(String[] twoHandedAnimations) {
|
||||
this.twoHandedAnimations = twoHandedAnimations;
|
||||
}
|
||||
|
||||
public String[] getPolearmAnimations() {
|
||||
return polearmAnimations;
|
||||
}
|
||||
|
||||
public void setPolearmAnimations(String[] polearmAnimations) {
|
||||
this.polearmAnimations = polearmAnimations;
|
||||
}
|
||||
|
||||
public String[] getUnarmedAnimations() {
|
||||
return unarmedAnimations;
|
||||
}
|
||||
|
||||
public void setUnarmedAnimations(String[] unarmedAnimations) {
|
||||
this.unarmedAnimations = unarmedAnimations;
|
||||
}
|
||||
|
||||
public String[] getPistolAnimations() {
|
||||
return pistolAnimations;
|
||||
}
|
||||
|
||||
public void setPistolAnimations(String[] pistolAnimations) {
|
||||
this.pistolAnimations = pistolAnimations;
|
||||
}
|
||||
|
||||
public String[] getCarbineAnimations() {
|
||||
return carbineAnimations;
|
||||
}
|
||||
|
||||
public void setCarbineAnimations(String[] carbineAnimations) {
|
||||
this.carbineAnimations = carbineAnimations;
|
||||
}
|
||||
|
||||
public String[] getLightRifleAnimations() {
|
||||
return lightRifleAnimations;
|
||||
}
|
||||
|
||||
public void setLightRifleAnimations(String[] lightRifleAnimations) {
|
||||
this.lightRifleAnimations = lightRifleAnimations;
|
||||
}
|
||||
|
||||
public String[] getRifleAnimations() {
|
||||
return rifleAnimations;
|
||||
}
|
||||
|
||||
public void setRifleAnimations(String[] rifleAnimations) {
|
||||
this.rifleAnimations = rifleAnimations;
|
||||
}
|
||||
|
||||
public String[] getHeavyWpnAnimations() {
|
||||
return heavyWpnAnimations;
|
||||
}
|
||||
|
||||
public void setHeavyWpnAnimations(String[] heavyWpnAnimations) {
|
||||
this.heavyWpnAnimations = heavyWpnAnimations;
|
||||
}
|
||||
|
||||
public String[] getOneHandedLSAnimations() {
|
||||
return oneHandedLSAnimations;
|
||||
}
|
||||
|
||||
public void setOneHandedLSAnimations(String[] oneHandedLSAnimations) {
|
||||
this.oneHandedLSAnimations = oneHandedLSAnimations;
|
||||
}
|
||||
|
||||
public String[] getTwoHandedLSAnimations() {
|
||||
return twoHandedLSAnimations;
|
||||
}
|
||||
|
||||
public void setTwoHandedLSAnimations(String[] twoHandedLSAnimations) {
|
||||
this.twoHandedLSAnimations = twoHandedLSAnimations;
|
||||
}
|
||||
|
||||
public String[] getPolearmLSAnimations() {
|
||||
return polearmLSAnimations;
|
||||
}
|
||||
|
||||
public void setPolearmLSAnimations(String[] polearmLSAnimations) {
|
||||
this.polearmLSAnimations = polearmLSAnimations;
|
||||
}
|
||||
|
||||
public String[] getThrownAnimations() {
|
||||
return thrownAnimations;
|
||||
}
|
||||
|
||||
public void setThrownAnimations(String[] thrownAnimations) {
|
||||
this.thrownAnimations = thrownAnimations;
|
||||
}
|
||||
|
||||
public String getRandomAnimation(WeaponObject weapon) {
|
||||
int weaponType = weapon.getWeaponType();
|
||||
String[] animations;
|
||||
|
||||
switch (weaponType) {
|
||||
case 0:
|
||||
animations = rifleAnimations;
|
||||
break;
|
||||
case 1:
|
||||
animations = carbineAnimations;
|
||||
break;
|
||||
case 2:
|
||||
animations = pistolAnimations;
|
||||
break;
|
||||
case 3:
|
||||
animations = heavyWpnAnimations;
|
||||
break;
|
||||
case 4:
|
||||
animations = oneHandedAnimations;
|
||||
break;
|
||||
case 5:
|
||||
animations = twoHandedAnimations;
|
||||
break;
|
||||
case 6:
|
||||
animations = defaultAnimations;
|
||||
break;
|
||||
case 7:
|
||||
animations = polearmAnimations;
|
||||
break;
|
||||
case 8:
|
||||
animations = thrownAnimations;
|
||||
break;
|
||||
case 9:
|
||||
animations = oneHandedLSAnimations;
|
||||
break;
|
||||
case 10:
|
||||
animations = twoHandedLSAnimations;
|
||||
break;
|
||||
case 11:
|
||||
animations = polearmLSAnimations;
|
||||
break;
|
||||
default:
|
||||
animations = defaultAnimations;
|
||||
break;
|
||||
}
|
||||
|
||||
if (animations.length == 0) {
|
||||
animations = defaultAnimations;
|
||||
}
|
||||
|
||||
return animations[new Random().nextInt(animations.length)];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,28 +21,11 @@
|
||||
******************************************************************************/
|
||||
package services.command;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import resources.objects.weapon.WeaponObject;
|
||||
import engine.clientdata.ClientFileManager;
|
||||
import engine.clientdata.visitors.DatatableVisitor;
|
||||
|
||||
public class CombatCommand extends BaseSWGCommand {
|
||||
|
||||
private String[] defaultAnimations = new String[]{};
|
||||
private String[] oneHandedAnimations = new String[]{};
|
||||
private String[] twoHandedAnimations = new String[]{};
|
||||
private String[] polearmAnimations = new String[]{};
|
||||
private String[] unarmedAnimations = new String[]{};
|
||||
private String[] pistolAnimations = new String[]{};
|
||||
private String[] carbineAnimations = new String[]{};
|
||||
private String[] lightRifleAnimations = new String[]{};
|
||||
private String[] rifleAnimations = new String[]{};
|
||||
private String[] heavyWpnAnimations = new String[]{};
|
||||
private String[] oneHandedLSAnimations = new String[]{};
|
||||
private String[] twoHandedLSAnimations = new String[]{};
|
||||
private String[] polearmLSAnimations = new String[]{};
|
||||
private String[] thrownAnimations = new String[]{};
|
||||
private byte validTargetType;
|
||||
private byte hitType;
|
||||
private byte healType;
|
||||
@@ -67,16 +50,12 @@ public class CombatCommand extends BaseSWGCommand {
|
||||
private int damageType, elementalType, elementalValue;
|
||||
private String performanceSpam;
|
||||
private byte hitSpam;
|
||||
//private float cooldown;
|
||||
private String delayAttackEggTemplate;
|
||||
private String delayAttackParticle;
|
||||
private float initialAttackDelay;
|
||||
private float delayAttackInterval;
|
||||
private int delayAttackLoops;
|
||||
private int delayAttackEggPosition;
|
||||
//private String cooldownGroup;
|
||||
//private float executeTime;
|
||||
//private float warmupTime;
|
||||
private float vigorCost; // for commando kill meter and bm specials
|
||||
private float criticalChance;
|
||||
private int attack_rolls;
|
||||
@@ -166,119 +145,7 @@ public class CombatCommand extends BaseSWGCommand {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getDefaultAnimations() {
|
||||
return defaultAnimations;
|
||||
}
|
||||
|
||||
public void setDefaultAnimations(String[] defaultAnimations) {
|
||||
this.defaultAnimations = defaultAnimations;
|
||||
}
|
||||
|
||||
public String[] getOneHandedAnimations() {
|
||||
return oneHandedAnimations;
|
||||
}
|
||||
|
||||
public void setOneHandedAnimations(String[] oneHandedAnimations) {
|
||||
this.oneHandedAnimations = oneHandedAnimations;
|
||||
}
|
||||
|
||||
public String[] getTwoHandedAnimations() {
|
||||
return twoHandedAnimations;
|
||||
}
|
||||
|
||||
public void setTwoHandedAnimations(String[] twoHandedAnimations) {
|
||||
this.twoHandedAnimations = twoHandedAnimations;
|
||||
}
|
||||
|
||||
public String[] getPolearmAnimations() {
|
||||
return polearmAnimations;
|
||||
}
|
||||
|
||||
public void setPolearmAnimations(String[] polearmAnimations) {
|
||||
this.polearmAnimations = polearmAnimations;
|
||||
}
|
||||
|
||||
public String[] getUnarmedAnimations() {
|
||||
return unarmedAnimations;
|
||||
}
|
||||
|
||||
public void setUnarmedAnimations(String[] unarmedAnimations) {
|
||||
this.unarmedAnimations = unarmedAnimations;
|
||||
}
|
||||
|
||||
public String[] getPistolAnimations() {
|
||||
return pistolAnimations;
|
||||
}
|
||||
|
||||
public void setPistolAnimations(String[] pistolAnimations) {
|
||||
this.pistolAnimations = pistolAnimations;
|
||||
}
|
||||
|
||||
public String[] getCarbineAnimations() {
|
||||
return carbineAnimations;
|
||||
}
|
||||
|
||||
public void setCarbineAnimations(String[] carbineAnimations) {
|
||||
this.carbineAnimations = carbineAnimations;
|
||||
}
|
||||
|
||||
public String[] getLightRifleAnimations() {
|
||||
return lightRifleAnimations;
|
||||
}
|
||||
|
||||
public void setLightRifleAnimations(String[] lightRifleAnimations) {
|
||||
this.lightRifleAnimations = lightRifleAnimations;
|
||||
}
|
||||
|
||||
public String[] getRifleAnimations() {
|
||||
return rifleAnimations;
|
||||
}
|
||||
|
||||
public void setRifleAnimations(String[] rifleAnimations) {
|
||||
this.rifleAnimations = rifleAnimations;
|
||||
}
|
||||
|
||||
public String[] getHeavyWpnAnimations() {
|
||||
return heavyWpnAnimations;
|
||||
}
|
||||
|
||||
public void setHeavyWpnAnimations(String[] heavyWpnAnimations) {
|
||||
this.heavyWpnAnimations = heavyWpnAnimations;
|
||||
}
|
||||
|
||||
public String[] getOneHandedLSAnimations() {
|
||||
return oneHandedLSAnimations;
|
||||
}
|
||||
|
||||
public void setOneHandedLSAnimations(String[] oneHandedLSAnimations) {
|
||||
this.oneHandedLSAnimations = oneHandedLSAnimations;
|
||||
}
|
||||
|
||||
public String[] getTwoHandedLSAnimations() {
|
||||
return twoHandedLSAnimations;
|
||||
}
|
||||
|
||||
public void setTwoHandedLSAnimations(String[] twoHandedLSAnimations) {
|
||||
this.twoHandedLSAnimations = twoHandedLSAnimations;
|
||||
}
|
||||
|
||||
public String[] getPolearmLSAnimations() {
|
||||
return polearmLSAnimations;
|
||||
}
|
||||
|
||||
public void setPolearmLSAnimations(String[] polearmLSAnimations) {
|
||||
this.polearmLSAnimations = polearmLSAnimations;
|
||||
}
|
||||
|
||||
public String[] getThrownAnimations() {
|
||||
return thrownAnimations;
|
||||
}
|
||||
|
||||
public void setThrownAnimations(String[] thrownAnimations) {
|
||||
this.thrownAnimations = thrownAnimations;
|
||||
}
|
||||
|
||||
|
||||
public byte getValidTargetType() {
|
||||
return validTargetType;
|
||||
}
|
||||
@@ -550,64 +417,7 @@ public class CombatCommand extends BaseSWGCommand {
|
||||
public void setHitSpam(byte hitSpam) {
|
||||
this.hitSpam = hitSpam;
|
||||
}
|
||||
|
||||
public String getRandomAnimation(WeaponObject weapon) {
|
||||
|
||||
int weaponType = weapon.getWeaponType();
|
||||
String[] animations;
|
||||
|
||||
switch(weaponType) {
|
||||
|
||||
case 0:
|
||||
animations = rifleAnimations;
|
||||
break;
|
||||
case 1:
|
||||
animations = carbineAnimations;
|
||||
break;
|
||||
case 2:
|
||||
animations = pistolAnimations;
|
||||
break;
|
||||
case 3:
|
||||
animations = heavyWpnAnimations;
|
||||
break;
|
||||
case 4:
|
||||
animations = oneHandedAnimations;
|
||||
break;
|
||||
case 5:
|
||||
animations = twoHandedAnimations;
|
||||
break;
|
||||
case 6:
|
||||
animations = defaultAnimations;
|
||||
break;
|
||||
case 7:
|
||||
animations = polearmAnimations;
|
||||
break;
|
||||
case 8:
|
||||
animations = thrownAnimations;
|
||||
break;
|
||||
case 9:
|
||||
animations = oneHandedLSAnimations;
|
||||
break;
|
||||
case 10:
|
||||
animations = twoHandedLSAnimations;
|
||||
break;
|
||||
case 11:
|
||||
animations = polearmLSAnimations;
|
||||
break;
|
||||
|
||||
default:
|
||||
animations = defaultAnimations;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if(animations.length == 0)
|
||||
animations = defaultAnimations;
|
||||
|
||||
return animations[new Random().nextInt(animations.length)];
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String getDelayAttackEggTemplate() {
|
||||
return delayAttackEggTemplate;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import java.util.Vector;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import main.NGECore;
|
||||
|
||||
@@ -43,19 +42,20 @@ import engine.resources.scene.Point3D;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
import resources.common.*;
|
||||
import resources.datatables.StateStatus;
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import protocol.swg.objectControllerObjects.CommandEnqueue;
|
||||
import protocol.swg.objectControllerObjects.CommandEnqueueRemove;
|
||||
import protocol.swg.objectControllerObjects.ShowFlyText;
|
||||
import protocol.swg.objectControllerObjects.StartTask;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.harvester.HarvesterObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import resources.objects.weapon.WeaponObject;
|
||||
|
||||
public class CommandService implements INetworkDispatch {
|
||||
|
||||
private Vector<BaseSWGCommand> commandLookup = new Vector<BaseSWGCommand>();
|
||||
private ConcurrentHashMap<Integer, Integer> aliases = new ConcurrentHashMap<Integer, Integer>();
|
||||
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
private NGECore core;
|
||||
|
||||
@@ -63,6 +63,10 @@ public class CommandService implements INetworkDispatch {
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
public void registerAlias(String name, String target) {
|
||||
aliases.put(CRC.StringtoCRC(name.toLowerCase()), CRC.StringtoCRC(target.toLowerCase()));
|
||||
}
|
||||
|
||||
public boolean callCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) {
|
||||
if (actor == null) {
|
||||
return false;
|
||||
@@ -80,7 +84,7 @@ public class CommandService implements INetworkDispatch {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.getGodLevel() > 0 && !actor.getClient().isGM()) {
|
||||
if (command.getGodLevel() > 0 && (actor.getClient() == null || !actor.getClient().isGM())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -94,14 +98,14 @@ public class CommandService implements INetworkDispatch {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The two below statements need testing before use
|
||||
|
||||
for (long state : command.getInvalidStates()) {
|
||||
if ((actor.getStateBitmask() & state) == state) {
|
||||
//return false;
|
||||
}
|
||||
}
|
||||
|
||||
// This SHOULD be invalid locomotions but we don't track these currently.
|
||||
// Postures are the best we can do.
|
||||
for (byte posture : command.getInvalidPostures()) {
|
||||
if (actor.getPosture() == posture) {
|
||||
//return false;
|
||||
@@ -109,9 +113,7 @@ public class CommandService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
switch (command.getTargetType()) {
|
||||
case 0: // Target Not Used For This Command or Self
|
||||
target = actor;
|
||||
|
||||
case 0: // Target Not Used For This Command
|
||||
break;
|
||||
case 1: // Other Only
|
||||
if (target == null || target == actor) {
|
||||
@@ -122,7 +124,7 @@ public class CommandService implements INetworkDispatch {
|
||||
break;
|
||||
}
|
||||
|
||||
if (actor.getPosition().getDistance(target.getPosition()) > command.getMaxRangeToTarget()) {
|
||||
if (command.getMaxRangeToTarget() != 0 && actor.getPosition().getDistance(target.getPosition()) > command.getMaxRangeToTarget()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -136,7 +138,7 @@ public class CommandService implements INetworkDispatch {
|
||||
target = actor;
|
||||
}
|
||||
|
||||
if (target != actor) {
|
||||
if (target != actor && target instanceof CreatureObject) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -176,7 +178,7 @@ public class CommandService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
// Without this we could be buffing ally NPCs and such
|
||||
if (object.getSlottedObject("ghost") == null) {
|
||||
if (actor.getSlottedObject("ghost") != null && object.getSlottedObject("ghost") == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -208,46 +210,20 @@ public class CommandService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
long warmupTime = (long) (command.getWarmupTime() * 1000F);
|
||||
final CreatureObject actorObject = actor;
|
||||
final SWGObject targetObject = target;
|
||||
|
||||
if (warmupTime != 0) {
|
||||
scheduler.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
processCommand(actorObject, targetObject, command, actionCounter, commandArgs);
|
||||
}
|
||||
|
||||
}, warmupTime, TimeUnit.MILLISECONDS);
|
||||
} else {
|
||||
processCommand(actor, target, command, actionCounter, commandArgs);
|
||||
try {
|
||||
Thread.sleep(warmupTime);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
processCommand(actor, target, command, actionCounter, commandArgs);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void callCommand(SWGObject actor, String commandName, SWGObject target, String commandArgs) {
|
||||
if (actor == null)
|
||||
return;
|
||||
|
||||
BaseSWGCommand command = getCommandByName(commandName);
|
||||
|
||||
if (command == null)
|
||||
return;
|
||||
|
||||
if(command instanceof CombatCommand) {
|
||||
CombatCommand command2;
|
||||
try {
|
||||
command2 = (CombatCommand) command.clone();
|
||||
processCombatCommand((CreatureObject) actor, target, command2, 0, "");
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandArgs);
|
||||
callCommand((CreatureObject) actor, target, getCommandByName(commandName), 0, commandArgs);
|
||||
}
|
||||
|
||||
public BaseSWGCommand getCommandByCRC(int commandCRC) {
|
||||
@@ -284,12 +260,7 @@ public class CommandService implements INetworkDispatch {
|
||||
sub += 5;
|
||||
}
|
||||
|
||||
boolean isCombatCommand = false;
|
||||
|
||||
if(visitor.getObject(i, 82-sub) instanceof Boolean)
|
||||
isCombatCommand = (Boolean) visitor.getObject(i, 82-sub);
|
||||
|
||||
if (hasCharacterAbility || isCombatCommand) {
|
||||
if (hasCharacterAbility || isCombatCommand(name)) {
|
||||
CombatCommand command = new CombatCommand(name.toLowerCase());
|
||||
commandLookup.add(command);
|
||||
return command;
|
||||
@@ -345,12 +316,7 @@ public class CommandService implements INetworkDispatch {
|
||||
sub += 5;
|
||||
}
|
||||
|
||||
boolean isCombatCommand = false;
|
||||
|
||||
if(visitor.getObject(i, 82-sub) instanceof Boolean)
|
||||
isCombatCommand = (Boolean) visitor.getObject(i, 82-sub);
|
||||
|
||||
if (hasCharacterAbility || isCombatCommand) {
|
||||
if (hasCharacterAbility || isCombatCommand(commandName)) {
|
||||
CombatCommand command = new CombatCommand(commandName);
|
||||
commandLookup.add(command);
|
||||
return command;
|
||||
@@ -370,6 +336,22 @@ public class CommandService implements INetworkDispatch {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isCombatCommand(String commandName) {
|
||||
try {
|
||||
DatatableVisitor visitor = ClientFileManager.loadFile("datatables/combat/combat_data.iff", DatatableVisitor.class);
|
||||
|
||||
for (int i = 0; i < visitor.getRowCount(); i++) {
|
||||
if (visitor.getObject(i, 0) != null && ((String) (visitor.getObject(i, 0))).equalsIgnoreCase(commandName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void processCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) {
|
||||
actor.addCooldown(command.getCooldownGroup(), command.getCooldown());
|
||||
|
||||
@@ -378,22 +360,17 @@ public class CommandService implements INetworkDispatch {
|
||||
} else {
|
||||
if (FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName() + ".py")) {
|
||||
core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandArgs);
|
||||
} else if (FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) {
|
||||
core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "run", core, actor, target, commandArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void processCombatCommand(CreatureObject attacker, SWGObject target, CombatCommand command, int actionCounter, String commandArgs) {
|
||||
|
||||
// Check if the person has access to this ability.
|
||||
// Abilities (inc expertise ones) are added automatically as they level
|
||||
// by reading the datatables.
|
||||
// disabled for now (breaks all combat)
|
||||
//if (!attacker.hasAbility(command.getCommandName())) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
if(FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py"))
|
||||
{
|
||||
core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "setup", core, attacker, target, command);
|
||||
}
|
||||
|
||||
boolean success = true;
|
||||
|
||||
@@ -497,7 +474,6 @@ public class CommandService implements INetworkDispatch {
|
||||
|
||||
@Override
|
||||
public void handlePacket(IoSession session, IoBuffer data) throws Exception {
|
||||
|
||||
data.order(ByteOrder.LITTLE_ENDIAN);
|
||||
Client client = core.getClient(session);
|
||||
|
||||
@@ -509,7 +485,13 @@ public class CommandService implements INetworkDispatch {
|
||||
CommandEnqueue commandEnqueue = new CommandEnqueue();
|
||||
commandEnqueue.deserialize(data);
|
||||
|
||||
BaseSWGCommand command = getCommandByCRC(commandEnqueue.getCommandCRC());
|
||||
int commandCRC = commandEnqueue.getCommandCRC();
|
||||
|
||||
if (aliases.containsKey(commandEnqueue.getCommandCRC())) {
|
||||
commandCRC = aliases.get(commandCRC);
|
||||
}
|
||||
|
||||
BaseSWGCommand command = getCommandByCRC(commandCRC);
|
||||
|
||||
if (command == null) {
|
||||
//System.out.println("Unknown Command CRC: " + commandEnqueue.getCommandCRC());
|
||||
@@ -540,6 +522,45 @@ public class CommandService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
objControllerOpcodes.put(ObjControllerOpcodes.RESOURCE_EMPTY_HOPPER, new INetworkRemoteEvent() {
|
||||
|
||||
@Override
|
||||
public void handlePacket(IoSession session, IoBuffer data) throws Exception {
|
||||
data.order(ByteOrder.LITTLE_ENDIAN);
|
||||
Client client = core.getClient(session);
|
||||
CommandEnqueue commandEnqueue = new CommandEnqueue();
|
||||
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// for (byte b : data.array()) {
|
||||
// sb.append(String.format("%02X ", b));
|
||||
// }
|
||||
// System.out.println(sb.toString());
|
||||
|
||||
/*
|
||||
05 00 46 5E CE 80 83 00 00 00 ED 00 00 00 3E 45
|
||||
04 00 00 00 00 00 00 00 00 00 3E 45 04 00 00 00
|
||||
00 00 90 52 05 00 00 00 00 00 D7 35 05 00 00 00
|
||||
00 00 01 00 00 00 00 07
|
||||
*/
|
||||
|
||||
long playerId = data.getLong(); // 3E 45 04 00 00 00 00 00
|
||||
data.getInt(); // 00 00 00 00
|
||||
data.getLong(); // 3E 45 04 00 00 00 00 00
|
||||
long harvesterId = data.getLong(); // 1E 55 05 00 00 00 00 00
|
||||
//long containerId = data.getLong(); // 1E 55 05 00 00 00 00 00 Resources ID
|
||||
long resourceId = data.getLong(); // 1E 55 05 00 00 00 00 00 Resources ID
|
||||
int stackCount = data.getInt(); // Stack count
|
||||
byte actionMode = data.get(); // 0 for retrieving, 1 for discarding
|
||||
byte updateCount = data.get(); // updateCount
|
||||
|
||||
CreatureObject actor = (CreatureObject) client.getParent();
|
||||
SWGObject target = core.objectService.getObject(harvesterId);
|
||||
|
||||
core.harvesterService.handleEmptyHopper(actor,target,harvesterId,resourceId,stackCount,actionMode,updateCount);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -548,26 +569,8 @@ public class CommandService implements INetworkDispatch {
|
||||
|
||||
}
|
||||
|
||||
public CombatCommand registerCombatCommand(String name) {
|
||||
BaseSWGCommand command = getCommandByName(name);
|
||||
|
||||
if (command == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (command instanceof CombatCommand) {
|
||||
return (CombatCommand) command;
|
||||
} else {
|
||||
System.out.println("Warning: Forced to make non-combat command " + name + " a combat command.");
|
||||
commandLookup.remove(command);
|
||||
CombatCommand combatCommand = new CombatCommand(name.toLowerCase());
|
||||
commandLookup.add(combatCommand);
|
||||
return combatCommand;
|
||||
}
|
||||
}
|
||||
|
||||
public BaseSWGCommand registerCombatCommand(String name) { return getCommandByName(name); }
|
||||
public BaseSWGCommand registerCommand(String name) { return getCommandByName(name); }
|
||||
public BaseSWGCommand registerGmCommand(String name) { return getCommandByName(name); }
|
||||
public void registerAlias(String name, String target) { }
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ import protocol.swg.FactionResponseMessage;
|
||||
import resources.common.FileUtilities;
|
||||
import resources.common.Opcodes;
|
||||
import resources.datatables.FactionStatus;
|
||||
import resources.datatables.Options;
|
||||
import resources.datatables.PvpStatus;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.player.PlayerObject;
|
||||
|
||||
@@ -23,7 +23,6 @@ package services.guild;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import resources.common.Console;
|
||||
import resources.guild.Guild;
|
||||
import resources.objects.SWGList;
|
||||
import resources.objects.guild.GuildObject;
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package services.housing;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import engine.resources.scene.Point3D;
|
||||
|
||||
public class HouseTemplate
|
||||
{
|
||||
private String deedTemplate;
|
||||
private String buildingTemplate;
|
||||
private int lotCost;
|
||||
private int defaultItemLimit;
|
||||
private Vector<String> placeablePlanets;
|
||||
private Map<String, Point3D> buildingSigns;
|
||||
|
||||
public HouseTemplate(String deedTemplate, String buildingTemplate, int lotCost)
|
||||
{
|
||||
this.deedTemplate = deedTemplate;
|
||||
this.buildingTemplate = buildingTemplate;
|
||||
this.lotCost = lotCost;
|
||||
this.defaultItemLimit = 50;
|
||||
this.placeablePlanets = new Vector<String>();
|
||||
this.buildingSigns = new HashMap<String, Point3D>();
|
||||
}
|
||||
|
||||
public void addBuildingSign(String signTemplate, Point3D signPosition)
|
||||
{
|
||||
buildingSigns.put(signTemplate, signPosition);
|
||||
}
|
||||
public void addPlaceablePlanet(String planetName)
|
||||
{
|
||||
this.placeablePlanets.add(planetName);
|
||||
}
|
||||
public void setDefaultItemLimit(int itemLimit)
|
||||
{
|
||||
this.defaultItemLimit = itemLimit;
|
||||
}
|
||||
|
||||
public String getDeedTemplate()
|
||||
{
|
||||
return this.deedTemplate;
|
||||
}
|
||||
public String getBuildingTemplate()
|
||||
{
|
||||
return this.buildingTemplate;
|
||||
}
|
||||
public Map<String, Point3D> getBuildingSigns()
|
||||
{
|
||||
return this.buildingSigns;
|
||||
}
|
||||
public Vector<String> getPlaceablePlanets()
|
||||
{
|
||||
return this.placeablePlanets;
|
||||
}
|
||||
public boolean canBePlacedOn(String planetName)
|
||||
{
|
||||
if(placeablePlanets.contains(planetName)) return true;
|
||||
return false;
|
||||
}
|
||||
public int getLotCost()
|
||||
{
|
||||
return this.lotCost;
|
||||
}
|
||||
public int getDefaultItemLimit()
|
||||
{
|
||||
return this.defaultItemLimit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* This File is part of NGECore2.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
|
||||
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
|
||||
******************************************************************************/
|
||||
package services.housing;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.FileVisitor;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import main.NGECore;
|
||||
import protocol.swg.EnterStructurePlacementModeMessage;
|
||||
import resources.objects.building.BuildingObject;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.tangible.TangibleObject;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Point3D;
|
||||
import engine.resources.scene.Quaternion;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
|
||||
public class HousingService implements INetworkDispatch {
|
||||
|
||||
private NGECore core;
|
||||
private Map<String, HouseTemplate> housingTemplates = new ConcurrentHashMap<String, HouseTemplate>();
|
||||
|
||||
public HousingService(NGECore core) {
|
||||
this.core = core;
|
||||
core.commandService.registerCommand("placestructure");
|
||||
core.commandService.registerCommand("movefurniture");
|
||||
core.commandService.registerCommand("rotatefurniture");
|
||||
}
|
||||
|
||||
public void enterStructureMode(CreatureObject actor, TangibleObject deed)
|
||||
{
|
||||
if(!actor.getClient().isGM() && !core.terrainService.canBuildAtPosition(actor, actor.getWorldPosition().x, actor.getWorldPosition().z))
|
||||
{
|
||||
actor.sendSystemMessage("You may not place a structure here.", (byte) 0); // should probably load this from an stf
|
||||
return;
|
||||
}
|
||||
|
||||
if(housingTemplates.containsKey(deed.getTemplate()))
|
||||
{
|
||||
HouseTemplate houseTemplate = housingTemplates.get(deed.getTemplate());
|
||||
EnterStructurePlacementModeMessage packet = new EnterStructurePlacementModeMessage(deed, houseTemplate.getBuildingTemplate());
|
||||
actor.getClient().getSession().write(packet.serialize());
|
||||
}
|
||||
}
|
||||
|
||||
public void placeStructure(final CreatureObject actor, TangibleObject deed, float positionX, float positionZ, float rotation)
|
||||
{
|
||||
HouseTemplate houseTemplate = housingTemplates.get(deed.getTemplate());
|
||||
|
||||
int structureLotCost = houseTemplate.getLotCost();
|
||||
String structureTemplate = houseTemplate.getBuildingTemplate();
|
||||
|
||||
if(!houseTemplate.canBePlacedOn(actor.getPlanet().getName()))
|
||||
{
|
||||
actor.sendSystemMessage("You may not place this structure on this planet.", (byte) 0); // should probably load this from an stf
|
||||
return;
|
||||
}
|
||||
|
||||
if(!actor.getClient().isGM() && !core.terrainService.canBuildAtPosition(actor, positionX, positionZ))
|
||||
{
|
||||
actor.sendSystemMessage("You may not place a structure here.", (byte) 0); // should probably load this from an stf
|
||||
return;
|
||||
}
|
||||
|
||||
// Lot stuff
|
||||
if(!actor.getPlayerObject().deductLots(structureLotCost))
|
||||
{
|
||||
actor.sendSystemMessage("You do not have enough available lots to place this structure.", (byte) 0); // should probably load this from an stf
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate our orientation and height
|
||||
Quaternion quaternion = new Quaternion(1, 0, 0, 0);
|
||||
quaternion = resources.common.MathUtilities.rotateQuaternion(quaternion, (float)((Math.PI/2) * rotation), new Point3D(0, 1, 0));
|
||||
|
||||
float positionY = core.terrainService.getHeight(actor.getPlanetId(), positionX, positionZ) + 2f;
|
||||
|
||||
// Create the building
|
||||
BuildingObject building = (BuildingObject) core.objectService.createObject(structureTemplate, 0, actor.getPlanet(), new Point3D(positionX, positionY, positionZ), quaternion);
|
||||
core.simulationService.add(building, building.getPosition().x, building.getPosition().z, true);
|
||||
|
||||
// Name the sign
|
||||
TangibleObject sign = (TangibleObject) building.getAttachment("structureSign");
|
||||
String playerFirstName = actor.getCustomName().split(" ")[0];
|
||||
sign.setCustomName2(playerFirstName + "'s House");
|
||||
//building.add(sign);
|
||||
|
||||
core.objectService.destroyObject(deed);
|
||||
|
||||
// Structure management
|
||||
Vector<Long> admins = new Vector<>();
|
||||
admins.add(actor.getObjectID());
|
||||
|
||||
building.setAttachment("structureOwner", actor.getObjectID());
|
||||
building.setAttachment("structureAdmins", admins);
|
||||
|
||||
// Save structure to DB
|
||||
//building.createTransaction(core.getBuildingODB().getEnvironment());
|
||||
//core.getBuildingODB().put(building, Long.class, BuildingObject.class, building.getTransaction());
|
||||
//building.getTransaction().commitSync();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean getPermissions(SWGObject player, SWGObject container)
|
||||
{
|
||||
if(((Vector<Long>) container.getContainer().getAttachment("structureAdmins")).contains(player.getObjectID())) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addHousingTemplate(HouseTemplate houseTemplate)
|
||||
{
|
||||
housingTemplates.put(houseTemplate.getDeedTemplate(), houseTemplate);
|
||||
}
|
||||
|
||||
public void loadHousingTemplates() {
|
||||
Path p = Paths.get("scripts/houses/");
|
||||
FileVisitor<Path> fv = new SimpleFileVisitor<Path>()
|
||||
{
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException
|
||||
{
|
||||
System.out.println("Loading housing template " + file.getFileName());
|
||||
core.scriptService.callScript("scripts/houses/", file.getFileName().toString().replace(".py", ""), "setup", core);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
};
|
||||
try
|
||||
{
|
||||
Files.walkFileTree(p, fv);
|
||||
}
|
||||
catch (IOException e) { e.printStackTrace(); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void insertOpcodes(Map<Integer, INetworkRemoteEvent> arg0,
|
||||
Map<Integer, INetworkRemoteEvent> arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -58,10 +58,6 @@ import com.sleepycat.persist.EntityCursor;
|
||||
import com.sleepycat.persist.model.Entity;
|
||||
import com.sleepycat.persist.model.PrimaryKey;
|
||||
|
||||
import protocol.swg.ChatFriendsListUpdate;
|
||||
import protocol.swg.ChatOnChangeFriendStatus;
|
||||
import protocol.swg.ChatOnGetFriendsList;
|
||||
import protocol.swg.ChatRoomList;
|
||||
import protocol.swg.CmdSceneReady;
|
||||
import protocol.swg.CmdStartScene;
|
||||
import protocol.swg.HeartBeatMessage;
|
||||
@@ -70,6 +66,13 @@ import protocol.swg.ParametersMessage;
|
||||
import protocol.swg.SelectCharacter;
|
||||
import protocol.swg.ServerTimeMessage;
|
||||
import protocol.swg.UnkByteFlag;
|
||||
import protocol.swg.chat.ChatFriendsListUpdate;
|
||||
import protocol.swg.chat.ChatOnChangeFriendStatus;
|
||||
import protocol.swg.chat.ChatOnConnectAvatar;
|
||||
import protocol.swg.chat.ChatOnGetFriendsList;
|
||||
import protocol.swg.chat.ChatRoomList;
|
||||
import protocol.swg.chat.ChatServerStatus;
|
||||
import protocol.swg.chat.VoiceChatStatus;
|
||||
import protocol.swg.objectControllerObjects.UiPlayEffect;
|
||||
import engine.clientdata.ClientFileManager;
|
||||
import engine.clientdata.visitors.CrcStringTableVisitor;
|
||||
@@ -93,8 +96,11 @@ import resources.objects.Delta;
|
||||
import resources.objects.building.BuildingObject;
|
||||
import resources.objects.cell.CellObject;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.deed.Harvester_Deed;
|
||||
import resources.objects.group.GroupObject;
|
||||
import resources.objects.guild.GuildObject;
|
||||
import resources.objects.harvester.HarvesterObject;
|
||||
import resources.objects.installation.InstallationObject;
|
||||
import resources.objects.intangible.IntangibleObject;
|
||||
import resources.objects.mission.MissionObject;
|
||||
import resources.objects.player.PlayerObject;
|
||||
@@ -311,7 +317,11 @@ public class ObjectService implements INetworkDispatch {
|
||||
|
||||
object = new SurveyTool(objectID, planet, Template, position, orientation);
|
||||
|
||||
}else if(Template.startsWith("object/tangible")) {
|
||||
} else if(Template.startsWith("object/tangible/deed/harvester_deed") || Template.startsWith("object/tangible/deed/generator_deed")) {
|
||||
|
||||
object = new Harvester_Deed(objectID, planet, Template, position, orientation);
|
||||
|
||||
} else if(Template.startsWith("object/tangible")) {
|
||||
|
||||
object = new TangibleObject(objectID, planet, Template, position, orientation);
|
||||
|
||||
@@ -367,7 +377,22 @@ public class ObjectService implements INetworkDispatch {
|
||||
|
||||
object = new ResourceContainerObject(objectID, planet, Template, position, orientation);
|
||||
|
||||
}else {
|
||||
} else if(Template.startsWith("object/installation/mining_ore/construction")) {
|
||||
|
||||
float positionY = core.terrainService.getHeight(planet.getID(), position.x, position.z)-1f;
|
||||
Point3D newpoint = new Point3D(position.x,positionY,position.z);
|
||||
object = new InstallationObject(objectID, planet, Template, newpoint, orientation);
|
||||
|
||||
} else if(Template.startsWith("object/installation/mining_ore") || Template.startsWith("object/installation/mining_liquid") ||
|
||||
Template.startsWith("object/installation/mining_gas") || Template.startsWith("object/installation/mining_organic") ||
|
||||
Template.startsWith("object/installation/generators")) {
|
||||
|
||||
float positionY = core.terrainService.getHeight(planet.getID(), position.x, position.z)-1f;
|
||||
Point3D newpoint = new Point3D(position.x,positionY,position.z);
|
||||
object = new HarvesterObject(objectID, planet, Template, newpoint, orientation);
|
||||
core.harvesterService.addHarvester(object);
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -750,7 +775,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
objectList.put(object.getObjectID(), object);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
if(creature.getParentId() != 0) {
|
||||
SWGObject parent = getObject(creature.getParentId());
|
||||
@@ -776,17 +801,25 @@ public class ObjectService implements INetworkDispatch {
|
||||
CmdStartScene startScene = new CmdStartScene((byte) 0, objectId, creature.getPlanet().getPath(), creature.getTemplate(), position.x, position.y, position.z, core.getGalacticTime(), 0);
|
||||
session.write(startScene.serialize());
|
||||
|
||||
ChatServerStatus chatServerStatus = new ChatServerStatus();
|
||||
client.getSession().write(chatServerStatus.serialize());
|
||||
|
||||
VoiceChatStatus voiceStatus = new VoiceChatStatus();
|
||||
client.getSession().write(voiceStatus.serialize());
|
||||
|
||||
ParametersMessage parameters = new ParametersMessage();
|
||||
session.write(parameters.serialize());
|
||||
|
||||
creature.makeAware(core.guildService.getGuildObject());
|
||||
ChatOnConnectAvatar chatConnect = new ChatOnConnectAvatar();
|
||||
creature.getClient().getSession().write(chatConnect.serialize());
|
||||
|
||||
creature.makeAware(core.guildService.getGuildObject());
|
||||
core.chatService.loadMailHeaders(client);
|
||||
|
||||
core.simulationService.handleZoneIn(client);
|
||||
|
||||
creature.makeAware(creature);
|
||||
|
||||
ChatRoomList chatRooms = new ChatRoomList(core.chatService.getChatRooms());
|
||||
creature.getClient().getSession().write(chatRooms.serialize());
|
||||
//ChatOnGetFriendsList friendsListMessage = new ChatOnGetFriendsList(ghost);
|
||||
//client.getSession().write(friendsListMessage.serialize());
|
||||
|
||||
@@ -877,7 +910,7 @@ public class ObjectService implements INetworkDispatch {
|
||||
* @param position The position as an offset to the parent object.
|
||||
* @param orientation The orientation as an offset to the parent object.
|
||||
*/
|
||||
public void createChildObject(SWGObject parent, String template, Point3D position, Quaternion orientation, int cellNumber) {
|
||||
public SWGObject createChildObject(SWGObject parent, String template, Point3D position, Quaternion orientation, int cellNumber) {
|
||||
|
||||
if(cellNumber == -1) {
|
||||
|
||||
@@ -907,15 +940,15 @@ public class ObjectService implements INetworkDispatch {
|
||||
child.setAttachment("cellNumber", cellNumber);
|
||||
|
||||
//core.simulationService.add(child, x, z);
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
public void createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw) {
|
||||
createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0), -1);
|
||||
public SWGObject createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw) {
|
||||
return createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0), -1);
|
||||
}
|
||||
|
||||
public void createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw, int cellNumber) {
|
||||
createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0), cellNumber);
|
||||
public SWGObject createChildObject(SWGObject parent, String template, float x, float y, float z, float qy, float qw, int cellNumber) {
|
||||
return createChildObject(parent, template, new Point3D(x, y, z), new Quaternion(qw, 0, qy, 0), cellNumber);
|
||||
}
|
||||
|
||||
public void loadBuildoutObjects(Planet planet) throws InstantiationException, IllegalAccessException {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,14 +28,16 @@ import java.util.Random;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.sleepycat.persist.EntityCursor;
|
||||
|
||||
import main.NGECore;
|
||||
import engine.resources.common.CRC;
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.service.INetworkDispatch;
|
||||
import engine.resources.service.INetworkRemoteEvent;
|
||||
import resources.objects.creature.CreatureObject;
|
||||
import resources.objects.harvester.HarvesterObject;
|
||||
import resources.objects.resource.GalacticResource;
|
||||
import resources.objects.resource.ResourceContainerObject;
|
||||
import resources.objects.resource.ResourceRoot;
|
||||
@@ -11307,6 +11309,36 @@ public class ResourceService implements INetworkDispatch {
|
||||
return resource;
|
||||
}
|
||||
|
||||
public Vector<GalacticResource> getSpawnedResourcesByPlanetAndHarvesterType(int planetId, byte harvesterType) {
|
||||
Vector<GalacticResource> planetResourceList = new Vector<GalacticResource>();
|
||||
byte searchtype = harvesterType;
|
||||
if (harvesterType==7) searchtype = (byte) 0;
|
||||
for (GalacticResource gal : allSpawnedResources){
|
||||
if (gal.isSpawnedOn(planetId) && gal.getGeneralType()==searchtype)
|
||||
if (harvesterType!=HarvesterObject.HARVESTER_TYPE_FUSION)
|
||||
planetResourceList.add(gal);
|
||||
else if (harvesterType==HarvesterObject.HARVESTER_TYPE_FUSION) {
|
||||
System.err.println("gal.getContainerType() " + gal.getContainerType());
|
||||
if (gal.getResourceRoot().getContainerType()==ResourceRoot.CONTAINER_TYPE_ENERGY_RADIOACTIVE)
|
||||
planetResourceList.add(gal);
|
||||
} else if (harvesterType==HarvesterObject.HARVESTER_TYPE_GEO) {
|
||||
System.err.println("gal.getContainerType() " + gal.getContainerType());
|
||||
if (gal.getGeneralType()==GalacticResource.GENERAL_GEOTHERM)
|
||||
planetResourceList.add(gal);
|
||||
}
|
||||
}
|
||||
return planetResourceList;
|
||||
}
|
||||
|
||||
public GalacticResource findResourceById(long id){
|
||||
GalacticResource resource = new GalacticResource();
|
||||
for (GalacticResource sampleResource : allSpawnedResources){
|
||||
if (sampleResource.getId()==id)
|
||||
return sampleResource;
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
|
||||
// ToDo: Improve
|
||||
public GalacticResource grabMeatForCreature(CreatureObject corpse){
|
||||
GalacticResource resource = null;
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.engio.mbassy.listener.Handler;
|
||||
import resources.common.collidables.AbstractCollidable;
|
||||
import resources.common.collidables.AbstractCollidable.EnterEvent;
|
||||
import resources.common.collidables.AbstractCollidable.ExitEvent;
|
||||
import services.SimulationService.MoveEvent;
|
||||
import engine.resources.scene.Planet;
|
||||
|
||||
public class DynamicSpawnArea extends SpawnArea {
|
||||
|
||||
@@ -23,10 +23,8 @@ package services.spawn;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import main.NGECore;
|
||||
import resources.datatables.Options;
|
||||
import resources.datatables.PvpStatus;
|
||||
import resources.objects.weapon.WeaponObject;
|
||||
|
||||
public class MobileTemplate {
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import net.engio.mbassy.listener.Handler;
|
||||
import resources.common.collidables.AbstractCollidable;
|
||||
import resources.common.collidables.AbstractCollidable.EnterEvent;
|
||||
import resources.common.collidables.AbstractCollidable.ExitEvent;
|
||||
import services.SimulationService.MoveEvent;
|
||||
|
||||
import engine.resources.objects.SWGObject;
|
||||
import engine.resources.scene.Planet;
|
||||
|
||||
@@ -38,8 +38,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import org.python.core.Py;
|
||||
|
||||
import resources.common.collidables.CollidableCircle;
|
||||
import resources.datatables.Options;
|
||||
import resources.datatables.PvpStatus;
|
||||
@@ -166,6 +164,7 @@ public class SpawnService {
|
||||
AIActor actor = new AIActor(creature, creature.getPosition(), scheduler);
|
||||
creature.setAttachment("AI", actor);
|
||||
actor.setMobileTemplate(mobileTemplate);
|
||||
|
||||
|
||||
|
||||
if(cell == null) {
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.engio.mbassy.listener.Handler;
|
||||
import resources.common.collidables.AbstractCollidable;
|
||||
import resources.common.collidables.AbstractCollidable.EnterEvent;
|
||||
import resources.common.collidables.AbstractCollidable.ExitEvent;
|
||||
import services.SimulationService.MoveEvent;
|
||||
import engine.resources.scene.Planet;
|
||||
|
||||
public class StaticSpawnArea extends SpawnArea {
|
||||
|
||||
@@ -23,7 +23,6 @@ package services.sui;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -47,6 +46,7 @@ import resources.common.FileUtilities;
|
||||
import resources.common.ObjControllerOpcodes;
|
||||
import resources.common.Opcodes;
|
||||
import resources.common.RadialOptions;
|
||||
import resources.objects.harvester.HarvesterObject;
|
||||
import services.sui.SUIWindow.SUICallback;
|
||||
import services.sui.SUIWindow.Trigger;
|
||||
import engine.clients.Client;
|
||||
@@ -82,6 +82,36 @@ public class SUIService implements INetworkDispatch {
|
||||
if(target == null || owner == null)
|
||||
return;
|
||||
|
||||
if (target instanceof HarvesterObject){
|
||||
HarvesterObject harvester = (HarvesterObject) target;
|
||||
Vector<String> admins = harvester.getAdminList();
|
||||
Vector<String> hoppers = harvester.getHopperList();
|
||||
|
||||
if (harvester.getOwner()==owner && !admins.contains(owner.getCustomName())){
|
||||
admins.add(owner.getCustomName());
|
||||
}
|
||||
|
||||
if (! admins.contains(owner.getCustomName()) && ! hoppers.contains(owner.getCustomName())){
|
||||
return; // Completely unauthorized
|
||||
}
|
||||
|
||||
if (! admins.contains(owner.getCustomName()) && hoppers.contains(owner.getCustomName())){
|
||||
// authorized for hopper
|
||||
// change radialOptions to hopper access
|
||||
harvester.setAttachment("radial_filename", "harvesterHopper");
|
||||
}
|
||||
}
|
||||
|
||||
if(target.getGrandparent() != null && target.getGrandparent().getAttachment("structureAdmins") != null)
|
||||
{
|
||||
if(core.housingService.getPermissions(owner, target.getContainer()))
|
||||
{
|
||||
core.scriptService.callScript("scripts/radial/", "moveable", "createRadial", core, owner, target, request.getRadialOptions());
|
||||
sendRadial(owner, target, request.getRadialOptions(), request.getRadialCount());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
core.scriptService.callScript("scripts/radial/", getRadialFilename(target), "createRadial", core, owner, target, request.getRadialOptions());
|
||||
if(getRadialFilename(target).equals("default"))
|
||||
return;
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.nio.ByteOrder;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
Reference in New Issue
Block a user