added source folders

This commit is contained in:
purpleyouko committed 2025-08-11 11:09:09 -05:00
1 parent f23521f720
commit cfdc19df45
145 files changed
+54574

No files matched your search

File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+247
View File
@@ -0,0 +1,247 @@
// Props to ExJam for this code :D
#define AIACT(act) int F_AI_ACT_ ## act (class CWorldServer* server, class CCharacter* entity, byte* raw)
typedef int (*fpAiAct)(class CWorldServer*, class CCharacter*, byte*);
#define GETAIACTDATA(act) STR_AI_ACT_ ## act * data = (STR_AI_ACT_ ## act *)raw;
AIACT(000);AIACT(001);AIACT(002);
AIACT(003);AIACT(004);AIACT(005);
AIACT(006);AIACT(007);AIACT(008);
AIACT(009);AIACT(010);AIACT(011);
AIACT(012);AIACT(013);AIACT(014);
AIACT(015);AIACT(016);AIACT(017);
AIACT(018);AIACT(019);AIACT(020);
AIACT(021);AIACT(022);AIACT(023);
AIACT(024);AIACT(025);AIACT(026);
AIACT(027);AIACT(028);AIACT(029);
AIACT(030);AIACT(031);AIACT(032);
AIACT(033);AIACT(034);AIACT(035);
AIACT(036);AIACT(037);AIACT(038);
#define AI_ACT_COUNT 38
struct STR_AI_ACT_000 {
//Unknown (0x00 bytes)
};
struct STR_AI_ACT_001 {
//Do Action (0x04 bytes)
byte cAction; //Pos: 0x00
};
struct STR_AI_ACT_002 {
//Say LTB String (0x04 bytes)
dword iStrID; //Pos: 0x00
};
struct STR_AI_ACT_003 {
//Move (1) (0x08 bytes)
dword iDistance; //Pos: 0x00
byte cSpeed; //Pos: 0x04
};
struct STR_AI_ACT_004 {
//Move (2) (0x08 bytes)
dword iDistance; //Pos: 0x00
byte cSpeed; //Pos: 0x04
};
struct STR_AI_ACT_005 {
//Move (3) (0x04 bytes)
byte cSpeed; //Pos: 0x00
};
struct STR_AI_ACT_006 {
//Move (?) (0x08 bytes)
dword iDistance; //Pos: 0x00
byte cAbType; //Pos: 0x04
byte cMoreLess; //Pos: 0x05
};
struct STR_AI_ACT_007 {
//Unknown (0x00 bytes)
};
struct STR_AI_ACT_008 {
//Move (4) (0x08 bytes)
dword iDistance; //Pos: 0x00
byte cSpeed; //Pos: 0x04
};
struct STR_AI_ACT_009 {
//Spawn Monster (1) (0x04 bytes)
word wMonster; //Pos: 0x00
};
struct STR_AI_ACT_010 {
//Spawn Monster (2) (0x04 bytes)
word wMonster; //Pos: 0x00
};
struct STR_AI_ACT_011 {
//Spawn Monster (3) (0x08 bytes)
int iDistance; //Pos: 0x00
int iNumOfMonster; //Pos: 0x04
};
struct STR_AI_ACT_012 {
//Unknown (0x00 bytes)
};
struct STR_AI_ACT_013 {
//Unknown (0x00 bytes)
};
struct STR_AI_ACT_014 {
//Unknown (0x04 bytes)
int iDistance; //Pos: 0x00
};
struct STR_AI_ACT_015 {
//Retaliate ? (0x00 bytes)
};
struct STR_AI_ACT_016 {
//Unknown (0x04 bytes)
int iDistance; //Pos: 0x00
};
struct STR_AI_ACT_017 {
//Drop Item (0x10 bytes)
word items[6];
byte btToOwner; //Pos: 0x0c
};
struct STR_AI_ACT_018 {
//Spawn Monster (4) (0x08 bytes)
short cMonster; //Pos: 0x00
short wHowMany; //Pos: 0x02
int iDistance; //Pos: 0x04
};
struct STR_AI_ACT_019 {
//Unknown (0x00 bytes)
};
struct STR_AI_ACT_020 {
//Spawn Monster (5) (0x08 bytes)
word cMonster; //Pos: 0x00
byte btPos; //Pos: 0x02
int iDistance; //Pos: 0x04
};
struct STR_AI_ACT_021 {
//Unknown (0x00 bytes)
};
struct STR_AI_ACT_022 {
//Unknown (0x00 bytes)
};
struct STR_AI_ACT_023 {
//Unknown (0x00 bytes)
};
struct STR_AI_ACT_024 {
//Do Skill (0x08 bytes)
byte btTarget; //Pos: 0x00
word nSkill; //Pos: 0x02
word nMotion; //Pos: 0x04
};
struct STR_AI_ACT_025
{
//Set Variable (1) (0x0c bytes)
union
{
byte btVarIDX; //Pos: 0x00
char cVarIdx[4];
};
dword iValue; //Pos: 0x04
byte btOp; //Pos: 0x08
};
struct STR_AI_ACT_026 {
//Set Variable (2) (0x00 bytes)
union{word nVarNo; //Pos: 0x00
char cVarNo[4];};
dword iValue; //Pos: 0x04
byte btOp; //Pos: 0x08
};
struct STR_AI_ACT_027 {
//Set Variable (3) (0x00 bytes)
union{word nVarNo; //Pos: 0x00
char cVarNo[4];};
dword iValue; //Pos: 0x04
byte btOp; //Pos: 0x08
};
struct STR_AI_ACT_028
{
//Shout/Ann LTB String (0x08 bytes)
union
{
byte btMsgType;
int iMsgType;
};
dword iStrID; //Pos: 0x04
};
struct STR_AI_ACT_029 {
//Unknown (0x00 bytes)
};
struct STR_AI_ACT_030 {
//Do Trigger (0x0d bytes)
word lenszTrigger; //Pos: 0x00
char* szTrigger; //Pos: 0x02
};
struct STR_AI_ACT_031 {
//Unknown (0x00 bytes)
};
struct STR_AI_ACT_032 {
//Zone (1) (0x04 bytes)
word nZoneNo; //Pos: 0x00
byte btOnOff; //Pos: 0x02
};
struct STR_AI_ACT_033 {
//Zone (2) (0x00 bytes)
};
struct STR_AI_ACT_034 {
//Item (?) (0x04 bytes)
word nItemNum; //Pos: 0x00
word nCount; //Pos: 0x02
};
struct STR_AI_ACT_035 {
//Set Variable (4) (0x0c bytes)
union{word nVarIDX; //Pos: 0x00
char cVarIdx[4];};
dword iValue; //Pos: 0x04
byte btOp; //Pos: 0x08
};
struct STR_AI_ACT_036 {
//Monster (1) (0x04 bytes)
word nMonster; //Pos: 0x00
byte btMaster; //Pos: 0x02
};
struct STR_AI_ACT_037 {
//Monster (2) (0x0c bytes)
word nMonster; //Pos: 0x00
byte nPos; //Pos: 0x02
dword iDistance; //Pos: 0x04
byte btMaster; //Pos: 0x08
};
struct STR_AI_ACT_038
{
//TDEF set destiny position
byte cSpeed;
};
File diff suppressed because it is too large. Load diff
+266
View File
@@ -0,0 +1,266 @@
// Props to ExJam for this code :D
#define AICOND(cond) int F_AI_COND_ ## cond (class CWorldServer* server, class CCharacter* entity, byte* raw)
typedef int (*fpAiCond)(class CWorldServer*, class CCharacter*, byte*);
#define GETAICONDDATA(cond) STR_AI_COND_ ## cond * data = (STR_AI_COND_ ## cond *)raw;
AICOND(000);AICOND(001);AICOND(002);
AICOND(003);AICOND(004);AICOND(005);
AICOND(006);AICOND(007);AICOND(008);
AICOND(009);AICOND(010);AICOND(011);
AICOND(012);AICOND(013);AICOND(014);
AICOND(015);AICOND(016);AICOND(017);
AICOND(018);AICOND(019);AICOND(020);
AICOND(021);AICOND(022);AICOND(023);
AICOND(024);AICOND(025);AICOND(026);
AICOND(027);AICOND(028);AICOND(029);
AICOND(030);AICOND(031);AICOND(032);
#define AI_COND_COUNT 33
struct STR_AI_COND_000
{
//Hold or Attack (0x04 bytes)
byte cNotfightOrDelay; //Pos: 0x00
};
struct STR_AI_COND_001
{
//Damage (0x08 bytes)
dword iDamage; //Pos: 0x00
byte cRecvOrGive; //Pos: 0x04
};
struct STR_AI_COND_002
{
//Check Near (1) (0x0c bytes)
int iDistance; //Pos: 0x00
union
{
byte btIsAllied; //Pos: 0x04
word nIsAllied;
};
short nLevelDiff; //Pos: 0x06
short nLevelDiff2; //Pos: 0x08
word wChrNum; //Pos: 0x0a
};
struct STR_AI_COND_003
{
//Check Distance (1) (0x04 bytes)
int iDistance; //Pos: 0x00
};
struct STR_AI_COND_004
{
//Check Distance (2) (0x08 bytes)
int iDistance; //Pos: 0x00
byte cMoreLess; //Pos: 0x04
};
struct STR_AI_COND_005
{
//Check AB (1) (0x0c bytes)
byte cAbType; //Pos: 0x00
int iDiff; //Pos: 0x04
byte cMoreLess; //Pos: 0x08
};
struct STR_AI_COND_006
{
//Check HP (0x08 bytes)
dword wHP; //Pos: 0x00
byte cMoreLess; //Pos: 0x04
};
struct STR_AI_COND_007
{
//Random Chance (0x04 bytes)
byte cPercent; //Pos: 0x00
};
struct STR_AI_COND_008
{
//Check Near (2) (0x0c bytes)
dword iDistance; //Pos: 0x00
short nLevelDiff; //Pos: 0x04
short nLevelDiff2; //Pos: 0x06
byte btIsAllied; //Pos: 0x08
};
struct STR_AI_COND_009
{
//Unknown (0x00 bytes)
};
struct STR_AI_COND_010
{
//Check AB (2) (0x04 bytes)
byte cAbType; //Pos: 0x00
byte cMoreLess; //Pos: 0x01
};
struct STR_AI_COND_011 {
//Check AB (3) (0x0c bytes)
byte cAbType; //Pos: 0x00
word tBuffer; //Pos: 0x02
dword iValue; //Pos: 0x04
byte cMoreLess; //Pos: 0x08
};
struct STR_AI_COND_012
{
//Check Time (1) (0x04 bytes)
byte cWhen; //Pos: 0x00
};
struct STR_AI_COND_013
{
//Check Target (1) (0x04 bytes)
byte btCheckTarget; //Pos: 0x00
byte btStatusType; //Pos: 0x01
byte btHave; //Pos: 0x02
};
struct STR_AI_COND_014
{
//Check Variable (1) (0x0c bytes)
byte btVarIDX; //Pos: 0x00
word tBuffer; //Pos: 0x02
dword iValue; //Pos: 0x04
byte btOp; //Pos: 0x08
};
struct STR_AI_COND_015
{
//Check Variable (2) (0x0c bytes)
word nVarIDX; //Pos: 0x00
word tBuffer; //Pos: 0x02
dword iValue; //Pos: 0x04
byte btOp; //Pos: 0x08
};
struct STR_AI_COND_016
{
//Check Variable (3) (0x00 bytes)
word nVarIDX; //Pos: 0x00
word tBuffer; //Pos: 0x02
dword iValue; //Pos: 0x04
byte btOp; //Pos: 0x08
};
struct STR_AI_COND_017
{
//Select NPC (0x04 bytes)
dword iNpcNo; //Pos: 0x00
};
struct STR_AI_COND_018
{
//Check Distance (3) (0x08 bytes)
dword iDistance; //Pos: 0x00
byte btOp; //Pos: 0x04
};
struct STR_AI_COND_019
{
//Check Time (2) (0x08 bytes)
dword ulTime; //Pos: 0x00
dword ulEndTime; //Pos: 0x04
};
struct STR_AI_COND_020
{
//Check AB (4) (0x0c bytes)
union
{
byte btAbType; //Pos: 0x00
dword iAbType;
};
dword iValue; //Pos: 0x04
byte btOp; //Pos: 0x08
};
struct STR_AI_COND_021
{
//Unknown (0x00 bytes)
};
struct STR_AI_COND_022
{
//Unknown (0x00 bytes)
};
struct STR_AI_COND_023
{
//Check Time (3) (0x08 bytes)
dword ulTime; //Pos: 0x00
dword ulEndTime; //Pos: 0x04
};
struct STR_AI_COND_024
{
//Check Date Time (4) (0x08 bytes)
byte btDate; //Pos: 0x00
byte btHour1; //Pos: 0x01
byte btMin1; //Pos: 0x02
byte btHour2; //Pos: 0x03
byte btMin2; //Pos: 0x04
};
struct STR_AI_COND_025
{
//Check Weekday Time (5) (0x08 bytes)
byte btWeekDay; //Pos: 0x00
byte btHour1; //Pos: 0x01
byte btMin1; //Pos: 0x02
byte btHour2; //Pos: 0x03
byte btMin2; //Pos: 0x04
};
struct STR_AI_COND_026
{
//Check Position (0x04 bytes)
word nMin; //Pos: 0x00
word nMax; //Pos: 0x02
};
struct STR_AI_COND_027
{
//Check Near Character (0x10 bytes)
int iDistance; //Pos: 0x00
byte btIsAllied; //Pos: 0x04
short nLevelDiff; //Pos: 0x06
short nLevelDiff2; //Pos: 0x08
short wChrNum; //Pos: 0x0a
byte btOp; //Pos: 0x0c
};
struct STR_AI_COND_028
{
//Check Variable (4) (0x0c bytes)
word nVarIDX; //Pos: 0x00
dword iValue; //Pos: 0x04
byte btOp; //Pos: 0x08
};
struct STR_AI_COND_029
{
//Check Target (2) (0x04 bytes)
byte btTargetType; //Pos: 0x00
};
struct STR_AI_COND_030
{
//Unknown (0x04 bytes)
dword Timer; //Pos: 0x00
};
struct STR_AI_COND_031
{
//no data needed here
};
struct STR_AI_COND_032
{
//no data needed here
};
+167
View File
@@ -0,0 +1,167 @@
// Props to ExJam for this code :D
#include "../WorldServer.h"
void CWorldServer::ReadAIP(strings path, dword index)
{
CRoseFile* fh = new CRoseFile(path, FM_READ | FM_BINARY);
if(fh->IsOpen())
{ // goto done;
//Log(MSG_LOAD, "Loading %s ", path);
dword BlockCount = fh->Get<dword>();
dword mintime = fh->Get<dword>();
dword mindamage = fh->Get<dword>();
dword titlestringlength = fh->Get<dword>();
strings title = new char[titlestringlength+1];
strings title2 = new char[32+1];
fh->Read(title, titlestringlength, 1);
for(dword i = 0; i < BlockCount; i++)
{
titlestringlength = 32;
fh->Read(title2, titlestringlength, 1);//on spawn-idle-attack-attacked-killed target-dead
dword RecordCount = fh->Get<dword>();
for(dword j = 0; j < RecordCount; j++)
{
CAip* script = new CAip();
fh->Read(title2, titlestringlength, 1);// 00 ==============================
script->ConditionCount = fh->Get<dword>();
if(script->ConditionCount > 0)
{
script->Conditions = new CAip::SAipDatum*[script->ConditionCount];
for(dword k = 0; k < script->ConditionCount; k++)
{
CAip::SAipDatum* data = new CAip::SAipDatum();
data->size = fh->Get<dword>();
data->opcode = fh->Get<dword>() - 0x04000001;
data->data = new byte[data->size - 8];
fh->Read(data->data, data->size - 8, 1);
script->Conditions[k] = data;
}
}
else
{
script->Conditions = NULL;
}
script->ActionCount = fh->Get<dword>();
if(script->ActionCount > 0)
{
script->Actions = new CAip::SAipDatum*[script->ActionCount];
for(dword k = 0; k < script->ActionCount; k++)
{
CAip::SAipDatum* data = new CAip::SAipDatum();
data->size = fh->Get<dword>();
data->opcode = fh->Get<dword>() - 0x0B000001;
data->data = new byte[data->size - 8];
fh->Read(data->data, data->size - 8, 1);
script->Actions[k] = data;
}
}
else
{
script->Actions = NULL;
}
script->AInumber = index;
script->AipID=((index*0x10000)+(i*0x100)+j);
script->minDamage = mindamage;
script->minTime = mintime;
script->recordcount[i] = RecordCount;
AipList.push_back( script );
}
}
}
else
Log( MSG_ERROR, "AIP File: '%s' failed to load properly", path );
fh->Close();
delete fh;
}
void CWorldServer::LoadAipData()
{
CStrStb* stbAip = new CStrStb("3DDATA\\STB\\FILE_AI.STB");
Log(MSG_INFO, "Loading AIP files");
for(dword i = 1; i < stbAip->Rows(); i++)
{
if(stbAip->Data(i, 0))
{
GServer->ReadAIP(stbAip->Data(i, 0),i);
}
}
//Log(MSG_INFO, "%i aip entrys",AipList.size());
Log(MSG_INFO, "Finished loading aip data ");
aiCondFunc[0] = &F_AI_COND_000;
aiCondFunc[1] = &F_AI_COND_001;
aiCondFunc[2] = &F_AI_COND_002;
aiCondFunc[3] = &F_AI_COND_003;
aiCondFunc[4] = &F_AI_COND_004;
aiCondFunc[5] = &F_AI_COND_005;
aiCondFunc[6] = &F_AI_COND_006;
aiCondFunc[7] = &F_AI_COND_007;
aiCondFunc[8] = &F_AI_COND_008;
aiCondFunc[9] = &F_AI_COND_009;
aiCondFunc[10] = &F_AI_COND_010;
aiCondFunc[11] = &F_AI_COND_011;
aiCondFunc[12] = &F_AI_COND_012;
aiCondFunc[13] = &F_AI_COND_013;
aiCondFunc[14] = &F_AI_COND_014;
aiCondFunc[15] = &F_AI_COND_015;
aiCondFunc[16] = &F_AI_COND_016;
aiCondFunc[17] = &F_AI_COND_017;
aiCondFunc[18] = &F_AI_COND_018;
aiCondFunc[19] = &F_AI_COND_019;
aiCondFunc[20] = &F_AI_COND_020;
aiCondFunc[21] = &F_AI_COND_021;
aiCondFunc[22] = &F_AI_COND_022;
aiCondFunc[23] = &F_AI_COND_023;
aiCondFunc[24] = &F_AI_COND_024;
aiCondFunc[25] = &F_AI_COND_025;
aiCondFunc[26] = &F_AI_COND_026;
aiCondFunc[27] = &F_AI_COND_027;
aiCondFunc[28] = &F_AI_COND_028;
aiCondFunc[29] = &F_AI_COND_029;
aiCondFunc[30] = &F_AI_COND_030;
aiActFunc[0] = &F_AI_ACT_000;
aiActFunc[1] = &F_AI_ACT_001;
aiActFunc[2] = &F_AI_ACT_002;
aiActFunc[3] = &F_AI_ACT_003;
aiActFunc[4] = &F_AI_ACT_004;
aiActFunc[5] = &F_AI_ACT_005;
aiActFunc[6] = &F_AI_ACT_006;
aiActFunc[7] = &F_AI_ACT_007;
aiActFunc[8] = &F_AI_ACT_008;
aiActFunc[9] = &F_AI_ACT_009;
aiActFunc[10] = &F_AI_ACT_010;
aiActFunc[11] = &F_AI_ACT_011;
aiActFunc[12] = &F_AI_ACT_012;
aiActFunc[13] = &F_AI_ACT_013;
aiActFunc[14] = &F_AI_ACT_014;
aiActFunc[15] = &F_AI_ACT_015;
aiActFunc[16] = &F_AI_ACT_016;
aiActFunc[17] = &F_AI_ACT_017;
aiActFunc[18] = &F_AI_ACT_018;
aiActFunc[19] = &F_AI_ACT_019;
aiActFunc[20] = &F_AI_ACT_020;
aiActFunc[21] = &F_AI_ACT_021;
aiActFunc[22] = &F_AI_ACT_022;
aiActFunc[23] = &F_AI_ACT_023;
aiActFunc[24] = &F_AI_ACT_024;
aiActFunc[25] = &F_AI_ACT_025;
aiActFunc[26] = &F_AI_ACT_026;
aiActFunc[27] = &F_AI_ACT_027;
aiActFunc[28] = &F_AI_ACT_028;
aiActFunc[29] = &F_AI_ACT_029;
aiActFunc[30] = &F_AI_ACT_030;
aiActFunc[31] = &F_AI_ACT_031;
aiActFunc[32] = &F_AI_ACT_032;
aiActFunc[33] = &F_AI_ACT_033;
aiActFunc[34] = &F_AI_ACT_034;
aiActFunc[35] = &F_AI_ACT_035;
aiActFunc[36] = &F_AI_ACT_036;
aiActFunc[37] = &F_AI_ACT_037;
delete stbAip;
}
+29
View File
@@ -0,0 +1,29 @@
// Props to ExJam for this code :]
class CAip
{
public:
struct SAipDatum
{
int size;
int opcode;
byte* data;
};
dword AInumber;
dword AipID;
dword minDamage;
dword minTime;
byte recordcount[6];
dword ConditionCount;
SAipDatum** Conditions;
dword ActionCount;
SAipDatum** Actions;
int AipVar;
private:
};
#define AI_FAILURE 8
#define AI_SUCCESS 7
#include "AiConditions.h"
#include "AiActions.h"