From 62ed0d6de914c5e4fd6a01cc8612483989c8b937 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 2 Jul 2021 10:41:36 +0800 Subject: [PATCH] Generate generic ai actions for magic damage --- .../extract_r2_required/creature_desc.tsv | 60 ++++++++++ .../extract_r2_required/generate_aiaction.py | 103 ++++++++++++++++++ ryzom/tools/extract_r2_required/readme.txt | 3 + 3 files changed, 166 insertions(+) create mode 100644 ryzom/tools/extract_r2_required/creature_desc.tsv create mode 100644 ryzom/tools/extract_r2_required/generate_aiaction.py diff --git a/ryzom/tools/extract_r2_required/creature_desc.tsv b/ryzom/tools/extract_r2_required/creature_desc.tsv new file mode 100644 index 000000000..1c093a7d3 --- /dev/null +++ b/ryzom/tools/extract_r2_required/creature_desc.tsv @@ -0,0 +1,60 @@ +arma +bul +c1 +c2 +c3 +c4 +c5 +c6 +c7 +capryni +cephaloplant +chonari +cococlaw +cute +dag +diranak +electroalgs +estrasson +filin +frahar +gibbai +h1 +h2 +h3 +h4 +h5 +h6 +h7 +h8 +h9 +h10 +h11 +h12 +hachtaha +jungler +kakty +kazoar +kitifly +kitihank +kitiharak +kitikil +kitimandib +kitinagan +kitinega +kitinokto +lightbird +mektoub +phytopsy +pucetron +regus +ryzerb +ryzoholo +ryzoholok +sap_enslaver +spitting_weeds +swarmplants +vampignon +varinx +yber +zerx diff --git a/ryzom/tools/extract_r2_required/generate_aiaction.py b/ryzom/tools/extract_r2_required/generate_aiaction.py new file mode 100644 index 000000000..ad2b50e52 --- /dev/null +++ b/ryzom/tools/extract_r2_required/generate_aiaction.py @@ -0,0 +1,103 @@ + +import os, zlib + +meleeSpec = [ "slashing", "piercing", "blunt" ] +curseSpec = [ "blind", "fear", "madness", "root", "sleep", "slow", "snare", "stun" ] +magicSpec = [ "acid", "cold", "rot", "fire", "poison", "electricity", "shockwave" ] + +variantSpec = [ "a", "b", "c", "d", "e", "f" ] # Newbie, Basic, Fine, Choice, Excellent, Supreme + +aiActionFolder = "R:\\leveldesign\\game_elem\\creature\\npc\\bestiary\\aiaction\\generic" +if not os.path.isdir(aiActionFolder): + os.makedirs(aiActionFolder) + +base = { + "combat": { + "fauna": meleeSpec, + "melee": meleeSpec, + "range": meleeSpec, + }, + # "hybrid": { + # "melee": meleeSpec * magicSpec, + # "range": meleeSpec * magicSpec, + # }, + "magic": { + "damage": magicSpec, + "dot": magicSpec, + "heal": [ "hp", "sap", "stamina", "focus" ], + "curse": curseSpec, + }, + # "debuff": { + # "skill": [ "melee", "range", "magic" ], + # "resist": magicSpec, + # }, +} + +# Damage +# ------ +# Total Magic Damage = DamageValue + (SpellPowerFactor * creature.AttackLevel) + +# Let's say 10k average total HP for homins and creatures at lvl 250 +# Linear increase of 40 HP per level, so 400 HP per 10 levels, or 200 HP every 5 levels +maxLevel = 250 +averageMaxHP = 10000 + +# Settle a fight in 10 seconds, that's an attack of 1000 at lvl 250 for a 1 second attack +# Add a base boost of 10 levels, that's 40 base attack +combatTime = 10 + +# Magic may do double the damage of melee +magicDamageBoost = 2 + +# Different boosts for each variant +variantBoost = { "a": 0.1, "b": 1.0, "c": 1.25, "d": 1.75, "e": 2.5, "f": 4.0 } +variantBaseLevel = { "a": 5, "b": 5, "c": 10, "d": 15, "e": 20, "f": 25 } +randomVariance = 0.1 # Random variance on the generated sheets + +# Spell time +spellBaseTime = 1 +spellRandomBaseTime = 2 +spellPostTime = 0.5 +spellRandomPostTime = 1 + +# magic_damage +for spec in magicSpec: + for variant in variantSpec: + name = "magic_damage_" + spec + "_" + variant + randBoostFactor = zlib.crc32("SpellPowerFactor" + name) & 0xffffffff + randBoostFactor = (((randBoostFactor % 2000) - 1000) * randomVariance) / 1000.0 + randBoostAdd = zlib.crc32("DamageValue" + name) & 0xffffffff + randBoostAdd = (((randBoostAdd % 2000) - 1000) * randomVariance) / 1000.0 + randBaseTime = zlib.crc32("CastingTime" + name) & 0xffffffff + randBaseTime = ((randBaseTime % 1000) * spellRandomBaseTime) / 1000.0 + randPostTime = zlib.crc32("PostActionTime" + name) & 0xffffffff + randPostTime = ((randPostTime % 1000) * spellRandomPostTime) / 1000.0 + baseTime = int((spellBaseTime + randBaseTime) * 10) * 0.1 + postTime = int((spellPostTime + randPostTime) * 10) * 0.1 + totalTime = baseTime + postTime + maxLevelDamage = (averageMaxHP * totalTime * magicDamageBoost) / combatTime + damagePerLevel = maxLevelDamage / maxLevel + damagePerLevelFactor = (damagePerLevel + (damagePerLevel * randBoostFactor)) * variantBoost[variant] + damageAdd = (damagePerLevel + (damagePerLevel * randBoostAdd)) * variantBaseLevel[variant] + behaviour = "CAST_" + spec.upper() + if behaviour == "CAST_ELECTRICITY": + behaviour = "CAST_ELEC" + if behaviour == "CAST_SHOCKWAVE": + behaviour = "CAST_SHOCK" + damageType = spec.upper() + if damageType == "SHOCKWAVE": + damageType = "SHOCK" + with open(aiActionFolder + "\\" + name + ".aiaction", "w") as f: + f.write("\n") + f.write("
\n") + f.write(" \n") + f.write(" \n") + f.write(" \n") + f.write(" \n") + f.write(" \n") + f.write(" \n") + f.write(" \n") + f.write(" \n") + f.write(" \n") + f.write(" \n") + f.write("
\n") diff --git a/ryzom/tools/extract_r2_required/readme.txt b/ryzom/tools/extract_r2_required/readme.txt index b14081782..b4d09ee2c 100644 --- a/ryzom/tools/extract_r2_required/readme.txt +++ b/ryzom/tools/extract_r2_required/readme.txt @@ -17,3 +17,6 @@ ring melee hands: blunt pierce slash ring magic hands: acid cold electricity fire poison rot shockwave ring magic curser hands: blind fear madness root sleep slow snare stun ring level: 1 2 3 4 +creature levels: a(0-20) b(20-50) c(50-100) d(100-150) e(150-200) f(200-250) +creature levels: b1 b2 b3 b4 (b5 b6 b7) - variants within the level range +