Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d238497
add quest serialization
boraini Oct 21, 2024
71b3054
wire up quests
boraini Oct 21, 2024
3e68e68
add random quest generation
boraini Oct 24, 2024
964bda3
add daily quests
boraini Oct 26, 2024
b941e14
change collect item tracking
boraini Oct 26, 2024
384b30d
java 8 compatibility
boraini Oct 26, 2024
7967443
java 8 compatibility 2
boraini Oct 26, 2024
c236ccf
multiple daily quests and aesthetic changes
boraini Oct 29, 2024
4efd397
update random-quests.json
boraini Oct 29, 2024
3e85204
reduce repeated types of daily quests
boraini Nov 13, 2024
ec0fe64
get rid of RandomList.toConcrete
boraini Nov 13, 2024
e9cd791
add craft quest type
boraini Nov 13, 2024
7f16662
update random-quests.json
boraini Nov 13, 2024
f433070
refactor various things and fix bugs
boraini Nov 14, 2024
6a73896
add multistep random quests
boraini Nov 14, 2024
8e8f25e
add more random quest config examples
boraini Nov 14, 2024
518e39a
code quality
boraini Nov 17, 2024
26cfb3c
language
boraini Nov 19, 2024
0dcaefc
remove setters for state variables
boraini Nov 19, 2024
132fdc6
fix some null errors
boraini Nov 20, 2024
8529d4b
fix collect item quantity bug
boraini Nov 29, 2024
1ef7e1f
make some changes
boraini Dec 4, 2024
d5f73e8
make task description overrides more consistent
boraini Dec 4, 2024
2d410c8
add a more practical random quest configuration
boraini Dec 4, 2024
a512675
fix non-entity explode bug
boraini Dec 8, 2024
68a2475
handle quest completion as an event
boraini Dec 8, 2024
130fbdc
refactor task complete checks
boraini Dec 8, 2024
b20570f
events nullable
boraini Dec 8, 2024
1e1cff9
send xp and crown info to the client
boraini Dec 12, 2024
0555eb8
add a couple more event tracking
boraini Dec 18, 2024
392fdc0
fix natural block check
boraini Dec 20, 2024
960612b
actually check for inventory requirement
boraini Dec 23, 2024
5be65f7
prevent collect inventory completing from showing up
boraini Dec 23, 2024
08dad6d
improve styling of the quests dialog
boraini Dec 23, 2024
2d280ed
Merge branch 'develop' into quests-without-android
boraini Dec 24, 2024
8244dd6
quantity default value fix
boraini Jan 7, 2025
5be8caa
show daily quest expiry time
boraini Jan 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gameserver/src/main/java/brainwine/gameserver/GameServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import brainwine.gameserver.player.NotificationType;
import brainwine.gameserver.player.PlayerManager;
import brainwine.gameserver.prefab.PrefabManager;
import brainwine.gameserver.quest.Quests;
import brainwine.gameserver.server.NetworkRegistry;
import brainwine.gameserver.server.Server;
import brainwine.gameserver.zone.EntityManager;
Expand Down Expand Up @@ -50,6 +51,7 @@ public GameServer() {
EntityRegistry.init();
EntityManager.loadEntitySpawns();
GrowthManager.loadGrowthData();
Quests.loadQuests();
lootManager = new LootManager();
prefabManager = new PrefabManager();
ZoneGenerator.init();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package brainwine.gameserver.command;

import brainwine.gameserver.player.NotificationType;
import brainwine.gameserver.player.Player;
import brainwine.gameserver.quest.PlayerQuestDialog;

@CommandInfo(name = "quests", description = "Lists your ongoing and completed quests.")
public class QuestsCommand extends Command {

@Override
public void execute(CommandExecutor executor, String[] args) {
if (!(executor instanceof Player)) {
executor.notify("You can only view your quests as a player!", NotificationType.SYSTEM);
}

PlayerQuestDialog.showPlayerQuests((Player) executor);
}

@Override
public String getUsage(CommandExecutor executor) {
return "/quests";
}

@Override
public boolean canExecute(CommandExecutor executor) {
return executor instanceof Player;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public class DialogSection {
private List<DialogListItem> items = new ArrayList<>();
private String title;
private String text;
private String choice;
private String textColor;
private double textScale;
private Vector2i location;
private DialogInput input;
private String choice;

public DialogSection addItem(DialogListItem item) {
items.add(item);
Expand Down Expand Up @@ -54,15 +54,6 @@ public String getText() {
return text;
}

public DialogSection setChoice(String choice) {
this.choice = choice;
return this;
}

public String getChoice() {
return choice;
}

/**
* v2 clients only!
* For v3 clients, use {@link #setText} with HTML color tags.
Expand Down Expand Up @@ -110,4 +101,13 @@ public DialogSection setInput(DialogInput input) {
public DialogInput getInput() {
return input;
}

public DialogSection setChoice(String choice) {
this.choice = choice;
return this;
}

public String getChoice() {
return this.choice;
}
}
15 changes: 15 additions & 0 deletions gameserver/src/main/java/brainwine/gameserver/entity/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import brainwine.gameserver.item.ItemUseType;
import brainwine.gameserver.item.Layer;
import brainwine.gameserver.player.Player;
import brainwine.gameserver.quest.QuestEvents;
import brainwine.gameserver.server.Message;
import brainwine.gameserver.server.messages.EffectMessage;
import brainwine.gameserver.server.messages.EntityChangeMessage;
Expand Down Expand Up @@ -101,19 +102,33 @@ public void attack(Entity attacker, Item weapon, float baseDamage, DamageType da
// Kill entity if attacker is a player in god mode
if(attacker != null && attacker.isPlayer() && ((Player)attacker).isGodMode()) {
setHealth(0.0F);

if(isDead()) {
QuestEvents.handleKill((Player) attacker, this);
}

return;
}

// Ignore multipliers if true damage should be dealt
if(trueDamage) {
setHealth(health - baseDamage);

if(isDead() && attacker != null && attacker.isPlayer()) {
QuestEvents.handleKill((Player) attacker, this);
}

return;
}

float attackMultiplier = attacker != null ? Math.max(0.0F, attacker.getAttackMultiplier(attack)) : 1.0F;
float defense = Math.max(0.0F, 1.0F - getDefense(attack));
float damage = baseDamage * attackMultiplier * defense;
setHealth(health - damage);

if(isDead() && attacker != null && attacker.isPlayer()) {
QuestEvents.handleKill((Player) attacker, this);
}
}

public float getAttackMultiplier(EntityAttack attack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
Expand All @@ -26,6 +27,7 @@ public class EntityConfig {

private final String name;
private final int type;
private String title = "Unknown";
private int experienceYield;
private float maxHealth = Entity.DEFAULT_HEALTH;
private float baseSpeed = 3;
Expand Down Expand Up @@ -68,6 +70,18 @@ public String getName() {
public int getType() {
return type;
}

public String getTitle() {
return title;
}

@JsonIgnore
public String getCategory() {
String id = getName();

int index = id.indexOf('/');
return index > 1 ? id.substring(0, index) : null;
}

@JsonProperty("xp")
public int getExperienceYield() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package brainwine.gameserver.item;

import brainwine.gameserver.util.LazyGetter;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.io.IOException;

@JsonSerialize(using = LazyItemGetter.Serializer.class)
public class LazyItemGetter extends LazyGetter<String, Item> {

public LazyItemGetter(String in) {
Expand All @@ -12,4 +19,11 @@ public LazyItemGetter(String in) {
public Item load() {
return ItemRegistry.getItem(in);
}

public static class Serializer extends JsonSerializer {
@Override
public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeString(((LazyItemGetter)value).get().getId());
}
}
}
Loading