/
human.cpp
7911 lines (6655 loc) · 241 KB
/
human.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
*
* Iter Vehemens ad Necem (IVAN)
* Copyright (C) Timo Kiviluoto
* Released under the GNU General
* Public License
*
* See LICENSING which should be included
* along with this file for more details
*
*/
/* Compiled through charsset.cpp */
#include "dbgmsgproj.h"
#include "whandler.h"
#include "devcons.h"
cint humanoid::DrawOrder[] =
{ TORSO_INDEX, GROIN_INDEX, RIGHT_LEG_INDEX, LEFT_LEG_INDEX, RIGHT_ARM_INDEX, LEFT_ARM_INDEX, HEAD_INDEX };
truth humanoid::BodyPartIsVital(int I) const { return I == TORSO_INDEX || I == HEAD_INDEX || I == GROIN_INDEX; }
truth humanoid::BodyPartCanBeSevered(int I) const { return I != TORSO_INDEX && I != GROIN_INDEX; }
int humanoid::OpenMultiplier() const { return HasAUsableArm() ? 1 : 3; }
int humanoid::CloseMultiplier() const { return HasAUsableArm() ? 1 : 2; }
int humanoid::GetCarryingStrength() const { return Max(GetAttribute(LEG_STRENGTH), 1) + CarryingBonus; }
void humanoid::CalculateBodyParts() { BodyParts = HUMANOID_BODYPARTS; }
void humanoid::CalculateAllowedWeaponSkillCategories() { AllowedWeaponSkillCategories = WEAPON_SKILL_CATEGORIES; }
v2 farmer::GetHeadBitmapPos() const { return v2(96, (4 + (RAND() & 1)) << 4); }
v2 farmer::GetRightArmBitmapPos() const { return v2(64, (RAND() & 1) << 4); }
void guard::SetWayPoints(const fearray<packv2>& What) { ArrayToVector(What, WayPoints); }
cchar* oree::FirstPersonBiteVerb() const { return "vomit acidous blood at"; }
cchar* oree::FirstPersonCriticalBiteVerb() const { return "vomit very acidous blood at"; }
cchar* oree::ThirdPersonBiteVerb() const { return "vomits acidous blood at"; }
cchar* oree::ThirdPersonCriticalBiteVerb() const { return "vomits very acidous blood at"; }
cchar* oree::BiteNoun() const { return "liquid"; }
truth skeleton::BodyPartIsVital(int I) const { return I == GROIN_INDEX || I == TORSO_INDEX; }
truth communist::ShowClassDescription() const { return GetAssignedName() != "Ivan"; }
v2 housewife::GetHeadBitmapPos() const { return v2(112, (RAND() % 6) << 4); }
truth zombie::BodyPartIsVital(int I) const { return I == GROIN_INDEX || I == TORSO_INDEX; }
festring zombie::GetZombieDescription() const { return Description; }
truth ghost::BodyPartIsVital(int I) const { return I == GROIN_INDEX || I == TORSO_INDEX; }
festring ghost::GetGhostDescription() const { return Description; }
cchar* ghost::FirstPersonUnarmedHitVerb() const { return "touch"; }
cchar* ghost::FirstPersonCriticalUnarmedHitVerb() const
{ return "critically touch"; }
cchar* ghost::ThirdPersonUnarmedHitVerb() const { return "touches"; }
cchar* ghost::ThirdPersonCriticalUnarmedHitVerb() const
{ return "critically touches"; }
truth angel::BodyPartIsVital(int I) const { return I == TORSO_INDEX || I == HEAD_INDEX; }
truth nihil::BodyPartIsVital(int I) const { return I == TORSO_INDEX || I == HEAD_INDEX; }
truth genie::BodyPartIsVital(int I) const { return I == TORSO_INDEX || I == HEAD_INDEX; }
material* golem::CreateBodyPartMaterial(int, long Volume) const { return MAKE_MATERIAL(GetConfig(), Volume); }
truth sumowrestler::EquipmentIsAllowed(int I) const { return I == BELT_INDEX; }
truth ghost::SpecialEnemySightedReaction(character*) { return !(Active = true); }
petrus::~petrus()
{
game::SetPetrus(0);
}
truth ennerbeast::Hit(character* Enemy, v2, int, int)
{
if(CheckIfTooScaredToHit(Enemy))
return false;
if(RAND() & 1)
ADD_MESSAGE("%s yells: UGH UGHAaaa!", CHAR_DESCRIPTION(DEFINITE));
else
ADD_MESSAGE("%s yells: Uga Ugar Ugade Ugat!", CHAR_DESCRIPTION(DEFINITE));
rect Rect;
femath::CalculateEnvironmentRectangle(Rect, GetLevel()->GetBorder(), GetPos(), 30);
for(int x = Rect.X1; x <= Rect.X2; ++x)
for(int y = Rect.Y1; y <= Rect.Y2; ++y)
{
int ScreamStrength = int(70 / (hypot(GetPos().X - x, GetPos().Y - y) + 1));
if(ScreamStrength)
{
character* Char = GetNearSquare(x, y)->GetCharacter();
if(Char && Char != this)
{
msgsystem::EnterBigMessageMode();
if(Char->IsPlayer())
ADD_MESSAGE("You are hit by the horrible waves of high sound.");
else if(Char->CanBeSeenByPlayer())
ADD_MESSAGE("%s is hit by the horrible waves of high sound.", Char->CHAR_NAME(DEFINITE));
Char->ReceiveDamage(this, ScreamStrength, SOUND, ALL, YOURSELF, true);
Char->CheckDeath(CONST_S("killed @bkp scream"), this);
msgsystem::LeaveBigMessageMode();
}
GetNearLSquare(x, y)->GetStack()->ReceiveDamage(this, ScreamStrength, SOUND);
}
}
EditNP(-100);
EditAP(-1000000 / GetCWeaponSkill(BITE)->GetBonus());
EditStamina(-1000, false);
return true;
}
truth ennerchild::Hit(character* Enemy, v2, int, int)
{
if(CheckIfTooScaredToHit(Enemy))
return false;
if(RAND() & 1)
ADD_MESSAGE("%s yells: UGH UGHAaaa!", CHAR_DESCRIPTION(DEFINITE));
else
ADD_MESSAGE("%s yells: Uga Ugar Ugade Ugat!", CHAR_DESCRIPTION(DEFINITE));
rect Rect;
femath::CalculateEnvironmentRectangle(Rect, GetLevel()->GetBorder(), GetPos(), 30);
// Enner girl is older
int BaseScreamStrength = 50;
if(GetConfig() == BOY)
BaseScreamStrength = 40;
for(int x = Rect.X1; x <= Rect.X2; ++x)
for(int y = Rect.Y1; y <= Rect.Y2; ++y)
{
int ScreamStrength = int(BaseScreamStrength / (hypot(GetPos().X - x, GetPos().Y - y) + 1));
if(ScreamStrength)
{
character* Char = GetNearSquare(x, y)->GetCharacter();
if(Char && Char != this)
{
msgsystem::EnterBigMessageMode();
if(Char->IsPlayer())
ADD_MESSAGE("You are hit by the horrible waves of high sound.");
else if(Char->CanBeSeenByPlayer())
ADD_MESSAGE("%s is hit by the horrible waves of high sound.", Char->CHAR_NAME(DEFINITE));
Char->ReceiveDamage(this, ScreamStrength, SOUND, ALL, YOURSELF, true);
Char->CheckDeath(CONST_S("killed @bkp scream"), this);
msgsystem::LeaveBigMessageMode();
}
GetNearLSquare(x, y)->GetStack()->ReceiveDamage(this, ScreamStrength, SOUND);
}
}
EditNP(-100);
EditAP(-1000000 / GetCWeaponSkill(BITE)->GetBonus());
EditStamina(-1000, false);
return true;
}
truth ennerchild::ReceiveDamage(character* Damager, int Damage, int Type, int TargetFlags, int Direction,
truth Divide, truth PenetrateArmor, truth Critical, truth ShowMsg)
{
truth Success = false;
if(Type != SOUND)
{
Success = humanoid::ReceiveDamage(Damager, Damage, Type, TargetFlags, Direction,
Divide, PenetrateArmor, Critical, ShowMsg);
}
return Success;
}
void skeleton::CreateCorpse(lsquare* Square)
{
if(GetHead())
{
item* Skull = SevereBodyPart(HEAD_INDEX, false, Square->GetStack());
Square->AddItem(Skull);
}
int Amount = 2 + (RAND() & 3);
for(int c = 0; c < Amount; ++c)
Square->AddItem(bone::Spawn());
SendToHell();
}
void petrus::CreateCorpse(lsquare* Square)
{
if(game::GetGloomyCaveStoryState() == 2)
game::GetTeam(ATTNAM_TEAM)->SetRelation(game::GetTeam(PLAYER_TEAM), FRIEND);
Square->AddItem(leftnutofpetrus::Spawn());
SendToHell();
}
void humanoid::Save(outputfile& SaveFile) const
{
character::Save(SaveFile);
SaveFile << SWeaponSkill;
}
void humanoid::Load(inputfile& SaveFile)
{
character::Load(SaveFile);
SaveFile >> SWeaponSkill;
if(GetRightWielded())
for(sweaponskill* p : SWeaponSkill)
if(p->IsSkillOf(GetRightWielded()))
{
SetCurrentRightSWeaponSkill(p);
break;
}
if(GetLeftWielded())
for(sweaponskill* p : SWeaponSkill)
if(p->IsSkillOf(GetLeftWielded()))
{
SetCurrentLeftSWeaponSkill(p);
break;
}
}
truth golem::MoveRandomly()
{
if(!(RAND() % 500))
{
Engrave(CONST_S("Golem Needs Master"));
EditAP(-1000);
return true;
}
else
return character::MoveRandomly();
}
void ennerbeast::GetAICommand()
{
SeekLeader(GetLeader());
if(StateIsActivated(PANIC) || !(RAND() % 3))
Hit(0, ZERO_V2, YOURSELF);
if(CheckForEnemies(false, false, true))
return;
if(FollowLeader(GetLeader()))
return;
if(MoveRandomly())
return;
EditAP(-1000);
}
void ennerchild::GetAICommand()
{
SeekLeader(GetLeader());
if(StateIsActivated(PANIC) || !(RAND() % 3))
Hit(0, ZERO_V2, YOURSELF);
if(CheckForEnemies(false, false, true))
return;
if(FollowLeader(GetLeader()))
return;
if(MoveRandomly())
return;
EditAP(-1000);
}
void petrus::GetAICommand()
{
int Enemies = 0;
for(int c = 0; c < game::GetTeams(); ++c)
if(GetTeam()->GetRelation(game::GetTeam(c)) == HOSTILE)
Enemies += game::GetTeam(c)->GetEnabledMembers();
if(Enemies && !RAND_N(250 / Min(Enemies, 50)))
{
if(CanBeSeenByPlayer())
ADD_MESSAGE("%s shouts a magnificent prayer to Valpurus.", CHAR_NAME(DEFINITE));
angel* Angel = angel::Spawn(VALPURUS);
Angel->SetLifeExpectancy(10000, 0);
v2 Where = GetLevel()->GetNearestFreeSquare(Angel, GetPos());
if(Where == ERROR_V2)
Where = GetLevel()->GetRandomSquare(Angel);
Angel->SetTeam(GetTeam());
Angel->PutTo(Where);
if(Angel->CanBeSeenByPlayer())
ADD_MESSAGE("%s materializes.", Angel->CHAR_NAME(INDEFINITE));
EditAP(-1000);
return;
}
if(HP << 1 < MaxHP && (GetPos() - v2(28, 20)).GetLengthSquare() > 400 && !RAND_N(10))
{
if(CanBeSeenByPlayer())
ADD_MESSAGE("%s disappears.", CHAR_NAME(DEFINITE));
GetLevel()->GetLSquare(28, 20)->KickAnyoneStandingHereAway();
Move(v2(28, 20), true);
EditAP(-1000);
return;
}
if(!LastHealed || game::GetTick() - LastHealed > 16384)
for(int d = 0; d < GetNeighbourSquares(); ++d)
{
square* Square = GetNeighbourSquare(d);
if(Square)
{
character* Char = Square->GetCharacter();
if(Char && GetRelation(Char) == FRIEND && HealFully(Char))
return;
}
}
StandIdleAI();
}
truth petrus::HealFully(character* ToBeHealed)
{
truth DidSomething = false;
for(int c = 0; c < ToBeHealed->GetBodyParts(); ++c)
if(!ToBeHealed->GetBodyPart(c))
{
bodypart* BodyPart = 0;
for(ulong ID : ToBeHealed->GetOriginalBodyPartID(c))
{
BodyPart = static_cast<bodypart*>(ToBeHealed->SearchForItem(ID));
if(BodyPart)
break;
}
if(!BodyPart || !BodyPart->CanRegenerate())
continue;
BodyPart->RemoveFromSlot();
ToBeHealed->AttachBodyPart(BodyPart);
BodyPart->RestoreHP();
DidSomething = true;
if(ToBeHealed->IsPlayer())
ADD_MESSAGE("%s attaches your old %s back and heals it.",
CHAR_NAME(DEFINITE), BodyPart->GetBodyPartName().CStr());
else if(CanBeSeenByPlayer())
ADD_MESSAGE("%s attaches the old %s of %s back and heals it.",
CHAR_NAME(DEFINITE), BodyPart->GetBodyPartName().CStr(), ToBeHealed->CHAR_DESCRIPTION(DEFINITE));
}
if(ToBeHealed->IsInBadCondition())
{
ToBeHealed->RestoreLivingHP();
DidSomething = true;
if(ToBeHealed->IsPlayer())
ADD_MESSAGE("%s heals you fully.", CHAR_DESCRIPTION(DEFINITE));
else if(CanBeSeenByPlayer())
ADD_MESSAGE("%s heals %s fully.", CHAR_DESCRIPTION(DEFINITE), ToBeHealed->CHAR_DESCRIPTION(DEFINITE));
}
if(ToBeHealed->TemporaryStateIsActivated(POISONED))
{
ToBeHealed->DeActivateTemporaryState(POISONED);
DidSomething = true;
if(ToBeHealed->IsPlayer())
ADD_MESSAGE("%s removes the foul poison in your body.", CHAR_DESCRIPTION(DEFINITE));
else if(CanBeSeenByPlayer())
ADD_MESSAGE("%s removes the foul poison in %s's body.",
CHAR_DESCRIPTION(DEFINITE), ToBeHealed->CHAR_DESCRIPTION(DEFINITE));
}
if(DidSomething)
{
LastHealed = game::GetTick();
DexterityAction(10);
return true;
}
else
return false;
}
void petrus::Save(outputfile& SaveFile) const
{
humanoid::Save(SaveFile);
SaveFile << LastHealed;
}
void petrus::Load(inputfile& SaveFile)
{
humanoid::Load(SaveFile);
SaveFile >> LastHealed;
game::SetPetrus(this);
}
item* humanoid::GetMainWielded() const
{
if(GetMainArm())
if(GetMainArm()->GetWielded())
return GetMainArm()->GetWielded();
else
if(GetSecondaryArm())
return GetSecondaryArm()->GetWielded();
else
return 0;
else
if(GetSecondaryArm())
return GetSecondaryArm()->GetWielded();
else
return 0;
}
item* humanoid::GetSecondaryWielded() const
{
if(GetMainArm() && GetMainArm()->GetWielded() && GetSecondaryArm())
return GetSecondaryArm()->GetWielded();
else
return 0;
}
truth humanoid::Hit(character* Enemy, v2 HitPos, int Direction, int Flags)
{
if(CheckIfTooScaredToHit(Enemy))
return false;
if(IsPlayer())
{
if(!(Enemy->IsMasochist() && GetRelation(Enemy) == FRIEND) && GetRelation(Enemy) != HOSTILE
&& !game::TruthQuestion(CONST_S("This might cause a hostile reaction. Are you sure? [y/N]")))
return false;
}
else if(GetAttribute(WISDOM) >= Enemy->GetAttackWisdomLimit())
return false;
if(GetBurdenState() == OVER_LOADED)
{
if(IsPlayer())
ADD_MESSAGE("You cannot fight while carrying so much.");
return false;
}
int c, AttackStyles;
for(c = 0, AttackStyles = 0; c < 8; ++c)
if(GetAttackStyle() & (1 << c))
++AttackStyles;
int Chosen = RAND() % AttackStyles;
for(c = 0, AttackStyles = 0; c < 8; ++c)
if(GetAttackStyle() & (1 << c) && AttackStyles++ == Chosen)
{
Chosen = 1 << c;
break;
}
if(StateIsActivated(VAMPIRISM) && !(RAND() % 2))
{
if(Chosen == USE_ARMS && CanAttackWithAnArm())
if(!GetRightWielded() && !GetLeftWielded())
Chosen = USE_HEAD;
if(Chosen == USE_LEGS && HasTwoUsableLegs())
Chosen = USE_HEAD;
}
switch(Chosen)
{
case USE_ARMS:
if(CanAttackWithAnArm() && (!(Flags & SADIST_HIT) || HasSadistWeapon()))
{
msgsystem::EnterBigMessageMode();
Hostility(Enemy);
long FirstAPCost = 0, SecondAPCost = 0;
arm* FirstArm, * SecondArm;
if(RAND() & 1)
{
FirstArm = GetRightArm();
SecondArm = GetLeftArm();
}
else
{
FirstArm = GetLeftArm();
SecondArm = GetRightArm();
}
int Strength = Max(GetAttribute(ARM_STRENGTH), 1);
if(FirstArm && FirstArm->GetDamage() && (!(Flags & SADIST_HIT) || FirstArm->HasSadistWeapon()))
{
FirstAPCost = FirstArm->GetAPCost();
FirstArm->Hit(Enemy, HitPos, Direction, Flags);
if(StateIsActivated(LEPROSY) && !RAND_N(25 * GetAttribute(ENDURANCE)))
DropBodyPart(FirstArm->GetBodyPartIndex());
}
if(!GetAction() && IsEnabled() && Enemy->IsEnabled() && SecondArm && SecondArm->GetDamage()
&& (!(Flags & SADIST_HIT) || SecondArm->HasSadistWeapon()))
{
SecondAPCost = SecondArm->GetAPCost();
SecondArm->Hit(Enemy, HitPos, Direction, Flags);
if(StateIsActivated(LEPROSY) && !RAND_N(25 * GetAttribute(ENDURANCE)))
DropBodyPart(SecondArm->GetBodyPartIndex());
}
EditNP(-50);
EditAP(-Max(FirstAPCost, SecondAPCost));
EditStamina(GetAdjustedStaminaCost(-1000, Strength), false);
msgsystem::LeaveBigMessageMode();
return true;
}
case USE_LEGS:
if(HasTwoUsableLegs())
{
msgsystem::EnterBigMessageMode();
Hostility(Enemy);
Kick(GetNearLSquare(HitPos), Direction, Flags & SADIST_HIT);
if(StateIsActivated(LEPROSY) && !RAND_N(25 * GetAttribute(ENDURANCE)))
DropBodyPart(RAND_2 ? RIGHT_LEG_INDEX : LEFT_LEG_INDEX);
msgsystem::LeaveBigMessageMode();
return true;
}
case USE_HEAD:
if(GetHead())
{
msgsystem::EnterBigMessageMode();
Hostility(Enemy);
Bite(Enemy, HitPos, Direction, Flags & SADIST_HIT);
msgsystem::LeaveBigMessageMode();
return true;
}
default:
if(IsPlayer())
ADD_MESSAGE("You are currently quite unable to damage anything.");
return false;
}
}
truth humanoid::AddSpecialSkillInfo(felist& List) const
{
truth Something = false;
if(CurrentRightSWeaponSkill && CurrentRightSWeaponSkill->GetHits() / 100)
{
List.AddEntry(CONST_S(""), LIGHT_GRAY);
festring Buffer = CONST_S("right accustomization");
Buffer.Resize(30);
Buffer << CurrentRightSWeaponSkill->GetLevel();
Buffer.Resize(40);
Buffer << CurrentRightSWeaponSkill->GetHits() / 100;
Buffer.Resize(50);
if(CurrentRightSWeaponSkill->GetLevel() != 20)
Buffer << (CurrentRightSWeaponSkill->GetLevelMap(CurrentRightSWeaponSkill->GetLevel() + 1)
- CurrentRightSWeaponSkill->GetHits()) / 100;
else
Buffer << '-';
Buffer.Resize(60);
int Bonus = CurrentRightSWeaponSkill->GetBonus();
Buffer << '+' << (Bonus - 1000) / 10;
if(Bonus %= 10)
Buffer << '.' << Bonus;
Buffer << '%';
List.AddEntry(Buffer, WHITE);
Something = true;
}
if(CurrentLeftSWeaponSkill && CurrentLeftSWeaponSkill->GetHits() / 100)
{
if(!Something)
List.AddEntry(CONST_S(""), LIGHT_GRAY);
festring Buffer = CONST_S("left accustomization");
Buffer.Resize(30);
Buffer << CurrentLeftSWeaponSkill->GetLevel();
Buffer.Resize(40);
Buffer << CurrentLeftSWeaponSkill->GetHits() / 100;
Buffer.Resize(50);
if(CurrentLeftSWeaponSkill->GetLevel() != 20)
Buffer << (CurrentLeftSWeaponSkill->GetLevelMap(CurrentLeftSWeaponSkill->GetLevel() + 1)
- CurrentLeftSWeaponSkill->GetHits()) / 100;
else
Buffer << '-';
Buffer.Resize(60);
int Bonus = CurrentLeftSWeaponSkill->GetBonus();
Buffer << '+' << (Bonus - 1000) / 10;
if(Bonus %= 10)
Buffer << '.' << Bonus;
Buffer << '%';
List.AddEntry(Buffer, WHITE);
Something = true;
}
return Something;
}
void petrus::BeTalkedTo()
{
if(!GetPos().IsAdjacent(PLAYER->GetPos()))
return;
if(GetRelation(PLAYER) == HOSTILE)
{
ADD_MESSAGE("Heretic! Dev/null is a place not worthy to receive thee!");
return;
}
if(PLAYER->HasMuramasa() && PLAYER->HasMasamune())
{
if(game::TruthQuestion(CONST_S("Report your actions in the kingdom of Aslona? [y/N]"), REQUIRES_ANSWER))
{
game::PlayVictoryMusic();
game::TextScreen(CONST_S("\"Yes, citizen? Ah, it is thee. I was wondering were hast thou wandered off. Art thou\n"
"coming back to beg for forgiveness and mercy?\"\n\n"
"But Petrus' anger is quickly quelled when you fall to your knees and present to him\n"
"the two regal swords of Aslona. He takes them and admires them in silence for a while,\n"
"though interrupted by Sir Lancelyn who realizes your deeds, screams in rage and is\n"
"promptly dragged away to a prison cell.\n\n"
"Lost in thoughts, Petrus hands the swords to a servant and turns back to you again:\n\n"
"\"I have decided thy fate, slave. I shan't have thee executed if thou canst prove thy worth.\n"
"Sir Galladon hast telepathically informed me that our trainee guards are just about ready\n"
"for their first war. Thou shalt join my army and help conquer Aslona while they are reeling.\n"
"For the glory of Valpurus!\"\n\nYou are victorious!"));
game::GetCurrentArea()->SendNewDrawRequest();
game::DrawEverything();
PLAYER->ShowAdventureInfo();
festring Msg = CONST_S("became an officer of the Attnamese army");
AddScoreEntry(Msg, 3, false);
game::End(Msg);
return;
}
}
if(PLAYER->HasGoldenEagleShirt())
{
ADD_MESSAGE("Petrus smiles. \"Thou hast defeated Oree! Mayst thou be blessed by Valpurus for the rest of thy life! "
"And thou possess the Shirt of the Golden Eagle, the symbol of Our status! Return it now, please.\"");
if(game::TruthQuestion(CONST_S("Will you give the Shirt of the Golden Eagle to Petrus? [y/n]"), REQUIRES_ANSWER))
{
game::PlayVictoryMusic();
game::TextScreen(CONST_S("The Holy Shirt is returned to its old owner and you kneel down to receive your reward.\n"
"Petrus taps your shoulder with the Justifier and raises you to nobility. Later you\n"
"receive a small dukedom in the middle of tundra where you rule with justice till\n"
"the end of your content life.\n\nYou are victorious!"));
game::GetCurrentArea()->SendNewDrawRequest();
game::DrawEverything();
PLAYER->ShowAdventureInfo();
festring Msg = CONST_S("retrieved the Shirt of the Golden Eagle and was raised to nobility");
AddScoreEntry(Msg, 4, false);
game::End(Msg);
return;
}
else
{
ADD_MESSAGE("Petrus's face turns red. \"I see. Thy greed hath overcome thy wisdom. Then, "
"we shall fight for the shiny shirt. May Valpurus bless him who is better.\"");
/* And now we actually make his face change color ;-) */
GetHead()->GetMainMaterial()->SetSkinColor(MakeRGB16(255, 75, 50));
GetHead()->UpdatePictures();
SendNewDrawRequest();
game::AskForKeyPress(CONST_S("You are attacked! [press any key to continue]"));
PLAYER->GetTeam()->Hostility(GetTeam());
game::SetGloomyCaveStoryState(2);
return;
}
}
if(PLAYER->HasHeadOfElpuri())
{
game::PlayVictoryMusic();
game::TextScreen(CONST_S("You have slain Elpuri, and Petrus grants you the freedom you desire.\n"
"You spend the next months in Attnam as an honored hero and when the\n"
"sea finally melts, you board the first ship, leaving your past forever\n"
"behind.\n\nYou are victorious!"));
game::GetCurrentArea()->SendNewDrawRequest();
game::DrawEverything();
PLAYER->ShowAdventureInfo();
festring Msg = CONST_S("defeated Elpuri and continued to further adventures");
AddScoreEntry(Msg, 2, false);
game::End(Msg);
}
else if(game::GetGloomyCaveStoryState() == 1)
{
ADD_MESSAGE("Petrus says: \"Bring me the head of Elpuri and we'll talk.\"");
return;
}
if(!game::GetStoryState())
{
if(PLAYER->RemoveEncryptedScroll())
{
game::TextScreen(CONST_S("You kneel down and bow before the high priest and hand him the encrypted scroll.\n"
"Petrus raises his arm, the scroll glows yellow, and lo! The letters are clear and\n"
"readable. Petrus asks you to voice them aloud. The first two thousand words praise\n"
"Valpurus the Creator and all His manifestations and are followed by a canticle of\n"
"Saint Petrus the Lion-Hearted lasting roughly three thousand words. Finally there\n"
"are some sentences actually concerning your mission:\n\n"
"\"Alas, I fear dirty tongues have spread lies to my Lord's ears. I assure all tales\n"
"of treasures here in New Attnam are but mythic legends. There is nothing of value here.\n"
"The taxes are already an unbearable burden and I can't possibly pay more. However I do\n"
"not question the wisdom of the government's decisions. I will contribute what I can:\n"
"the ostriches will deliver an extra 10000 bananas to the capital and additionally the\n"
"slave that brought the message will henceforth be at Your disposal. I am certain this\n"
"satisfies the crown's needs.\"\n\n"
"\"Yours sincerely,\n"
"Richel Decos, the viceroy of New Attnam\""));
game::TextScreen(CONST_S("You almost expected the last bit. Petrus seems to be deep in his thoughts and you\n"
"wonder what shape your destiny is taking in his mind. Suddenly he seems to return\n"
"to this reality and talks to you.\n\n"
"\"Oh, thou art still here. We were just discussing telepathically with Sir Galladon.\n"
"We started doubting Decos's alleged poverty a while back when he bought a couple of\n"
"medium-sized castles nearby. Thy brethren from New Attnam have also told Us about\n"
"vast riches seized from them. Our law says all such stolen valuables belong to \n"
"the Cathedral's treasury, so this is a severe claim. However, proof is needed,\n"
"and even if such was provided, We couldn't send soldiers over the snow fields\n"
"ere spring.\"\n\n"
"\"However, since thou now servest Us, We ought to find thee something to do. In Our\n"
"immesurable kindness and generosity, we giveth thee some time to see this majestic\n"
"city of Ours and marvel at its glory. Return to Us once thou hast admired Our\n"
"monumental Cathedral enough, and we shall have decided thy fate by then.\""));
GetArea()->SendNewDrawRequest();
ADD_MESSAGE("\"The patrol guard will watch out for you, so don't thee think of running away.\"");
game::SetStoryState(1);
}
else
ADD_MESSAGE("\"Yes, citizen? We are quite busy now, thou shalt not disturb Us without proper cause.\"");
}
else if(game::GetStoryState() == 1)
{
game::TextScreen(CONST_S("\"Ah, here thou art, my brave warrior savage! Our agents hast informed Us that they\n"
"witnessed thou leaving the dreaded underwater tunnel. This means thou most likely hast\n"
"defeated Genetrix Vesana and art a talented monster slayer. We happen to have a task\n"
"perfect for such a person.\"\n\n"
"\"An evil dark frog named Elpuri who hates Valpurus and Attnam more than anything hath\n"
"taken control over an abandoned mine nearby. It is pestering our fine city in many ways\n"
"and reconnaissance has reported an army of monsters gathering in the cave. Our guards\n"
"are not trained to fight underground and We dare not send them. To make things worse,\n"
"someone hath recently stolen from Us the greatest armor in existence - the Shirt of the Golden Eagle.\n"
"Elpuri cannot wear it but he who can is now nearly immortal.\"\n\n"
"\"We have marked the location of the gloomy cave on thy map. We want you to dive\n"
"into it and slay the vile frog. Bring Us its head and We reward thee with freedom.\n"
"Shouldst thou also find the Shirt, We'll knight thee.\"\n\n"
"\"Good luck, and return when thou hast succeeded.\""));
game::LoadWorldMap();
v2 ElpuriCavePos = game::GetWorldMap()->GetEntryPos(0, ELPURI_CAVE);
game::GetWorldMap()->GetWSquare(ElpuriCavePos)->ChangeOWTerrain(elpuricave::Spawn());
game::GetWorldMap()->RevealEnvironment(ElpuriCavePos, 1);
game::SaveWorldMap();
GetArea()->SendNewDrawRequest();
ADD_MESSAGE("\"And by the way, visit the librarian. He might have advice for thee.\"");
game::SetGloomyCaveStoryState(1);
game::SetStoryState(2);
}
else // StoryState == 2
ADD_MESSAGE("\"Yes, citizen? We are quite busy now, thou shalt not disturb Us without proper cause.\"");
}
void priest::BeTalkedTo()
{
if(GetRelation(PLAYER) == HOSTILE)
{
character::BeTalkedTo();
return;
}
else if(!GetPos().IsAdjacent(PLAYER->GetPos()))
{
static long Said;
if(GetConfig() != SILVA)
humanoid::BeTalkedTo();
else if(!game::TweraifIsFree())
ProcessAndAddMessage(GetFriendlyReplies()[RandomizeReply(Said, 4)]);
else
ProcessAndAddMessage(GetFriendlyReplies()[4 + RandomizeReply(Said, 3)]);
return;
}
if(PLAYER->IsBurning())
{
long Price = GetConfig() == VALPURUS ? 25 : 5;
if(PLAYER->GetMoney() >= Price)
{
ADD_MESSAGE("\"Good %s, you're on fire! Quick, hand over %ld gold!\"", GetMasterGod()->GetName(), Price);
if(game::TruthQuestion(CONST_S("Do you agree? [y/N]")))
{
PLAYER->Extinguish(true);
PLAYER->SetMoney(PLAYER->GetMoney() - Price);
SetMoney(GetMoney() + Price);
return;
}
}
else
ADD_MESSAGE("\"Good %s, you're on fire! Quick, go find %ld gold so that I can help!\"", GetMasterGod()->GetName(), Price);
}
for(int c = 0; c < PLAYER->GetBodyParts(); ++c)
{
if(!PLAYER->GetBodyPart(c) && PLAYER->CanCreateBodyPart(c))
{
truth HasOld = false;
for(ulong ID : PLAYER->GetOriginalBodyPartID(c))
{
bodypart* OldBodyPart = static_cast<bodypart*>(PLAYER->SearchForItem(ID));
if(OldBodyPart)
{
HasOld = true;
long Price = GetConfig() == VALPURUS ? 50 : 10;
if(PLAYER->GetMoney() >= Price)
{
if(!OldBodyPart->CanRegenerate())
ADD_MESSAGE("\"Sorry, I cannot put back bodyparts made of %s, not even your severed %s.\"",
OldBodyPart->GetMainMaterial()->GetName(false, false).CStr(),
PLAYER->GetBodyPartName(c).CStr());
else
{
ADD_MESSAGE("\"I could put your old %s back in exchange for %ld gold.\"",
PLAYER->GetBodyPartName(c).CStr(), Price);
if(game::TruthQuestion(CONST_S("Do you agree? [y/N]")))
{
OldBodyPart->SetHP(1);
PLAYER->SetMoney(PLAYER->GetMoney() - Price);
SetMoney(GetMoney() + Price);
OldBodyPart->RemoveFromSlot();
PLAYER->AttachBodyPart(OldBodyPart);
return;
}
}
}
else
ADD_MESSAGE("\"Your %s is severed. Help yourself and get %ldgp and I'll help you too.\"",
PLAYER->GetBodyPartName(c).CStr(), Price);
}
}
long Price = GetConfig() == VALPURUS ? 100 : 20;
if(PLAYER->GetMoney() >= Price)
{
if(HasOld)
ADD_MESSAGE("\"I could still summon up a new one for %ld gold.\"", Price);
else
ADD_MESSAGE("\"Since you don't seem to have your original %s with you, "
"I could summon up a new one for %ld gold.\"",
PLAYER->GetBodyPartName(c).CStr(), Price);
if(game::TruthQuestion(CONST_S("Agreed? [y/N]")))
{
PLAYER->SetMoney(PLAYER->GetMoney() - Price);
SetMoney(GetMoney() + Price);
PLAYER->CreateBodyPart(c);
PLAYER->GetBodyPart(c)->SetHP(1);
return;
}
}
else if(!HasOld)
ADD_MESSAGE("\"You don't have your original %s with you. I could create you a new one, "
"but my Divine Employer is not a communist and you need %ldgp first.\"",
PLAYER->GetBodyPartName(c).CStr(), Price);
}
if(PLAYER->GetBodyPart(c))
{
bodypart* BodyPart = PLAYER->GetBodyPart(c);
if(BodyPart->CanRegenerate() && BodyPart->IsBurnt())
{
long Price = GetConfig() == VALPURUS ? 25 : 5;
if(PLAYER->GetMoney() >= Price)
{
ADD_MESSAGE("\"I could cure the burns on your %s in exchange for %ld gold.\"",
PLAYER->GetBodyPartName(c).CStr(), Price);
if(game::TruthQuestion(CONST_S("Do you agree? [y/N]")))
{
BodyPart->ResetBurning();
PLAYER->SetMoney(PLAYER->GetMoney() - Price);
SetMoney(GetMoney() + Price);
return;
}
}
else
ADD_MESSAGE("\"Your %s is burnt. Bring me %ld gold pieces and I'll make it all better.\"",
PLAYER->GetBodyPartName(c).CStr(), Price);
}
else if(!BodyPart->CanRegenerate() && BodyPart->IsBurnt())
ADD_MESSAGE("\"Sorry, I cannot heal bodyparts made of %s, not even your burnt %s.\"",
BodyPart->GetMainMaterial()->GetName(false, false).CStr(),
PLAYER->GetBodyPartName(c).CStr());
}
}
if(PLAYER->TemporaryStateIsActivated(POISONED))
{
long Price = GetConfig() == VALPURUS ? 25 : 5;
if(PLAYER->GetMoney() >= Price)
{
ADD_MESSAGE("\"You seem to be rather ill. I could give you a "
"small dose of antidote for %ld gold pieces.\"", Price);
if(game::TruthQuestion(CONST_S("Do you agree? [y/N]")))
{
ADD_MESSAGE("You feel better.");
PLAYER->DeActivateTemporaryState(POISONED);
PLAYER->SetMoney(PLAYER->GetMoney() - Price);
SetMoney(GetMoney() + Price);
return;
}
}
else
ADD_MESSAGE("\"You seem to be rather ill. Get %ld gold pieces and I'll fix that.\"", Price);
}
if(PLAYER->TemporaryStateIsActivated(LEPROSY))
{
long Price = GetConfig() == VALPURUS ? 100 : 20;
if(PLAYER->GetMoney() >= Price)
{
ADD_MESSAGE("\"You seem to have contracted the vile disease of leprosy. "
"I could give you a small dose of medicine for %ld gold pieces.\"", Price);
if(game::TruthQuestion(CONST_S("Do you agree? [y/N]")))
{
ADD_MESSAGE("You feel better.");
PLAYER->DeActivateTemporaryState(LEPROSY);
PLAYER->SetMoney(PLAYER->GetMoney() - Price);
SetMoney(GetMoney() + Price);
return;
}
}
else
ADD_MESSAGE("\"You seem to be falling apart. Get %ld gold pieces and I'll fix that.\"", Price);
}
if(PLAYER->TemporaryStateIsActivated(LYCANTHROPY))
{