-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDialoggestures.d
110 lines (96 loc) · 3.19 KB
/
Dialoggestures.d
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
/***********************************\
DIALOGGESTURES
\***********************************/
//========================================
// [intern]
//========================================
var int _DIAG_Max;
var int _DIAG_Min;
//========================================
// [intern]
//========================================
func void _DIAG_Patch() {
const int address = 0;
if(address) {
return;
};
address = MEM_Alloc(19);
MemoryProtectionOverride(oCNpc__StartDialogAniX, 5);
MEM_WriteInt(oCNpc__StartDialogAniX + 0, 233);
MEM_WriteInt(oCNpc__StartDialogAniX + 1, address-(oCNpc__StartDialogAniX+5));
/*
mov ecx, [_DIAG_Max]
idiv ecx
add ebx, [_DIAG_Min]
*/
MEM_WriteByte(address+0, 139);
MEM_WriteByte(address+1, 013); MEM_WriteInt(address+2, MEM_GetIntAddress(_DIAG_Max));
MEM_WriteByte(address+6, 247);
MEM_WriteByte(address+7, 249);
MEM_WriteByte(address+8, 003);
MEM_WriteByte(address+9, 021); MEM_WriteInt(address+10, MEM_GetIntAddress(_DIAG_Min));
MEM_WriteByte(address+14, 233);
MEM_WriteInt (address+15, oCNpc__StartDialogAniY-(address+19));
};
//========================================
// Minimum und Maximum direkt setzen
//========================================
func void DIAG_SetMinMax(var int min, var int max) {
_DIAG_Patch();
min -= 1;
_DIAG_Min = min;
_DIAG_Max = max-min;
};
//========================================
// Animation direkt setzen
//========================================
func void _DIAG_SetAni(var string AniName) {
_DIAG_Patch();
MemoryProtectionOverride(T_DIALOGGESTURE_, 16);
AniName = STR_Upper(AniName);
var zString ani; ani = MEM_PtrToInst(STR_GetAddress(AniName));
if(ani.len < 1 || ani.len > 17) {
MEM_Error("DIAG_SetAni: Length of AniName has to be between 0 and 18");
};
MEM_CopyBytes(ani.ptr, T_DIALOGGESTURE_, ani.len+1); // +1 für \0
};
func void DIAG_SetAni(var string AniName) {
AniName = ConcatStrings(DIAG_Prefix, AniName);
AniName = ConcatStrings(AniName, DIAG_Suffix);
_DIAG_SetAni(AniName);
};
//========================================
// Gesten in Dialogen wechseln
//========================================
func void DIAG(var string AniName, var int Min, var int Max) {
const int ptr = 0;
ptr = MEM_Alloc(8);
MEM_WriteInt(ptr, Min);
MEM_WriteInt(ptr+4, Max);
AI_WaitTillEnd(self, other);
AI_WaitTillEnd(other, self);
AI_Function_SI(other, _DIAG, AniName, ptr);
AI_WaitTillEnd(self, other);
};
//========================================
// Gesten zurücksetzen
//========================================
func void DIAG_Reset() {
AI_WaitTillEnd(self, other);
AI_WaitTillEnd(other, self);
AI_Function_SI(other, _DIAG, "T_DIALOGGESTURE_", -1);
AI_WaitTillEnd(self, other);
};
//========================================
// [intern]
//========================================
func void _DIAG(var string AniName, var int ptr) {
if(!STR_Compare(AniName, "T_DIALOGGESTURE_")) {
DIAG_SetMinMax(1, 20);
_DIAG_SetAni(AniName);
return;
};
DIAG_SetMinMax(MEM_ReadInt(ptr), MEM_ReadInt(ptr+4));
MEM_Free(ptr);
DIAG_SetAni(AniName);
};