Add starting rank and XP rate config options

This commit is contained in:
Jakob Gillich 2020-10-11 14:37:56 +02:00
parent 35b07f897d
commit 47d0013e42
5 changed files with 36 additions and 9 deletions

View file

@ -69,6 +69,20 @@ database {
game {
# Allow instant action to AMS
instant-action-ams = no
# Battle experience rate
bep-rate = 1.0
# Command experience rate
cep-rate = 1.0
new-avatar {
# Starting battle rank
br = 1
# Starting command rank
cr = 1
}
}
anti-cheat {

View file

@ -58,7 +58,7 @@ import net.psforever.types.{
}
import net.psforever.util.Database._
import net.psforever.persistence
import net.psforever.util.DefinitionUtil
import net.psforever.util.{Config, DefinitionUtil}
import org.joda.time.{LocalDateTime, Seconds}
import net.psforever.services.ServiceManager
import net.psforever.services.avatar.{AvatarAction, AvatarServiceMessage}
@ -306,7 +306,9 @@ class AvatarActor(
_.factionId -> lift(empire.id),
_.headId -> lift(head),
_.voiceId -> lift(voice.id),
_.genderId -> lift(gender.id)
_.genderId -> lift(gender.id),
_.bep -> lift(Config.app.game.newAvatar.br.experience),
_.cep -> lift(Config.app.game.newAvatar.cr.experience)
)
.returningGenerated(_.id)
)
@ -330,7 +332,7 @@ class AvatarActor(
case Failure(e) => log.error(e)("db failure")
}
case Some(_) =>
// send "char already exist"
// send "char already exists"
sessionActor ! SessionActor.SendResponse(ActionResultMessage.Fail(1))
}
case Failure(e) =>

View file

@ -1820,8 +1820,8 @@ class SessionActor(middlewareActor: typed.ActorRef[MiddlewareActor.Command], con
sendResponse(DestroyDisplayMessage(killer, victim, method, unk))
// TODO Temporary thing that should go somewhere else and use proper xp values
if (killer.CharId == avatar.id && killer.Faction != victim.Faction) {
avatarActor ! AvatarActor.AwardBep(1000)
avatarActor ! AvatarActor.AwardCep(100)
avatarActor ! AvatarActor.AwardBep((1000 * Config.app.game.bepRate).toLong)
avatarActor ! AvatarActor.AwardCep((100 * Config.app.game.cepRate).toLong)
}
case AvatarResponse.DropItem(pkt) =>

View file

@ -25,8 +25,8 @@ object ServerType extends IntEnum[ServerType] {
case object Released extends ServerType(3, "released")
case object ReleasedGemini extends ServerType(4, "released_gemini")
val values = findValues
implicit val codec = PacketHelpers.createIntEnumCodec(this, uint8L)
val values: IndexedSeq[ServerType] = findValues
implicit val codec: Codec[ServerType] = PacketHelpers.createIntEnumCodec(this, uint8L)
}
// This MUST be an IP address. The client DOES NOT do name resolution properly

View file

@ -5,6 +5,7 @@ import java.nio.file.Paths
import com.typesafe.config.{Config => TypesafeConfig}
import enumeratum.{Enum, EnumEntry}
import enumeratum.values.{IntEnum, IntEnumEntry}
import net.psforever.objects.avatar.{BattleRank, CommandRank}
import net.psforever.packet.game.ServerType
import net.psforever.types.ChatMessageType
import pureconfig.ConfigConvert.viaNonEmptyStringOpt
@ -30,7 +31,9 @@ object Config {
viaNonEmptyStringOpt[A](
v =>
enum.values.toList.collectFirst {
case e: ServerType if e.name == v => e.asInstanceOf[A]
case e: ServerType if e.name == v => e.asInstanceOf[A]
case e: BattleRank if e.value.toString == v => e.asInstanceOf[A]
case e: CommandRank if e.value.toString == v => e.asInstanceOf[A]
},
_.value.toString
)
@ -120,7 +123,15 @@ case class SessionConfig(
)
case class GameConfig(
instantActionAms: Boolean
instantActionAms: Boolean,
bepRate: Double,
cepRate: Double,
newAvatar: NewAvatar
)
case class NewAvatar(
br: BattleRank,
cr: CommandRank
)
case class DevelopmentConfig(