-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathHitFX-basic.rul
More file actions
164 lines (157 loc) · 5.46 KB
/
HitFX-basic.rul
File metadata and controls
164 lines (157 loc) · 5.46 KB
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
# HitFX Basic Version
extended:
tags:
BattleUnit:
LAST_HIT_FRAME: int
# 1: only armor damaged, 2: hp damaged, 3: stun taken, 4: morale damaged, 5: wounded
LAST_HIT_TYPE: int
LAST_HIT_POWER: int
scripts:
# hitUnit required to find side hit
# Otherwise we cannot get the armor value delta
hitUnit:
- offset: 20
code: |
var int unit_id;
unit.getId unit_id;
return power part side;
damageUnit:
- offset: 20
code: |
var int temp;
var int unit_id;
var int unit_health;
var int unit_armor;
var int hits_to_kill;
battle_game.getAnimFrame temp;
unit.getId unit_id;
unit.getHealth unit_health;
unit.getArmor unit_armor side;
set hits_to_kill unit_health;
unit.setTag Tag.LAST_HIT_POWER 1;
# unit.setTag Tag.LAST_HIT_FRAME 0;
unit.setTag Tag.LAST_HIT_FRAME temp;
if eq to_health 0;
if gt to_wound 0;
unit.setTag Tag.LAST_HIT_TYPE 5;
else gt to_armor 0;
unit.setTag Tag.LAST_HIT_TYPE 1;
else eq to_armor 0;
if gt to_stun 0;
unit.setTag Tag.LAST_HIT_TYPE 3;
else gt to_morale 0;
unit.setTag Tag.LAST_HIT_TYPE 4;
else;
unit.setTag Tag.LAST_HIT_TYPE 0;
end;
end;
else gt to_health 0;
if eq to_wound 0;
unit.setTag Tag.LAST_HIT_TYPE 2;
else;
unit.setTag Tag.LAST_HIT_TYPE 5;
end;
# hits_to_kill = uni health here
div hits_to_kill to_health;
# If it takes 3 or more hits_to_kill, use weaker hit effect
if ge hits_to_kill 3;
unit.setTag Tag.LAST_HIT_POWER 0;
end;
# Do we have stun damage? Yes
if gt to_stun 0;
# Will the hit kill the unit? No
if gt unit_health to_health;
# Are there any wounds? No
if eq to_wound 0;
# Is stun bigger than hp damage? Yes
if gt to_stun to_health;
# Then let's use the stun effect instead.
unit.setTag Tag.LAST_HIT_TYPE 3;
# Would it take 6 or less such hits to kill?
# Yes means we need to use a weaker red hit effect
if le hits_to_kill 6;
unit.setTag Tag.LAST_HIT_TYPE 2;
unit.setTag Tag.LAST_HIT_POWER 0;
# Would it take 3 or less such hits to kill?
# Yes means we need to use the stronger red hit effect
if le hits_to_kill 3;
unit.setTag Tag.LAST_HIT_POWER 1;
end;
end;
end;
end;
end;
end;
end;
return;
recolorUnitSprite:
- offset: 20
code: |
var int temp;
var int hittype;
var int hitpower;
var int wounds;
unit.getTag temp Tag.LAST_HIT_FRAME;
unit.getTag hittype Tag.LAST_HIT_TYPE;
unit.getTag hitpower Tag.LAST_HIT_POWER;
unit.getFatalwoundsTotal wounds;
if neq temp 0;
sub temp anim_frame;
if eq hittype 0;
if gt temp -3; # number of frames to blink
#set_color new_pixel 112;
#set_shade new_pixel 0;
end;
# Hit type 1 = armor only damage
else eq hittype 1;
if gt temp -3; # number of frames to blink
set_color new_pixel 14;
set_shade new_pixel 0;
end;
# Hit type 5 = wound
else eq hittype 5;
if eq wounds 0;
set hittype 2;
else;
if eq hitpower 0;
if gt temp -3; # number of frames to blink
set_color new_pixel 2;
set_shade new_pixel 0;
end;
else gt hitpower 0;
if gt temp -2;
set_color new_pixel 2;
set_shade new_pixel 0;
end;
end;
end;
# Hit type 3 = stun damage
else eq hittype 3;
if gt temp -3; # number of frames to blink
set_color new_pixel 175;
#set_color new_pixel 0;
#set_shade new_pixel 10;
end;
# Hit type 4 = morale damage
else eq hittype 4;
if gt temp -10; # number of frames to blink
set_color new_pixel 112;
#set_shade new_pixel 0;
end;
end;
# Hit type 2 = hitpoint damage; we need to test this separately due to wounding logic
if eq hittype 2;
if eq hitpower 0;
if gt temp -3; # number of frames to blink
set_color new_pixel 6;
#set_shade new_pixel 0;
end;
else gt hitpower 0;
if gt temp -2; # number of frames to blink
set_color new_pixel 6;
set_shade new_pixel 5;
end;
end;
end;
end;
return new_pixel;