From 69ac60d76f6f4f0c708bb2d85b65b725b98bce15 Mon Sep 17 00:00:00 2001 From: Ziggy Date: Thu, 7 Jan 2021 04:58:10 +0100 Subject: [PATCH] Added npc_animation and player_animation events to conversations #303 --- .../imperial_recruiter/neutral_root.json | 9 +++- .../events/NpcAnimationEvent.java | 46 +++++++++++++++++ .../events/PlayerAnimationEvent.java | 49 +++++++++++++++++++ .../conversation/ConversationLoader.java | 4 ++ .../events/NpcAnimationEventParser.java | 42 ++++++++++++++++ .../events/PlayerAnimationEventParser.java | 42 ++++++++++++++++ 6 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/projectswg/holocore/resources/gameplay/conversation/events/NpcAnimationEvent.java create mode 100644 src/main/java/com/projectswg/holocore/resources/gameplay/conversation/events/PlayerAnimationEvent.java create mode 100644 src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/conversation/events/NpcAnimationEventParser.java create mode 100644 src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/conversation/events/PlayerAnimationEventParser.java diff --git a/serverdata/nge/conversation/imperial_recruiter/neutral_root.json b/serverdata/nge/conversation/imperial_recruiter/neutral_root.json index b79b5aacc..cf5e2c47d 100644 --- a/serverdata/nge/conversation/imperial_recruiter/neutral_root.json +++ b/serverdata/nge/conversation/imperial_recruiter/neutral_root.json @@ -22,5 +22,12 @@ } } ], - "events": [] + "events": [ + { + "type": "npc_animation", + "args": { + "animation": "greet" + } + } + ] } \ No newline at end of file diff --git a/src/main/java/com/projectswg/holocore/resources/gameplay/conversation/events/NpcAnimationEvent.java b/src/main/java/com/projectswg/holocore/resources/gameplay/conversation/events/NpcAnimationEvent.java new file mode 100644 index 000000000..45c3cf8f5 --- /dev/null +++ b/src/main/java/com/projectswg/holocore/resources/gameplay/conversation/events/NpcAnimationEvent.java @@ -0,0 +1,46 @@ +/*********************************************************************************** + * Copyright (c) 2021 /// 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 . * + ***********************************************************************************/ +package com.projectswg.holocore.resources.gameplay.conversation.events; + +import com.projectswg.common.network.packets.swg.zone.object_controller.Animation; +import com.projectswg.holocore.resources.gameplay.conversation.model.Event; +import com.projectswg.holocore.resources.support.global.player.Player; +import com.projectswg.holocore.resources.support.objects.swg.custom.AIObject; + +public class NpcAnimationEvent implements Event { + + private final String animationName; + + public NpcAnimationEvent(String animationName) { + this.animationName = animationName; + } + + @Override + public void trigger(Player player, AIObject npc) { + npc.sendObservers(new Animation(npc.getObjectId(), animationName)); + } +} diff --git a/src/main/java/com/projectswg/holocore/resources/gameplay/conversation/events/PlayerAnimationEvent.java b/src/main/java/com/projectswg/holocore/resources/gameplay/conversation/events/PlayerAnimationEvent.java new file mode 100644 index 000000000..c155b418e --- /dev/null +++ b/src/main/java/com/projectswg/holocore/resources/gameplay/conversation/events/PlayerAnimationEvent.java @@ -0,0 +1,49 @@ +/*********************************************************************************** + * Copyright (c) 2021 /// 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 . * + ***********************************************************************************/ +package com.projectswg.holocore.resources.gameplay.conversation.events; + +import com.projectswg.common.network.packets.swg.zone.object_controller.Animation; +import com.projectswg.holocore.resources.gameplay.conversation.model.Event; +import com.projectswg.holocore.resources.support.global.player.Player; +import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject; +import com.projectswg.holocore.resources.support.objects.swg.custom.AIObject; + +public class PlayerAnimationEvent implements Event { + + private final String animationName; + + public PlayerAnimationEvent(String animationName) { + this.animationName = animationName; + } + + @Override + public void trigger(Player player, AIObject npc) { + CreatureObject creatureObject = player.getCreatureObject(); + + creatureObject.sendObservers(new Animation(creatureObject.getObjectId(), animationName)); + } +} diff --git a/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/conversation/ConversationLoader.java b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/conversation/ConversationLoader.java index 75fc88d55..ef8251466 100644 --- a/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/conversation/ConversationLoader.java +++ b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/conversation/ConversationLoader.java @@ -34,6 +34,8 @@ import com.projectswg.holocore.resources.gameplay.conversation.model.Requirement import com.projectswg.holocore.resources.support.data.server_info.SdbLoader; import com.projectswg.holocore.resources.support.data.server_info.loader.DataLoader; import com.projectswg.holocore.resources.support.data.server_info.loader.conversation.events.ChangePlayerFactionEventParser; +import com.projectswg.holocore.resources.support.data.server_info.loader.conversation.events.NpcAnimationEventParser; +import com.projectswg.holocore.resources.support.data.server_info.loader.conversation.events.PlayerAnimationEventParser; import com.projectswg.holocore.resources.support.data.server_info.loader.conversation.requirements.FactionNameRequirementParser; import com.projectswg.holocore.resources.support.data.server_info.loader.conversation.requirements.FactionStatusRequirementParser; import me.joshlarson.jlcommon.log.Log; @@ -194,6 +196,8 @@ public class ConversationLoader extends DataLoader { private void initEventParsers() { eventParserMap.put("faction_change", new ChangePlayerFactionEventParser()); + eventParserMap.put("player_animation", new PlayerAnimationEventParser()); + eventParserMap.put("npc_animation", new NpcAnimationEventParser()); } private void loadSpawnToConversations() throws IOException { diff --git a/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/conversation/events/NpcAnimationEventParser.java b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/conversation/events/NpcAnimationEventParser.java new file mode 100644 index 000000000..333d08dbd --- /dev/null +++ b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/conversation/events/NpcAnimationEventParser.java @@ -0,0 +1,42 @@ +/*********************************************************************************** + * Copyright (c) 2021 /// 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 . * + ***********************************************************************************/ +package com.projectswg.holocore.resources.support.data.server_info.loader.conversation.events; + +import com.projectswg.holocore.resources.gameplay.conversation.events.NpcAnimationEvent; +import com.projectswg.holocore.resources.support.data.server_info.loader.conversation.EventParser; + +import java.util.Map; + +public class NpcAnimationEventParser implements EventParser { + + @Override + public NpcAnimationEvent parse(Map args) { + String animation = (String) args.get("animation"); + + return new NpcAnimationEvent(animation); + } +} diff --git a/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/conversation/events/PlayerAnimationEventParser.java b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/conversation/events/PlayerAnimationEventParser.java new file mode 100644 index 000000000..36bd7a79f --- /dev/null +++ b/src/main/java/com/projectswg/holocore/resources/support/data/server_info/loader/conversation/events/PlayerAnimationEventParser.java @@ -0,0 +1,42 @@ +/*********************************************************************************** + * Copyright (c) 2021 /// 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 . * + ***********************************************************************************/ +package com.projectswg.holocore.resources.support.data.server_info.loader.conversation.events; + +import com.projectswg.holocore.resources.gameplay.conversation.events.PlayerAnimationEvent; +import com.projectswg.holocore.resources.support.data.server_info.loader.conversation.EventParser; + +import java.util.Map; + +public class PlayerAnimationEventParser implements EventParser { + + @Override + public PlayerAnimationEvent parse(Map args) { + String animation = (String) args.get("animation"); + + return new PlayerAnimationEvent(animation); + } +}