summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-08-04 16:10:54 -0300
committerJesusaves <cpntb1@ymail.com>2021-08-04 16:10:54 -0300
commitcbc4395890fdd7ca1794c7f75929348b4d19d421 (patch)
tree30c7d7f5800ea04883180979f2b024327236fcb3
parente184170fe599cae7b9b57a7db46c4c10b74a47bc (diff)
downloadserver-cbc4395890fdd7ca1794c7f75929348b4d19d421.tar.gz
server-cbc4395890fdd7ca1794c7f75929348b4d19d421.tar.bz2
server-cbc4395890fdd7ca1794c7f75929348b4d19d421.tar.xz
server-cbc4395890fdd7ca1794c7f75929348b4d19d421.zip
Send damage over the packets as well
-rw-r--r--battle/common.py4
-rw-r--r--battle/main.py11
-rw-r--r--battle/skills.py2
-rw-r--r--battle/spheres.py15
-rw-r--r--consts.py5
5 files changed, 25 insertions, 12 deletions
diff --git a/battle/common.py b/battle/common.py
index e9bf3ee..f359597 100644
--- a/battle/common.py
+++ b/battle/common.py
@@ -80,7 +80,7 @@ def calc_dmg(token, attacker, defender, base, crit=0.1):
# Attack all, scope can be: "enemy" or "party"
def attackall(token, atker, scope):
- for i in Battle[token][scope]:
+ for c, i in enumerate(Battle[token][scope]):
if (i["hp"] < 0):
continue
i["hp"]-=calc_dmg(token, atker, i, atker["atk"], 0.0)
@@ -88,6 +88,8 @@ def attackall(token, atker, scope):
# If passed with a negative value...
if (i["hp"] > i["max_hp"]):
i["hp"]=0+i["max_hp"]
+
+ #Battle[token]["log"].append(["party", idx, sphere, dmg, scope, c])
return False
# Find and return target ID in Battle[token][scope].
diff --git a/battle/main.py b/battle/main.py
index 4cd5f7c..bd9c90a 100644
--- a/battle/main.py
+++ b/battle/main.py
@@ -23,7 +23,7 @@ from consts import (CRYSTAL_MIN, CRYSTAL_MAX, EXPRATE_MIN, EXPRATE_MAX,
SFLAG_CLEARGEMS, SFLAG_DOUBLEGEMS, SFLAG_SPECIAL,
SFLAG_FIRSTLOOT, SFLAG_DOUBLEEXP, SFLAG_DOUBLEGP,
SPH_WIDEATTACK, SPH_PIERCE, SPH_ASSAULT, SPH_HEAL, SPH_HEALALL, SPH_ATKUP,
- SPH_DEFUP, SPH_NONE)
+ SPH_DEFUP, SPH_NONE, SRV_WAVE, SRV_SPHERE)
import json, random, traceback
import player
from battle.common import (find_target, check_enemy_alive, check_player_alive,
@@ -42,7 +42,7 @@ random.seed()
def advance_wave(token, world, quest_id, next_wave):
global Battle, allquests
Battle[token]["enemy"]=[]
- Battle[token]["log"].append(["WAVE", 0, True, "", 0])
+ Battle[token]["log"].append(["", 0, SRV_WAVE, 0, "", 0])
stdout("advance_wave was called")
quest=dl_search(allquests[world], "quest_id", quest_id)
@@ -360,7 +360,7 @@ def battle_endturn(token, spheres):
SPH_ATKUP,
SPH_DEFUP
])
- Battle[token]["log"].append(["SP", len(Battle[token]["spheres"]), sp, "", 0])
+ Battle[token]["log"].append(["spheres", len(Battle[token]["spheres"]), SRV_SPHERE, sp, "", 0])
Battle[token]["spheres"].append(sp)
stdout("Spheres added; Status before adjust: %s" % (str(Battle[token]["spheres"])), 2)
@@ -521,10 +521,11 @@ def battle(args, token):
target_id=find_target(token, "party")
stdout("ENEMY: Perform attack against %d" % target_id, 2)
target=Battle[token]["party"][target_id]
- target["hp"]-=calc_dmg(token, bat, target, bat["atk"])
+ dmg=calc_dmg(token, bat, target, bat["atk"])
+ target["hp"]-=dmg
Battle[token]["bp"]+=1
- Battle[token]["log"].append(["enemy", idx, SPH_NONE, "party", target_id])
+ Battle[token]["log"].append(["enemy", idx, SPH_NONE, dmg, "party", target_id])
stdout("ENEMY: Attack performed", 2)
# If HP ends up broken
diff --git a/battle/skills.py b/battle/skills.py
index e88a2ff..91bb990 100644
--- a/battle/skills.py
+++ b/battle/skills.py
@@ -81,7 +81,7 @@ def skill_core(token, mask, force, element):
def handle_skill(token, skill_id):
global Battle
# TODO
- #Battle[token]["log"].append(["who", 0, skill_id << ??, "target", 0])
+ #Battle[token]["log"].append(["who", 0, skill_id << ??, dmg, "target", 0])
return
diff --git a/battle/spheres.py b/battle/spheres.py
index d0e42b4..594636f 100644
--- a/battle/spheres.py
+++ b/battle/spheres.py
@@ -25,6 +25,7 @@ from battle.common import find_target, attackall, calc_dmg
def sphere_attack(token, unit, sphere, idx=0):
stdout("%s is attacking" % str(unit), 2)
stdout("Sphere selected: %d" % sphere, 2)
+ dmg = 0
# Select the enemy which should be attacked
target_id=find_target(token, "enemy")
@@ -37,15 +38,18 @@ def sphere_attack(token, unit, sphere, idx=0):
attackall(token, unit, "enemy")
elif (sphere == SPH_PIERCE):
# Pierce sphere (100% critical chance)
- target["hp"]-=calc_dmg(token, unit, target, unit["atk"], 1.0)
+ dmg = calc_dmg(token, unit, target, unit["atk"], 1.0)
+ target["hp"]-=dmg
elif (sphere == SPH_ASSAULT):
# Assault sphere (50% critical chance)
- target["hp"]-=calc_dmg(token, unit, target, unit["atk"], 0.5)
+ dmg = calc_dmg(token, unit, target, unit["atk"], 0.5)
+ target["hp"]-=dmg
elif (sphere == SPH_HEAL):
# Heal sphere (30% healing). Need to redefine target
target_id=find_target(token, "party")
target=Battle[token]["party"][target_id]
- target["hp"]+=int(target["max_hp"]*0.3)
+ dmg=-int(target["max_hp"]*0.3)
+ target["hp"]-=dmg
if (target["hp"] > target["max_hp"]):
target["hp"]=0+target["max_hp"]
elif (sphere == SPH_HEALALL):
@@ -56,7 +60,8 @@ def sphere_attack(token, unit, sphere, idx=0):
elif (sphere == SPH_NONE):
# Normal Attack
stdout("It's a normal attack!", 2)
- target["hp"]-=calc_dmg(token, unit, target, unit["atk"])
+ dmg=calc_dmg(token, unit, target, unit["atk"])
+ target["hp"]-=dmg
elif (sphere == SPH_ATKUP):
# Attack up sphere: Add SC_ATKUP to all members (even dead ones)
for target in Battle[token]["party"]:
@@ -74,6 +79,6 @@ def sphere_attack(token, unit, sphere, idx=0):
# We are done!
#stdout("Attack completed")
- Battle[token]["log"].append(["party", idx, sphere, "enemy", target_id])
+ Battle[token]["log"].append(["party", idx, sphere, dmg, "enemy", target_id])
return True
diff --git a/consts.py b/consts.py
index 6dd83d0..01fe345 100644
--- a/consts.py
+++ b/consts.py
@@ -51,6 +51,11 @@ SPH_HEALALL =5
SPH_ATKUP =6
SPH_DEFUP =7
+# Combat code
+SRV_SKILL =1000
+SRV_WAVE =9901
+SRV_SPHERE =9902
+
# Status Conditions
SC_ATKUP =1
SC_DEFUP =2