mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-16 00:26:07 +09:00
weponmeleecore
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -18,6 +18,7 @@ external_resource_packs.zip
|
|||||||
|
|
||||||
# IntelliJ
|
# IntelliJ
|
||||||
workspace.xml
|
workspace.xml
|
||||||
|
*/workspace.xml
|
||||||
|
|
||||||
# Temporary files
|
# Temporary files
|
||||||
.tmp*
|
.tmp*
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package net.torvald.random
|
package net.torvald.random
|
||||||
|
|
||||||
import java.util.Random
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-02-03.
|
* Created by minjaesong on 2016-02-03.
|
||||||
@@ -20,7 +20,7 @@ open class FudgeDice
|
|||||||
*/
|
*/
|
||||||
fun roll(): Int {
|
fun roll(): Int {
|
||||||
var diceResult = 0
|
var diceResult = 0
|
||||||
for (c in 0..diceCount - 1) {
|
for (c in 0 until diceCount) {
|
||||||
diceResult += rollSingleDie()
|
diceResult += rollSingleDie()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,12 +29,18 @@ open class FudgeDice
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Roll dice and get result, for array index
|
* Roll dice and get result, for array index
|
||||||
* @return Normally distributed integer [0 , N] for N = 2 × DiceCounts + 1. 0 is the most frequent return.
|
* @return Normally distributed integer [0 , N] for N = 2 × DiceCounts + 1. (diceCount) is the most frequent return.
|
||||||
*/
|
*/
|
||||||
fun rollForArray(): Int {
|
fun rollForArray(): Int {
|
||||||
return roll() + diceCount
|
return roll() + diceCount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun <T> rollForArray(array: Array<T>): T = array[rollForArray()]
|
||||||
|
fun rollForArray(intArray: IntArray): Int = intArray[rollForArray()]
|
||||||
|
fun rollForArray(longArray: LongArray): Long = longArray[rollForArray()]
|
||||||
|
fun rollForArray(floatArray: FloatArray): Float = floatArray[rollForArray()]
|
||||||
|
fun rollForArray(doubleArray: DoubleArray): Double = doubleArray[rollForArray()]
|
||||||
|
|
||||||
val sizeOfProbabilityRange: Int
|
val sizeOfProbabilityRange: Int
|
||||||
get() = 2 * diceCount + 1
|
get() = 2 * diceCount + 1
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class AppLoader implements ApplicationListener {
|
|||||||
* <p>
|
* <p>
|
||||||
* e.g. 0x02010034 will be translated as 2.1.52
|
* e.g. 0x02010034 will be translated as 2.1.52
|
||||||
*/
|
*/
|
||||||
public static final int VERSION_RAW = 0x00_02_04B1;
|
public static final int VERSION_RAW = 0x00_02_0590;
|
||||||
|
|
||||||
public static final String getVERSION_STRING() {
|
public static final String getVERSION_STRING() {
|
||||||
return String.format("%d.%d.%d", VERSION_RAW >>> 24, (VERSION_RAW & 0xff0000) >>> 16, VERSION_RAW & 0xFFFF);
|
return String.format("%d.%d.%d", VERSION_RAW >>> 24, (VERSION_RAW & 0xff0000) >>> 16, VERSION_RAW & 0xFFFF);
|
||||||
@@ -596,7 +596,13 @@ public class AppLoader implements ApplicationListener {
|
|||||||
);
|
);
|
||||||
fontSmallNumbers = TinyAlphNum.INSTANCE;
|
fontSmallNumbers = TinyAlphNum.INSTANCE;
|
||||||
|
|
||||||
audioDevice = Gdx.audio.newAudioDevice(48000, false);
|
try {
|
||||||
|
audioDevice = Gdx.audio.newAudioDevice(48000, false);
|
||||||
|
}
|
||||||
|
catch (NullPointerException deviceInUse) {
|
||||||
|
deviceInUse.printStackTrace();
|
||||||
|
System.err.println("[AppLoader] failed to create audio device: Audio device occupied by Exclusive Mode Device? (e.g. ASIO4all)");
|
||||||
|
}
|
||||||
|
|
||||||
// if there is a predefined screen, open that screen after my init process
|
// if there is a predefined screen, open that screen after my init process
|
||||||
if (injectScreen != null) {
|
if (injectScreen != null) {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ abstract class GameItem : Comparable<GameItem>, Cloneable {
|
|||||||
|
|
||||||
var nameColour = Color.WHITE
|
var nameColour = Color.WHITE
|
||||||
|
|
||||||
/** In kg */
|
/** In kg. Weapon with different material must have different mass. In this case, you MUST use IRON as a reference (or default) material. */
|
||||||
abstract var baseMass: Double
|
abstract var baseMass: Double
|
||||||
|
|
||||||
/** In kg */
|
/** In kg */
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package net.torvald.terrarum.modulebasegame.items
|
||||||
|
|
||||||
|
import net.torvald.random.Fudge3
|
||||||
|
import net.torvald.random.HQRNG
|
||||||
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||||
|
import kotlin.math.pow
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2019-03-17.
|
||||||
|
*/
|
||||||
|
object WeaponMeleeCore {
|
||||||
|
|
||||||
|
val SQRT2 = Math.sqrt(2.0)
|
||||||
|
|
||||||
|
private val dF3 = Fudge3(HQRNG())
|
||||||
|
private val randomiser = doubleArrayOf(0.94, 0.96, 0.98, 1.0, 1.02, 1.04, 1.06)
|
||||||
|
|
||||||
|
private fun randomise() = dF3.rollForArray(randomiser)
|
||||||
|
private fun getAttackMomentum(weapon: WeaponMeleeBase, actor: ActorHumanoid) =
|
||||||
|
weapon.mass * weapon.material.density * weapon.velocityMod * actor.scale.pow(SQRT2) // TODO multiply racial strength from RaceCodex
|
||||||
|
fun getAttackPower(weapon: WeaponMeleeBase, actor: ActorHumanoid, actee: ActorHumanoid) =
|
||||||
|
getAttackMomentum(weapon, actor) * randomise() * maxOf(1.0, (actee.hitbox.endY - actor.hitbox.startY) / actee.hitbox.height)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class WeaponMeleeBase : GameItem() {
|
||||||
|
abstract val velocityMod: Double
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ class SortedArrayList<T: Comparable<T>>(initialSize: Int = 10) {
|
|||||||
*/
|
*/
|
||||||
fun add(elem: T) {
|
fun add(elem: T) {
|
||||||
// don't append-at-tail-and-sort; just insert at right index
|
// don't append-at-tail-and-sort; just insert at right index
|
||||||
|
// this is a modified binary search to search the right "spot" where the insert elem fits
|
||||||
ReentrantLock().lock {
|
ReentrantLock().lock {
|
||||||
var low = 0
|
var low = 0
|
||||||
var high = arrayList.size
|
var high = arrayList.size
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user