-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZS_Attack.d
315 lines (281 loc) · 10.9 KB
/
ZS_Attack.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
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
func void ZS_Attack ()
{
PrintDebugNpc (PD_ZS_FRAME, "ZS_Attack" );
C_ZSInit ();
PrintGlobals (PD_ZS_FRAME);
Npc_PercEnable (self, PERC_ASSESSMURDER, B_CombatAssessMurder );
Npc_PercEnable (self, PERC_ASSESSDEFEAT, B_CombatAssessDefeat );
Npc_PercEnable (self, PERC_ASSESSDAMAGE, B_CombatReactToDamage );
Npc_PercEnable (self, PERC_ASSESSSURPRISE , ZS_AssessSurprise );
Npc_PercEnable (self, PERC_ASSESSMAGIC, B_AssessMagic );
Npc_PercEnable (self, PERC_ASSESSREMOVEWEAPON , B_CombatRemoveWeapon );
Npc_PercEnable (self, PERC_ASSESSENTERROOM , B_CombatAssessEnterRoom );
Npc_PercEnable (self, PERC_CATCHTHIEF , B_CombatCatchThief );
Npc_GetTarget (self);
B_WhirlAround (self, other);
B_SelectWeapon (self, other);
AI_SetWalkmode (self, NPC_RUN); // Walkmode für den Zustand
};
func int ZS_Attack_Loop()
{
PrintDebugNpc (PD_ZS_LOOP, "ZS_Attack_Loop");
Npc_GetTarget (self);
PrintGlobals (PD_ZS_DETAIL);
//-------- Wenn Gegner Bewußtlos oder Tod... --------
if (C_NpcIsDown(other) || !Hlp_IsValidNpc(other))
{
PrintDebugNpc (PD_ZS_CHECK, "...Ziel ist kampf-unfähig oder ungültig!");
Npc_PerceiveAll (self); // nötig, da Npc_GetNextTarget() auf der Liste der zuletzt Wahrgenommenen VOBs beruht
self.aivar[AIV_LASTTARGET] = Hlp_GetInstanceID(other);
if (Npc_GetNextTarget(self)) // Vorsicht: löscht 'other', wenn kein neues Ziel gefunden
{
if (Hlp_IsValidNpc(other)
&& !C_NpcIsDown(other)
&& Npc_CanSeeNpcFreeLOS(self,other)
&& !C_OtherIsToleratedEnemy(self,other)) // sonst ignorierte Feinde nicht in die Auswahl mit aufnehmen
{
PrintDebugString (PD_ZS_CHECK, "...neues Ziel gefunden: ", other.name);
}
else
{
PrintDebugNpc (PD_ZS_CHECK, "...kein Neues Ziel vorhanden!");
return LOOP_END;
};
}
else
{
PrintDebugNpc (PD_ZS_CHECK, "...KEIN neues Ziel gefunden!");
return LOOP_END;
};
};
if (Npc_GetStateTime(self) > 2)
{
//-------- Nahkampfdistanz zu groß ? --------
if ((!Npc_IsInFightMode(self, FMODE_FAR) && !Npc_IsInFightMode(self, FMODE_MAGIC))
&& (!Npc_IsInFightMode(other, FMODE_FAR) && !Npc_IsInFightMode(other, FMODE_MAGIC)) )
{
PrintDebugNpc (PD_ZS_CHECK, "...WEDER NSC noch Gegner führen Fernkampfwaffen!" );
if ( (Npc_GetDistToNpc(self, other)>HAI_DIST_ABORT_MELEE) && (self.aivar[AIV_LASTHITBYRANGEDWEAPON]==FALSE) )
{
PrintDebugNpc (PD_ZS_CHECK, "...Gegner außerhalb Nahkampfreichweite & letzter Treffer nicht durch Fernkampfwaffe!");
B_FullStop (self);
PrintGlobals (PD_ZS_CHECK);
if (C_NpcIsHuman(other))
{
B_AssessAndMemorize (NEWS_DEFEAT,NEWS_SOURCE_WITNESS, self, self, other);
if (Npc_GetPermAttitude (self, other) != ATT_HOSTILE) //MH: sonst kommt SVM püntig!
{
AI_PointAtNpc (self, other);
B_Say (self, other, "$RUNCOWARD");
AI_StopPointAt (self);
};
};
return LOOP_END;
};
}
//-------- Fernkampfdistanz zu groß ? --------
else
{
PrintDebugNpc (PD_ZS_CHECK, "...entweder NSC oder Gegner FÜHREN Fernkampfwaffen!" );
if (Npc_GetDistToNpc(self, other) > HAI_DIST_ABORT_RANGED)
{
PrintDebugNpc (PD_ZS_CHECK, "...Gegner außerhalb Fernkampfreichweite!" );
B_FullStop (self);
return LOOP_END;
};
};
//-------- SC-Gegner rennt schon zu lange (davon) ? --------
var int countPursuitCycles; // 2. Zähler neben StateTime für Verfolgungsabbruch nach Zeit
countPursuitCycles = countPursuitCycles + 1;
if (Npc_IsPlayer(other)
&& (C_BodyStateContains(other,BS_RUN) || C_BodyStateContains(other,BS_JUMP))
&& !Npc_IsInFightMode(self,FMODE_FAR)
&& !Npc_IsInFightMode(self,FMODE_MAGIC)
&& (C_GetAttackReason(self)!=AIV_AR_INTRUDER) )
{
if (countPursuitCycles > HAI_TIME_FOLLOW) // einige ZS_Attack_Loop's lang verfolgen
{
PrintDebugNpc (PD_ZS_CHECK, "...Gegner rennt schon zu lange weg!" );
B_FullStop (self);
if (C_NpcIsHuman(other))
{
B_AssessAndMemorize (NEWS_DEFEAT,NEWS_SOURCE_WITNESS, self, self, other);
if (Npc_GetPermAttitude (self, other) != ATT_HOSTILE) //MH: sonst kommt SVM püntig!
{
AI_PointAtNpc (self, other);
B_Say (self, other, "$RUNCOWARD");
AI_StopPointAt (self);
};
AI_Wait (self, 5);
};
return LOOP_END;
};
}
else
{
countPursuitCycles = 0;
};
//-------- Auswahl/Wechsel der richtigen Waffe --------
PrintGlobals (PD_ZS_DETAIL);
Npc_ClearAIQueue (self); // falls sich FAI-Moves schneller ansammeln, als sie abgearbeitet werden können.
B_SelectWeapon (self, other);
AI_SetWalkmode (self, NPC_RUN); // falls durch den Waffenwechsel ein AI_Standup() passiert!
Npc_SetStateTime (self, 0);
};
/* -------- eigentliches Anwerfen der FAI -------- */
if (other.aivar[AIV_INVINCIBLE]==FALSE) //MH: wird z.B. im Dialog auf True gesetzt, d.h. verfolgter SC kann sich unterhalten, ohne von aNSC angegriffen zu werden
{
AI_Attack (self);
}
else
{
AI_Wait (self, 0.5);
};
//-------- Flucht antreten? --------
if (self.npctype==NPCTYPE_AMBIENT)
|| (self.npctype==NPCTYPE_OW_AMBIENT)
|| (self.npctype==NPCTYPE_MINE_AMBIENT)
|| (self.fight_Tactic == FAI_HUMAN_COWARD)
{
if ( (self.fight_Tactic == FAI_HUMAN_COWARD) && (self.attribute[ATR_HITPOINTS] < (self.attribute[ATR_HITPOINTS_MAX] / 2) ) )
{
PrintDebugNpc(PD_ZS_CHECK, "...coward flees!" );
AI_StartState( self, ZS_Flee, 0, "" );
};
if ( (self.fight_Tactic == FAI_HUMAN_STRONG) && (self.attribute[ATR_HITPOINTS] < (self.attribute[ATR_HITPOINTS_MAX] / 4 * 3) ) )
{
PrintDebugNpc(PD_ZS_CHECK, "...strong flees!" );
AI_StartState( self, ZS_Flee, 0, "" );
};
if ( (self.fight_Tactic == FAI_HUMAN_MAGE) && (self.attribute[ATR_MANA] < (self.attribute[ATR_MANA_MAX] / 5)) )
{
PrintDebugNpc(PD_ZS_CHECK, "...mage flees!" );
AI_StartState( self, ZS_Flee, 0, "" );
};
if ( (self.fight_Tactic == FAI_HUMAN_RANGED) && (self.attribute[ATR_HITPOINTS] < (self.attribute[ATR_HITPOINTS_MAX] / 3)) )
{
PrintDebugNpc(PD_ZS_CHECK, "...ranged fighter flees!" );
AI_StartState( self, ZS_Flee, 0, "" );
};
};
return LOOP_CONTINUE;
};
func void ZS_Attack_End()
{
PrintDebugNpc (PD_ZS_FRAME, "ZS_Attack_End" );
other = Hlp_GetNpc(self.aivar[AIV_LASTTARGET]); //SN: 'other' wird durch ein erfolgloses Npc_GetNextTarget() manchmal gelöscht!
PrintGlobals (PD_ZS_CHECK);
/* ---- Ist der Gegner "nur" bewußtlos... ---- */
if ( Npc_IsInState(other, ZS_Unconscious) && (self.fight_tactic != FAI_HUMAN_RANGED))
{
PrintDebugNpc (PD_ZS_CHECK, "...Ziel bewußtlos/magisch schlafend und NSC kein purer Fernkämpfer!" );
if (Npc_GetAttitude (self, other) == ATT_FRIENDLY)
{
B_RemoveWeapon (self);
B_Say (self, other, "$LETSFORGETOURLITTLEFIGHT");
C_StopLookAt (self);
AI_StartState (self, ZS_HealSelf, 1, "");
};
if ((Npc_GetPermAttitude(self, other) == ATT_HOSTILE)
|| ((C_GetAttackReason(self) == AIV_AR_INTRUDER) && Npc_HasNews(self, NEWS_DEFEAT,self, other)))
{
// ---- ... wird er "gefinished" wenn er ein Feind oder Eindringling ist... ----
PrintDebugNpc (PD_ZS_CHECK, "...Hostile/Intruder wird gefinished" );
B_FullStop (self);
PrintGlobals (PD_ZS_CHECK);
AI_FinishingMove(self, other);
AI_Wait (self, 1);
}
else
{
// ---- ... oder ihm geraten es nicht wieder zu versuchen ----
PrintDebugNpc (PD_ZS_CHECK, "...Nicht hostile" );
B_Say (self, other, "$NEVERTRYTHATAGAIN" );
};
};
//-------- Nachbereitungen --------
B_RemoveWeapon (self);
C_StopLookAt (self);
B_ResetTempAttitude (self);
B_SetAttackReason (self, AIV_AR_NONE);
if (other.aivar[AIV_GUARDPASSAGE_STATUS] == AIV_GPS_PUNISH)
{
other.aivar[AIV_GUARDPASSAGE_STATUS] = AIV_GPS_FIRSTWARN;
};
//-------- Plündern ! --------
if (!C_NpcIsBoss(self) && C_NpcIsHuman(other) && (Npc_IsInState(other, ZS_Unconscious) || Npc_IsDead(other) || Npc_IsInState(other, ZS_MagicSleep)) )
{
if (self.fight_tactic != FAI_HUMAN_RANGED)
{
PrintDebugNpc (PD_ZS_CHECK, "...Plünderbedingungen erüllt!");
AI_StartState (self, ZS_AssessBody, 1, "");
return;
};
};
//-------- Heilen ! --------
AI_StartState (self, ZS_HealSelf, 1, "");
};
//------------------------------------------------------------------------------------------------------
// Die letzt Chance für einen Abbruch des Kampfes
//
// Bedingung:
// - Angriffsgrund: Nichtbefolgen der Aufforderung "Waffe weg!"
// - NSC nocht nicht verletzt
//------------------------------------------------------------------------------------------------------
func void B_CombatRemoveWeapon ()
{
PrintDebugNpc (PD_ZS_FRAME, "B_CombatRemoveWeapon");
if (Npc_WasInState(self,ZS_AssessFighter) || Npc_WasInState(self,ZS_AssessFighterWait)) // Angriffs-Grund das Nichtbefolgen des "Waffe weg"?...
{
PrintDebugNpc (PD_ZS_CHECK, "...Angriffsgrund: Waffe nicht weggesteckt!");
if (self.attribute[ATR_HITPOINTS]==self.attribute[ATR_HITPOINTS_MAX]) // ...und wurde der NSC noch nicht getroffen...
{
PrintDebugNpc (PD_ZS_CHECK, "...NSC unverletzt!");
B_FullStop (self);
B_ResetTempAttitude (self);
B_AssessRemoveWeapon(); // ...dann bricht der NSC den Kampf gerade noch ab!
};
};
};
//------------------------------------------------------------------------------------------------------
// Die letzt Chance für einen Abbruch des Kampfes
//
// Bedingung:
// - Angriffsgrund: nicht schnell genug nach einer Warnung den Raum verlassen
// - NSC noch nicht verletzt
// - SC darf noch nichts geklaut haben
//------------------------------------------------------------------------------------------------------
func void B_CombatAssessEnterRoom ()
{
PrintDebugNpc (PD_ZS_FRAME, "B_CombatAssessEnterRoom");
if (Wld_GetPlayerPortalGuild() == GIL_NONE
&& !Npc_HasNews(self, NEWS_THEFT, other, self))
{
PrintDebugNpc (PD_ZS_CHECK, "...SC hat Raum des NSCs verlassen und noch nichts geklaut!");
if (self.attribute[ATR_HITPOINTS]==self.attribute[ATR_HITPOINTS_MAX]) // ...und wurde der NSC noch nicht getroffen...
{
PrintDebugNpc (PD_ZS_CHECK, "...NSC unverletzt!");
B_FullStop (self);
B_ResetTempAttitude (self);
B_AssessRemoveWeapon(); // ...dann bricht der NSC den Kampf gerade noch ab!
};
};
};
//------------------------------------------------------------------------------------------------------
// Der Spieler klaut während der Nsc Kämpft
//
// Bedingung:
// - Speieler beklaut mich
// - dadurch wird alles andere unwichtig
//
//------------------------------------------------------------------------------------------------------
func void B_CombatCatchThief ()
{
PrintDebugNpc (PD_ZS_FRAME, "B_CombatAssessTheft");
B_AssessAndMemorize ( NEWS_THEFT, NEWS_SOURCE_WITNESS, self, other, self);
B_FullStop ( self);
B_WhirlAround ( self, other);
B_SayOverlay ( self, other, "$DIRTYTHIEF");
Npc_SetTarget ( self, other);
AI_StartState ( self, ZS_Attack, 0, "");
};