nonhumans separation
[k8-i-v-a-n.git] / src / game / humans / humanoid_playerkind.cpp
blob89ee4b2614f98aa929de977a630ce94319112293
1 #ifdef HEADER_PHASE
2 CHARACTER(playerkind, humanoid)
4 public:
5 playerkind();
6 playerkind(const playerkind&);
7 virtual void Save(outputfile&) const;
8 virtual void Load(inputfile&);
9 virtual void SetSoulID(feuLong);
10 virtual truth SuckSoul(character*);
11 virtual truth TryToRiseFromTheDead();
12 virtual void FinalProcessForBone();
13 virtual void BeTalkedTo();
14 virtual truth IsHuman() const { return true; }
15 virtual col16 GetHairColor() const { return HairColor; }
16 virtual col16 GetEyeColor() const { return EyeColor; }
17 virtual v2 GetHeadBitmapPos() const;
18 virtual v2 GetRightArmBitmapPos() const;
19 virtual v2 GetLeftArmBitmapPos() const;
20 virtual int GetNaturalSparkleFlags() const;
21 virtual truth IsPlayerKind() const { return true; }
22 virtual double GetNaturalExperience(int) const;
23 protected:
24 virtual bodypart* MakeBodyPart(int) const;
25 virtual void PostConstruct();
26 feuLong SoulID;
27 col16 HairColor;
28 col16 EyeColor;
29 int Talent;
30 int Weakness;
31 truth IsBonePlayer;
32 truth IsClone;
36 #else
39 cint TalentOfAttribute[ATTRIBUTES] = { TALENT_HEALTHY, TALENT_FAST_N_ACCURATE, TALENT_CLEVER, TALENT_CLEVER, TALENT_CLEVER, TALENT_CLEVER, TALENT_CLEVER, TALENT_STRONG, TALENT_STRONG, TALENT_FAST_N_ACCURATE, TALENT_FAST_N_ACCURATE };
40 const double TalentBonusOfAttribute[ATTRIBUTES] = { 1.1, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25 };
43 playerkind::playerkind() : SoulID(0), IsBonePlayer(false), IsClone(false)
49 void playerkind::Save(outputfile& SaveFile) const
51 humanoid::Save(SaveFile);
52 SaveFile << SoulID << HairColor << EyeColor << Talent << Weakness << IsBonePlayer << IsClone;
57 void playerkind::Load(inputfile& SaveFile)
59 humanoid::Load(SaveFile);
60 SaveFile >> SoulID >> HairColor >> EyeColor >> Talent >> Weakness >> IsBonePlayer >> IsClone;
65 void playerkind::SetSoulID(feuLong What)
67 SoulID = What;
69 if(GetPolymorphBackup())
70 GetPolymorphBackup()->SetSoulID(What);
75 truth playerkind::SuckSoul(character* Soul)
77 if(Soul->GetID() == SoulID)
79 SoulID = 0;
80 return true;
83 return false;
88 truth playerkind::TryToRiseFromTheDead()
90 if(humanoid::TryToRiseFromTheDead())
92 if(IsEnabled() && SoulID)
94 ADD_MESSAGE("The soulless body of %s wobbles for a moment.", CHAR_NAME(DEFINITE));
95 return false;
98 return true;
100 else
101 return false;
106 void playerkind::FinalProcessForBone()
108 humanoid::FinalProcessForBone();
109 IsBonePlayer = true;
111 if(SoulID)
113 boneidmap::iterator BI = game::GetBoneCharacterIDMap().find(SoulID);
115 if(BI != game::GetBoneCharacterIDMap().end())
116 SoulID = BI->second;
117 else
118 SoulID = 0;
124 playerkind::playerkind(const playerkind& Char) : mybase(Char), SoulID(Char.SoulID), HairColor(Char.HairColor), EyeColor(Char.EyeColor), Talent(Char.Talent), Weakness(Char.Weakness), IsBonePlayer(Char.IsBonePlayer), IsClone(true)
130 void playerkind::BeTalkedTo()
132 if(IsClone && IsBonePlayer)
134 if(GetRelation(PLAYER) == HOSTILE)
136 ADD_MESSAGE("Oh no, you too! Why does everyone bully me!");
137 return;
140 static sLong Said;
142 switch(RandomizeReply(Said, 4))
144 case 0:
145 ADD_MESSAGE("\"I'd like to write a memoir, but alas I doubt anyone would believe it.\"");
146 break;
147 case 1:
148 ADD_MESSAGE("\"Then that damned clone appeared, took all my equipment and claimed I was his slave...\"");
149 break;
150 case 2:
151 ADD_MESSAGE("\"The level was a catastrophe for the party, but luckily you saved the day.\"");
152 break;
153 case 3:
154 ADD_MESSAGE("\"Oh, how I hate bananas. I Hate Them! I HATE THEM SO MUCH!!!\"");
155 break;
158 else if(IsClone)
160 if(GetRelation(PLAYER) == HOSTILE)
162 ADD_MESSAGE("%s seems extremely irritated. \"Vanish, you foul mirror image!\"", CHAR_DESCRIPTION(DEFINITE));
163 return;
166 static sLong Said;
168 switch(RandomizeReply(Said, 4))
170 case 0:
171 ADD_MESSAGE("\"Hey, those clothes are mine! Give them back!\"");
172 break;
173 case 1:
174 ADD_MESSAGE("\"What, you summoned me? What a coincidence, I remember summoning you, too.\"");
175 break;
176 case 2:
177 ADD_MESSAGE("\"I'm leading this party, not you, Mr. copy guy!\"");
178 break;
179 case 3:
180 ADD_MESSAGE("\"Oh, how I hate bananas. I Hate Them! I HATE THEM SO MUCH!!!\"");
181 break;
184 else
186 if(GetRelation(PLAYER) == HOSTILE)
188 ADD_MESSAGE("Let's finish what my ghost failed to do!");
189 return;
192 static sLong Said;
194 switch(RandomizeReply(Said, 4))
196 case 0:
197 ADD_MESSAGE("\"What was it like? Death, you mean? Well, just like New Attnam. Very hot and whips everywhere.\"");
198 break;
199 case 1:
200 ADD_MESSAGE("\"Stop it already! I *don't* want to know how my corpse smelled!\"");
201 break;
202 case 2:
203 ADD_MESSAGE("\"I'm sorry about that ghost thing. That YASD was just a bit too much to handle, so I lost myself.\"");
204 break;
205 case 3:
206 ADD_MESSAGE("\"Oh, how I hate bananas. I Hate Them! I HATE THEM SO MUCH!!!\"");
207 break;
214 bodypart* playerkind::MakeBodyPart(int I) const
216 switch(I)
218 case TORSO_INDEX: return playerkindtorso::Spawn(0, NO_MATERIALS);
219 case HEAD_INDEX: return playerkindhead::Spawn(0, NO_MATERIALS);
220 case RIGHT_ARM_INDEX: return playerkindrightarm::Spawn(0, NO_MATERIALS);
221 case LEFT_ARM_INDEX: return playerkindleftarm::Spawn(0, NO_MATERIALS);
222 case GROIN_INDEX: return playerkindgroin::Spawn(0, NO_MATERIALS);
223 case RIGHT_LEG_INDEX: return playerkindrightleg::Spawn(0, NO_MATERIALS);
224 case LEFT_LEG_INDEX: return playerkindleftleg::Spawn(0, NO_MATERIALS);
227 ABORT("Weird bodypart to make for a playerkind. It must be your fault!");
228 return 0;
233 void playerkind::PostConstruct()
235 int R = 0, G = 0, B = 0;
237 switch(RAND_N(4))
239 case 0: R = 195; G = 165; B = 40; break;
240 case 1: R = 130; G = 30; B = 0; break;
241 case 2: R = 30; G = 30; B = 15; break;
242 case 3: R = 50; G = 30; B = 5; break;
245 HairColor = MakeRGB16(R + RAND_N(41), G + RAND_N(41), B + RAND_N(41));
247 switch(RAND_N(4))
249 case 0: R = 25; G = 0; B = 70; break;
250 case 1: R = 5; G = 0; B = 50; break;
251 case 2: R = 10; G = 10; B = 10; break;
252 case 3: R = 60; G = 20; B = 0; break;
255 EyeColor = MakeRGB16(R + RAND_N(41), G + RAND_N(41), B + RAND_N(41));
256 Talent = RAND_N(TALENTS);
257 Weakness = RAND_N(TALENTS);
262 v2 playerkind::GetHeadBitmapPos() const
264 int Sum = GetAttribute(INTELLIGENCE, false) + GetAttribute(WISDOM, false);
266 if(Sum >= 60)
267 return v2(96, 480);
268 else if(Sum >= 40)
269 return v2(96, 464);
270 else
271 return v2(96, 416);
276 v2 playerkind::GetRightArmBitmapPos() const
278 if(GetRightArm()->GetAttribute(ARM_STRENGTH, false) >= 20)
279 return v2(64, 448);
280 else
281 return v2(64, 416);
286 v2 playerkind::GetLeftArmBitmapPos() const
288 if(GetLeftArm()->GetAttribute(ARM_STRENGTH, false) >= 20)
289 return v2(64, 448);
290 else
291 return v2(64, 416);
296 int playerkind::GetNaturalSparkleFlags() const
298 return GetAttribute(CHARISMA) >= 30 ? SKIN_COLOR : 0;
303 double playerkind::GetNaturalExperience(int Identifier) const
305 double NE = DataBase->NaturalExperience[Identifier];
307 if(Talent == TalentOfAttribute[Identifier])
308 NE *= TalentBonusOfAttribute[Identifier];
310 if(Weakness == TalentOfAttribute[Identifier])
311 NE /= TalentBonusOfAttribute[Identifier];
313 return NE;
315 #endif