Damage - noonmaru/psychics GitHub Wiki
๊ฐ์
๊ฐ์ฒด์๊ฒ EsperAttribute์ ์์น๋ฅผ ์ด์ฉํด ํผํด๋ฅผ ์ ํ๋ ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค.
LivingEntity์ ํ์ฅํจ์๋ก ๋ง์ธํฌ๋ํํธ ๋ฐฉ์ด๋ ฅ๊ณผ ์ํธ์์ฉํ์ฌ ํผํด๋ฅผ ์ ํ ์ ์์ต๋๋ค.
์์
LivingEntity.psychicDamage (com.github.noonmaru.psychics.DamageSupport.kt์ ์ ์๋์ด์๋ ํ์ฅํจ์)
์ง์ Esper
๋ก๋ถํฐ EsperStatistics
๋ฅผ ์ด์ฉํด ๋ฅ๋ ฅ์น๋ฅผ ๊ฐ์ ธ์จ ์์น๋งํผ ํผํด๋ฅผ ์
ํ๋ ์ฝ๋์
๋๋ค.
class MyAbility : ActiveAbility<AbilityConcept>() {
init {
targeter = {
val eyeLocation = esper.player.eyeLocation
val direction = eyeLocation.direction
eyeLocation.world.rayTraceEntities(
eyeLocation,
direction, 64.0,
1.0
)
}
}
override fun onCast(target: Any?) {
// target = targetEntity
val targetEntity = target as LivingEntity
val stats = EsperStatistic.of(EsperAttribute.ATTACK_DAMAGE to 1.0)
val damageType = DamageType.RANGED
val damageAmount = esper.getStatistic(stats)
targetEntity.psychicDamage(
this, // ๊ณต๊ฒฉ์์ Ability
damageType, // ๋ฐ๋ฏธ์ง ํ์
damageAmount, // ๋ฐ๋ฏธ์ง๋
esper.player, // ๊ณต๊ฒฉ์ ํ๋ ์ด์ด
esper.player.location, // ๋๋ฐฑ ๊ธฐ์ค ์ขํ
1.0) // ๋๋ฐฑ ๊ฐ๋
}
}
LivingEntity.psychicDamage (com.github.noonmaru.psychics.Ability์ ์ ์๋์ด์๋ ๋ด๋ถ ํ์ฅํจ์)
์ ํ์ฅํจ์๋ฅผ com.github.noonmaru.damage.Damage
ํด๋์ค๋ฅผ ์ด์ฉํด ์กฐ๊ธ ๋ ๋ง๋ฒ์ ์ธ ๋ฐฉ๋ฒ์ผ๋ก ํธ์ถํฉ๋๋ค.
Ability๋ด์ ์ ์ธ๋์ด์๋ ํ์ฅํจ์์ด๋ฏ๋ก ๋ด๋ถ ์์ฑ์ ์ด์ฉํด ๋ฅ๋ ฅ ์ฌ์ฉ์์ ๋ฅ๋ ฅ์น๋ฅผ ๊ฐ์ ธ์ ํผํด๋์ ์ ์ฉํฉ๋๋ค.
class MyAbility : ActiveAbility<AbilityConcept>() {
init {
targeter = {
val eyeLocation = esper.player.eyeLocation
val direction = eyeLocation.direction
eyeLocation.world.rayTraceEntities(
eyeLocation,
direction, 64.0,
1.0
)
}
}
override fun onCast(target: Any?) {
// target = targetEntity
val targetEntity = target as LivingEntity
val damage = Damage(DamageType.RANGED, EsperStatistic.of(EsperAttribute.ATTACK_DAMAGE to 1.0))
targetEntity.psychicDamage(damage, esper.player.eyeLocation, 1.0)
}
}
AbilityConcept
์๋ damage์์ฑ์ด ์ ์๋์ด์์ต๋๋ค.
damage์์ฑ์ด null์ด ์๋๊ฒฝ์ฐ ์ด๋ฅผ ์ด์ฉํด ์๋์ฒ๋ผ ๊ฐ๋จํ๊ฒ ์ ์ฉํ ์ ์์ต๋๋ค.
class MyAbility : ActiveAbility<AbilityConcept>() {
init {
targeter = {
val eyeLocation = esper.player.eyeLocation
val direction = eyeLocation.direction
eyeLocation.world.rayTraceEntities(
eyeLocation,
direction, 64.0,
1.0
)
}
}
override fun onCast(target: Any?) {
// target = targetEntity
val targetEntity = target as LivingEntity
concept.damage?.let { targetEntity.psychicDamage(it) }
}
}