Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DD2Film.cs
Go to the documentation of this file.
1using System;
7using Terraria.ID;
8
9namespace Terraria.Cinematics;
10
11public class DD2Film : Film
12{
13 private NPC _dryad;
14
15 private NPC _ogre;
16
17 private NPC _portal;
18
19 private List<NPC> _army = new List<NPC>();
20
21 private List<NPC> _critters = new List<NPC>();
22
24
51
53 {
55 }
56
58 {
60 _dryad.knockBackResist = 0f;
61 _dryad.immortal = true;
62 _dryad.dontTakeDamage = true;
63 _dryad.takenDamageMultiplier = 0f;
64 _dryad.immune[255] = 100000;
65 }
66
68 {
69 if (_dryad != null)
70 {
71 _dryad.ai[0] = 9f;
72 if (evt.IsFirstFrame)
73 {
74 _dryad.ai[1] = evt.Duration;
75 }
76 _dryad.localAI[0] = 0f;
77 }
78 }
79
81 {
82 int num = NPC.NewNPC(new EntitySource_Film(), (int)_portal.Center.X, (int)_portal.Bottom.Y, 568);
83 NPC nPC = Main.npc[num];
84 nPC.knockBackResist = 0f;
85 nPC.immortal = true;
86 nPC.dontTakeDamage = true;
87 nPC.takenDamageMultiplier = 0f;
88 nPC.immune[255] = 100000;
89 nPC.friendly = _ogre.friendly;
90 _army.Add(nPC);
91 }
92
94 {
95 int num = NPC.NewNPC(new EntitySource_Film(), (int)_portal.Center.X, (int)_portal.Bottom.Y, 561);
96 NPC nPC = Main.npc[num];
97 nPC.knockBackResist = 0f;
98 nPC.immortal = true;
99 nPC.dontTakeDamage = true;
100 nPC.takenDamageMultiplier = 0f;
101 nPC.immune[255] = 100000;
102 nPC.friendly = _ogre.friendly;
103 _army.Add(nPC);
104 }
105
107 {
108 int num = NPC.NewNPC(new EntitySource_Film(), (int)_portal.Center.X, (int)_portal.Bottom.Y, 552);
109 NPC nPC = Main.npc[num];
110 nPC.knockBackResist = 0f;
111 nPC.immortal = true;
112 nPC.dontTakeDamage = true;
113 nPC.takenDamageMultiplier = 0f;
114 nPC.immune[255] = 100000;
115 nPC.friendly = _ogre.friendly;
116 _army.Add(nPC);
117 }
118
120 {
121 for (int i = 0; i < 5; i++)
122 {
123 float num = (float)i / 5f;
124 NPC nPC = PlaceNPCOnGround(Utils.SelectRandom(Main.rand, new short[4] { 46, 46, 299, 538 }), _startPoint + new Vector2((num - 0.25f) * 400f + Main.rand.NextFloat() * 50f - 25f, 0f));
125 nPC.ai[0] = 0f;
126 nPC.ai[1] = 600f;
128 }
129 if (_dryad != null)
130 {
131 for (int j = 0; j < 10; j++)
132 {
133 _ = (float)j / 10f;
134 int num2 = NPC.NewNPC(new EntitySource_Film(), (int)_dryad.position.X + Main.rand.Next(-1000, 800), (int)_dryad.position.Y - Main.rand.Next(-50, 300), 356);
135 NPC nPC2 = Main.npc[num2];
136 nPC2.ai[0] = Main.rand.NextFloat() * 4f - 2f;
137 nPC2.ai[1] = Main.rand.NextFloat() * 4f - 2f;
138 nPC2.velocity.X = Main.rand.NextFloat() * 4f - 2f;
140 }
141 }
142 }
143
148
150 {
151 if (_dryad != null)
152 {
153 if (evt.Frame == 20)
154 {
155 _dryad.velocity.Y -= 7f;
156 _dryad.velocity.X -= 8f;
158 }
159 if (evt.Frame >= 20)
160 {
161 _dryad.ai[0] = 1f;
162 _dryad.ai[1] = evt.Remaining;
163 _dryad.rotation += 0.05f;
164 }
165 }
166 if (_ogre != null)
167 {
168 if (evt.Frame > 40)
169 {
170 _ogre.target = Main.myPlayer;
171 _ogre.direction = 1;
172 return;
173 }
174 _ogre.direction = -1;
175 _ogre.ai[1] = 0f;
176 _ogre.ai[0] = Math.Min(40f, _ogre.ai[0]);
177 _ogre.target = 300 + _dryad.whoAmI;
178 }
179 }
180
182 {
183 _ogre.friendly = true;
184 foreach (NPC item in _army)
185 {
186 item.friendly = true;
187 }
188 }
189
191 {
192 _ogre.friendly = false;
193 foreach (NPC item in _army)
194 {
195 item.friendly = false;
196 }
197 }
198
200 {
201 if (_dryad == null || _portal == null)
202 {
203 return;
204 }
205 if (evt.IsFirstFrame)
206 {
208 }
209 float val = (float)(evt.Frame - 7) / (float)(evt.Duration - 7);
210 val = Math.Max(0f, val);
211 _dryad.color = new Color(Vector3.Lerp(Vector3.One, new Vector3(0.5f, 0f, 0.8f), val));
212 _dryad.Opacity = 1f - val;
213 _dryad.rotation += 0.05f * (val * 4f + 1f);
214 _dryad.scale = 1f - val;
216 {
217 _dryad.velocity.X *= 0.95f;
218 _dryad.velocity.Y *= 0.55f;
219 }
220 int num = (int)(6f * val);
221 float num2 = _dryad.Size.Length() / 2f;
222 num2 /= 20f;
223 for (int i = 0; i < num; i++)
224 {
225 if (Main.rand.Next(5) == 0)
226 {
228 dust.scale = 0.55f;
229 dust.fadeIn = 0.7f;
230 dust.velocity *= 0.1f * num2;
231 dust.velocity += _dryad.velocity;
232 }
233 }
234 }
235
237 {
238 _portal = PlaceNPCOnGround(549, _startPoint + new Vector2(-240f, 0f));
239 _portal.immortal = true;
240 }
241
243 {
244 if (_dryad != null)
245 {
246 _dryad.ai[0] = 0f;
247 _dryad.ai[1] = evt.Remaining;
248 }
249 }
250
252 {
253 if (_dryad != null)
254 {
255 _dryad.direction = 1;
256 _dryad.spriteDirection = 1;
257 }
258 }
259
261 {
262 if (_dryad != null)
263 {
264 _dryad.direction = -1;
265 _dryad.spriteDirection = -1;
266 }
267 }
268
270 {
271 _dryad.ai[0] = 1f;
272 _dryad.ai[1] = 2f;
273 }
274
276 {
277 if (_dryad != null && evt.IsFirstFrame)
278 {
279 EmoteBubble.NewBubble(87, new WorldUIAnchor(_dryad), evt.Duration);
280 }
281 }
282
284 {
285 if (_dryad != null && evt.IsFirstFrame)
286 {
287 EmoteBubble.NewBubble(3, new WorldUIAnchor(_dryad), evt.Duration);
288 }
289 }
290
292 {
293 int num = NPC.NewNPC(new EntitySource_Film(), (int)_portal.Center.X, (int)_portal.Bottom.Y, 576);
294 _ogre = Main.npc[num];
295 _ogre.knockBackResist = 0f;
296 _ogre.immortal = true;
297 _ogre.dontTakeDamage = true;
298 _ogre.takenDamageMultiplier = 0f;
299 _ogre.immune[255] = 100000;
300 }
301
303 {
304 if (_ogre != null)
305 {
306 _ogre.ai[0] = 0f;
307 _ogre.ai[1] = 0f;
308 _ogre.velocity = Vector2.Zero;
309 }
310 }
311
313 {
314 if (_dryad != null)
315 {
316 _dryad.ai[0] = 14f;
317 _dryad.ai[1] = evt.Remaining;
318 _dryad.dryadWard = false;
319 }
320 }
321
323 {
324 if (_ogre != null)
325 {
326 _ogre.direction = 1;
327 _ogre.spriteDirection = 1;
328 }
329 }
330
332 {
333 if (_ogre != null)
334 {
335 _ogre.direction = -1;
336 _ogre.spriteDirection = -1;
337 }
338 }
339
340 public override void OnBegin()
341 {
342 Main.NewText("DD2Film: Begin");
343 Main.dayTime = true;
344 Main.time = 27000.0;
345 _startPoint = Main.screenPosition + new Vector2(Main.mouseX, (float)Main.mouseY - 32f);
346 base.OnBegin();
347 }
348
349 private NPC PlaceNPCOnGround(int type, Vector2 position)
350 {
351 int num = (int)position.X;
352 int num2 = (int)position.Y;
353 int i = num / 16;
354 int j;
355 for (j = num2 / 16; !WorldGen.SolidTile(i, j); j++)
356 {
357 }
358 num2 = j * 16;
359 int start = 100;
360 switch (type)
361 {
362 case 20:
363 start = 1;
364 break;
365 case 576:
366 start = 50;
367 break;
368 }
369 int num3 = NPC.NewNPC(new EntitySource_Film(), num, num2, type, start);
370 return Main.npc[num3];
371 }
372
373 public override void OnEnd()
374 {
375 if (_dryad != null)
376 {
377 _dryad.active = false;
378 }
379 if (_portal != null)
380 {
381 _portal.active = false;
382 }
383 if (_ogre != null)
384 {
385 _ogre.active = false;
386 }
387 foreach (NPC critter in _critters)
388 {
389 critter.active = false;
390 }
391 foreach (NPC item in _army)
392 {
393 item.active = false;
394 }
395 Main.NewText("DD2Film: End");
396 base.OnEnd();
397 }
398}
void Add(TKey key, TValue value)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static void PlaySound(int type, Vector2 position, int style=1)
void SpawnGoblin(FrameEventData evt)
Definition DD2Film.cs:106
void OgreStand(FrameEventData evt)
Definition DD2Film.cs:302
void SpawnWitherBeast(FrameEventData evt)
Definition DD2Film.cs:80
void DryadPortalFade(FrameEventData evt)
Definition DD2Film.cs:199
void SpawnJavalinThrower(FrameEventData evt)
Definition DD2Film.cs:93
void RestoreEnemyDamage(FrameEventData evt)
Definition DD2Film.cs:190
void CreateCritters(FrameEventData evt)
Definition DD2Film.cs:119
void DryadConfusedEmote(FrameEventData evt)
Definition DD2Film.cs:275
void DryadInteract(FrameEventData evt)
Definition DD2Film.cs:67
void CreatePortal(FrameEventData evt)
Definition DD2Film.cs:236
NPC PlaceNPCOnGround(int type, Vector2 position)
Definition DD2Film.cs:349
void OgreLookRight(FrameEventData evt)
Definition DD2Film.cs:322
void DryadAttack(FrameEventData evt)
Definition DD2Film.cs:312
void CreateOgre(FrameEventData evt)
Definition DD2Film.cs:291
void OgreLookLeft(FrameEventData evt)
Definition DD2Film.cs:331
void DryadLookRight(FrameEventData evt)
Definition DD2Film.cs:251
void DryadWalk(FrameEventData evt)
Definition DD2Film.cs:269
void PerFrameSettings(FrameEventData evt)
Definition DD2Film.cs:52
void DryadAlertEmote(FrameEventData evt)
Definition DD2Film.cs:283
void CreateDryad(FrameEventData evt)
Definition DD2Film.cs:57
void RemoveEnemyDamage(FrameEventData evt)
Definition DD2Film.cs:181
void DryadStand(FrameEventData evt)
Definition DD2Film.cs:242
void OgreSwingSound(FrameEventData evt)
Definition DD2Film.cs:144
override void OnBegin()
Definition DD2Film.cs:340
void DryadPortalKnock(FrameEventData evt)
Definition DD2Film.cs:149
void DryadLookLeft(FrameEventData evt)
Definition DD2Film.cs:260
override void OnEnd()
Definition DD2Film.cs:373
void AppendKeyFrames(params FrameEvent[] frameEvents)
Definition Film.cs:90
void AppendKeyFrame(FrameEvent frameEvent)
Definition Film.cs:85
void AppendSequence(int duration, FrameEvent frameEvent)
Definition Film.cs:56
void AddKeyFrame(int frame, FrameEvent frameEvent)
Definition Film.cs:100
void AddSequences(int start, int duration, params FrameEvent[] frameEvents)
Definition Film.cs:61
void AppendSequences(int duration, params FrameEvent[] frameEvents)
Definition Film.cs:69
void AddSequence(int start, int duration, FrameEvent frameEvent)
Definition Film.cs:49
static void clearAll()
static Dust NewDustDirect(Vector2 Position, int Width, int Height, int Type, float SpeedX=0f, float SpeedY=0f, int Alpha=0, Color newColor=default(Color), float Scale=1f)
Definition Dust.cs:63
Vector2 Center
Definition Entity.cs:43
Vector2 Size
Definition Entity.cs:151
Vector2 Bottom
Definition Entity.cs:115
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
Vector2 Right
Definition Entity.cs:67
static int NewBubble(int emoticon, WorldUIAnchor bubbleAnchor, int time)
static readonly LegacySoundStyle DD2_EtherianPortalDryadTouch
Definition SoundID.cs:916
static readonly LegacySoundStyle DD2_OgreAttack
Definition SoundID.cs:882
static int myPlayer
Definition Main.cs:1801
static void NewText(string newText, byte R=byte.MaxValue, byte G=byte.MaxValue, byte B=byte.MaxValue)
Definition Main.cs:61429
static UnifiedRandom rand
Definition Main.cs:1387
static NPC[] npc
Definition Main.cs:1685
static int mouseY
Definition Main.cs:606
static int mouseX
Definition Main.cs:604
int[] immune
Definition NPC.cs:441
float[] localAI
Definition NPC.cs:449
float[] ai
Definition NPC.cs:447
bool friendly
Definition NPC.cs:555
static int NewNPC(IEntitySource source, int X, int Y, int Type, int Start=0, float ai0=0f, float ai1=0f, float ai2=0f, float ai3=0f, int Target=255)
Definition NPC.cs:77654
static bool SolidTile(Tile testTile)
static Vector3 Lerp(Vector3 value1, Vector3 value2, float amount)
Definition Vector3.cs:307