Merged in M4SS/holocore/flourishes (pull request #280)

Flourishes
This commit is contained in:
Obique PSWG
2016-09-08 20:20:40 -05:00
4 changed files with 142 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
/***********************************************************************************
* Copyright (c) 2015 /// Project SWG /// www.projectswg.com *
* *
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
* Our goal is to create an emulator which will provide a server for players to *
* continue playing a game similar to the one they used to play. We are basing *
* it on the final publish of the game prior to end-game events. *
* *
* This file is part of Holocore. *
* *
* -------------------------------------------------------------------------------- *
* *
* Holocore is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* Holocore 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 Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
package intents;
import resources.control.Intent;
import resources.player.Player;
/**
*
* @author Mads
*/
public class FlourishIntent extends Intent {
public static final String TYPE = "FlourishIntent";
private final Player performer;
private final String flourishName;
public FlourishIntent(Player performer, String flourishName) {
super(TYPE);
this.performer = performer;
this.flourishName = flourishName;
}
public Player getPerformer() {
return performer;
}
public String getFlourishName() {
return flourishName;
}
}
@@ -0,0 +1,68 @@
/************************************************************************************
* Copyright (c) 2015 /// Project SWG /// www.projectswg.com *
* *
* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on *
* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. *
* Our goal is to create an emulator which will provide a server for players to *
* continue playing a game similar to the one they used to play. We are basing *
* it on the final publish of the game prior to end-game events. *
* *
* This file is part of Holocore. *
* *
* -------------------------------------------------------------------------------- *
* *
* Holocore is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* Holocore 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 Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with Holocore. If not, see <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
package resources.commands.callbacks;
import intents.FlourishIntent;
import intents.chat.ChatBroadcastIntent;
import resources.commands.ICmdCallback;
import resources.objects.SWGObject;
import resources.player.Player;
import services.galaxy.GalacticManager;
/**
*
* @author Mads
*/
public class FlourishCmdCallback implements ICmdCallback {
@Override
public void execute(GalacticManager galacticManager, Player player, SWGObject target, String args) {
// No performance, no flourish!
if (!player.getCreatureObject().isPerforming()) {
new ChatBroadcastIntent(player, "@performance:flourish_not_performing").broadcast();
return;
}
try {
int flourishNumber = Integer.parseInt(args);
if(flourishNumber < 1 || flourishNumber > 9) {
new ChatBroadcastIntent(player, "@performance:flourish_not_valid").broadcast();
} else if(flourishNumber == 9) {
new FlourishIntent(player, "mistake").broadcast();
} else {
new FlourishIntent(player, "skill_action_" + flourishNumber).broadcast();
}
} catch (NumberFormatException e) {
new ChatBroadcastIntent(player, "@performance:flourish_not_valid").broadcast();
}
}
}
@@ -313,6 +313,7 @@ public class CommandService extends Service {
registerCallback("goto", GotoCmdCallback.class);
registerCallback("startDance", StartDanceCallback.class);
registerCallback("requestBiography", RequestBiographyCmdCallback.class);
registerCallback("flourish", FlourishCmdCallback.class);
}
private void clearCommands() {
@@ -28,6 +28,7 @@
package services.commands;
import intents.DanceIntent;
import intents.FlourishIntent;
import intents.PlayerEventIntent;
import intents.chat.ChatBroadcastIntent;
import intents.experience.ExperienceIntent;
@@ -37,12 +38,14 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import network.packets.swg.zone.object_controller.Animation;
import resources.Posture;
import resources.client_info.ClientFactory;
import resources.client_info.visitors.DatatableData;
import resources.control.Intent;
import resources.control.Service;
import resources.objects.creature.CreatureObject;
import resources.player.Player;
import resources.server_info.Log;
/**
@@ -64,6 +67,7 @@ public class EntertainmentService extends Service {
executorService = Executors.newSingleThreadScheduledExecutor();
registerForIntent(DanceIntent.TYPE);
registerForIntent(PlayerEventIntent.TYPE);
registerForIntent(FlourishIntent.TYPE);
}
@Override
@@ -97,6 +101,9 @@ public class EntertainmentService extends Service {
case PlayerEventIntent.TYPE:
handlePlayerEventIntent((PlayerEventIntent) i);
break;
case FlourishIntent.TYPE:
handleFlourishIntent((FlourishIntent) i);
break;
}
}
@@ -151,6 +158,14 @@ public class EntertainmentService extends Service {
}
}
private void handleFlourishIntent(FlourishIntent i) {
Player performer = i.getPerformer();
CreatureObject performerObject = performer.getCreatureObject();
// Send the flourish animation to the owner of the creature and owners of creatures observing
performerObject.sendObserversAndSelf(new Animation(performerObject.getObjectId(), i.getFlourishName()));
new ChatBroadcastIntent(performer, "@performance:flourish_perform").broadcast();
}
/**
* Checks if the {@code CreatureObject} is a Novice Entertainer.