From 7db4e20fd7ee7cf1c25d5c2c5e9e1b1cf97d4c97 Mon Sep 17 00:00:00 2001 From: Debucquoy Anthony tonitch Date: Tue, 26 Sep 2023 23:54:37 +0200 Subject: adding endermite (#5460) * First Draft of adding endermite * Update src/Mobs/Endermite.h Co-authored-by: x12xx12x <44411062+12xx12@users.noreply.github.com> * Adding Protocols + SpawnEgg TODO: don't forget to put the endermite in core plugin for the summon command * Adding endermite to monster.ini * Adding 5% change of spawning endermite when throwing enderpearl * Spawn endermite at last position instead of Hit Position + .cache to .gitignore * fixup! Spawn endermite at last position instead of Hit Position + .cache to .gitignore * destroy endermite if 2 min, not if name is set * Syntax * Adding Enderman targeting endermite + fixing syntax * Fixing compile error + return error [but crash on enderman spawn] * Fix crash but enderman doesn't target * Enderman targeting endermite finished * checking style because i'm a noob at git... * fixup! checking style because i'm a noob at git... * Added endermite egg meta to docs * Final touches Removed unnecesary imports fixed callback to run only in sight distance and actually check sigtlines * Fixed error after not pulling branch --------- Co-authored-by: x12xx12x <44411062+12xx12@users.noreply.github.com> Co-authored-by: Debucquoy --- src/Entities/Entity.cpp | 1 + src/Entities/ThrownEnderPearlEntity.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'src/Entities') diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index b6204387b..4d61a5744 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -494,6 +494,7 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) case mtSpider: case mtCaveSpider: case mtSilverfish: + case mtEndermite: { MagicalCriticalHit = true; a_TDI.FinalDamage += 2.5f * BaneOfArthropodsLevel; diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp index 6fe4ce5be..6fc21e179 100644 --- a/src/Entities/ThrownEnderPearlEntity.cpp +++ b/src/Entities/ThrownEnderPearlEntity.cpp @@ -1,6 +1,8 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules +#include "FastRandom.h" +#include "Mobs/MonsterTypes.h" #include "ThrownEnderPearlEntity.h" #include "Player.h" @@ -56,11 +58,25 @@ void cThrownEnderPearlEntity::TeleportCreator(Vector3d a_HitPos) return; } + + GetWorld()->FindAndDoWithPlayer(m_CreatorData.m_Name, [=](cPlayer & a_Entity) { + + auto & Random = GetRandomProvider(); + + // 5% chance to spawn an endermite + if (Random.RandBool(0.05)) + { + Vector3d PlayerPosition = a_Entity.GetPosition(); + m_World->SpawnMob(PlayerPosition.x, PlayerPosition.y, PlayerPosition.z, mtEndermite); + } + + // Teleport the creator here, make them take 5 damage: a_Entity.TeleportToCoords(a_HitPos.x, a_HitPos.y + 0.2, a_HitPos.z); a_Entity.TakeDamage(dtEnderPearl, this, 5, 0); + return false; }); } -- cgit v1.2.3