- Joined
- Oct 12, 2011
- Messages
- 3,449
Anyone knows a nice damage calculation for RPG game? I have googled it around and some people said that some kind of damage calculations took about 500 lines of codes. o 0
I only use variables like damage min, damage max, and defense by the way. I hope that someone can help me thnks..
EDIT: I meant dont use "damage final=(random from damage min to damage max) - defense". it's bad calculation..
EDIT 2
I have a new problem here.. I have a formula like this
here is the formula
I think the problem is the formula is too long or complex. where if I use a simple calculation it works normally, or anyone knows another reason?
I had tried to separate the calculation into several variables
like
but it also wont works, sorry, I converted it to text using JNGP so that's the result..
I use unit level for unit's index at my library btw..
I only use variables like damage min, damage max, and defense by the way. I hope that someone can help me thnks..
EDIT: I meant dont use "damage final=(random from damage min to damage max) - defense". it's bad calculation..
EDIT 2
I have a new problem here.. I have a formula like this
-
Monster Attacks
- Events
- Conditions
-
Actions
-
Do Multiple ActionsFor each (Integer Hostile_Integer[4]) from 1 to Hostile_TotalOnMap, do (Actions)
-
Loop - Actions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Damage source) Equal to (==) Hostile_Unit[Hostile_Integer[4]]
-
Then - Actions
- Set Global_DamageMultiplier = 1
- Set Global_DefenseMultiplier = 1
- Game - Display to (All players) the text: a
- Set Hostile_Damage = (((Random integer number between Hostile_LibDamageMin[(Level of Hostile_Unit[Hostile_Integer[4]])] and Hostile_LibDamageMax[(Level of Hostile_Unit[Hostile_Integer[4]])]) x Global_DamageMultiplier) - (((Status_Defense x Global_DefenseMultiplier) x Status_Defen
- Game - Display to (All players) the text: b
- Set DamageEvent_Amount = Hostile_Damage
- Game - Display to (All players) the text: c
- Set DamageEvent_Target = MainUnit
- Game - Display to (All players) the text: d
- Set DamageEvent_Source = Hostile_Unit[Hostile_Integer[4]]
- Game - Display to (All players) the text: e
- Set DamageEvent_Type = physic
- Game - Display to (All players) the text: f
- Set DamageEvent_Real = 1.00
- Game - Display to (All players) the text: g
- Set DamageEvent_Real = 0.00
- Game - Display to (All players) the text: h
- Else - Actions
-
If - Conditions
-
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Do Multiple ActionsFor each (Integer Hostile_Integer[4]) from 1 to Hostile_TotalOnMap, do (Actions)
here is the formula
set udg_Hostile_Damage = ( ( GetRandomInt(udg_Hostile_LibDamageMin[GetUnitLevel(udg_Hostile_Unit[udg_Hostile_Integer[4]])], udg_Hostile_LibDamageMax[GetUnitLevel(udg_Hostile_Unit[udg_Hostile_Integer[4]])]) * udg_Global_DamageMultiplier ) - ( ( ( udg_Status_Defense * udg_Global_DefenseMultiplier ) * udg_Status_DefenseGauge_Current ) / udg_Status_DefenseGauge_Max ) )
I think the problem is the formula is too long or complex. where if I use a simple calculation it works normally, or anyone knows another reason?
I had tried to separate the calculation into several variables
like
set udg_Hostile_Damage[1] = GetRandomInt(udg_Hostile_LibDamageMin[GetUnitLevel(udg_Hostile_Unit[udg_Hostile_Integer[4]])], udg_Hostile_LibDamageMax[GetUnitLevel(udg_Hostile_Unit[udg_Hostile_Integer[4]])])
set udg_Hostile_Damage[2] = udg_Hostile_Damage[1] * udg_Global_DamageMultiplier
set udg_Hostile_Damage[3] = ( (udg_Status_Defense * udg_Global_DefenseMultiplier ) * udg_Status_DefenseGauge_Current ) / udg_Status_DefenseGauge_Max
set udg_Hostile_Damage[4] = udg_Hostile_Damage[2] - udg_Hostile_Damage[3]
set udg_DamageEvent_Amount = udg_Hostile_Damage[4]
but it also wont works, sorry, I converted it to text using JNGP so that's the result..
I use unit level for unit's index at my library btw..
Last edited by a moderator: