finished adding content from CLIVAN; not tested yet
[k8-i-v-a-n.git] / src / game / humans / humanoid_ennerbeast.cpp
blob1fcc71be8276b848ee1219ef140e4cded9c239ff
1 #ifdef HEADER_PHASE
2 CHARACTER(ennerbeast, humanoid)
4 public:
5 virtual truth Hit(character*, v2, int, int = 0);
6 virtual truth MustBeRemovedFromBone() const;
7 protected:
8 virtual bodypart* MakeBodyPart(int) const;
9 virtual void GetAICommand();
10 virtual truth AttackIsBlockable(int) const { return false; }
14 #else
18 truth ennerbeast::Hit(character* Enemy, v2, int, int)
20 if(CheckIfTooScaredToHit(Enemy))
21 return false;
23 if(RAND() & 1)
24 ADD_MESSAGE("%s yells: UGH UGHAaaa!", CHAR_DESCRIPTION(DEFINITE));
25 else
26 ADD_MESSAGE("%s yells: Uga Ugar Ugade Ugat!", CHAR_DESCRIPTION(DEFINITE));
28 rect Rect;
29 femath::CalculateEnvironmentRectangle(Rect, GetLevel()->GetBorder(), GetPos(), 30);
31 for(int x = Rect.X1; x <= Rect.X2; ++x)
32 for(int y = Rect.Y1; y <= Rect.Y2; ++y)
34 int ScreamStrength = int(70 / (hypot(GetPos().X - x, GetPos().Y - y) + 1));
36 if(ScreamStrength)
38 character* Char = GetNearSquare(x, y)->GetCharacter();
40 if(Char && Char != this)
42 msgsystem::EnterBigMessageMode();
44 if(Char->IsPlayer())
45 ADD_MESSAGE("You are hit by the horrible waves of high sound.");
46 else if(Char->CanBeSeenByPlayer())
47 ADD_MESSAGE("%s is hit by the horrible waves of high sound.", Char->CHAR_NAME(DEFINITE));
49 Char->ReceiveDamage(this, ScreamStrength, SOUND, ALL, YOURSELF, true);
50 Char->CheckDeath(CONST_S("killed @bkp scream"), this);
51 msgsystem::LeaveBigMessageMode();
53 if (Char->IsPlayer() && Char->HasOmmelBlood() && CanBeSeenByPlayer()) {
54 if (Char->CurdleOmmelBlood()) ADD_MESSAGE("Your vial of Ommel Blood vibrates and it contents curdles with the scream of the Enner Beast.");
58 GetNearLSquare(x, y)->GetStack()->ReceiveDamage(this, ScreamStrength, SOUND);
62 EditNP(-100);
63 EditAP(-1000000 / GetCWeaponSkill(BITE)->GetBonus());
64 EditStamina(-1000, false);
65 return true;
70 void ennerbeast::GetAICommand()
72 SeekLeader(GetLeader());
74 if(StateIsActivated(PANIC) || !(RAND() % 3))
75 Hit(0, ZERO_V2, YOURSELF);
77 if(CheckForEnemies(false, false, true))
78 return;
80 if(FollowLeader(GetLeader()))
81 return;
83 if(MoveRandomly())
84 return;
86 EditAP(-1000);
91 truth ennerbeast::MustBeRemovedFromBone() const
93 return !IsEnabled() || GetTeam()->GetID() != MONSTER_TEAM || GetDungeon()->GetIndex() != ELPURI_CAVE || GetLevel()->GetIndex() != ENNER_BEAST_LEVEL;
98 bodypart* ennerbeast::MakeBodyPart(int I) const
100 if(I == HEAD_INDEX)
101 return ennerhead::Spawn(0, NO_MATERIALS);
102 else
103 return humanoid::MakeBodyPart(I);
105 #endif