-
Notifications
You must be signed in to change notification settings - Fork 1
/
hero.cpp
3859 lines (3409 loc) · 97.6 KB
/
hero.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
// #define PLAYER_IS_IMMORTAL
// #define SHOW_TURN_NUMBER
#include "mem_check.h"
#include "monster.h"
#include "map.h"
#include "keyboard.h"
#include "actions.h"
#include "system.h"
#include "global.h"
#include "directions.h"
#include "options.h"
#include "attrib.h"
#include "level.h"
#include "places.h"
#include "parser.h"
#include "sounds.h"
#include <list>
using namespace std;
extern void make_screenshot(string filename,bool put_date);
#include <stdlib.h> // dla exit(0)
// z pliku global.cpp
extern GAME game;
extern KEYBOARD keyboard;
extern LEVEL level;
extern MYSCREEN screen;
extern DEFINITIONS definitions;
extern PLACES places;
extern class OPTIONS options;
extern DESCRIPTIONS descriptions;
extern SOUNDS sounds;
extern void turn_on_wait_for_key();
extern void turn_off_wait_for_key();
HERO :: HERO()
{
ClassName = "HERO";
UniqueNumber = PLAYER_UNIQUE_NUMBER;
tile='@';
color=14;
size=100;
weight=80000;
stop_repeating();
rename("Player");
// player x and y position
ChangePosition(-1,-1);
hit_points.val=23;
hit_points.max=23;
strength.val=12;
dexterity.val=8;
endurance.val=10;
intelligence.val=10;
speed.val=30;
unarmed.rename("맨손");
unarmed.DMG=5;
unarmed.HIT=3;
unarmed.DEF=1;
no_armor.rename("맨몸");
no_armor.ARM=1;
no_armor.owner=this;
last_activated=NULL;
enemy=NULL;
experience=0;
level_at_experience=500;
exp_level=1;
free_skill_pointes=150;
adaptation_points = 0;
ID_of_level = "";
next_action_time=0;
turns_of_rest=0;
group_affiliation = GROUP_HERO;
for (int a=0;a<NUMBER_OF_RESISTS;a++)
experience_in_skill[a]=0;
action_to_repeat=REPEAT_ACTION_NONE;
}
void HERO :: give_experience(unsigned long value)
{
experience += value;
free_skill_pointes += value;
while( experience >= level_at_experience)
got_level_up();
}
void HERO :: got_level_up()
{
exp_level++;
// incrase attributes
screen.console.add("* 레벨이 오른다! *\n",10);
sounds.PlaySoundOnce("data/sounds/other/levelup.wav",255);
if (exp_level%3==0)
{
strength.val++;
strength.max++;
dexterity.val++;
dexterity.max++;
speed.val++;
speed.max++;
screen.console.add("* 힘이 강해지고 움직임이 빨라진다! *\n",10);
}
if (exp_level%4==0)
{
endurance.val++;
endurance.max++;
screen.console.add("* 신체가 강인해진다 *\n",10);
}
level_at_experience*=2;
int random_value = random(3)+1;
// proportional incrase of metabolism.
int new_metabolism = ((metabolism.max+1)*(hit_points.max+random_value))/hit_points.max;
metabolism.val += (new_metabolism - metabolism.max);
metabolism.max = new_metabolism;
hit_points.max += random_value;
hit_points.val += random_value;
// add adaptation points
if (exp_level%3==0)
adaptation_points+=(endurance.val/4);
}
void HERO :: show_attributes()
{
string text,exp;
set_color(7);
text="HP: " + IntToStr(hit_points.GetValue()) + "/" + IntToStr(hit_points.max) + " EP: ";
if (energy_points.val>0)
text+=IntToStr(energy_points.GetValue());
else
text+='-';
print_text(0,47,text);
if (have_low_hp())
{
if (have_critically_low_hp())
{
sounds.PlayHeartBeat();
set_color(4);
}
else
{
set_color(14);
sounds.StopHeartBeat();
}
text=IntToStr(hit_points.GetValue());
print_text(4,47,text);
set_color(7);
}
else
sounds.StopHeartBeat();
if (options.number[OPTION_EXPERIENCE]==false)
exp = " EXP: " + IntToStr(exp_level) + "/" + IntToStr(experience) + " (" + IntToStr(free_skill_pointes) + ")";
else
exp = " EXP: " + IntToStr(exp_level) + "\\" + IntToStr(level_at_experience - experience) + " (" + IntToStr(free_skill_pointes) + ")";
text="힘: " + IntToStr(strength.GetValue()) + " 재주: " + IntToStr(dexterity.GetValue());
int speed_pos = text.size();
text += " 속도: " + IntToStr(speed.GetValue()) + " 체력: " + IntToStr(endurance.GetValue()) + " 지능: " + IntToStr(intelligence.GetValue()) + exp;
print_text(20,47,text);
if (isBurdened())
{
if (isStrained())
set_color(12);
else
set_color(14);
print_text(21+speed_pos,47,"속도");
set_color(7);
}
#ifdef SHOW_TURN_NUMBER
print_text(70,48, "T: " +IntToStr(next_action_time));
#endif
// show level name
print_text(79-level.levels[ID_of_level].name.size(),49,level.levels[ID_of_level].name);
if (weapon!=NULL)
{
text="x " + (weapon->ITEM::show_name()).substr(0,25);
if (weapon->property_load_ammo())
{
text="x " + (weapon->ITEM::show_name()).substr(0,17);
RANGED_WEAPON *ranged_weapon = weapon->IsShootingWeapon();
if (ranged_weapon!=NULL)
{
text+=" " + IntToStr ( ranged_weapon->ammo.quantity );
text+="/" + IntToStr ( ranged_weapon->magazine_capacity);
text+=" ";
switch( ranged_weapon->fire_type)
{
case FIRE_SINGLE:
text+="(1)";
break;
case FIRE_DOUBLE:
text+="(2)";
break;
case FIRE_TRIPLE:
text+="(3)";
break;
case FIRE_BURST:
text+="(B)";
break;
}
} // endof if
}
if (weapon->energy_activated==1)
set_color(13);
else
set_color(7);
print_text(20,48,text);
weapon->draw_at(20,48);
}
// armor always !=NULL
text=(armor->ITEM::show_name()).substr(0,25);
if (armor->hit_points < armor->max_hit_points/2)
{
if (armor->hit_points <= armor->max_hit_points/4)
{
set_color(4);
}
else
{
if (armor->energy_activated==1)
set_color(5);
else
set_color(14);
}
}
else
{
if (armor->energy_activated==1)
set_color(13);
else
set_color(7);
}
print_text(53,48,text);
armor->draw_at(51,48);
// print enemy
if (enemy!=NULL)
{
set_color(7);
print_text(20,49,"목표: ");
if (enemy->have_low_hp())
{
if (enemy->have_critically_low_hp())
set_color(4);
else
set_color(14);
}
else
set_color(9);
print_text(28,49,enemy->name);
}
// print status
if (IsRadiated())
{
set_color(14);
print_text(0,49,"오염");
}
if (IsPoisoned())
{
set_color(2);
print_text(5,49,"중독");
}
if (IsBurning())
{
set_color(4);
print_text(10,49,"화상");
}
else if (IsFreezed())
{
set_color(15);
print_text(10,49,"동상");
}
if (IsSlowed())
{
set_color(1);
print_text(15,49,"감속");
}
else if (IsHasted())
{
set_color(9);
print_text(15,49,"가속");
}
}
void HERO :: display()
{
TILE :: display();
show_attributes();
}
void HERO::stop_repeating()
{
turns_of_rest=0;
travel_dest_x = -1;
travel_dest_y = -1;
action_to_repeat=REPEAT_ACTION_NONE;
inventory_repeat_break=true;
}
void HERO::repeat_action(ERepeatAction a_to_repeat)
{
action_to_repeat=a_to_repeat;
}
ACTION HERO :: get_action()
{
if (IsStunned())
{
level.map.UnSeenMap();
level.map.HideFromPlayerSight();
ptr_list::iterator m,_m;
MONSTER *temp;
for(m=level.monsters.begin(),_m=level.monsters.end(); m!=_m; m++)
{
temp=(MONSTER *)*m;
if (temp!=level.player)
temp->seen_now = false;
}
return ACTION_WAIT_STUNNED;
}
// repeating
if (action_to_repeat==REPEAT_ACTION_REST)
{
if (turns_of_rest>0)
{
turns_of_rest--;
return ACTION_WAIT;
}
else
repeat_action(REPEAT_ACTION_NONE);
}
// show screen before player movement
// do fov calculation
look_around();
if (action_to_repeat==REPEAT_ACTION_EXPLORE)
{
// set_direction_to_unexplored
if (set_direction_to_closest_unexplored())
{
screen.draw();
myrefresh();
delay(20);
return ACTION_MOVE;
}
else
return ACTION_NOTHING;
}
if (action_to_repeat==REPEAT_ACTION_TRAVEL)
{
if (set_direction_to_cell_by_shortest_path(travel_dest_x,travel_dest_y,true))
{
screen.draw();
myrefresh();
delay(20);
return ACTION_MOVE;
}
else
{
stop_repeating();
return ACTION_NOTHING;
}
}
if (options.number[OPTION_AIM_IF_NO_ENEMY]==true && enemy==NULL)
select_closest_enemy();
if (options.number[OPTION_AUTO_AIM]==true)
select_closest_enemy();
if (level.player->is_repeating_action()==false)
{
screen.clear_all();
screen.draw();
screen.console.clean();
// print items pod nogami po of movement
if (last_pX!=pX() || last_pY!=pY())
{
level.player->show_laying_items();
}
screen.console.show();
screen.console.zero();
}
int key=0;
if (is_repeating_action()==false)
{
if (options.number[OPTION_CURSOR]==true)
{
show_cursor();
print_text(level.player->pX(),level.player->pY(),"");
set_cursor(level.player->pX(),level.player->pY());
}
key=keyboard.wait_for_key();
if (options.number[OPTION_CURSOR]==true)
{
hide_cursor();
}
}
if (key==keyboard.n)
{
direction=_kn;
return ACTION_MOVE;
}
else if (key==keyboard.ne)
{
direction=_kne;
return ACTION_MOVE;
}
else if (key==keyboard.e)
{
direction=_ke;
return ACTION_MOVE;
}
else if (key==keyboard.se)
{
direction=_kse;
return ACTION_MOVE;
}
else if (key==keyboard.s)
{
direction=_ks;
return ACTION_MOVE;
}
else if (key==keyboard.sw)
{
direction=_ksw;
return ACTION_MOVE;
}
else if (key==keyboard.w)
{
direction=_kw;
return ACTION_MOVE;
}
else if (key==keyboard.nw)
{
direction=_knw;
return ACTION_MOVE;
}
else if (key==keyboard.quit)
{
screen.console.add_and_zero("정말로 *저장하지 않고* 종료할까? (예Y/아니오N)\n",7);
if (keyboard.yes_no()==true)
return ACTION_QUIT;
return ACTION_NOTHING;
}
else if (key==keyboard.save && level.ID!="Tutorial")
{
screen.console.add_and_zero("저장하고 종료할까? (예Y/아니오N)\n",7);
if (keyboard.yes_no()==true)
return ACTION_SAVE;
return ACTION_NOTHING;
}
else if (key==keyboard.exchange)
{
set_ready_weapon();
return ACTION_NOTHING;
}
else if (key==keyboard.up)
{
return ACTION_STAIRS_UP;
}
else if (key==keyboard.down)
{
return ACTION_STAIRS_DOWN;
}
else if (key==keyboard.rest)
{
return ACTION_REST;
}
else if (key==keyboard.explore)
{
return ACTION_EXPLORE;
}
else if (key==keyboard.travel)
{
return ACTION_TRAVEL;
}
else if (key==keyboard.wait)
{
return ACTION_WAIT;
}
else if (key==keyboard.get)
{
return ACTION_GET;
}
else if (key==keyboard.look)
{
return ACTION_LOOK;
}
else if (key==keyboard.show_visible)
{
print_visible_monsters_and_items();
return ACTION_NOTHING;
}
else if (key==keyboard.messagebuffer)
{
return ACTION_SHOW_MESSAGE_BUFFER;
}
else if (key==keyboard.inventory || action_to_repeat==REPEAT_ACTION_INVENTORY)
{
return ACTION_INVENTORY;
}
else if (key==keyboard.fire)
{
return ACTION_FIRE;
}
else if (key==keyboard.help)
{
return ACTION_SHOW_HELP;
}
else if (key==keyboard.char_info)
{
return ACTION_SHOW_INFO;
}
else if (key==keyboard.inc_fire)
{
return ACTION_INC_FIRE;
}
else if (key==keyboard.dec_fire)
{
return ACTION_DEC_FIRE;
}
else if (key==keyboard.options)
{
return ACTION_OPTIONS;
}
else if (key==keyboard.reload)
{
return ACTION_RELOAD;
}
else if (key==keyboard._throw)
{
return ACTION_THROW;
}
else if (key==keyboard.activate_weapon)
{
return ACTION_ACTIVATE_WEAPON;
}
else if (key==keyboard.activate_armor)
{
return ACTION_ACTIVATE_ARMOR;
}
else if (key==keyboard.escape)
{
enemy=NULL; // zero enemy
return ACTION_NOTHING;
}
else if (key==keyboard.nearest)
{
if (enemy==NULL)
select_closest_enemy();
else // go through all of enemies
{
ptr_list::iterator m,_m;
MONSTER *temp, *first=NULL, *next=NULL;
bool wybierz_kolejnego=false;
for(m=level.monsters.begin(),_m=level.monsters.end(); m!=_m; m++)
{
temp=(MONSTER *)*m;
if (temp->seen_now && this->is_enemy(temp))
{
if (wybierz_kolejnego==true)
{
next=temp;
break;
}
if (first==NULL)
first=temp;
if (temp==enemy)
wybierz_kolejnego=true;
}
}
if (next!=NULL)
enemy=next;
else
enemy=first;
}
return ACTION_NOTHING;
}
else if (key==keyboard.open)
{
return ACTION_OPEN;
}
else if (key==keyboard.close)
{
return ACTION_CLOSE;
}
else if (key==keyboard.attack)
{
return ACTION_ATTACK;
}
return ACTION_NOTHING;
}
bool HERO::print_visible_monsters_and_items()
{
ptr_list::iterator m,_m;
MONSTER *monster;
ITEM *item;
screen.console.add("\n현재 시야에 보이는 괴물: ",7);
bool something_seen=false;
for(m=level.monsters.begin(),_m=level.monsters.end(); m!=_m; m++)
{
monster=(MONSTER *)*m;
if (monster==this)
continue;
if (monster->seen_now)
{
if (is_enemy(monster)) // enemy
{
screen.console.add(string()+monster->tile,monster->color);
screen.console.add(monster->name,7);
something_seen=true;
}
}
}
if (!something_seen)
screen.console.add("없음.",7);
// seen items
something_seen=false;
screen.console.add("\n현재 시야에 보이는 물건: ",7);
for(m=level.items_on_map.begin(),_m=level.items_on_map.end(); m!=_m; m++)
{
item=(ITEM *)*m;
if (level.map.seen_by_camera(item->pX(),item->pY()) || (level.map.seen(item->pX(),item->pY()) && distance(item->pX(),item->pY(),pX(),pY())<fov_radius.GetValue()))
{
if (!item->property_controller() && !item->invisible)
{
screen.console.add(string()+item->tile,item->color);
screen.console.add(item->show_name(),7);
something_seen=true;
}
}
}
if (!something_seen)
screen.console.add("없음.\n",7);
else
screen.console.add("\n",7);
return true;
}
bool HERO::look_around()
{
level.map.HideFromPlayerSight();
level.fov.Start(&level.map,level.player->pX(),level.player->pY(),level.player->fov_radius.GetValue());
MONSTER::look_around();
string to_print;
bool was_stop=false;
for(int x=0; x<MAPWIDTH; x++)
for(int y=0; y<MAPHEIGHT; y++)
{
if ( (level.map.seen(x,y) && distance(x,y,level.player->pX(),level.player->pY()) < level.player->fov_radius.GetValue()) ||
level.map.seen_by_camera(x,y))
{
// stop repeating if player sees a new item
if (action_to_repeat!=REPEAT_ACTION_NONE)
{
if (!level.map.seen_once(x,y) && level.map.GetNumberOfItems(x,y)!=0)
{
ptr_list items;
level.list_of_items_from_cell(&items,x,y);
ptr_list::iterator m,_m;
ITEM *item;
for (m=items.begin(),_m=items.end();m!=_m;++m)
{
ITEM *item = (ITEM *) *m;
if (!item->property_controller() && !item->invisible) // gdy nie jest to sterujacy i gdy nie invisible
{
if (was_stop)
to_print+=string(", ");
else
{
to_print+=string("Stop: ");
was_stop=true;
}
to_print+=item->show_name();
}
}
}
}
level.map.setSeenByPlayer(x,y);
}
}
// seen monsters
ptr_list::iterator m,_m;
MONSTER *current_monster;
for(m=level.monsters.begin(),_m=level.monsters.end(); m!=_m; m++)
{
current_monster=(MONSTER *)*m;
if (level.map.seen_by_player(current_monster->pX(),current_monster->pY()))
{
current_monster->seen_now=true;
if (is_repeating_action())
{
if (current_monster!=level.player && current_monster->is_enemy(level.player)) // if player sees monster, then stop repeating
{
if (was_stop)
to_print+=string(", ");
else
{
to_print+=string("Stop: ");
was_stop=true;
}
to_print+=current_monster->name;
}
}
// to experience - player get for killing if seen recently
current_monster->seen_last_time_in_turn=level.turn;
}
else // when not seen
{
current_monster->seen_now=false;
if (current_monster==level.player->enemy) // current target
level.player->enemy=NULL;
}
}
if (to_print.size()>0)
{
stop_repeating();
to_print+='.';
screen.console.add(to_print,7);
}
return true;
}
ITEM *HERO :: choose_item_from_backpack(int character)
{
ptr_list::iterator m,_m;
ITEM *temp;
for(m=backpack.begin(),_m=backpack.end(); m!=_m; m++)
{
temp=(ITEM *)*m;
if (temp->inventory_letter == character)
return temp;
}
return NULL;
}
void HERO :: show_laying_items()
{
ptr_list::iterator m,_m;
ITEM *temp;
ptr_list items;
// check stairs
STAIRS *stairs = level.map.StairsAt(pX(),pY());
if (stairs!=NULL)
screen.console.add(stairs->name +"\n",15);
// print items
level.list_of_items_from_cell(&items,pX(),pY());
if (items.size()==0) // when none
{
return;
}
else if (items.size()==1)
{
temp=(ITEM *)*items.begin();
screen.console.add(string("이곳에 ") + temp->article_a() + temp->show_name() + "이 떨어져 있다.\n",7);
}
else if (items.size()<4)
{
screen.console.add("이곳에 있는 물건:\n",7);
for(m=items.begin(),_m=items.end(); m!=_m; m++)
{
temp=(ITEM *)*m;
screen.console.add(temp->article_a() + temp->show_name() + "\n",7);
}
}
else
{
screen.console.add("이곳에 물건 여러 개가 떨어져 있다...",7);
}
}
ITEM * HERO :: choose_item_to_pick_up()
{
ptr_list items;
level.list_of_items_from_cell(&items,pX(),pY());
if (items.size()==0)
{
screen.console.add("주울 물건이 없다.",7);
return NULL;
}
if (items.size()==1)
return (ITEM *)*items.begin();
// there are more
return choose_item_from_list(items,"주울 물건을 선택하라");
}
bool HERO::throw_item_to (int x, int y, ITEM *item)
{
COUNTABLE *countable = item->IsCountable();
if (countable!=NULL && countable->quantity>1)
{
int posy=12;
struct Screen_copy scr_copy;
store_screen(&scr_copy);
string text = item->show_name() + "을 몇 개 던질까? ";
screen.draw_box(2,40-text.size()/2-2,posy,40+text.size()/2+1,posy+2);
set_color(15);
print_text(40-text.size()/2,posy,text);
set_color(2);
print_character(40-text.size()/2-1,posy,'[');
print_character(40+text.size()/2,posy,']');
set_color(7);
int value = keyboard.get_value(38,posy+1,4);
restore_screen(&scr_copy);
if (value==0)
return false;
if (value!=-1 && value<countable->quantity) // split countable
{
// duplicate item
COUNTABLE *new_one;
int old_number = countable->quantity;
countable->quantity=value;
countable->ChangePosition(-1,-1);
new_one = (COUNTABLE *) countable->duplicate();
countable->quantity=old_number-value;
item=new_one;
}
}
return INTELLIGENT::throw_item_to (x,y,item);
}
int HERO::drop_item(ITEM *item,bool visible_dropping)
{
COUNTABLE *countable = item->IsCountable();
item->ChangePosition(pX(),pY());
if (countable!=NULL && countable->quantity>1)
{
int posy=12;
struct Screen_copy scr_copy;
store_screen(&scr_copy);
string text = item->show_name() + "을 몇 개 버릴까? ";
screen.draw_box(2,40-text.size()/2-2,posy,40+text.size()/2+1,posy+2);
set_color(15);
print_text(40-text.size()/2,posy,text);
set_color(2);
print_character(40-text.size()/2-1,posy,'[');
print_character(40+text.size()/2,posy,']');
set_color(7);
int value = keyboard.get_value(38,posy+1,4);
restore_screen(&scr_copy);
if (value==0)
return false;
if (value!=-1 && value<countable->quantity) // split countable
{
// duplicate item
COUNTABLE *new_one;
int old_number = countable->quantity;
countable->quantity=value;
new_one = (COUNTABLE *) countable->duplicate();
countable->quantity=old_number-value;
if (visible_dropping)
if (this->seen_now==true)
{
text=this->name + "은 " + new_one->article_the() + new_one->show_name() + "을 버린다.";
screen.console.add(text,3,false);
return true;
}
}
}
return INTELLIGENT::drop_item(item,visible_dropping);
}
int HERO :: get_action_for_item(ITEM *item)
{
ITEM *temp;
int character;
while (1)
{
character=keyboard.wait_for_key();
if (character=='x')
{
descriptions.show_description(item->ITEM::show_name());
}
if (character=='u' && item->property_use())
{
use_item(item);
return true;
}
if (character=='d' && item->property_drop())
{
drop_item(item,true);
return true;
}
if (character=='t' && item->property_throw())
{
last_activated=item;
if (do_action(ACTION_THROW)!=0)
return true;
}
if (character=='p' && item->property_put_on())
{
if (item!=armor)
set_armor(item);
else
set_armor(&no_armor);
return true;
}
if (character=='w' && item->property_wield())
{
if (item!=weapon)
set_weapon(item);
else
set_weapon(&unarmed);
return true;
}
if (character=='a' && item->property_activate())
{
last_activated=item;
screen.console.add(name + "은 " + item->show_name() + "을 작동시킨다.\n",3,false);
item->activate();
return true;