mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
@@ -1,28 +0,0 @@
|
||||
# Unresolved #
|
||||
|
||||
### Character ###
|
||||
|
||||
* Arm behind the body seems unnatural
|
||||
|
||||
|
||||
### Physics ###
|
||||
|
||||
|
||||
### System ###
|
||||
|
||||
|
||||
|
||||
# Resolved #
|
||||
|
||||
* Cannot fit into single-tile width pit
|
||||
Cause: Player/NPC looks slim enough to fit, but don't fit in the game
|
||||
Solution: Player/NPC hitbox now have a width of 15 pixels.
|
||||
|
||||
* Actor stick to wall and not get off
|
||||
Cause: Unknown
|
||||
Solution: Changed collision detection method to CCD (continuous collision detection)
|
||||
|
||||
* Actor with mass <2 behaves erratically
|
||||
Details: Velocity becomes NaN when jumped
|
||||
Cause: Floating-point precision error?
|
||||
Solution: Changed every physics variable that uses Float to Double
|
||||
132
assets/locales/nameset_dwarven.csv
Normal file
132
assets/locales/nameset_dwarven.csv
Normal file
@@ -0,0 +1,132 @@
|
||||
# Nameset - Dwarven (DF)
|
||||
# Picked randomly from its massive 2195 entries
|
||||
|
||||
"HEADER";"LatinAlph";"HangulKoKR";"KanaJaJP";"CyrilRuRU";"AlphElGR";"HanziZhCN";"HanziZhTW";"AksonThTH";"AlefbetHeIL"
|
||||
"NAMESET_DWARVEN_001";"Asdos";
|
||||
"NAMESET_DWARVEN_002";"Ngárak";
|
||||
"NAMESET_DWARVEN_003";"Dùstik";
|
||||
"NAMESET_DWARVEN_004";"Ish";
|
||||
"NAMESET_DWARVEN_005";"Reked";
|
||||
"NAMESET_DWARVEN_006";"Noval";
|
||||
"NAMESET_DWARVEN_007";"Feb";
|
||||
"NAMESET_DWARVEN_008";"Ostar";
|
||||
"NAMESET_DWARVEN_009";"Nicat";
|
||||
"NAMESET_DWARVEN_010";"Kogan";
|
||||
"NAMESET_DWARVEN_011";"Alud";
|
||||
"NAMESET_DWARVEN_012";"Bidok";
|
||||
"NAMESET_DWARVEN_013";"Thatthil";
|
||||
"NAMESET_DWARVEN_014";"Olmul";
|
||||
"NAMESET_DWARVEN_015";"Comníth";
|
||||
"NAMESET_DWARVEN_016";"Erong";
|
||||
"NAMESET_DWARVEN_017";"Rërith";
|
||||
"NAMESET_DWARVEN_018";"Äkim";
|
||||
"NAMESET_DWARVEN_019";"Öntak";
|
||||
"NAMESET_DWARVEN_020";"Kitïg";
|
||||
"NAMESET_DWARVEN_021";"Thoth";
|
||||
"NAMESET_DWARVEN_022";"Tílgil";
|
||||
"NAMESET_DWARVEN_023";"Ingish";
|
||||
"NAMESET_DWARVEN_024";"Alak";
|
||||
"NAMESET_DWARVEN_025";"Egdoth";
|
||||
"NAMESET_DWARVEN_026";"Ùst";
|
||||
"NAMESET_DWARVEN_027";"Rimtar";
|
||||
"NAMESET_DWARVEN_028";"Bugsud";
|
||||
"NAMESET_DWARVEN_029";"Selsten";
|
||||
"NAMESET_DWARVEN_030";"Âtrid";
|
||||
"NAMESET_DWARVEN_031";"Roder";
|
||||
"NAMESET_DWARVEN_032";"Othsin";
|
||||
"NAMESET_DWARVEN_033";"Enôr";
|
||||
"NAMESET_DWARVEN_034";"Fer";
|
||||
"NAMESET_DWARVEN_035";"Dolush";
|
||||
"NAMESET_DWARVEN_036";"Ermis";
|
||||
"NAMESET_DWARVEN_037";"Åblel";
|
||||
"NAMESET_DWARVEN_038";"Agêk";
|
||||
"NAMESET_DWARVEN_039";"Ucat";
|
||||
"NAMESET_DWARVEN_040";"Ethbesh";
|
||||
"NAMESET_DWARVEN_041";"Nïng";
|
||||
"NAMESET_DWARVEN_042";"Emär";
|
||||
"NAMESET_DWARVEN_043";"Shalig";
|
||||
"NAMESET_DWARVEN_044";"Suthmam";
|
||||
"NAMESET_DWARVEN_045";"Ugath";
|
||||
"NAMESET_DWARVEN_046";"Udir";
|
||||
"NAMESET_DWARVEN_047";"Bemòng";
|
||||
"NAMESET_DWARVEN_048";"Tegir";
|
||||
"NAMESET_DWARVEN_049";"Nug";
|
||||
"NAMESET_DWARVEN_050";"Dudgoth";
|
||||
"NAMESET_DWARVEN_051";"Ogîk";
|
||||
"NAMESET_DWARVEN_052";"Robek";
|
||||
"NAMESET_DWARVEN_053";"Ilush";
|
||||
"NAMESET_DWARVEN_054";"Berim";
|
||||
"NAMESET_DWARVEN_055";"Emuth";
|
||||
"NAMESET_DWARVEN_056";"Sedil";
|
||||
"NAMESET_DWARVEN_057";"Izeg";
|
||||
"NAMESET_DWARVEN_058";"Okab";
|
||||
"NAMESET_DWARVEN_059";"Anam";
|
||||
"NAMESET_DWARVEN_060";"Girtol";
|
||||
"NAMESET_DWARVEN_061";"Etäg";
|
||||
"NAMESET_DWARVEN_062";"Stalkòb";
|
||||
"NAMESET_DWARVEN_063";"Enir";
|
||||
"NAMESET_DWARVEN_064";"Tosid";
|
||||
"NAMESET_DWARVEN_065";"Ím";
|
||||
"NAMESET_DWARVEN_066";"Lisig";
|
||||
"NAMESET_DWARVEN_067";"Stal";
|
||||
"NAMESET_DWARVEN_068";"Mafol";
|
||||
"NAMESET_DWARVEN_069";"Onshen";
|
||||
"NAMESET_DWARVEN_070";"Äs";
|
||||
"NAMESET_DWARVEN_071";"Sidos";
|
||||
"NAMESET_DWARVEN_072";"Sid";
|
||||
"NAMESET_DWARVEN_073";"Thîkut";
|
||||
"NAMESET_DWARVEN_074";"Gòstang";
|
||||
"NAMESET_DWARVEN_075";"Idek";
|
||||
"NAMESET_DWARVEN_076";"Themor";
|
||||
"NAMESET_DWARVEN_077";"Lurak";
|
||||
"NAMESET_DWARVEN_078";"Gost";
|
||||
"NAMESET_DWARVEN_079";"Namàsh";
|
||||
"NAMESET_DWARVEN_080";"Alåth";
|
||||
"NAMESET_DWARVEN_081";"Libash";
|
||||
"NAMESET_DWARVEN_082";"Dënush";
|
||||
"NAMESET_DWARVEN_083";"Biban";
|
||||
"NAMESET_DWARVEN_084";"Onlìl";
|
||||
"NAMESET_DWARVEN_085";"Lokast";
|
||||
"NAMESET_DWARVEN_086";"Rozsed";
|
||||
"NAMESET_DWARVEN_087";"Utheg";
|
||||
"NAMESET_DWARVEN_088";"Shin";
|
||||
"NAMESET_DWARVEN_089";"Mokez";
|
||||
"NAMESET_DWARVEN_090";"Lanlar";
|
||||
"NAMESET_DWARVEN_091";"Ebsas";
|
||||
"NAMESET_DWARVEN_092";"Osod";
|
||||
"NAMESET_DWARVEN_093";"Mabdug";
|
||||
"NAMESET_DWARVEN_094";"Ibruk";
|
||||
"NAMESET_DWARVEN_095";"Murak";
|
||||
"NAMESET_DWARVEN_096";"Cös";
|
||||
"NAMESET_DWARVEN_097";"Olom";
|
||||
"NAMESET_DWARVEN_098";"Kiror";
|
||||
"NAMESET_DWARVEN_099";"Kâkdal";
|
||||
"NAMESET_DWARVEN_100";"Zustash";
|
||||
"NAMESET_DWARVEN_101";"Okon";
|
||||
"NAMESET_DWARVEN_102";"Gatal";
|
||||
"NAMESET_DWARVEN_103";"Nazush";
|
||||
"NAMESET_DWARVEN_104";"Kun";
|
||||
"NAMESET_DWARVEN_105";"Nokzam";
|
||||
"NAMESET_DWARVEN_106";"Ëlot";
|
||||
"NAMESET_DWARVEN_107";"Stumäm";
|
||||
"NAMESET_DWARVEN_108";"Setnek";
|
||||
"NAMESET_DWARVEN_109";"Nural";
|
||||
"NAMESET_DWARVEN_110";"Tarmid";
|
||||
"NAMESET_DWARVEN_111";"Lek";
|
||||
"NAMESET_DWARVEN_112";"Cog";
|
||||
"NAMESET_DWARVEN_113";"Sákrith";
|
||||
"NAMESET_DWARVEN_114";"Ugog";
|
||||
"NAMESET_DWARVEN_115";"Ustos";
|
||||
"NAMESET_DWARVEN_116";"Thos";
|
||||
"NAMESET_DWARVEN_117";"Kovath";
|
||||
"NAMESET_DWARVEN_118";"Idos";
|
||||
"NAMESET_DWARVEN_119";"Nel";
|
||||
"NAMESET_DWARVEN_120";"Tobul";
|
||||
"NAMESET_DWARVEN_121";"Nashon";
|
||||
"NAMESET_DWARVEN_122";"Nicol";
|
||||
"NAMESET_DWARVEN_123";"Uvel";
|
||||
"NAMESET_DWARVEN_124";"Rorul";
|
||||
"NAMESET_DWARVEN_125";"Gasol";
|
||||
"NAMESET_DWARVEN_126";"Osed";
|
||||
"NAMESET_DWARVEN_127";"Lakish";
|
||||
"NAMESET_DWARVEN_128";"Okag";
|
||||
|
6
assets/locales/nameset_exotic_deities.csv
Normal file
6
assets/locales/nameset_exotic_deities.csv
Normal file
@@ -0,0 +1,6 @@
|
||||
# Nameset - Fictional, used for deity names
|
||||
# Mostly randomly generated, plus:
|
||||
# References for mass media -- are allowed, as long as it does not impose copyright infringement
|
||||
|
||||
"HEADER";"LatinAlph";"HangulKoKR";"KanaJaJP";"CyrilRuRU";"AlphElGR";"HanziZhCN";"HanziZhTW";"AksonThTH";"AlefbetHeIL";"Reference"
|
||||
"NAMESET_DEITIES_001";"Armok";;;;;;;;"From game series Slaves to Armok: God of Blood"
|
||||
|
@@ -1,6 +1,11 @@
|
||||
# Nameset - Scandinavian
|
||||
# Data taken from www.behindthename.com
|
||||
# Translator note: this nameset does not contain name that has [ɹ](american english 'r') sound (except '-er'). i.e. for Korean, 'Carl' should be '카를', 'Aleksander' should be '알렉산더'.
|
||||
|
||||
# Each column stands for the writing system:
|
||||
# LatinAlph - Latin Alphabet; HangulKoKR - Hangul, Korean; CyrilRuRU - Cyrillic, Russian; etc.
|
||||
|
||||
# Translator note: this nameset does not contain name that has [ɹ](american english 'r') sound
|
||||
# (except '-er'). i.e. for Korean, 'Carl' should be '카를', 'Aleksander' should be '알렉산더'.
|
||||
|
||||
"HEADER";"LatinAlph";"HangulKoKR";"KanaJaJP";"CyrilRuRU";"AlphElGR";"HanziZhCN";"HanziZhTW";"AksonThTH";"AlefbetHeIL"
|
||||
"NAMESET_SCAN_F_001";"Agnes";"아그네스";
|
||||
|
||||
|
@@ -1,3 +1,8 @@
|
||||
THIS IS UNUSED AND SHOULD BE REMOVED
|
||||
|
||||
|
||||
|
||||
|
||||
"STRING_ID";"IETF language tag(s) without dash";"enUS";"frFR";"esES";"deDE";"itIT";"ptBR";"ptPT";"ruRU";"elGR";"trTR";"daDK";"noNB";"svSE";"nlNL";"plPL";"fiFI";"jaJP";"zhCN";"zhTW";"koKR";"csCZ";"huHU";"roRO";"thTH";"bgBG";"heIL";"jakanaJP"
|
||||
|
||||
"TILE_STONE";;"Stone";"Roche";;;;;;;;;;;;;;;;;;"돌";
|
||||
|
||||
|
@@ -6,4 +6,4 @@
|
||||
# module_name,description_in_English_no_comma,(external Jar 1);(external Jar 2); ...
|
||||
|
||||
basegame,The base game,
|
||||
dwarventech,Logic gates and machines,
|
||||
dwarventech,Dwarven technicians are emerged,
|
||||
|
||||
|
@@ -1,10 +1,15 @@
|
||||
"idst";"forcemod";"comments"
|
||||
"rock"; "1";
|
||||
"cupr"; "2";
|
||||
"egls"; "4";"elven glass"
|
||||
"iron"; "5";
|
||||
"argn"; "9";"argentum"
|
||||
"stal"; "14";"steel"
|
||||
"eaur"; "21";"elven aurichalcum"
|
||||
"tial"; "33";"titanium alloy"
|
||||
"admt"; "71";"adamant metal"
|
||||
"idst";"forcemod";"endurance";"comments"
|
||||
"rock"; "1"; "0.42";
|
||||
"cupr"; "2"; "1.00";"copper"
|
||||
"egls"; "4"; "0.82";"elven glass"
|
||||
"iron"; "5"; "1.42";
|
||||
"argn"; "9"; "0.91";"argentum/silver"
|
||||
"stal"; "14"; "1.73";"steel"
|
||||
"eaur"; "21"; "1.36";"elven aurichalcum"
|
||||
"tial"; "33"; "2.16";"titanium alloy"
|
||||
"admt"; "71"; "3.42";"adamant"
|
||||
|
||||
# forcemod: related to attack points
|
||||
# Attack points = `4 * forcemod.sqrt()` for each strike
|
||||
|
||||
# endurance: multiplier, using copper as reference; determines durability of tools/weapons/armours/etc.
|
||||
|
||||
|
@@ -8,11 +8,11 @@ import net.torvald.colourutil.CIEXYZUtil.toColor
|
||||
import net.torvald.terrarum.ModMgr
|
||||
|
||||
/**
|
||||
* RGB-modeled CCT calculator
|
||||
* RGB- and CIE-Modeled CCT calculator
|
||||
* Created by minjaesong on 16-07-26.
|
||||
*/
|
||||
object ColourTemp {
|
||||
private var envOverlayColourmap = Image(ModMgr.getPath("basegame", "colourmap/black_body_col_1000_40000_K.tga"))
|
||||
private var clut = Image(ModMgr.getPath("basegame", "colourmap/black_body_col_1000_40000_K.tga"))
|
||||
|
||||
private fun colTempToImagePos(K: Int): Int {
|
||||
if (K < 1000 || K >= 40000) throw IllegalArgumentException("K: out of range. ($K)")
|
||||
@@ -21,7 +21,7 @@ object ColourTemp {
|
||||
|
||||
/** returns sRGB-normalised colour */
|
||||
operator fun invoke(temp: Int): Color =
|
||||
envOverlayColourmap.getPixel(colTempToImagePos(temp), 0).toColor()
|
||||
clut.getPixel(colTempToImagePos(temp), 0).toColor()
|
||||
|
||||
/** returns CIExyY-based colour converted to slick.color
|
||||
* @param CIE_Y 0.0 - 1.0+ */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.torvald.terrarum
|
||||
package net.torvald.dataclass
|
||||
|
||||
|
||||
/**
|
||||
@@ -75,6 +75,10 @@ object DefaultConfig {
|
||||
jsonObject.addProperty("safetywarning", true)
|
||||
|
||||
|
||||
jsonObject.addProperty("maxparticles", 768)
|
||||
|
||||
|
||||
|
||||
return jsonObject
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum
|
||||
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.Terrarum.UPDATE_DELTA
|
||||
import net.torvald.terrarum.Terrarum.delta
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
import net.torvald.terrarum.virtualcomputer.computer.TerrarumComputer
|
||||
import net.torvald.terrarum.virtualcomputer.peripheral.PeripheralVideoCard
|
||||
@@ -90,7 +90,7 @@ class StateGraphicComputerTest : BasicGameState() {
|
||||
var angle = 0.0
|
||||
|
||||
override fun update(container: GameContainer, game: StateBasedGame?, delta: Int) {
|
||||
UPDATE_DELTA = delta
|
||||
Terrarum.delta = delta
|
||||
|
||||
Terrarum.appgc.setTitle("VT — F: ${container.fps}" +
|
||||
" — M: ${Terrarum.memInUse}M / ${Terrarum.memTotal}M / ${Terrarum.memXmx}M" +
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package net.torvald.terrarum
|
||||
|
||||
import net.torvald.dataclass.CircularArray
|
||||
import net.torvald.imagefont.GameFontBase
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.Terrarum.UPDATE_DELTA
|
||||
import net.torvald.terrarum.Terrarum.delta
|
||||
import net.torvald.terrarum.audio.AudioResourceLibrary
|
||||
import net.torvald.terrarum.concurrent.ThreadParallel
|
||||
import net.torvald.terrarum.console.*
|
||||
@@ -40,6 +41,7 @@ import java.lang.management.ManagementFactory
|
||||
import java.util.*
|
||||
import java.util.concurrent.locks.Lock
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import javax.swing.JOptionPane
|
||||
import kotlin.collections.HashMap
|
||||
|
||||
/**
|
||||
@@ -48,15 +50,13 @@ import kotlin.collections.HashMap
|
||||
class StateInGame : BasicGameState() {
|
||||
private val ACTOR_UPDATE_RANGE = 4096
|
||||
|
||||
internal var game_mode = 0
|
||||
|
||||
lateinit var world: GameWorld
|
||||
|
||||
/**
|
||||
* list of Actors that is sorted by Actors' referenceID
|
||||
*/
|
||||
val ACTORCONTAINER_INITIAL_SIZE = 128
|
||||
val PARTICLES_MAX = 768
|
||||
val ACTORCONTAINER_INITIAL_SIZE = 64
|
||||
val PARTICLES_MAX = Terrarum.getConfigInt("maxparticles")
|
||||
val actorContainer = ArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
val actorContainerInactive = ArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
val particlesContainer = CircularArray<ParticleBase>(PARTICLES_MAX)
|
||||
@@ -67,11 +67,6 @@ class StateInGame : BasicGameState() {
|
||||
private val actorsRenderMidTop = ArrayList<ActorVisible>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
private val actorsRenderFront = ArrayList<ActorVisible>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
|
||||
lateinit var consoleHandler: UIHandler
|
||||
lateinit var debugWindow: UIHandler
|
||||
lateinit var notifier: UIHandler
|
||||
|
||||
|
||||
var playableActorDelegate: PlayableActorDelegate? = null // DO NOT LATEINIT!
|
||||
private set
|
||||
internal val player: ActorHumanoid? // currently POSSESSED actor :)
|
||||
@@ -95,7 +90,12 @@ class StateInGame : BasicGameState() {
|
||||
val KEY_LIGHTMAP_RENDER = Key.F7
|
||||
val KEY_LIGHTMAP_SMOOTH = Key.F8
|
||||
|
||||
// UI aliases (no pause)
|
||||
|
||||
|
||||
lateinit var consoleHandler: UIHandler
|
||||
lateinit var debugWindow: UIHandler
|
||||
lateinit var notifier: UIHandler
|
||||
|
||||
lateinit var uiPieMenu: UIHandler
|
||||
lateinit var uiQuickBar: UIHandler
|
||||
lateinit var uiInventoryPlayer: UIHandler
|
||||
@@ -103,10 +103,12 @@ class StateInGame : BasicGameState() {
|
||||
lateinit var uiVitalPrimary: UIHandler
|
||||
lateinit var uiVitalSecondary: UIHandler
|
||||
lateinit var uiVitalItem: UIHandler // itemcount/durability of held block or active ammo of held gun. As for the block, max value is 500.
|
||||
lateinit var uiAliases: Array<UIHandler>
|
||||
|
||||
// UI aliases (pause)
|
||||
val uiAlasesPausing = ArrayList<UIHandler>()
|
||||
// UI aliases
|
||||
lateinit var uiAliases: ArrayList<UIHandler>
|
||||
private set
|
||||
lateinit var uiAlasesPausing: ArrayList<UIHandler>
|
||||
private set
|
||||
|
||||
var paused: Boolean = false
|
||||
get() = uiAlasesPausing.map { if (it.isOpened) 1 else 0 }.sum() > 0
|
||||
@@ -212,7 +214,7 @@ class StateInGame : BasicGameState() {
|
||||
|
||||
|
||||
// batch-process uiAliases
|
||||
uiAliases = arrayOf(
|
||||
uiAliases = arrayListOf(
|
||||
uiPieMenu,
|
||||
uiQuickBar,
|
||||
uiInventoryPlayer,
|
||||
@@ -221,6 +223,9 @@ class StateInGame : BasicGameState() {
|
||||
uiVitalSecondary,
|
||||
uiVitalItem
|
||||
)
|
||||
uiAlasesPausing = arrayListOf(
|
||||
consoleHandler
|
||||
)
|
||||
uiAlasesPausing.forEach { uiContainer.add(it) } // put them all to the UIContainer
|
||||
uiAliases.forEach { uiContainer.add(it) } // put them all to the UIContainer
|
||||
|
||||
@@ -238,7 +243,7 @@ class StateInGame : BasicGameState() {
|
||||
|
||||
override fun update(gc: GameContainer, sbg: StateBasedGame, delta: Int) {
|
||||
particlesActive = 0
|
||||
UPDATE_DELTA = delta
|
||||
Terrarum.delta = delta
|
||||
setAppTitle()
|
||||
|
||||
|
||||
@@ -337,7 +342,7 @@ class StateInGame : BasicGameState() {
|
||||
}
|
||||
|
||||
playableActorDelegate = newActor
|
||||
WorldSimulator(player, UPDATE_DELTA)
|
||||
WorldSimulator(player, delta)
|
||||
}
|
||||
|
||||
private fun changePossession(refid: Int) {
|
||||
@@ -352,7 +357,7 @@ class StateInGame : BasicGameState() {
|
||||
// accept new delegate
|
||||
playableActorDelegate = PlayableActorDelegate(getActorByID(refid) as ActorHumanoid)
|
||||
playableActorDelegate!!.actor.collisionType = ActorWithPhysics.COLLISION_KINEMATIC
|
||||
WorldSimulator(player, UPDATE_DELTA)
|
||||
WorldSimulator(player, delta)
|
||||
}
|
||||
|
||||
private fun setAppTitle() {
|
||||
@@ -525,75 +530,15 @@ class StateInGame : BasicGameState() {
|
||||
}
|
||||
|
||||
GameController.keyPressed(key, c)
|
||||
|
||||
if (canPlayerControl) {
|
||||
player?.keyPressed(key, c)
|
||||
}
|
||||
|
||||
if (Terrarum.getConfigIntArray("keyquickselalt").contains(key)
|
||||
|| key == Terrarum.getConfigInt("keyquicksel")) {
|
||||
uiPieMenu.setAsOpen()
|
||||
uiQuickBar.setAsClose()
|
||||
}
|
||||
|
||||
uiContainer.forEach { it.keyPressed(key, c) } // for KeyboardControlled UIcanvases
|
||||
}
|
||||
|
||||
override fun keyReleased(key: Int, c: Char) {
|
||||
GameController.keyReleased(key, c)
|
||||
|
||||
if (Terrarum.getConfigIntArray("keyquickselalt").contains(key)
|
||||
|| key == Terrarum.getConfigInt("keyquicksel")) {
|
||||
uiPieMenu.setAsClose()
|
||||
uiQuickBar.setAsOpen()
|
||||
}
|
||||
|
||||
uiContainer.forEach { it.keyReleased(key, c) } // for KeyboardControlled UIcanvases
|
||||
}
|
||||
|
||||
override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||
GameController.mouseMoved(oldx, oldy, newx, newy)
|
||||
|
||||
uiContainer.forEach { it.mouseMoved(oldx, oldy, newx, newy) } // for MouseControlled UIcanvases
|
||||
}
|
||||
|
||||
override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||
GameController.mouseDragged(oldx, oldy, newx, newy)
|
||||
|
||||
uiContainer.forEach { it.mouseDragged(oldx, oldy, newx, newy) } // for MouseControlled UIcanvases
|
||||
}
|
||||
|
||||
override fun mousePressed(button: Int, x: Int, y: Int) {
|
||||
GameController.mousePressed(button, x, y)
|
||||
|
||||
uiContainer.forEach { it.mousePressed(button, x, y) } // for MouseControlled UIcanvases
|
||||
}
|
||||
|
||||
override fun mouseReleased(button: Int, x: Int, y: Int) {
|
||||
GameController.mouseReleased(button, x, y)
|
||||
|
||||
uiContainer.forEach { it.mouseReleased(button, x, y) } // for MouseControlled UIcanvases
|
||||
}
|
||||
|
||||
override fun mouseWheelMoved(change: Int) {
|
||||
GameController.mouseWheelMoved(change)
|
||||
|
||||
uiContainer.forEach { it.mouseWheelMoved(change) } // for MouseControlled UIcanvases
|
||||
}
|
||||
|
||||
override fun controllerButtonPressed(controller: Int, button: Int) {
|
||||
GameController.controllerButtonPressed(controller, button)
|
||||
|
||||
uiContainer.forEach { it.controllerButtonPressed(controller, button) } // for GamepadControlled UIcanvases
|
||||
|
||||
// TODO use item on Player
|
||||
}
|
||||
|
||||
override fun controllerButtonReleased(controller: Int, button: Int) {
|
||||
GameController.controllerButtonReleased(controller, button)
|
||||
|
||||
uiContainer.forEach { it.controllerButtonReleased(controller, button) } // for GamepadControlled UIcanvases
|
||||
}
|
||||
override fun keyReleased(key: Int, c: Char) { GameController.keyReleased(key, c) }
|
||||
override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) { GameController.mouseMoved(oldx, oldy, newx, newy) }
|
||||
override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) { GameController.mouseDragged(oldx, oldy, newx, newy) }
|
||||
override fun mousePressed(button: Int, x: Int, y: Int) { GameController.mousePressed(button, x, y) }
|
||||
override fun mouseReleased(button: Int, x: Int, y: Int) { GameController.mouseReleased(button, x, y) }
|
||||
override fun mouseWheelMoved(change: Int) { GameController.mouseWheelMoved(change) }
|
||||
override fun controllerButtonPressed(controller: Int, button: Int) { GameController.controllerButtonPressed(controller, button) }
|
||||
override fun controllerButtonReleased(controller: Int, button: Int) { GameController.controllerButtonReleased(controller, button) }
|
||||
|
||||
override fun getID(): Int = Terrarum.STATE_ID_GAME
|
||||
|
||||
@@ -858,8 +803,10 @@ class StateInGame : BasicGameState() {
|
||||
if (index < 0) {
|
||||
index = actorContainerInactive.binarySearch(ID)
|
||||
|
||||
if (index < 0)
|
||||
if (index < 0) {
|
||||
JOptionPane.showMessageDialog(null, "Actor with ID $ID does not exist.", null, JOptionPane.ERROR_MESSAGE)
|
||||
throw IllegalArgumentException("Actor with ID $ID does not exist.")
|
||||
}
|
||||
else
|
||||
return actorContainerInactive[index]
|
||||
}
|
||||
|
||||
65
src/net/torvald/terrarum/StateStutterTest.kt
Normal file
65
src/net/torvald/terrarum/StateStutterTest.kt
Normal file
@@ -0,0 +1,65 @@
|
||||
package net.torvald.terrarum
|
||||
|
||||
import net.torvald.terrarum.gamecontroller.Key
|
||||
import org.newdawn.slick.Color
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.Image
|
||||
import org.newdawn.slick.state.BasicGameState
|
||||
import org.newdawn.slick.state.StateBasedGame
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-04-22.
|
||||
*/
|
||||
class StateStutterTest : BasicGameState() {
|
||||
|
||||
private val testImage = Image(4096, 1728)
|
||||
private val testImageG = testImage.graphics
|
||||
|
||||
override fun init(container: GameContainer?, game: StateBasedGame?) {
|
||||
}
|
||||
|
||||
override fun update(container: GameContainer, game: StateBasedGame, delta: Int) {
|
||||
Terrarum.appgc.setTitle("${Terrarum.NAME} — F: ${Terrarum.appgc.fps}")
|
||||
|
||||
|
||||
if (container.input.isKeyDown(Key.UP))
|
||||
dy -= moveDelta
|
||||
if (container.input.isKeyDown(Key.DOWN))
|
||||
dy += moveDelta
|
||||
if (container.input.isKeyDown(Key.LEFT))
|
||||
dx -= moveDelta
|
||||
if (container.input.isKeyDown(Key.RIGHT))
|
||||
dx += moveDelta
|
||||
}
|
||||
|
||||
override fun getID() = Terrarum.STATE_ID_TEST_REFRESHRATE
|
||||
|
||||
private var imageMade = false
|
||||
|
||||
private var moveDelta = 3
|
||||
private var dx = 0
|
||||
private var dy = 0
|
||||
|
||||
override fun render(container: GameContainer, game: StateBasedGame, g: Graphics) {
|
||||
if (!imageMade) {
|
||||
testImageG.font = Terrarum.fontGame
|
||||
testImageG.color = Color.white
|
||||
|
||||
(0x3400..0x9FFF).forEach {
|
||||
testImageG.drawString(
|
||||
"${it.toChar()}",
|
||||
(it - 0x3400) % 256 * 16f,
|
||||
(it - 0x3400) / 256 * 16f
|
||||
)
|
||||
}
|
||||
|
||||
testImageG.flush()
|
||||
|
||||
imageMade = true
|
||||
}
|
||||
|
||||
g.translate(-dx.toFloat(), -dy.toFloat())
|
||||
g.drawImage(testImage, 0f, 0f)
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class StateUITest : BasicGameState() {
|
||||
init {
|
||||
itemProperties[IVKey.ITEMTYPE] = IVKey.ItemType.HAMMER
|
||||
}
|
||||
override val id: Int = 5656
|
||||
override var id: Int = 5656
|
||||
override val isUnique: Boolean = true
|
||||
override var originalName: String = "Test tool"
|
||||
override var baseMass: Double = 12.0
|
||||
@@ -63,7 +63,7 @@ class StateUITest : BasicGameState() {
|
||||
init {
|
||||
itemProperties[IVKey.ITEMTYPE] = IVKey.ItemType.ARTEFACT
|
||||
}
|
||||
override val id: Int = 4633
|
||||
override var id: Int = 4633
|
||||
override val isUnique: Boolean = true
|
||||
override var originalName: String = "CONTEXT_ITEM_QUEST_NOUN"
|
||||
override var baseMass: Double = 1.4
|
||||
|
||||
@@ -159,6 +159,7 @@ object Terrarum : StateBasedGame(GAME_NAME) {
|
||||
val STATE_ID_TEST_TTY = 0x102
|
||||
val STATE_ID_TEST_BLUR = 0x103
|
||||
val STATE_ID_TEST_SHADER = 0x104
|
||||
val STATE_ID_TEST_REFRESHRATE = 0x105
|
||||
val STATE_ID_TEST_INPUT = 0x106
|
||||
|
||||
val STATE_ID_TEST_UI1 = 0x110
|
||||
@@ -197,7 +198,7 @@ object Terrarum : StateBasedGame(GAME_NAME) {
|
||||
"${VERSION_RAW.ushr(24)}.${VERSION_RAW.and(0xFF0000).ushr(16)}.${VERSION_RAW.and(0xFFFF)}"
|
||||
const val NAME = "Terrarum"
|
||||
|
||||
var UPDATE_DELTA: Int = 0
|
||||
var delta: Int = 0
|
||||
|
||||
// these properties goes into the GameContainer
|
||||
|
||||
@@ -332,6 +333,8 @@ object Terrarum : StateBasedGame(GAME_NAME) {
|
||||
//addState(StateControllerRumbleTest())
|
||||
//addState(StateMidiInputTest())
|
||||
//addState(StateNewRunesTest())
|
||||
//addState(StateStutterTest())
|
||||
|
||||
|
||||
ingame = StateInGame(); addState(ingame)
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
|
||||
|
||||
private val nullItem = object : InventoryItem() {
|
||||
override val id: Int = 0
|
||||
override var id: Int = 0
|
||||
override val isUnique: Boolean = false
|
||||
override var baseMass: Double = 0.0
|
||||
override var baseToolSize: Double? = null
|
||||
|
||||
@@ -44,12 +44,18 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
|
||||
// If we already have the item, increment the amount
|
||||
// If not, add item with specified amount
|
||||
val existingItem = getByID(item.id)
|
||||
|
||||
if (existingItem != null) { // if the item already exists
|
||||
val newCount = getByID(item.id)!!.amount + count
|
||||
itemList.remove(existingItem)
|
||||
itemList.add(InventoryPair(existingItem.item, newCount))
|
||||
}
|
||||
else {
|
||||
else { // new item
|
||||
if (item.isDynamic) {
|
||||
// assign new ID
|
||||
item.originalID = item.id
|
||||
item.id = InventoryItem.generateNewDynamicID(this)
|
||||
}
|
||||
itemList.add(InventoryPair(item, count))
|
||||
}
|
||||
insertionSortLastElem(itemList)
|
||||
@@ -121,12 +127,18 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
|
||||
false
|
||||
|
||||
|
||||
fun consumeItem(item: InventoryItem) {
|
||||
fun consumeItem(actor: Actor, item: InventoryItem) {
|
||||
if (item.consumable) {
|
||||
remove(item, 1)
|
||||
}
|
||||
else {
|
||||
item.durability -= 1f
|
||||
val baseDamagePerSwing = if (actor is ActorHumanoid)
|
||||
actor.avStrength / 1000.0
|
||||
else
|
||||
1.0 // TODO variable: scale, strength
|
||||
val swingDmgToFrameDmg = Terrarum.delta.toDouble() / actor.actorValue.getAsDouble(AVKey.ACTION_INTERVAL)!!
|
||||
|
||||
item.durability -= (baseDamagePerSwing * swingDmgToFrameDmg).toFloat()
|
||||
if (item.durability <= 0)
|
||||
remove(item, 1)
|
||||
}
|
||||
|
||||
@@ -107,9 +107,9 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
}
|
||||
@Transient val MASS_LOWEST = 0.1 // Kilograms
|
||||
/** Apparent mass. Use "avBaseMass" for base mass */
|
||||
var mass: Double
|
||||
val mass: Double
|
||||
get() = actorValue.getAsDouble(AVKey.BASEMASS) ?: MASS_DEFAULT * Math.pow(scale, 3.0)
|
||||
set(value) {
|
||||
/*set(value) { // use "var avBaseMass: Double"
|
||||
if (value <= 0)
|
||||
throw IllegalArgumentException("mass cannot be less than or equal to zero.")
|
||||
else if (value < MASS_LOWEST) {
|
||||
@@ -118,7 +118,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
}
|
||||
|
||||
actorValue[AVKey.BASEMASS] = value / Math.pow(scale, 3.0)
|
||||
}
|
||||
}*/
|
||||
@Transient private val MASS_DEFAULT: Double = 60.0
|
||||
/** Valid range: [0, 1] */
|
||||
var elasticity: Double = 0.0
|
||||
@@ -232,7 +232,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
protected val gameContainer: GameContainer
|
||||
get() = Terrarum.appgc
|
||||
protected val updateDelta: Int
|
||||
get() = Terrarum.UPDATE_DELTA
|
||||
get() = Terrarum.delta
|
||||
|
||||
/**
|
||||
* true: This actor had just made collision
|
||||
@@ -1286,15 +1286,12 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
set(value) {
|
||||
actorValue[AVKey.SCALE] = value
|
||||
}
|
||||
/** Apparent strength */
|
||||
var avStrength: Double
|
||||
get() = (actorValue.getAsDouble(AVKey.STRENGTH) ?: 0.0) *
|
||||
(actorValue.getAsDouble(AVKey.STRENGTHBUFF) ?: 0.0) * scale
|
||||
set(value) {
|
||||
actorValue[AVKey.STRENGTH] =
|
||||
value /
|
||||
((actorValue.getAsDouble(AVKey.STRENGTHBUFF) ?: 1.0) * (avBaseStrength ?: 1.0))
|
||||
}
|
||||
/**
|
||||
* Apparent strength. 1 000 is default value
|
||||
*/
|
||||
val avStrength: Double
|
||||
get() = (actorValue.getAsDouble(AVKey.STRENGTH) ?: 1000.0) *
|
||||
(actorValue.getAsDouble(AVKey.STRENGTHBUFF) ?: 1.0) * scale
|
||||
var avBaseStrength: Double?
|
||||
get() = actorValue.getAsDouble(AVKey.STRENGTH)
|
||||
set(value) {
|
||||
|
||||
@@ -17,7 +17,7 @@ class DroppedItem(private val item: InventoryItem) : ActorWithPhysics(Actor.Rend
|
||||
|
||||
isVisible = true
|
||||
|
||||
mass = if (item.id < TileCodex.TILE_UNIQUE_MAX)
|
||||
avBaseMass = if (item.id < TileCodex.TILE_UNIQUE_MAX)
|
||||
TileCodex[item.id].density / 1000.0
|
||||
else
|
||||
ItemCodex[item.id].mass
|
||||
|
||||
@@ -20,7 +20,7 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, maxLifeTime: Int? = null
|
||||
/** Will NOT actually delete from the CircularArray */
|
||||
@Volatile var flagDespawn = false
|
||||
|
||||
override fun run() = update(Terrarum.appgc, Terrarum.UPDATE_DELTA)
|
||||
override fun run() = update(Terrarum.appgc, Terrarum.delta)
|
||||
|
||||
var isNoSubjectToGrav = false
|
||||
var dragCoefficient = 3.0
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.newdawn.slick.Image
|
||||
class ParticleTestRain(posX: Double, posY: Double) : ParticleBase(Actor.RenderOrder.BEHIND, 6000) {
|
||||
|
||||
init {
|
||||
body = Image("./assets/graphics/weathers/raindrop.tga")
|
||||
body = Image("./assets/modules/basegame/weathers/raindrop.tga")
|
||||
val w = body.width.toDouble()
|
||||
val h = body.height.toDouble()
|
||||
hitbox.setFromWidthHeight(
|
||||
|
||||
@@ -16,7 +16,7 @@ class PhysTestBall : ActorWithPhysics(Actor.RenderOrder.MIDDLE, immobileBody = t
|
||||
|
||||
init {
|
||||
setHitboxDimension(16, 16, 0, 0)
|
||||
mass = 10.0
|
||||
avBaseMass = 10.0
|
||||
density = 200.0
|
||||
|
||||
color = RoguelikeRandomiser.composeColourFrom(RoguelikeRandomiser.POTION_PRIMARY_COLSET)
|
||||
|
||||
@@ -25,7 +25,7 @@ interface Pocketed {
|
||||
}
|
||||
|
||||
inventory.itemEquipped[item.equipPosition] = null
|
||||
item.effectOnUnequip(Terrarum.appgc, Terrarum.UPDATE_DELTA)
|
||||
item.effectOnUnequip(Terrarum.appgc, Terrarum.delta)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ interface Pocketed {
|
||||
|
||||
if (item.equipPosition >= 0) {
|
||||
inventory.itemEquipped[item.equipPosition] = item
|
||||
item.effectWhenEquipped(Terrarum.appgc, Terrarum.UPDATE_DELTA)
|
||||
item.effectWhenEquipped(Terrarum.appgc, Terrarum.delta)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,12 +55,13 @@ interface Pocketed {
|
||||
|
||||
|
||||
fun consumePrimary(item: InventoryItem) {
|
||||
if (item.primaryUse(Terrarum.appgc, Terrarum.UPDATE_DELTA))
|
||||
inventory.consumeItem(item) // consume on successful
|
||||
if (item.primaryUse(Terrarum.appgc, Terrarum.delta)) {
|
||||
inventory.consumeItem(this as Actor, item) // consume on successful
|
||||
}
|
||||
}
|
||||
|
||||
fun consumeSecondary(item: InventoryItem) {
|
||||
if (item.secondaryUse(Terrarum.appgc, Terrarum.UPDATE_DELTA))
|
||||
inventory.consumeItem(item) // consume on successful
|
||||
if (item.secondaryUse(Terrarum.appgc, Terrarum.delta))
|
||||
inventory.consumeItem(this as Actor, item) // consume on successful
|
||||
}
|
||||
}
|
||||
@@ -18,15 +18,17 @@ import org.newdawn.slick.Input
|
||||
*/
|
||||
object GameController {
|
||||
|
||||
private val ingame = Terrarum.ingame!!
|
||||
|
||||
// these four values can also be accessed with GameContainer.<varname>
|
||||
// e.g. gc.mouseTileX
|
||||
|
||||
/** position of the mouse (pixelwise) relative to the world (also, currently pointing world-wise coordinate, if the world coordinate is pixel-wise) */
|
||||
val mouseX: Float
|
||||
get() = (MapCamera.x + Terrarum.appgc.input.mouseX / (Terrarum.ingame?.screenZoom ?: 1f))
|
||||
get() = (MapCamera.x + Terrarum.appgc.input.mouseX / (ingame.screenZoom ?: 1f))
|
||||
/** position of the mouse (pixelwise) relative to the world (also, currently pointing world-wise coordinate, if the world coordinate is pixel-wise)*/
|
||||
val mouseY: Float
|
||||
get() = (MapCamera.y + Terrarum.appgc.input.mouseY / (Terrarum.ingame?.screenZoom ?: 1f))
|
||||
get() = (MapCamera.y + Terrarum.appgc.input.mouseY / (ingame.screenZoom ?: 1f))
|
||||
/** currently pointing tile coordinate */
|
||||
val mouseTileX: Int
|
||||
get() = (mouseX / FeaturesDrawer.TILE_SIZE).floorInt()
|
||||
@@ -35,81 +37,97 @@ object GameController {
|
||||
get() = (mouseY / FeaturesDrawer.TILE_SIZE).floorInt()
|
||||
|
||||
fun processInput(gc: GameContainer, delta: Int, input: Input) {
|
||||
if (Terrarum.ingame != null) {
|
||||
val ingame = Terrarum.ingame!!
|
||||
|
||||
|
||||
// actor process input
|
||||
if (!ingame.consoleHandler.isTakingControl) {
|
||||
if (ingame.canPlayerControl) {
|
||||
ingame.actorContainer.forEach {
|
||||
if (it is Controllable) {
|
||||
// disable control of actor if the actor is riding something?
|
||||
if ((it as ActorHumanoid).vehicleRiding != null) {
|
||||
it.vehicleRiding!!.processInput(gc, delta, input)
|
||||
}
|
||||
else {
|
||||
it.processInput(gc, delta, input)
|
||||
}
|
||||
// actor process input
|
||||
if (!ingame.consoleHandler.isTakingControl) {
|
||||
if (ingame.canPlayerControl) {
|
||||
ingame.actorContainer.forEach {
|
||||
if (it is Controllable) {
|
||||
// disable control of actor if the actor is riding something?
|
||||
if ((it as ActorHumanoid).vehicleRiding != null) {
|
||||
it.vehicleRiding!!.processInput(gc, delta, input)
|
||||
}
|
||||
else {
|
||||
it.processInput(gc, delta, input)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
ingame.uiContainer.forEach {
|
||||
it.processInput(gc, delta, input)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
ingame.consoleHandler.processInput(gc, delta, input)
|
||||
ingame.uiContainer.forEach {
|
||||
it.processInput(gc, delta, input)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
ingame.consoleHandler.processInput(gc, delta, input)
|
||||
}
|
||||
|
||||
|
||||
///////////////////
|
||||
// MOUSE CONTROL //
|
||||
///////////////////
|
||||
///////////////////
|
||||
// MOUSE CONTROL //
|
||||
///////////////////
|
||||
|
||||
// Use item: assuming the player has only one effective grip (EquipPosition.HAND_GRIP)
|
||||
if (ingame.player != null && ingame.canPlayerControl) {
|
||||
if (input.isMouseButtonDown(Terrarum.getConfigInt("mouseprimary")) || input.isMouseButtonDown(Terrarum.getConfigInt("mousesecondary"))) {
|
||||
val itemOnGrip = ingame.player!!.inventory.itemEquipped[InventoryItem.EquipPosition.HAND_GRIP]
|
||||
// Use item: assuming the player has only one effective grip (EquipPosition.HAND_GRIP)
|
||||
if (ingame.player != null && ingame.canPlayerControl) {
|
||||
if (input.isMouseButtonDown(Terrarum.getConfigInt("mouseprimary")) || input.isMouseButtonDown(Terrarum.getConfigInt("mousesecondary"))) {
|
||||
val itemOnGrip = ingame.player!!.inventory.itemEquipped[InventoryItem.EquipPosition.HAND_GRIP]
|
||||
|
||||
if (itemOnGrip != null) {
|
||||
if (input.isMouseButtonDown(Terrarum.getConfigInt("mouseprimary"))) {
|
||||
ingame.player!!.consumePrimary(itemOnGrip)
|
||||
}
|
||||
if (input.isMouseButtonDown(Terrarum.getConfigInt("mousesecondary"))) {
|
||||
ingame.player!!.consumeSecondary(itemOnGrip)
|
||||
}
|
||||
if (itemOnGrip != null) {
|
||||
if (input.isMouseButtonDown(Terrarum.getConfigInt("mouseprimary"))) {
|
||||
ingame.player!!.consumePrimary(itemOnGrip)
|
||||
}
|
||||
if (input.isMouseButtonDown(Terrarum.getConfigInt("mousesecondary"))) {
|
||||
ingame.player!!.consumeSecondary(itemOnGrip)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////
|
||||
// GAMEPAD CONTROL //
|
||||
/////////////////////
|
||||
}
|
||||
|
||||
|
||||
/////////////////////
|
||||
// GAMEPAD CONTROL //
|
||||
/////////////////////
|
||||
}
|
||||
|
||||
fun keyPressed(key: Int, c: Char) {
|
||||
|
||||
|
||||
|
||||
|
||||
if (ingame.canPlayerControl) {
|
||||
ingame.player?.keyPressed(key, c)
|
||||
}
|
||||
|
||||
if (Terrarum.getConfigIntArray("keyquickselalt").contains(key)
|
||||
|| key == Terrarum.getConfigInt("keyquicksel")) {
|
||||
ingame.uiPieMenu.setAsOpen()
|
||||
ingame.uiQuickBar.setAsClose()
|
||||
}
|
||||
|
||||
ingame.uiContainer.forEach { it.keyPressed(key, c) } // for KeyboardControlled UIcanvases
|
||||
}
|
||||
|
||||
fun keyReleased(key: Int, c: Char) {
|
||||
|
||||
if (Terrarum.getConfigIntArray("keyquickselalt").contains(key)
|
||||
|| key == Terrarum.getConfigInt("keyquicksel")) {
|
||||
ingame.uiPieMenu.setAsClose()
|
||||
ingame.uiQuickBar.setAsOpen()
|
||||
}
|
||||
|
||||
ingame.uiContainer.forEach { it.keyReleased(key, c) } // for KeyboardControlled UIcanvases
|
||||
}
|
||||
|
||||
fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||
|
||||
ingame.uiContainer.forEach { it.mouseMoved(oldx, oldy, newx, newy) } // for MouseControlled UIcanvases
|
||||
}
|
||||
|
||||
fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
|
||||
|
||||
ingame.uiContainer.forEach { it.mouseDragged(oldx, oldy, newx, newy) } // for MouseControlled UIcanvases
|
||||
}
|
||||
|
||||
fun mousePressed(button: Int, x: Int, y: Int) {
|
||||
|
||||
ingame.uiContainer.forEach { it.mousePressed(button, x, y) } // for MouseControlled UIcanvases
|
||||
}
|
||||
|
||||
fun mouseReleased(button: Int, x: Int, y: Int) {
|
||||
@@ -121,26 +139,29 @@ object GameController {
|
||||
|
||||
if (itemOnGrip != null) {
|
||||
if (button == Terrarum.getConfigInt("mousePrimary")) {
|
||||
itemOnGrip.endPrimaryUse(Terrarum.appgc, Terrarum.UPDATE_DELTA)
|
||||
itemOnGrip.endPrimaryUse(Terrarum.appgc, Terrarum.delta)
|
||||
}
|
||||
if (button == Terrarum.getConfigInt("mouseSecondary")) {
|
||||
itemOnGrip.endSecondaryUse(Terrarum.appgc, Terrarum.UPDATE_DELTA)
|
||||
itemOnGrip.endSecondaryUse(Terrarum.appgc, Terrarum.delta)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ingame.uiContainer.forEach { it.mouseReleased(button, x, y) } // for MouseControlled UIcanvases
|
||||
}
|
||||
}
|
||||
|
||||
fun mouseWheelMoved(change: Int) {
|
||||
|
||||
ingame.uiContainer.forEach { it.mouseWheelMoved(change) } // for MouseControlled UIcanvases
|
||||
}
|
||||
|
||||
fun controllerButtonPressed(controller: Int, button: Int) {
|
||||
|
||||
ingame.uiContainer.forEach { it.controllerButtonPressed(controller, button) } // for GamepadControlled UIcanvases
|
||||
}
|
||||
|
||||
fun controllerButtonReleased(controller: Int, button: Int) {
|
||||
|
||||
ingame.uiContainer.forEach { it.controllerButtonReleased(controller, button) } // for GamepadControlled UIcanvases
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -225,6 +225,8 @@ class GameWorld(val width: Int, val height: Int) {
|
||||
fun inflctTerrainDamage(x: Int, y: Int, damage: Float): Boolean {
|
||||
val addr = LandUtil.getTileAddr(x, y)
|
||||
|
||||
//println("[GameWorld] ($x, $y) Damage: $damage")
|
||||
|
||||
if (terrainDamages[addr] == null) { // add new
|
||||
terrainDamages[addr] = damage
|
||||
}
|
||||
@@ -238,7 +240,7 @@ class GameWorld(val width: Int, val height: Int) {
|
||||
//println("[GameWorld] accumulated damage: ${terrainDamages[addr]}")
|
||||
|
||||
// remove tile from the world
|
||||
if (terrainDamages[addr]!! >= TileCodex[getTileFromTerrain(x, y)].strength) {
|
||||
if (terrainDamages[addr] ?: 0f >= TileCodex[getTileFromTerrain(x, y)].strength) {
|
||||
setTileTerrain(x, y, 0)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.torvald.terrarum.itemproperties
|
||||
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
import net.torvald.terrarum.gameactors.sqrt
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-04-17.
|
||||
@@ -16,8 +15,8 @@ object Calculate {
|
||||
*
|
||||
* TODO Newtons as unit?
|
||||
*/
|
||||
fun pickaxePower(material: Material): Float {
|
||||
return 4f * material.forceMod.toFloat().sqrt()
|
||||
fun pickaxePower(actor: ActorHumanoid, material: Material): Float {
|
||||
return (4.0 * material.forceMod.toDouble().sqrt() * (actor.avStrength / 1000.0)).toFloat()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.torvald.terrarum.itemproperties
|
||||
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.ItemValue
|
||||
import net.torvald.terrarum.gameactors.ActorInventory
|
||||
import net.torvald.terrarum.gameactors.Pocketed
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
@@ -12,7 +14,7 @@ import org.newdawn.slick.GameContainer
|
||||
*/
|
||||
abstract class InventoryItem : Comparable<InventoryItem>, Cloneable {
|
||||
|
||||
abstract val id: Int
|
||||
abstract var id: Int
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -49,12 +51,23 @@ abstract class InventoryItem : Comparable<InventoryItem>, Cloneable {
|
||||
/** Single-use then destroyed (e.g. Tiles), aka negation of "stackable" */
|
||||
abstract var consumable: Boolean
|
||||
|
||||
/**
|
||||
* DYNAMIC means the item ID should be generated on the fly whenever the item is created.
|
||||
* This is to be used with weapons/armours/etc where multiple instances can exist, and
|
||||
* each of them should be treated as different item.
|
||||
*
|
||||
* ID Range: 32768..1048575 (ItemCodex.ITEM_DYNAMIC)
|
||||
*
|
||||
* The opposite of this is called STATIC and their example is a Block.
|
||||
*/
|
||||
open val isDynamic = false
|
||||
|
||||
/**
|
||||
* Where to equip the item
|
||||
*/
|
||||
open var equipPosition: Int = EquipPosition.NULL
|
||||
open val equipPosition: Int = EquipPosition.NULL
|
||||
|
||||
open var material: Material? = null
|
||||
open val material: Material? = null
|
||||
|
||||
/**
|
||||
* Apparent mass of the item. (basemass * scale^3)
|
||||
@@ -77,6 +90,7 @@ abstract class InventoryItem : Comparable<InventoryItem>, Cloneable {
|
||||
else
|
||||
throw NullPointerException("null input; nullify baseToolSize instead :p")
|
||||
}
|
||||
var originalID = id
|
||||
|
||||
/**
|
||||
* Scale of the item.
|
||||
@@ -226,4 +240,14 @@ abstract class InventoryItem : Comparable<InventoryItem>, Cloneable {
|
||||
|
||||
return clonedItem
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun generateNewDynamicID(inventory: ActorInventory): Int {
|
||||
var ret: Int
|
||||
do {
|
||||
ret = HQRNG().nextInt(ItemCodex.ITEM_DYNAMIC.endInclusive + 1 - ItemCodex.ITEM_DYNAMIC.first) + ItemCodex.ITEM_DYNAMIC.first
|
||||
} while (inventory.contains(ret))
|
||||
return ret
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ object ItemCodex {
|
||||
// tile items (blocks and walls are the same thing basically)
|
||||
for (i in ITEM_TILES + ITEM_WALLS) {
|
||||
itemCodex[i] = object : InventoryItem() {
|
||||
override val id: Int = i
|
||||
override var id: Int = i
|
||||
override val isUnique: Boolean = false
|
||||
override var baseMass: Double = TileCodex[i].density / 1000.0
|
||||
override var baseToolSize: Double? = null
|
||||
@@ -54,6 +54,7 @@ object ItemCodex {
|
||||
override val originalName = TileCodex[i % ITEM_WALLS.first].nameKey
|
||||
override var consumable = true
|
||||
override var inventoryCategory = Category.BLOCK
|
||||
override var isDynamic = true
|
||||
|
||||
init {
|
||||
itemProperties[IVKey.ITEMTYPE] = if (i in ITEM_TILES)
|
||||
@@ -103,19 +104,19 @@ object ItemCodex {
|
||||
|
||||
// test copper pickaxe
|
||||
itemCodex[ITEM_STATIC.first] = object : InventoryItem() {
|
||||
override val id = ITEM_STATIC.first
|
||||
override var id = ITEM_STATIC.first
|
||||
override val isUnique = false
|
||||
override val originalName = "Test Pick"
|
||||
override var baseMass = 10.0
|
||||
override var baseToolSize: Double? = 10.0
|
||||
override var consumable = false
|
||||
override var maxDurability = 147//606 // this much tiles before breaking
|
||||
override var maxDurability = 64//606 // this much tiles before breaking
|
||||
override var durability = maxDurability.toFloat()
|
||||
override var equipPosition = EquipPosition.HAND_GRIP
|
||||
override var inventoryCategory = Category.TOOL
|
||||
|
||||
private val testmaterial = Material(
|
||||
0,0,0,0,0,0,0,0,14,0.0 // quick test material Steel
|
||||
0,0,0,0,0,0,0,0,1,0.0 // quick test material Stone
|
||||
)
|
||||
|
||||
init {
|
||||
@@ -131,6 +132,7 @@ object ItemCodex {
|
||||
using = true
|
||||
|
||||
// linear search filter (check for intersection with tilewise mouse point and tilewise hitbox)
|
||||
// return false if hitting actors
|
||||
Terrarum.ingame!!.actorContainer.forEach {
|
||||
if (it is ActorWithPhysics && it.tilewiseHitbox.intersects(mousePoint))
|
||||
return false
|
||||
@@ -144,11 +146,12 @@ object ItemCodex {
|
||||
// filter passed, do the job
|
||||
val swingDmgToFrameDmg = delta.toDouble() / actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!!
|
||||
|
||||
return Terrarum.ingame!!.world.inflctTerrainDamage(
|
||||
Terrarum.ingame!!.world.inflctTerrainDamage(
|
||||
gc.mouseTileX,
|
||||
gc.mouseTileY,
|
||||
Calculate.pickaxePower(testmaterial) * swingDmgToFrameDmg.toFloat()
|
||||
Calculate.pickaxePower(Terrarum.ingame!!.player!!, testmaterial) * swingDmgToFrameDmg.toFloat()
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
override fun endPrimaryUse(gc: GameContainer, delta: Int): Boolean {
|
||||
@@ -164,6 +167,9 @@ object ItemCodex {
|
||||
// read from save (if applicable) and fill dynamicItemDescription
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns clone of the item in the Codex
|
||||
*/
|
||||
operator fun get(code: Int): InventoryItem {
|
||||
if (code <= ITEM_STATIC.endInclusive) // generic item
|
||||
return itemCodex[code]!!.clone() // from CSV
|
||||
|
||||
@@ -158,7 +158,7 @@ class PeripheralVideoCard(val host: TerrarumComputer, val termW: Int = 80, val t
|
||||
private val spriteBuffer = ImageBuffer(VSprite.width * 2, VSprite.height)
|
||||
|
||||
fun render(g: Graphics) {
|
||||
cursorBlinkTimer += Terrarum.UPDATE_DELTA
|
||||
cursorBlinkTimer += Terrarum.delta
|
||||
if (cursorBlinkTimer > cursorBlinkTime) {
|
||||
cursorBlinkTimer -= cursorBlinkTime
|
||||
cursorBlinkOn = !cursorBlinkOn
|
||||
|
||||
@@ -151,7 +151,7 @@ object WeatherMixer {
|
||||
// interpolate R, G and B
|
||||
val scale = (timeInSec % dataPointDistance).toFloat() / dataPointDistance // [0.0, 1.0]
|
||||
|
||||
val newCol = CIELChabUtil.getGradient(scale, colourThis, colourNext)
|
||||
val newCol = CIELabUtil.getGradient(scale, colourThis, colourNext)
|
||||
|
||||
/* // very nice monitor code
|
||||
// 65 -> 66 | 300 | 19623 | RGB8(255, 0, 255) -[41%]-> RGB8(193, 97, 23) | * `230`40`160`
|
||||
|
||||
14
work_files/GameDesign/ECONOMY.md
Normal file
14
work_files/GameDesign/ECONOMY.md
Normal file
@@ -0,0 +1,14 @@
|
||||
## Economy ##
|
||||
|
||||
Ref. How EVE Online's economy works and controlled
|
||||
|
||||
* Mobs/People can be killed, and they drop resources: THEY PRINTS MONEY.
|
||||
* If players die, some of (50 %?) their items are lost, forcing them to spend their money and resources.
|
||||
* Items break, also forcing them to spend money (see below:)
|
||||
|
||||
### Resource management ###
|
||||
|
||||
* Tools/Weapons have durability
|
||||
- And NOTHING IS INDESTRUCTIBLE (just cooldown time if they are "endgame" items, but not the weapon with highest damage -- see how Master Sword works in Zelda BotW)
|
||||
- Relevant UIs are completed, so no turning back --Torvald, 2017-04-22
|
||||
|
||||
@@ -42,13 +42,12 @@ Gemstones go elemental?! (pretty generic but otherwise there are no motivations
|
||||
|
||||
## Colouring ##
|
||||
|
||||
Natural: Use 4096
|
||||
Magical/Surreal: Use 24 Bits
|
||||
Artificial: Use 4096
|
||||
|
||||
* Colouring of potion
|
||||
- Randomised, roguelike fashion
|
||||
- Choose Col(R40, G40, B40) from set of finite cards:
|
||||
39, 39, 19, 19, 0, 0
|
||||
- Choose Col(RGB) from set of finite cards:
|
||||
255, 255, 128, 128, 0, 0
|
||||
- MULTIPLY blend chosen colour with white texture
|
||||
|
||||
|
||||
@@ -146,15 +145,9 @@ see SAVE_FORMAT.md
|
||||
- Health: Regen per time
|
||||
- Magic: Out power per time
|
||||
- "I somewhat doubt this now..." --Torvald, 2017-03-12
|
||||
- "It won't work." --Torvald, 2017-04-22
|
||||
|
||||
|
||||
## Resource management ##
|
||||
|
||||
* Tools/Weapons have durability
|
||||
- And NOTHING IS INDESTRUCTIBLE (just cooldown time if they are "endgame" items, but not the weapon with highest damage -- see how Master Sword works in Zelda BotW)
|
||||
- Hookshots are the exception!
|
||||
- I was against it, but now I think it would make the game more playable --Torvald, 2017-03-12
|
||||
|
||||
|
||||
## Civilisation ##
|
||||
|
||||
Binary file not shown.
21
work_files/dwarven_name_selector/dwarvenNameSelector.py
Normal file
21
work_files/dwarven_name_selector/dwarvenNameSelector.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from random import randint
|
||||
|
||||
size = 128
|
||||
|
||||
names = []
|
||||
keys = range(1, size + 1)
|
||||
|
||||
|
||||
with open("language_DWARF.txt") as f:
|
||||
names = [line.rstrip('\n') for line in f]
|
||||
|
||||
|
||||
for i in range(0, size):
|
||||
r = randint(0, size - 1)
|
||||
t = keys[i]
|
||||
keys[i] = keys[r]
|
||||
keys[r] = t
|
||||
|
||||
|
||||
for i in range(0, size):
|
||||
print('"NAMESET_DWARVEN_%03d";"%s";') % (i + 1, names[keys[i]])
|
||||
2195
work_files/dwarven_name_selector/language_DWARF.txt
Normal file
2195
work_files/dwarven_name_selector/language_DWARF.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user