Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ AI_019_Spears_Old()

void Terraria.Projectile.AI_019_Spears_Old ( )
inlineprivate

Definition at line 38142 of file Projectile.cs.

38143 {
38144 Vector2 vector = Main.player[owner].RotatedRelativePoint(Main.player[owner].MountedCenter);
38145 direction = Main.player[owner].direction;
38146 Main.player[owner].heldProj = whoAmI;
38147 Main.player[owner].MatchItemTimeToItemAnimation();
38148 position.X = vector.X - (float)(width / 2);
38149 position.Y = vector.Y - (float)(height / 2);
38150 bool flag = Main.player[owner].itemAnimation < Main.player[owner].itemAnimationMax / 3;
38151 if (!Main.player[owner].frozen)
38152 {
38153 if (type == 46)
38154 {
38155 if (ai[0] == 0f)
38156 {
38157 ai[0] = 3f;
38158 netUpdate = true;
38159 }
38160 if (flag)
38161 {
38162 ai[0] -= 1.6f;
38163 }
38164 else
38165 {
38166 ai[0] += 1.4f;
38167 }
38168 }
38169 else if (type == 105)
38170 {
38171 if (ai[0] == 0f)
38172 {
38173 ai[0] = 3f;
38174 netUpdate = true;
38175 }
38176 if (flag)
38177 {
38178 ai[0] -= 2.4f;
38179 }
38180 else
38181 {
38182 ai[0] += 2.1f;
38183 }
38184 }
38185 else if (type == 367)
38186 {
38188 if (ai[0] == 0f)
38189 {
38190 ai[0] = 3f;
38191 netUpdate = true;
38192 }
38193 if (flag)
38194 {
38195 ai[0] -= 1.6f;
38196 }
38197 else
38198 {
38199 ai[0] += 1.5f;
38200 }
38201 }
38202 else if (type == 368)
38203 {
38205 if (ai[0] == 0f)
38206 {
38207 ai[0] = 3f;
38208 netUpdate = true;
38209 }
38210 if (flag)
38211 {
38212 ai[0] -= 1.5f;
38213 }
38214 else
38215 {
38216 ai[0] += 1.4f;
38217 }
38218 }
38219 else if (type == 222)
38220 {
38221 if (ai[0] == 0f)
38222 {
38223 ai[0] = 3f;
38224 netUpdate = true;
38225 }
38226 if (flag)
38227 {
38228 ai[0] -= 2.4f;
38229 if (localAI[0] == 0f && Main.myPlayer == owner)
38230 {
38231 localAI[0] = 1f;
38233 }
38234 }
38235 else
38236 {
38237 ai[0] += 2.1f;
38238 }
38239 }
38240 else if (type == 342)
38241 {
38242 if (ai[0] == 0f)
38243 {
38244 ai[0] = 3f;
38245 netUpdate = true;
38246 }
38247 if (flag)
38248 {
38249 ai[0] -= 2.4f;
38250 if (localAI[0] == 0f && Main.myPlayer == owner)
38251 {
38252 localAI[0] = 1f;
38253 if (Collision.CanHit(Main.player[owner].position, Main.player[owner].width, Main.player[owner].height, new Vector2(base.Center.X + velocity.X * ai[0], base.Center.Y + velocity.Y * ai[0]), width, height))
38254 {
38255 NewProjectile(GetProjectileSource_FromThis(), base.Center.X + velocity.X * ai[0], base.Center.Y + velocity.Y * ai[0], velocity.X * 2.4f, velocity.Y * 2.4f, 343, (int)((double)damage * 0.8), knockBack * 0.85f, owner);
38256 }
38257 }
38258 }
38259 else
38260 {
38261 ai[0] += 2.1f;
38262 }
38263 }
38264 else if (type == 47)
38265 {
38266 if (ai[0] == 0f)
38267 {
38268 ai[0] = 4f;
38269 netUpdate = true;
38270 }
38271 if (flag)
38272 {
38273 ai[0] -= 1.2f;
38274 }
38275 else
38276 {
38277 ai[0] += 0.9f;
38278 }
38279 }
38280 else if (type == 153)
38281 {
38283 if (ai[0] == 0f)
38284 {
38285 ai[0] = 4f;
38286 netUpdate = true;
38287 }
38288 if (flag)
38289 {
38290 ai[0] -= 1.5f;
38291 }
38292 else
38293 {
38294 ai[0] += 1.3f;
38295 }
38296 }
38297 else if (type == 49)
38298 {
38299 if (ai[0] == 0f)
38300 {
38301 ai[0] = 4f;
38302 netUpdate = true;
38303 }
38304 if (flag)
38305 {
38306 ai[0] -= 1.1f;
38307 }
38308 else
38309 {
38310 ai[0] += 0.85f;
38311 }
38312 }
38313 else if (type == 730)
38314 {
38316 if (ai[0] == 0f)
38317 {
38318 ai[0] = 8f;
38319 netUpdate = true;
38320 if (localAI[0] == 0f && Main.myPlayer == owner)
38321 {
38322 localAI[0] = 1f;
38323 Vector2 vector2 = velocity * 4f;
38324 NewProjectile(GetProjectileSource_FromThis(), base.Center.X + velocity.X * ai[0], base.Center.Y + velocity.Y * ai[0], vector2.X, vector2.Y, 732, (int)((double)damage * 1.25), knockBack * 0.5f, owner);
38325 }
38326 }
38327 if (flag)
38328 {
38329 ai[0] -= 1.5f;
38330 }
38331 else
38332 {
38333 ai[0] += 1.2f;
38334 }
38335 }
38336 else if (type == 64 || type == 215)
38337 {
38339 if (ai[0] == 0f)
38340 {
38341 ai[0] = 3f;
38342 netUpdate = true;
38343 }
38344 if (flag)
38345 {
38346 ai[0] -= 1.9f;
38347 }
38348 else
38349 {
38350 ai[0] += 1.7f;
38351 }
38352 }
38353 else if (type == 66 || type == 97 || type == 212 || type == 218)
38354 {
38356 if (ai[0] == 0f)
38357 {
38358 ai[0] = 3f;
38359 netUpdate = true;
38360 }
38361 if (flag)
38362 {
38363 ai[0] -= 2.1f;
38364 }
38365 else
38366 {
38367 ai[0] += 1.9f;
38368 }
38369 }
38370 else if (type == 130)
38371 {
38373 if (ai[0] == 0f)
38374 {
38375 ai[0] = 3f;
38376 netUpdate = true;
38377 }
38378 if (flag)
38379 {
38380 ai[0] -= 1.3f;
38381 }
38382 else
38383 {
38384 ai[0] += 1f;
38385 }
38386 }
38387 }
38388 position += velocity * ai[0];
38389 if (type == 130)
38390 {
38391 if (ai[1] == 0f || ai[1] == 4f || ai[1] == 8f || ai[1] == 12f || ai[1] == 16f || ai[1] == 20f || ai[1] == 24f)
38392 {
38393 NewProjectile(GetProjectileSource_FromThis(), position.X + (float)(width / 2), position.Y + (float)(height / 2), velocity.X, velocity.Y, 131, damage / 3, 0f, owner);
38394 }
38395 ai[1] += 1f;
38396 }
38397 if (Main.player[owner].itemAnimation == 0)
38398 {
38399 Kill();
38400 }
38401 rotation = (float)Math.Atan2(velocity.Y, velocity.X) + 2.355f;
38402 if (spriteDirection == -1)
38403 {
38404 rotation -= 1.57f;
38405 }
38406 if (type == 46)
38407 {
38408 if (Main.rand.Next(5) == 0)
38409 {
38410 Dust.NewDust(position, width, height, 14, 0f, 0f, 150, default(Color), 1.4f);
38411 }
38412 int num = Dust.NewDust(position, width, height, 27, velocity.X * 0.2f + (float)(direction * 3), velocity.Y * 0.2f, 100, default(Color), 1.2f);
38413 Main.dust[num].noGravity = true;
38414 Main.dust[num].velocity.X /= 2f;
38415 Main.dust[num].velocity.Y /= 2f;
38416 num = Dust.NewDust(position - velocity * 2f, width, height, 27, 0f, 0f, 150, default(Color), 1.4f);
38417 Main.dust[num].velocity.X /= 5f;
38418 Main.dust[num].velocity.Y /= 5f;
38419 }
38420 if (type == 730)
38421 {
38422 if (Main.rand.Next(5) == 0)
38423 {
38424 Dust dust = Dust.NewDustDirect(position, width, height, 226, 0f, 0f, 150, default(Color), 0.7f);
38425 dust.noGravity = true;
38426 dust.velocity *= 1.4f;
38427 }
38428 if (Main.rand.Next(5) == 0)
38429 {
38430 Dust.NewDustDirect(position, width, height, 226, 0f, 0f, 150, default(Color), 0.5f).velocity.Y -= 0.5f;
38431 }
38432 }
38433 else if (type == 105)
38434 {
38435 if (Main.rand.Next(3) == 0)
38436 {
38437 int num2 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 57, velocity.X * 0.2f, velocity.Y * 0.2f, 200, default(Color), 1.2f);
38438 Main.dust[num2].velocity += velocity * 0.3f;
38439 Main.dust[num2].velocity *= 0.2f;
38440 }
38441 if (Main.rand.Next(4) == 0)
38442 {
38443 int num3 = Dust.NewDust(new Vector2(position.X, position.Y), width, height, 43, 0f, 0f, 254, default(Color), 0.3f);
38444 Main.dust[num3].velocity += velocity * 0.5f;
38445 Main.dust[num3].velocity *= 0.5f;
38446 }
38447 }
38448 else if (type == 153)
38449 {
38450 int num4 = Dust.NewDust(position - velocity * 3f, width, height, 115, velocity.X * 0.4f, velocity.Y * 0.4f, 140);
38451 Main.dust[num4].noGravity = true;
38452 Main.dust[num4].fadeIn = 1.25f;
38453 Main.dust[num4].velocity *= 0.25f;
38454 }
38455 }
static double Atan2(double y, double x)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
IEntitySource GetProjectileSource_FromThis()
static int NewProjectile(IEntitySource spawnSource, Vector2 position, Vector2 velocity, int Type, int Damage, float KnockBack, int Owner=-1, float ai0=0f, float ai1=0f, float ai2=0f)

References System.Math.Atan2(), Terraria.Collision.CanHit(), Terraria.Main.dust, Terraria.Main.myPlayer, Terraria.Dust.NewDust(), Terraria.Dust.NewDustDirect(), Terraria.Main.player, Terraria.Main.rand, System.type, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.