mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-09-28 13:12:54 -04:00
Merge branch 'master' of https://github.com/ProjectSWGCore/NGECore2
This commit is contained in:
@@ -17,7 +17,8 @@ def run(core, actor, target, commandString):
|
||||
|
||||
if commandString != '' and commandString != faction:
|
||||
if commandString == 'rebel' or commandString == 'imperial' or commandString == 'neutral':
|
||||
actor.sendSystemMessage('@faction_recruiter:sui_resig_complete_in_5', 0)
|
||||
if faction != 'neutral':
|
||||
actor.sendSystemMessage('@faction_recruiter:sui_resig_complete_in_5', 0)
|
||||
|
||||
if actor.getFactionStatus() == FactionStatus.SpecialForces:
|
||||
actor.setPvpStatus(PvpStatus.GoingCovert, True)
|
||||
|
||||
@@ -114,7 +114,10 @@ def run(core, actor, target, commandString):
|
||||
playerObject.setGodLevel(0)
|
||||
|
||||
elif command == 'setBounty' and arg1:
|
||||
core.missionService.createNewBounty(actor, int(arg1))
|
||||
if not core.missionService.addToExistingBounty(actor, int(arg1)):
|
||||
core.missionService.createNewBounty(actor, int(arg1))
|
||||
|
||||
actor.sendSystemMessage('Your bounty has been set to an additional ' + str(arg1) + ' credits.', 0)
|
||||
return
|
||||
|
||||
return
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
|
||||
def setup(core, object):
|
||||
core.mapService.addLocation(object.getPlanet(), 'Mission Terminal', object.getPosition().x, object.getPosition().z, 41, 44, 0)
|
||||
core.mapService.addLocation(object.getPlanet(), '@map_loc_cat_n:terminal_mission', object.getPosition().x, object.getPosition().z, 41, 44, 0)
|
||||
object.setAttachment("terminalType", 1)
|
||||
return
|
||||
|
||||
@@ -2,4 +2,5 @@ import sys
|
||||
|
||||
def setup(core, object):
|
||||
object.setAttachment("terminalType", 2)
|
||||
core.mapService.addLocation(object.getPlanet(), '@map_loc_cat_n:terminal_mission_bounty', object.getPosition().x, object.getPosition().z, 41, 78, 0)
|
||||
return
|
||||
@@ -29,6 +29,7 @@ import com.sleepycat.persist.model.PrimaryKey;
|
||||
|
||||
@Entity
|
||||
public class BountyListItem {
|
||||
|
||||
@PrimaryKey
|
||||
private long objectId;
|
||||
private int creditReward;
|
||||
@@ -84,7 +85,7 @@ public class BountyListItem {
|
||||
}
|
||||
|
||||
public void addBounty(int amountToAdd) {
|
||||
this.creditReward =+ amountToAdd;
|
||||
this.creditReward += amountToAdd;
|
||||
}
|
||||
|
||||
public List<Long> getAssignedHunters() {
|
||||
@@ -95,11 +96,11 @@ public class BountyListItem {
|
||||
this.assignedHunters = assignedHunters;
|
||||
}
|
||||
|
||||
public boolean addBountyHunter(long objectId) {
|
||||
return assignedHunters.add(objectId);
|
||||
public void addBountyHunter(long objectId) {
|
||||
assignedHunters.add(objectId);
|
||||
}
|
||||
|
||||
public boolean removeBountyHunter(long objectId) {
|
||||
return assignedHunters.remove(objectId);
|
||||
public void removeBountyHunter(long objectId) {
|
||||
assignedHunters.remove(objectId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,6 +270,8 @@ public class ConnectionService implements INetworkDispatch {
|
||||
}
|
||||
}*/
|
||||
|
||||
core.missionService.getBountyList().remove(core.getBountiesODB().get(object.getObjectId(), Long.class, BountyListItem.class));
|
||||
|
||||
ghost.toggleFlag(PlayerFlags.LD);
|
||||
|
||||
object.setPerformanceListenee(null);
|
||||
|
||||
@@ -1255,18 +1255,21 @@ public class PlayerService implements INetworkDispatch {
|
||||
}
|
||||
|
||||
public void sendSetBountyWindow(final CreatureObject victim, final CreatureObject attacker) {
|
||||
final SUIWindow bountyWindow = core.suiService.createInputBox(InputBoxType.INPUT_BOX_OK_CANCEL, "@bounty_hunter:setbounty_title", "@bounty_hunter:setbounty_prompt1 " + attacker.getCustomName() + "?" + "\n@bounty_hunter:setbounty_prompt2 " + victim.getBankCredits() + victim.getCashCredits(),
|
||||
SUIWindow bountyWindow = core.suiService.createInputBox(InputBoxType.INPUT_BOX_OK_CANCEL, "@bounty_hunter:setbounty_title", "@bounty_hunter:setbounty_prompt1 " + attacker.getCustomName() + "?" + "\n@bounty_hunter:setbounty_prompt2 " + victim.getBankCredits(),
|
||||
victim, null, (float) 10, new SUICallback() {
|
||||
|
||||
@Override
|
||||
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
|
||||
if (eventType == 0 && returnList.get(0) != null) {
|
||||
if (core.missionService.getBountyListItem(attacker.getObjectId()) != null) {
|
||||
BountyListItem currentBounty = core.missionService.getBountyListItem(attacker.getObjectId());
|
||||
currentBounty.addBounty(Integer.parseInt(returnList.get(0)));
|
||||
} else {
|
||||
core.missionService.createNewBounty(attacker, Integer.parseInt(returnList.get(0)));
|
||||
}
|
||||
int bounty = Integer.parseInt(returnList.get(0));
|
||||
|
||||
if (bounty > victim.getBankCredits())
|
||||
return;
|
||||
|
||||
if (!core.missionService.addToExistingBounty(attacker, bounty))
|
||||
core.missionService.createNewBounty(attacker, bounty);
|
||||
|
||||
victim.setBankCredits(victim.getBankCredits() - bounty);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -988,11 +988,12 @@ public class CombatService implements INetworkDispatch {
|
||||
target.setSpeedMultiplierBase(0);
|
||||
target.setTurnRadius(0);
|
||||
|
||||
if(target.getDuelList().contains(attacker)) handleEndDuel(target, attacker, false);
|
||||
if(!target.getDuelList().contains(attacker) && attacker.getSlottedObject("ghost") != null)
|
||||
core.playerService.sendSetBountyWindow(target, attacker);
|
||||
else
|
||||
handleEndDuel(target, attacker, false);
|
||||
|
||||
core.playerService.sendCloningWindow(target, attacker.getSlottedObject("ghost") != null);
|
||||
//if (attacker.getSlottedObject("ghost") != null)
|
||||
//core.playerService.sendSetBountyWindow(target, attacker);
|
||||
}
|
||||
|
||||
public boolean areInDuel(CreatureObject creature1, CreatureObject creature2) {
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
|
||||
import com.sleepycat.je.Transaction;
|
||||
import com.sleepycat.persist.EntityCursor;
|
||||
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import protocol.swg.objectControllerObjects.MissionAbort;
|
||||
@@ -83,6 +84,8 @@ public class MissionService implements INetworkDispatch {
|
||||
loadMissionEntryCounts();
|
||||
|
||||
bountiesODB = core.getBountiesODB();
|
||||
|
||||
cleanupBounties(); // delete any characters from the bounties odb if they no longer exist.
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -239,7 +242,7 @@ public class MissionService implements INetworkDispatch {
|
||||
missionStrings++;
|
||||
}
|
||||
}
|
||||
System.out.println("Loaded " + missionStrings + " mission entry counts.");
|
||||
//System.out.println("Loaded " + missionStrings + " mission entry counts.");
|
||||
}
|
||||
|
||||
|
||||
@@ -282,7 +285,8 @@ public class MissionService implements INetworkDispatch {
|
||||
randomDeliveryMission(player, mission);
|
||||
|
||||
else if (type == TerminalType.BOUNTY)
|
||||
randomBountyMission(player, mission);
|
||||
//randomBountyMission(player, mission);
|
||||
return;
|
||||
|
||||
else if (type == TerminalType.ARTISAN)
|
||||
return;
|
||||
@@ -519,34 +523,65 @@ public class MissionService implements INetworkDispatch {
|
||||
|
||||
BountyListItem bounty = new BountyListItem(bountyTarget.getObjectId(), reward, core.playerService.getFormalProfessionName(player.getProfession()), bountyTarget.getFaction(), bountyTarget.getCustomName());
|
||||
|
||||
Transaction txn = bountiesODB.getEnvironment().beginTransaction(null, null);
|
||||
bountiesODB.put(bounty, Long.class, BountyListItem.class, txn);
|
||||
txn.commitSync();
|
||||
|
||||
bountyList.add(bounty);
|
||||
|
||||
//Transaction txn = bountiesODB.getEnvironment().beginTransaction(null, null);
|
||||
//bountiesODB.put(bounty, Long.class, BountyListItem.class, txn);
|
||||
//txn.commitSync();
|
||||
|
||||
//System.out.println("Put in bounty for " + bounty.getName() + " with amount " + reward);
|
||||
|
||||
|
||||
//System.out.println("Created bounty of " + reward + " to " + bounty.getName());
|
||||
return bounty;
|
||||
}
|
||||
|
||||
public boolean addToExistingBounty(CreatureObject bountyTarget, int amountToAdd) {
|
||||
PlayerObject player = (PlayerObject) bountyTarget.getSlottedObject("ghost");
|
||||
if (player == null)
|
||||
return false;
|
||||
|
||||
|
||||
BountyListItem bounty = getBountyListItem(bountyTarget.getObjectId());
|
||||
|
||||
if (bounty == null)
|
||||
return false;
|
||||
|
||||
//Transaction txn = bountiesODB.getEnvironment().beginTransaction(null, null);
|
||||
//bountiesODB.get(bounty, Long.class, BountyListItem.class);
|
||||
//txn.commitSync();
|
||||
bounty.addBounty(amountToAdd);
|
||||
|
||||
Transaction txn = bountiesODB.getEnvironment().beginTransaction(null, null);
|
||||
bountiesODB.put(bounty, Long.class, BountyListItem.class, txn);
|
||||
txn.commitSync();
|
||||
|
||||
//System.out.println("Added bounty of " + amountToAdd + " to " + bounty.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeBounty(CreatureObject bountyTarget, boolean listRemove) {
|
||||
Transaction txn = bountiesODB.getEnvironment().beginTransaction(null, null);
|
||||
|
||||
if (listRemove)
|
||||
bountyList.remove(bountiesODB.get(bountyTarget.getObjectId(), Long.class, BountyListItem.class));
|
||||
|
||||
bountiesODB.delete(bountyTarget.getObjectId(), Long.class, BountyListItem.class, txn);
|
||||
txn.commitSync();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeBounty(CreatureObject bountyTarget) {
|
||||
return removeBounty(bountyTarget, true);
|
||||
}
|
||||
|
||||
private void cleanupBounties() {
|
||||
AtomicInteger bountyCount = new AtomicInteger();
|
||||
Transaction txn = bountiesODB.getEnvironment().beginTransaction(null, null);
|
||||
EntityCursor<BountyListItem> bountyCursor = bountiesODB.getEntityStore().getPrimaryIndex(Long.class, BountyListItem.class).entities(txn, null);
|
||||
bountyCursor.forEach(bounty -> {
|
||||
if (!core.characterService.playerExists(bounty.getObjectId())) {
|
||||
bountyCursor.delete();
|
||||
bountyCount.getAndIncrement();
|
||||
}
|
||||
});
|
||||
bountyCursor.close();
|
||||
txn.commitSync();
|
||||
|
||||
if (bountyCount.get() != 0)
|
||||
System.out.println("Removed " + bountyCount.get() + " bounties.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
}
|
||||
|
||||
@@ -913,6 +913,10 @@ public class ObjectService implements INetworkDispatch {
|
||||
if(!core.getConfig().getString("MOTD").equals(""))
|
||||
creature.sendSystemMessage(core.getConfig().getString("MOTD"), (byte) 2);
|
||||
|
||||
BountyListItem bounty = core.getBountiesODB().get(creature.getObjectId(), Long.class, BountyListItem.class);
|
||||
if (bounty != null)
|
||||
core.missionService.getBountyList().add(bounty);
|
||||
|
||||
core.playerService.postZoneIn(creature);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user