mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2025-12-26 16:07:57 +01:00
improve faction score math code
Signed-off-by: OMGeeky <git@omgeeky.de>
This commit is contained in:
@@ -48,10 +48,12 @@ public final class Constants {
|
||||
public static final String FILENAME_WORLDMAP_HTMLFILE_SUFFIX = ".html";
|
||||
public static final String FILENAME_SAVEGAME_FILENAME_PREFIX = "savegame";
|
||||
public static final String PLACEHOLDER_PLAYERNAME = "$playername";
|
||||
public static final String PLACEHOLDER_AKKU = "$akku";
|
||||
public static final String PLACEHOLDER_REG1 = "$reg1";
|
||||
public static final String CHEAT_DETECTION_FOLDER = "dEAGyGE3YojqXjI3x4x7";
|
||||
public static final String PASSIVE_ACHIEVEMENT_CHECK_PHRASE = "passive_achievement_check";
|
||||
|
||||
public static final String FACTION_SCORE_CALC_REGISTER_NAME = "reg1";
|
||||
|
||||
public static final String SAVEGAME_FILE_MIME_TYPE = "application/octet-stream";
|
||||
public static final String WORLDMAP_FILE_MIME_TYPE = "image/png";
|
||||
public static final String NO_FILE_EXTENSION_MIME_TYPE = "application/no_file_extension_mime_type";
|
||||
|
||||
@@ -100,10 +100,10 @@ public final class ConversationController {
|
||||
case alignmentSet:
|
||||
setAlignmentReward(player, effect.effectID, effect.value);
|
||||
break;
|
||||
case alignmentToAkku:
|
||||
case alignmentToReg1:
|
||||
toAkkuAlignmentReward(player, effect.effectID);
|
||||
break;
|
||||
case alignmentFromAkku:
|
||||
case alignmentFromReg1:
|
||||
fromAkkuAlignmentReward(player, effect.effectID);
|
||||
break;
|
||||
case alignmentAdd:
|
||||
@@ -219,34 +219,39 @@ public final class ConversationController {
|
||||
}
|
||||
|
||||
private void fromAkkuAlignmentReward(Player player, String faction) {
|
||||
Integer i = player.getAlignment("akku");
|
||||
Integer i = player.getAlignment(Constants.FACTION_SCORE_CALC_REGISTER_NAME);
|
||||
player.setAlignment(faction, i);
|
||||
MovementController.refreshMonsterAggressiveness(world.model.currentMaps.map, world.model.player);
|
||||
}
|
||||
|
||||
private void addAlignmentReward(Player player, String faction) {
|
||||
Integer i = player.getAlignment(faction);
|
||||
player.addAlignment("akku", i);
|
||||
player.addAlignment(Constants.FACTION_SCORE_CALC_REGISTER_NAME, i);
|
||||
}
|
||||
|
||||
private void subAlignmentReward(Player player, String faction) {
|
||||
Integer i = -1 * player.getAlignment(faction);
|
||||
player.addAlignment("akku", i);
|
||||
player.addAlignment(Constants.FACTION_SCORE_CALC_REGISTER_NAME, i);
|
||||
}
|
||||
|
||||
private void divAlignmentReward(Player player, String faction, int delta ) {
|
||||
Integer m, i1, i2;
|
||||
if (delta == 0) { m = 1; } else { m = delta; }
|
||||
i1 = player.getAlignment("akku");
|
||||
i2 = player.getAlignment(faction) * m;
|
||||
player.setAlignment("akku", i1 / i2 );
|
||||
/// @param multiplier multiplies the faction alignment before dividing. Use 100 for percentages.
|
||||
private void divAlignmentReward(Player player, String faction, int multiplier ) {
|
||||
Integer i1, i2;
|
||||
if (multiplier == 0) { multiplier = 1; }
|
||||
i1 = player.getAlignment(Constants.FACTION_SCORE_CALC_REGISTER_NAME);
|
||||
i2 = player.getAlignment(faction) * multiplier;
|
||||
if (i2 != 0)
|
||||
{
|
||||
player.setAlignment(Constants.FACTION_SCORE_CALC_REGISTER_NAME, i1 / i2 );
|
||||
}
|
||||
}
|
||||
|
||||
private void multAlignmentReward(Player player, String faction, int delta ) {
|
||||
Integer m, i;
|
||||
if (delta == 0) { m = player.getAlignment("akku"); } else { m = delta; }
|
||||
i = player.getAlignment(faction) * m;
|
||||
player.setAlignment("akku", i );
|
||||
/// @param multiplier the factor to multiply by. If 0, uses the faction score from the {@link Constants.FACTION_SCORE_CALC_REGISTER_NAME} as multiplier.
|
||||
private void multAlignmentReward(Player player, String faction, int multiplier ) {
|
||||
Integer i;
|
||||
if (multiplier == 0) { multiplier = player.getAlignment(Constants.FACTION_SCORE_CALC_REGISTER_NAME); }
|
||||
i = player.getAlignment(faction) * multiplier;
|
||||
player.setAlignment(Constants.FACTION_SCORE_CALC_REGISTER_NAME, i );
|
||||
}
|
||||
|
||||
private void addQuestProgressReward(Player player, String questID, int questProgress, ScriptEffectResult result) {
|
||||
@@ -427,7 +432,7 @@ public final class ConversationController {
|
||||
private static String getDisplayMessage(Reply reply, Player player) { return replacePlayerName(reply.text, player); }
|
||||
private static String replacePlayerName(String s, Player player) {
|
||||
return s.replace(Constants.PLACEHOLDER_PLAYERNAME, player.getName())
|
||||
.replace(Constants.PLACEHOLDER_AKKU, String.valueOf(player.getAlignment("akku")));
|
||||
.replace(Constants.PLACEHOLDER_REG1, String.valueOf(player.getAlignment(Constants.FACTION_SCORE_CALC_REGISTER_NAME)));
|
||||
}
|
||||
|
||||
public static final class ConversationStatemachine {
|
||||
|
||||
@@ -9,8 +9,8 @@ public final class ScriptEffect {
|
||||
, actorConditionImmunity
|
||||
, alignmentChange
|
||||
, alignmentSet
|
||||
, alignmentToAkku
|
||||
, alignmentFromAkku
|
||||
, alignmentToReg1
|
||||
, alignmentFromReg1
|
||||
, alignmentAdd
|
||||
, alignmentSub
|
||||
, alignmentMult
|
||||
|
||||
@@ -827,7 +827,11 @@ A **dialogue** ***can*** have the following fields defined:
|
||||
|
||||
|
||||
- A **reward** ***must*** have the following fields defined:
|
||||
- "rewardType" with one of the following values: "**questProgress**", "**removeQuestProgress**", "**dropList**", "**skillIncrease**", "**actorCondition**", "**actorConditionImmunity**", "**alignmentChange**", "**alignmentSet**", "**giveItem**", "**createTimer**", "**spawnAll**", "**removeSpawnArea**", "**deactivateSpawnArea**", "**activateMapObjectGroup**", "**deactivateMapObjectGroup**", "**changeMapFilter**", "**mapchange**". Explanation for all rewards type, and associated constraints on the other fields of a reply definition is below.
|
||||
- "rewardType" with one of the following values: "**questProgress**", "**removeQuestProgress**", "**dropList**", "**skillIncrease**",
|
||||
"**actorCondition**", "**actorConditionImmunity**", "**alignmentChange**", "**alignmentSet**", "**alignmentToReg1**", "**alignmentFromReg1**",
|
||||
"**alignmentAdd**", "**alignmentSub**", "**alignmentMult**", "**alignmentDiv**", "**giveItem**", "**createTimer**", "**spawnAll**",
|
||||
"**removeSpawnArea**", "**deactivateSpawnArea**", "**activateMapObjectGroup**", "**deactivateMapObjectGroup**", "**changeMapFilter**",
|
||||
"**mapchange**". Explanation for all rewards type, and associated constraints on the other fields of a reply definition is below.
|
||||
|
||||
- "rewardID" with a textual value generally matching the ID of a game object. As it depends on the "**rewardType**" selected, see below for details.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user