forked from h1pp0/FFACETools_ffevo.net
/
Structures.cs
507 lines (453 loc) · 16.3 KB
/
Structures.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
using System;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
namespace FFACETools
{
public partial class FFACE
{
/*
* Structures passed to/from FFACE
*/
#region PC/NPC
#region Player Information
/// <summary>
/// Stats of the player
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct PlayerStats
{
public short Str;
public short Dex;
public short Vit;
public short Agi;
public short Int;
public short Mnd;
public short Chr;
} // @ public struct PlayerStats
/// <summary>
/// Elemental resistances of the player
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct PlayerElements
{
public ushort Fire;
public ushort Ice;
public ushort Wind;
public ushort Earth;
public ushort Lightning;
public ushort Water;
public ushort Light;
public ushort Dark;
} // @ public struct PlayerElements
/// <summary>
/// Players Combat Skills
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
private struct PlayerCombatSkills
{
public ushort HandToHand;
public ushort Dagger;
public ushort Sword;
public ushort GreatSword;
public ushort Axe;
public ushort GreatAxe;
public ushort Scythe;
public ushort Polearm;
public ushort Katana;
public ushort GreatKatana;
public ushort Club;
public ushort Staff;
private ushort unkweap0;
private ushort unkweap1;
private ushort unkweap2;
private ushort unkweap3;
private ushort unkweap4;
private ushort unkweap5;
private ushort unkweap6;
private ushort unkweap7;
private ushort unkweap8;
private ushort unkweap9;
private ushort unkweap10;
private ushort unkweap11;
public ushort Archery;
public ushort Marksmanship;
public ushort Throwing;
public ushort Guarding;
public ushort Evasion;
public ushort Shield;
public ushort Parrying;
} // @ public struct PlayerCombatSkills
/// <summary>
/// Players magic skills
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
private struct PlayerMagicSkills
{
public ushort Divine;
public ushort Healing;
public ushort Enhancing;
public ushort Enfeebling;
public ushort Elemental;
public ushort Dark;
public ushort Summon;
public ushort Ninjitsu;
public ushort Singing;
public ushort String;
public ushort Wind;
public ushort BlueMagic;
private ushort unkmagic0;
private ushort unkmagic1;
private ushort unkmagic2;
private ushort unkmagic3;
} // @ public struct PlayerMagicSkills
/// <summary>
/// Players craft skills
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
private struct PlayerCraftLevels
{
public ushort Fishing;
public ushort Woodworking;
public ushort Smithing;
public ushort Goldsmithing;
public ushort Clothcraft;
public ushort Leathercraft;
public ushort Bonecraft;
public ushort Alchemy;
public ushort Cooking;
public ushort Synergy;
} // @ public struct PlayerCraftLevels
/// <summary>
/// Structure passed back from FFACE.GetPlayerInfo()
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
private struct PLAYERINFO
{
public int HPMax;
public int MPMax;
public Job MainJob;
public byte MainJobLVL;
public Job SubJob;
public byte SubJobLVL;
public ushort EXPIntoLVL;
public ushort EXPForLVL;
public PlayerStats Stats;
public PlayerStats StatModifiers;
public short Attack;
public short Defense;
public PlayerElements Elements;
public short Title;
public short Rank;
public short RankPts;
public byte Nation;
public byte Residence;
public int HomePoint;
public PlayerCombatSkills CombatSkills;
public PlayerMagicSkills MagicSkills;
public PlayerCraftLevels CraftLevels;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 144)]
private byte[] null0;
public ushort LimitPoints;
public byte MeritPoints;
public byte LimitMode;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 78)]
private byte[] null1;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public StatusEffect[] Buffs;
} // @ private struct PLAYERINFO
#endregion
/// <summary>
/// FFACE structure for a party member
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
private struct PARTYMEMBER
{
public int pad0;
public byte Index;
public byte MemberNumber;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 18)]
public string Name;
public int SvrID;
public int ID;
private int unknown0;
public int CurrentHP;
public int CurrentMP;
public int CurrentTP;
public byte CurrentHPP;
public byte CurrentMPP;
public short Zone;
private int pad1;
public uint FlagMask;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
private byte[] pad2;
public int SvrIDDupe;
public byte CurrentHPPDupe;
public byte CurrentMPPDupe;
public byte Active;
private byte pad3;
} // @ private struct PARTYMEMBER
/// <summary>
/// FFACE Structure for target information
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
private struct TARGETINFO
{
public int CurrentID;
public int SubID;
public int CurrentSvrID;
public int SubSrvID;
public ushort CurrentMask;
public ushort SubMask;
public byte IsLocked;
public byte IsSub;
public byte HPP;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 24)]
public string Name;
} // @ public struct TARGETINFO
/// <summary>
/// FFACE structure for alliance information
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
private struct ALLIANCEINFO
{
public int AllianceLeaderID;
public int Party0LeaderID;
public int Party1LeaderID;
public int Party2LeaderID;
public byte Party0Visible;
public byte Party1Visible;
public byte Party2Visible;
public byte Party0Count;
public byte Party1Count;
public byte Party2Count;
public byte Invited;
private byte unknown;
} // @ private struct ALLIANCEINFO
#endregion
#region Items
/// <summary>
/// FFACE structure for an inventory item
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
private struct INVENTORYITEM
{
public ushort ID;
public byte Index;
public uint Count;
public uint Flag;
public uint Price;
public ushort Extra;
} // @ public struct INVENTORYITEM
/// <summary>
/// Structure to hold information about an item in the treasure pool
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
private struct TREASUREITEM
{
public byte Flag; //3=no item, 2=item
public short ItemID;
public byte Count;
public TreasureStatus Status;
public short MyLot;
public short WinLot;
public int WinPlayerSrvID;
public int WinPlayerID;
public int TimeStamp; //utc timestamp
} // @ private struct TREASUREITEM
/// <summary>
/// Structure to hold information about a specific item in the trade window
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct TRADEITEM
{
public ushort ItemID;
public byte Index;
public byte Count;
} // @ private struct TRADEITEM
/// <summary>
/// Structure containing information about the trade window
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct TRADEINFO
{
public uint Gil;
public int TargetID;
public byte SelectedBox;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public TRADEITEM[] items;
} // @ private struct TRADEINFO
///<summary>
///FFACETools Structure for setTradeItems
///</summary>
public struct NPCTRADEINFO
{
public UInt32 Gil;
public TRADEITEM[] items;
}
#endregion
#region Chat
/// <summary>
/// Chat extra info structure
/// </summary>
//private struct CHATEXTRAINFO
//{
// public ChatMode MessageType;
//} // @ private struct CHATEXTRAINFO
#endregion
#region Menu
public class DialogText
{
private string _Question;
private string[] _Options;
private string _RawText;
private string[] CleanLine (string[] lines)
{
return CleanLine(lines, LineSettings.DialogDefault);
}
private string[] CleanLine (string[] lines, LineSettings lineSettings)
{
System.Collections.ArrayList ret = new System.Collections.ArrayList();
for (int i = 0; i < lines.Length; i++)
{
// CleanLine(lines[i]);
string x = FFACE.ChatTools.CleanLine(lines[i], lineSettings);
if (x == ".")
continue;
ret.Add(x);
}
string[] returnList = (string[])ret.ToArray(typeof(string));
return returnList;
}
#region Old_Code
/*
/// <summary>
/// Will strip abnormal characters (colors, etc) from the string
/// </summary>
/// <param name="line">line to clean (left intact)</param>
/// <returns>string containing the cleaned line</returns>
private string CleanLine(string line)
{
string cleanedString = line;
byte[] bytearray1252 = System.Text.Encoding.GetEncoding(1252).GetBytes(cleanedString);
int i = 0, len = bytearray1252.Length;
string sEF = "\xFF\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\xFF";
// 1f 20 21 22 23 24 25 26 27 28
string rep = "<FIAETWLD{}>";
string s1E = "\x01\x02\x03\xFC\xFD";
string s1F = "\x0E\x0F\x2F\x7F\x79\x7B\x7C\x8D\x88\x8A\xA1\xD0\r\n\x07";
string sExtra = "\r\n\x07\x7F\x81\x87";
System.Collections.Generic.List<Byte> cleaned = new System.Collections.Generic.List<byte>();
int ndx = -1;
for (int c = 0; c < len; ++c)
{
if ((bytearray1252[c] == '\xEF') && (((c + 1) < len) && ((ndx = sEF.IndexOf((char)bytearray1252[c + 1])) >= 0)))
{
// 3C < 3E >
// 7B { 7D }
if (sEF[ndx] != '\x28') // Not closing brace? Needs starter char
cleaned.Add((byte)rep[0]);
cleaned.Add((byte)rep[ndx]); // add rep.char based on Index
if (sEF[ndx] != '\x27') // Not opening brace? Needs closer char
cleaned.Add((byte)rep[rep.Length - 1]); // > Final: <{ and }> for Auto-translate braces
++c;
}
else if ((bytearray1252[c] == '\x1F') && (((c + 1) < len) && s1F.IndexOf((char)bytearray1252[c + 1]) >= 0))
{
++c;
}
else if ((bytearray1252[c] == '\x1E') && (((c + 1) < len) && s1E.IndexOf((char)bytearray1252[c + 1]) >= 0))
{
++c;
}
else
{
i = sExtra.IndexOf((char)bytearray1252[c]);
if (i >= 3) // \r\n\07 are singles, others are doubles
{
if (((bytearray1252[c] == '\x7F') && (((c + 1) < len) && bytearray1252[c + 1] == '\x31')) ||
((bytearray1252[c] == '\x81') && (((c + 1) < len) && bytearray1252[c + 1] == '\xA1')) ||
((bytearray1252[c] == '\x87') && (((c + 1) < len) && bytearray1252[c + 1] == '\xB2')) ||
((bytearray1252[c] == '\x87') && (((c + 1) < len) && bytearray1252[c + 1] == '\xB3')))
{
++c;
}
else
{
i = -1; // not a target, so "wasn't found"
}
}
if (i < 0)
{
cleaned.Add(bytearray1252[c]);
}
}
}
cleaned.Add(0);
if (cleaned[0] != 0)
cleanedString = System.Text.Encoding.GetEncoding(932).GetString(cleaned.ToArray());
else
cleanedString = String.Empty;
if (cleanedString.StartsWith("[")) // Detect and remove Windower Timestamp plugin text.
{
string text = cleanedString.Substring(1, 8);
string re1 = ".*?"; // Non-greedy match on filler
string re2 = "((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\\s?(?:am|AM|pm|PM))?)";
Regex r = new Regex(re1 + re2, RegexOptions.IgnoreCase | RegexOptions.Singleline);
Match m = r.Match(text);
if (m.Success)
{
cleanedString = cleanedString.Remove(0, 11); // this assumes timestamp found is only 10+1 space in length
// Better way? : line = line.Remove(0,m.Length+1);
}
} // Detect and remove Windower Timestamp plugin text.
return cleanedString;
} // private CleanLine(string line)
*/
#endregion
public DialogText Clone (DialogText dt)
{
if (dt == null)
return null;
DialogText ret = new DialogText(String.Empty);
ret._Question = dt._Question;
System.Collections.Generic.List<String> tmp = new System.Collections.Generic.List<string>();
tmp.AddRange(dt._Options);
ret._Options = new string[dt._Options.Length];
for (int i = 0; i < dt._Options.Length; i++)
{
ret._Options[i] = dt._Options[i];
}
return ret;
}
public DialogText Clone ()
{
return Clone(this);
}
public DialogText (string RawText) : this(RawText, LineSettings.DialogDefault) { }
public DialogText (string RawText, LineSettings lineSettings)
{
_RawText = RawText;
if (RawText == String.Empty)
{
_Question = String.Empty;
_Options = new string[0];
}
else
{
_Question = FFACE.ChatTools.CleanLine(RawText.Substring(0, RawText.IndexOf("\v") - 1), lineSettings);
string buffer = RawText.Substring(RawText.IndexOf("\v") + 1);
_Options = CleanLine(buffer.Split(new string[] { "\a" }, StringSplitOptions.RemoveEmptyEntries), lineSettings);
}
}
public string Question
{
get { return _Question; }
}
public string[] Options
{
get { return _Options; }
}
}
#endregion
} // @ public partial class FFACE
}