Level 120 (L1-L5): AVA2 maps, drops, dungeons, dungeon timer UI
- tools/server/level-120: sbtest install of the 120 exp table and the unsigned exp column. - tools/server/ava2-maps: the 10 AVA2 maps (pack, map data, regen, designed drops) for sbtest; Ava2MapsScript.inc, gr2 texture and mob_proto tests. - tools/server/ava2-dungeons: snow / ship defence / Meley quests ported from AVA2 (make_quests.py + install.sh). - mt_dungeon_timer (DungeonTimerScript.inc): AVA2 dungeon timer in place of the minimap (RefreshDungeonTimer) and the hydra mast HP bar (gethydrahp). - Autohunt skips a target that is hit but takes no damage for 4 s (blocked Meley statues) and keeps it skipped for 60 s; FindCloseTarget now honours the skip list. Meley full run passed on sbtest with the Mac client. Not deployed live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
657e49e52a
commit
a1e7da68a4
@@ -0,0 +1,15 @@
|
||||
// PORT: lists the texture paths named by each Granny model, for staging map/mob packs (tools/server/ava2-maps).
|
||||
// stdin: one model path per line; stdout: "TEX\t<model>\t<texture>" lines, then "OK\t<model>" or "ERR\t<model>\t<why>".
|
||||
#include <gr2/gr2.h>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
int main() {
|
||||
std::string path;
|
||||
while(std::getline(std::cin,path)) {
|
||||
gr2::LoadError e;auto f=gr2::File::load_path(path,&e);
|
||||
if(!f){std::printf("ERR\t%s\t%s %s\n",path.c_str(),e.stage.c_str(),e.message.c_str());continue;}
|
||||
for(auto& m:gr2::dump_materials(*f))for(auto& t:m.all_textures)std::printf("TEX\t%s\t%s\n",path.c_str(),t.c_str());
|
||||
std::printf("OK\t%s\n",path.c_str());std::fflush(stdout);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
// PORT: adds or replaces whole mob_proto records (TMobTable, 40250 layout); untouched records stay byte-identical.
|
||||
// Row: vnum type rank battle_type level size gold_min gold_max exp max_hp regen_cycle regen_pct def
|
||||
// ai_flag race_flag immune_flag str dex con int dam_min dam_max attack_speed move_speed aggressive_hp_pct
|
||||
// aggressive_sight attack_range enchant0..5 resist0..10 resurrection_vnum drop_item_vnum mount_capacity
|
||||
// on_click empire dam_multiply summon drain_sp color polymorph_item (skill_vnum skill_level)x5
|
||||
// berserk stoneskin godspeed deathblow revive \t folder \t name
|
||||
#include "GameLib/StdAfx.h"
|
||||
#include "UserInterface/StdAfx.h"
|
||||
#include "UserInterface/PythonNonPlayer.h"
|
||||
#include "EterBase/lzo.h"
|
||||
#include <array>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
using Mob=CPythonNonPlayer::TMobTable;
|
||||
static constexpr std::array<DWORD,4> mob_key{{4813894,18955,552631,6822045}};
|
||||
static constexpr size_t kFields=69;
|
||||
static std::vector<BYTE> read_file(const char* path){
|
||||
std::ifstream stream(path,std::ios::binary);
|
||||
if(!stream)throw std::runtime_error("cannot read proto");
|
||||
return {std::istreambuf_iterator<char>(stream),std::istreambuf_iterator<char>()};
|
||||
}
|
||||
static DWORD word(const std::vector<BYTE>& data,size_t offset){
|
||||
if(offset+4>data.size())throw std::runtime_error("truncated proto");
|
||||
DWORD value;std::memcpy(&value,data.data()+offset,4);return value;
|
||||
}
|
||||
static void put_word(std::vector<BYTE>& data,size_t offset,DWORD value){std::memcpy(data.data()+offset,&value,4);}
|
||||
static void dump(const Mob& r){
|
||||
std::printf("%u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %d %d %u %u %u",r.dwVnum,r.bType,r.bRank,r.bBattleType,r.bLevel,r.bSize,
|
||||
r.dwGoldMin,r.dwGoldMax,r.dwExp,r.dwMaxHP,r.bRegenCycle,r.bRegenPercent,r.wDef,r.dwAIFlag,r.dwRaceFlag,r.dwImmuneFlag,
|
||||
r.bStr,r.bDex,r.bCon,r.bInt,r.dwDamageRange[0],r.dwDamageRange[1],r.sAttackSpeed,r.sMovingSpeed,r.bAggresiveHPPct,r.wAggressiveSight,r.wAttackRange);
|
||||
for(auto value:r.cEnchants)std::printf(" %d",int(value));
|
||||
for(auto value:r.cResists)std::printf(" %d",int(value));
|
||||
std::printf(" %u %u %u %u %u %g %u %u %u %u",r.dwResurrectionVnum,r.dwDropItemVnum,r.bMountCapacity,r.bOnClickType,r.bEmpire,
|
||||
r.fDamMultiply,r.dwSummonVnum,r.dwDrainSP,r.dwMonsterColor,r.dwPolymorphItemVnum);
|
||||
for(const auto& skill:r.Skills)std::printf(" %u %u",skill.dwVnum,skill.bLevel);
|
||||
std::printf(" %u %u %u %u %u\t%.*s\t%.*s\n",r.bBerserkPoint,r.bStoneSkinPoint,r.bGodSpeedPoint,r.bDeathBlowPoint,r.bRevivePoint,
|
||||
int(strnlen(r.szFolder,sizeof(r.szFolder))),r.szFolder,int(strnlen(r.szLocaleName,sizeof(r.szLocaleName))),r.szLocaleName);
|
||||
}
|
||||
static Mob parse(const std::string& line){
|
||||
auto second=line.rfind('\t');if(second==std::string::npos||second==0)throw std::runtime_error("mob row without name");
|
||||
auto first=line.rfind('\t',second-1);if(first==std::string::npos)throw std::runtime_error("mob row without folder");
|
||||
const std::string name=line.substr(second+1),folder=line.substr(first+1,second-first-1);
|
||||
std::istringstream stream(line.substr(0,first));std::array<double,kFields> f{};
|
||||
for(auto& value:f)if(!(stream>>value))throw std::runtime_error("mob row: "+line.substr(0,40));
|
||||
double extra;if(stream>>extra)throw std::runtime_error("mob row has extra columns");
|
||||
if(name.size()>CHARACTER_NAME_MAX_LEN)throw std::runtime_error("mob name too long");
|
||||
if(folder.size()>64)throw std::runtime_error("mob folder too long");
|
||||
Mob r{};size_t i=0;auto n=[&]{return static_cast<long long>(f[i++]);};
|
||||
r.dwVnum=n();r.bType=n();r.bRank=n();r.bBattleType=n();r.bLevel=n();r.bSize=n();
|
||||
r.dwGoldMin=n();r.dwGoldMax=n();r.dwExp=n();r.dwMaxHP=n();r.bRegenCycle=n();r.bRegenPercent=n();r.wDef=n();
|
||||
r.dwAIFlag=n();r.dwRaceFlag=n();r.dwImmuneFlag=n();r.bStr=n();r.bDex=n();r.bCon=n();r.bInt=n();
|
||||
r.dwDamageRange[0]=n();r.dwDamageRange[1]=n();r.sAttackSpeed=n();r.sMovingSpeed=n();r.bAggresiveHPPct=n();
|
||||
r.wAggressiveSight=n();r.wAttackRange=n();
|
||||
for(auto& value:r.cEnchants)value=n();
|
||||
for(auto& value:r.cResists)value=n();
|
||||
r.dwResurrectionVnum=n();r.dwDropItemVnum=n();r.bMountCapacity=n();r.bOnClickType=n();r.bEmpire=n();
|
||||
r.fDamMultiply=float(f[i++]);r.dwSummonVnum=n();r.dwDrainSP=n();r.dwMonsterColor=n();r.dwPolymorphItemVnum=n();
|
||||
for(auto& skill:r.Skills){skill.dwVnum=n();skill.bLevel=n();}
|
||||
r.bBerserkPoint=n();r.bStoneSkinPoint=n();r.bGodSpeedPoint=n();r.bDeathBlowPoint=n();r.bRevivePoint=n();
|
||||
std::memcpy(r.szName,name.data(),name.size());std::memcpy(r.szLocaleName,name.data(),name.size());
|
||||
std::memcpy(r.szFolder,folder.data(),folder.size());
|
||||
return r;
|
||||
}
|
||||
int main(int argc,char** argv) {
|
||||
const bool dumping=argc==3&&!std::strcmp(argv[1],"--dump");
|
||||
if(argc!=4&&!dumping){std::fprintf(stderr,"usage: mob_proto_patch in_proto rows.tsv out_proto | --dump proto\n");return 2;}
|
||||
if(dumping)argv[1]=argv[2];
|
||||
try {
|
||||
static CLZO lzo; auto key=mob_key;
|
||||
auto input=read_file(argv[1]);
|
||||
if(input.size()<12 || std::memcmp(input.data(),"MMPT",4))throw std::runtime_error("mob proto signature");
|
||||
CLZObject decoded;
|
||||
if(!CLZO::Instance().Decompress(decoded,input.data()+12,key.data()))throw std::runtime_error("mob proto decode");
|
||||
if(decoded.GetSize()!=size_t(word(input,4))*sizeof(Mob))throw std::runtime_error("proto count/size mismatch");
|
||||
std::map<DWORD,Mob> rows;
|
||||
for(DWORD i=0;i<word(input,4);++i){Mob r;std::memcpy(&r,decoded.GetBuffer()+i*sizeof(Mob),sizeof(Mob));rows[r.dwVnum]=r;}
|
||||
if(dumping){for(const auto& pair:rows)dump(pair.second);return 0;}
|
||||
std::ifstream file(argv[2],std::ios::binary);std::string line;size_t added=0,replaced=0;
|
||||
while(std::getline(file,line)) {
|
||||
if(line.empty())continue;
|
||||
const Mob r=parse(line);
|
||||
(rows.count(r.dwVnum)?replaced:added)++;rows[r.dwVnum]=r;
|
||||
}
|
||||
std::vector<BYTE> plain;for(const auto& pair:rows){const BYTE* bytes=reinterpret_cast<const BYTE*>(&pair.second);plain.insert(plain.end(),bytes,bytes+sizeof(Mob));}
|
||||
CLZObject encoded;if(!CLZO::Instance().CompressEncryptedMemory(encoded,plain.data(),plain.size(),key.data()))throw std::runtime_error("encode");
|
||||
std::vector<BYTE> result(input.begin(),input.begin()+12);put_word(result,4,rows.size());put_word(result,8,encoded.GetSize());
|
||||
result.insert(result.end(),encoded.GetBuffer(),encoded.GetBuffer()+encoded.GetSize());
|
||||
CLZObject verified;if(!CLZO::Instance().Decompress(verified,result.data()+12,key.data()) || verified.GetSize()!=plain.size() || std::memcmp(verified.GetBuffer(),plain.data(),plain.size()))throw std::runtime_error("round-trip");
|
||||
std::ofstream out(argv[3],std::ios::binary|std::ios::trunc);
|
||||
if(!out.write(reinterpret_cast<const char*>(result.data()),result.size()))throw std::runtime_error("cannot write proto");
|
||||
std::printf("mobs added=%zu replaced=%zu total=%zu; verified round-trip\n",added,replaced,rows.size());return 0;
|
||||
}catch(const std::exception& e){std::fprintf(stderr,"%s\n",e.what());return 1;}
|
||||
}
|
||||
Reference in New Issue
Block a user