fixed some "indentation" shit from new shit++; and shut it up 4evar
[k8-i-v-a-n.git] / src / game / nonhumans / nonhumanoid_bunny.cpp
blob1d769ca94d639b2157b25b2664cc447a063598e7
1 #ifdef HEADER_PHASE
2 CHARACTER(bunny, nonhumanoid)
4 public:
5 virtual truth CheckIfSatiated() { return GetNP() > BLOATED_LEVEL; }
6 virtual void SignalNaturalGeneration();
7 virtual truth IsBunny() const { return true; }
8 virtual truth Catches(item*);
9 protected:
10 truth CheckForMatePartner();
11 virtual void GetAICommand();
15 #else
19 void bunny::GetAICommand()
21 if(GetConfig() < 4 && GetNP() > (SATIATED_LEVEL + BLOATED_LEVEL) >> 1)
23 if(CanBeSeenByPlayer())
24 ADD_MESSAGE("%s looks more mature.", CHAR_NAME(DEFINITE));
26 GetTorso()->SetSize(GetTorso()->GetSize() << 1);
27 LimitRef(StrengthExperience *= 2, MIN_EXP, MAX_EXP);
28 LimitRef(AgilityExperience *= 2, MIN_EXP, MAX_EXP);
30 for(int c = 0; c < BASE_ATTRIBUTES; ++c)
31 BaseExperience[c] = Limit(BaseExperience[c] * 2, MIN_EXP, MAX_EXP);
33 GetTorso()->GetMainMaterial()->SetVolume(GetTorso()->GetMainMaterial()->GetVolume() << 1);
34 SetConfig(GetConfig() + 2);
35 RestoreHP();
36 RestoreStamina();
39 SeekLeader(GetLeader());
41 if(FollowLeader(GetLeader()))
42 return;
44 if(CheckForEnemies(true, true, true))
45 return;
47 if(CheckForUsefulItemsOnGround())
48 return;
50 if(CheckForDoors())
51 return;
53 if(CheckForFood(5))
54 return;
56 if(CheckForMatePartner())
57 return;
59 if(MoveRandomly())
60 return;
62 EditAP(-1000);
67 void bunny::SignalNaturalGeneration()
69 character* Partner = bunny::Spawn(GetConfig()^1);
70 Partner->SetTeam(GetTeam());
71 Partner->SetGenerationDanger(GetGenerationDanger());
72 Partner->PutNear(GetPos());
77 truth bunny::CheckForMatePartner()
79 if(GetConfig() == ADULT_MALE)
81 character* BestPartner = 0;
82 double BestPartnerDanger = 0;
84 for(int c = 0; c < game::GetTeams(); ++c)
85 if(GetTeam()->GetRelation(game::GetTeam(c)) != HOSTILE)
86 for(std::list<character*>::const_iterator i = game::GetTeam(c)->GetMember().begin(); i != game::GetTeam(c)->GetMember().end(); ++i)
87 if((*i)->IsEnabled() && (*i)->IsBunny() && (*i)->GetConfig() == ADULT_FEMALE && (*i)->GetNP() > SATIATED_LEVEL)
89 double Danger = (*i)->GetRelativeDanger(this, true);
91 if(Danger > BestPartnerDanger)
93 BestPartner = *i;
94 BestPartnerDanger = Danger;
98 if(BestPartner && !GetPos().IsAdjacent(BestPartner->GetPos()))
100 SetGoingTo(BestPartner->GetPos());
101 MoveTowardsTarget(true);
102 return true;
106 if(GetConfig() == ADULT_FEMALE && GetNP() > NOT_HUNGER_LEVEL + 10000)
108 for(int d = 0; d < GetNeighbourSquares(); ++d)
110 lsquare* Square = GetNeighbourLSquare(d);
112 if(Square)
114 character* Father = Square->GetCharacter();
116 if(Father && Father->IsBunny() && Father->GetConfig() == ADULT_MALE && GetRelation(Father) != HOSTILE)
118 if(CanBeSeenByPlayer())
120 if(Father->IsPlayer())
121 ADD_MESSAGE("You have much fun with %s.", CHAR_NAME(DEFINITE));
122 else if(Father->CanBeSeenByPlayer())
123 ADD_MESSAGE("%s and %s seem to have much fun together.", Father->CHAR_NAME(DEFINITE), CHAR_NAME(DEFINITE));
124 else
125 ADD_MESSAGE("%s seems to have much fun.", CHAR_NAME(DEFINITE));
127 else
129 if(Father->IsPlayer())
130 ADD_MESSAGE("You have much fun with something.");
131 else if(Father->CanBeSeenByPlayer())
132 ADD_MESSAGE("%s seems to have much fun.", Father->CHAR_NAME(DEFINITE));
135 bunny* Baby = bunny::Spawn(BABY_MALE + (RAND() & 1));
136 Baby->StrengthExperience = RandomizeBabyExperience(StrengthExperience + static_cast<bunny*>(Father)->StrengthExperience);
137 Baby->AgilityExperience = RandomizeBabyExperience(AgilityExperience + static_cast<bunny*>(Father)->AgilityExperience);
139 if(Baby->GetConfig() == BABY_MALE)
141 Baby->StrengthExperience *= 4;
142 Baby->AgilityExperience *= 4;
144 else
146 Baby->StrengthExperience *= 2;
147 Baby->AgilityExperience *= 6;
150 Baby->StrengthExperience /= 3;
151 Baby->AgilityExperience /= 5;
153 for(int c = 0; c < BASE_ATTRIBUTES; ++c)
154 Baby->BaseExperience[c] = RandomizeBabyExperience(BaseExperience[c] + static_cast<bunny*>(Father)->BaseExperience[c]);
156 Baby->CalculateAll();
157 Baby->RestoreHP();
158 Baby->RestoreStamina();
159 Baby->SetTeam(GetTeam());
160 Baby->SetGenerationDanger(GetGenerationDanger());
161 Baby->PutNear(GetPos());
163 if(Baby->CanBeSeenByPlayer())
164 ADD_MESSAGE("%s is born.", Baby->CHAR_NAME(INDEFINITE));
166 EditNP(-10000);
167 Father->EditAP(-3000);
168 EditAP(-5000);
169 EditStamina(-GetMaxStamina() >> 1, true);
170 Father->EditStamina(-(Father->GetMaxStamina() << 2) / 5, true);
171 return true;
177 return false;
182 truth bunny::Catches(item* Thingy)
184 if(Thingy->BunnyWillCatchAndConsume(this))
186 if(ConsumeItem(Thingy, CONST_S("eating")))
188 if(IsPlayer())
189 ADD_MESSAGE("You catch %s in mid-air and consume it.", Thingy->CHAR_NAME(DEFINITE));
190 else
192 if(CanBeSeenByPlayer())
193 ADD_MESSAGE("%s catches %s and eats it.", CHAR_NAME(DEFINITE), Thingy->CHAR_NAME(DEFINITE));
195 ChangeTeam(PLAYER->GetTeam());
198 else if(IsPlayer())
199 ADD_MESSAGE("You catch %s in mid-air.", Thingy->CHAR_NAME(DEFINITE));
200 else if(CanBeSeenByPlayer())
201 ADD_MESSAGE("%s catches %s.", CHAR_NAME(DEFINITE), Thingy->CHAR_NAME(DEFINITE));
203 return true;
205 else
206 return false;
208 #endif