/
money.c
1128 lines (1062 loc) · 33.1 KB
/
money.c
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
/***********************************************************************
* *
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans-Henrik Stæfeldt, Tom Madsen and Katja Nyboe *
* *
* Merc Diku Mud improvements copyright (C) 1992, 1993 by *
* Michael Chastain, Michael Quan, and Mitchell Tse *
* *
* ROM 2.4 is copyright 1993-1998 Russ Taylor *
* Russ Taylor (rtaylor@hypercube.org) *
* Gabrielle Taylor (gtaylor@hypercube.org) *
* Brian Moore (zump@rom.org) *
* By using this code, you have agreed to follow the terms of the *
* ROM license, in the file Rom24/doc/rom.license *
* *
***********************************************************************
* *
* money.c and associated patches copyright 2009 by Gurthg *
* *
* In order to use any part of this ROM Merc Diku code you must comply *
* the original Diku license in 'license.doc' as well the Merc license *
* in 'license.txt' and also the ROM license in 'rom.license', each to *
* be found in doc/. Using the reward.c code without conforming to the *
* requirements of each of these documents is violation of any and all *
* applicable copyright laws. In particular, you may not remove any of *
* these copyright notices or claim other's work as your own. *
* *
* Much time and thought has gone into this software you are using. *
* We hope that you share your improvements, too. *
* "What goes around, comes around." *
* *
* KILLER MUD is copyright 2009-2011 Killer MUD Staff (alphabetical) *
* *
* ZMIENIA£E¦ CO¦? DOPISZ SIÊ! *
* *
* Pietrzak Marcin (marcin@iworks.pl ) [Gurthg ] *
* *
***********************************************************************
*
* $Id: money.c 110 2013-07-18 08:34:31Z gurthg $
* $HeadURL: svn+ssh://svn@killer.mud.pl/killer/branches/current/src/money.c $
*
*/
#if defined(macintosh)
#include <types.h>
#include <time.h>
#else
#include <sys/types.h>
#include <sys/time.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "merc.h"
#include "recycle.h"
#include "interp.h"
#include "money.h"
/**
* local functions
*/
void money_split_auto args ( ( CHAR_DATA *ch, OBJ_DATA *obj ) );
/**
* wylicz liczbê noszonych przez postaæ monet
*/
int money_count_weight_carried_by_character ( CHAR_DATA *ch )
{
return ( IS_NPC( ch ) )? 0 : money_weight( ch->copper, ch->silver, ch->gold, ch->mithril );
}
/**
* wylicz wagê noszonych przez postaæ monet
*/
int money_weight ( long int copper, long int silver, long int gold, long int mithril )
{
if ( copper > 0 || silver > 0 || gold > 0 || mithril > 0 )
{
return UMAX( 1, copper/40 + silver/20 + gold/10 + mithril/5 );
}
return 0;
}
/**
* przelicz podane pieni±dze na mied¼
*/
long int money_to_copper ( long int copper, long int silver, long int gold, long int mithril )
{
return UMAX( 0, copper + RATTING_SILVER * silver + RATTING_GOLD * gold + RATTING_MITHRIL * mithril );
}
/**
* przelicz podane pieni±dze na mied¼ z okreslonego nominalu
*/
long int money_to_copper_by_nomination ( long int amount, int nomination )
{
switch ( nomination )
{
case NOMINATION_COPPER:
return amount * RATTING_COPPER;
case NOMINATION_SILVER:
return amount * RATTING_SILVER;
case NOMINATION_GOLD:
return amount * RATTING_GOLD;
case NOMINATION_MITHRIL:
return amount * RATTING_MITHRIL;
}
bug( "money_to_copper_by_nomination: error select nomination", 0 );
return amount;
}
/**
* policz pieni±dze noszone przez ch
*/
long int money_count_copper ( CHAR_DATA *ch )
{
long int copper = 0;
copper += ( ch->copper > 0 )? ch->copper : 0;
copper += ( ch->silver > 0 )? RATTING_SILVER * ch->silver : 0;
copper += ( ch->gold > 0 )? RATTING_GOLD * ch->gold : 0;
copper += ( ch->mithril > 0 )? RATTING_MITHRIL * ch->mithril : 0;
return copper;
}
/**
* policz warto¶æ któr± mo¿e daæ obj
*/
long int money_count_copper_obj ( OBJ_DATA *obj )
{
long int copper = 0;
if ( obj->item_type == ITEM_MONEY )
{
copper += obj->value[0];
copper += obj->value[1] * RATTING_SILVER;
copper += obj->value[2] * RATTING_GOLD;
copper += obj->value[3] * RATTING_MITHRIL;
}
return copper;
}
/**
* policzca³kowit± kasê ch (wykorzystywane w rencie)
*/
long int money_count_copper_all ( CHAR_DATA *ch )
{
return UMAX( 0, money_count_copper( ch ) + ch->bank );
}
/**
* policz liczbê monet
*/
long int money_count_number_of_coinz ( OBJ_DATA *obj )
{
long int coinz = 0;
if ( obj->item_type == ITEM_MONEY )
{
coinz += obj->value[0];
coinz += obj->value[1];
coinz += obj->value[2];
coinz += obj->value[3];
}
return coinz;
}
/**
* zerowanie kasy ch
*/
void money_reset_character_money ( CHAR_DATA *ch )
{
ch->copper = 0;
ch->silver = 0;
ch->gold = 0;
ch->mithril = 0;
}
/**
* zmniejszanie kasy ch, wykorzystywaæ przy redukcjach
* pieni±dza, je¿eli nie ma rozró¿niania monet
*/
void money_reduce ( CHAR_DATA *ch, long int copper )
{
/**
* sprawdzamy czy ma wystarczajaca ilosc kasy
*/
if ( money_count_copper( ch ) > copper )
{
/**
* doprowadzamy do sytuacji w której ma wystarczajaco ilosc
* miedziakow, poprzez redukcje innych nominalow
*/
while ( ch->copper < copper )
{
if ( ch->silver > 0 )
{
ch->copper += RATTING_SILVER_TO_COPPER;
ch->silver -= 1;
}
else if ( ch->gold > 0 )
{
ch->silver += RATTING_GOLD_TO_SILVER;
ch->gold -= 1;
}
else
{
ch->gold += RATTING_MITHRIL_TO_GOLD;
ch->mithril -= 1;
}
}
ch->copper = UMAX( 0, ch->copper - copper );
}
/**
* w przeciwnym razie, kasujemu cala kasa juz
* bez wnikania ile dokladnie jej ma
*/
else
{
money_reset_character_money( ch );
}
}
/**
* dodawanie pieniedzy, wykorzystywac tylko w handlu z mobami
* oraz w operacjach bankowych
*/
void money_gain ( CHAR_DATA *ch, long int copper )
{
long int money = 0;
if ( copper > 0 && ! copper < RATTING_MITHRIL )
{
money = copper;
money /= RATTING_MITHRIL;
ch->mithril += UMAX( 0, money );
copper -= money * RATTING_MITHRIL;
}
if ( copper > 0 && ! copper < RATTING_GOLD )
{
money = copper;
money /= RATTING_GOLD;
ch->gold += UMAX( 0, money );
copper -= money * RATTING_GOLD;
}
if ( copper > 0 && ! copper < RATTING_SILVER )
{
money = copper;
money /= RATTING_SILVER;
ch->silver += UMAX( 0, money );
copper -= money * RATTING_SILVER;
}
if ( copper > 0 )
{
ch->copper += UMAX( 0, copper );
}
}
/**
* dzielenie siê pieniêdzmi
*/
void money_split( CHAR_DATA *ch, long int amount, int nomination, bool show_message, bool is_split_all, bool is_autosplit )
{
int multiplier = RATTING_NONE;
CHAR_DATA *gch;
long int members = 0, share, extra;
char buf[ MAX_INPUT_LENGTH ];
char buf_amount[ MAX_INPUT_LENGTH ];
switch ( nomination )
{
case NOMINATION_COPPER:
if ( ch->copper < amount )
{
if ( show_message || is_autosplit )
{
send_to_char( "Nie masz tylu miedzianych monet.\n\r", ch );
}
return;
}
break;
case NOMINATION_SILVER:
if ( ch->silver < amount )
{
if ( show_message || is_autosplit )
{
send_to_char( "Nie masz tylu srebrnych monet.\n\r", ch );
}
return;
}
break;
case NOMINATION_GOLD:
if ( ch->gold < amount )
{
if ( show_message || is_autosplit )
{
send_to_char( "Nie masz tylu zlotych monet.\n\r", ch );
}
return;
}
break;
case NOMINATION_MITHRIL:
if ( ch->mithril < amount )
{
if ( show_message || is_autosplit )
{
send_to_char( "Nie masz tylu mithrilowych monet.\n\r", ch );
}
return;
}
break;
}
for ( gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room )
{
if ( can_see( ch, gch ) && is_same_group( gch, ch ) && !IS_AFFECTED( gch, AFF_CHARM ) )
{
members++;
}
}
if ( members < 2 )
{
if ( show_message && ! is_autosplit )
{
send_to_char( "Dzielisz siê piêniedzmi sam ze sob±.\n\r", ch );
}
return;
}
if ( amount < members )
{
if ( show_message && ! is_split_all && ! is_autosplit )
{
send_to_char( "Nawet siê nie trud¼ <&sk±pcu/sk±pa kobieto/sk±pirad³o>.\n\r", ch );
}
return;
}
share = amount;
share /= members;
if ( share < 1 )
{
share = 0;
}
extra = amount;
extra %= members;
if ( extra < 1 )
{
extra = 0;
}
if ( share < 1 )
{
if ( show_message && ! is_split_all && ! is_autosplit )
{
send_to_char( "Nawet siê nie trud¼ <&sk±pcu/sk±pa kobieto/sk±pirad³o>.\n\r", ch );
}
return;
}
append_file_format_daily
(
ch,
MONEY_LOG_FILE,
"-> S: before split /%d/%d/%d/%d/",
ch->copper,
ch->silver,
ch->gold,
ch->mithril
);
switch ( nomination )
{
case NOMINATION_COPPER:
ch->copper += share + extra - amount;
multiplier = RATTING_COPPER;
break;
case NOMINATION_SILVER:
ch->silver += share + extra - amount;
multiplier = RATTING_SILVER;
break;
case NOMINATION_GOLD:
ch->gold += share + extra - amount;
multiplier = RATTING_GOLD;
break;
case NOMINATION_MITHRIL:
ch->mithril += share + extra - amount;
multiplier = RATTING_MITHRIL;
break;
}
append_file_format_daily
(
ch,
MONEY_LOG_FILE,
"-> S: %ld %ld (%ld) - splitn±³ kasê w wysoko¶ci %s (%d/%d) nominal: %d /%d/%d/%d/%d/",
money_count_copper( ch ) + ( extra + share - amount ) * multiplier,
money_count_copper( ch ),
( share + extra - amount ) * multiplier,
money_string_simple( amount, nomination, FALSE ),
share,
extra,
nomination,
ch->copper,
ch->silver,
ch->gold,
ch->mithril
);
if ( show_message || is_autosplit )
{
sprintf ( buf_amount, "%s", money_string_simple ( amount, nomination, TRUE ) );
sprintf( buf, "Rozdzielasz %s. Dostajesz %s.\n\r", buf_amount, money_string_simple ( share + extra, nomination, TRUE ) );
send_to_char( buf, ch );
sprintf ( buf, "%s rozdziela %s. Dostajesz swoj± czê¶æ, %s.\n\r", ch->name, buf_amount, money_string_simple ( share, nomination, TRUE) );
}
for ( gch = ch->in_room->people; gch != NULL; gch = gch->next_in_room )
{
if ( gch != ch && can_see( ch, gch ) && is_same_group( gch, ch ) && !IS_AFFECTED( gch, AFF_CHARM ) )
{
if ( show_message || is_autosplit )
{
/* act( buf, ch, NULL, gch, TO_VICT );*/
send_to_char( buf, gch );
}
append_file_format_daily
(
gch,
MONEY_LOG_FILE,
"-> S: %ld %ld (%ld) - dosta³ kasê ze splita od %s",
money_count_copper( gch ) - share * multiplier,
money_count_copper( gch ),
share * multiplier,
ch->name
);
switch ( nomination )
{
case NOMINATION_COPPER:
gch->copper += share;
break;
case NOMINATION_SILVER:
gch->silver += share;
break;
case NOMINATION_GOLD:
gch->gold += share;
break;
case NOMINATION_MITHRIL:
gch->mithril += share;
break;
}
}
}
}
/**
* przenoszenie pieniêdzy z objektu na character,
* wykorzystywane przy podnoszeniu ITEM_MONEY
*/
void money_gain_from_obj ( CHAR_DATA *ch, OBJ_DATA *obj, OBJ_DATA *container )
{
if ( obj->item_type == ITEM_MONEY )
{
long int copper = money_count_copper( ch );
ch->copper += UMAX ( 0, obj->value[ 0 ] );
ch->silver += UMAX ( 0, obj->value[ 1 ] );
ch->gold += UMAX ( 0, obj->value[ 2 ] );
ch->mithril += UMAX ( 0, obj->value[ 3 ] );
if ( container )
{
append_file_format_daily
(
ch,
MONEY_LOG_FILE,
"-> S: %ld %ld (%ld) - /%d/%d/%d/%d/- wzi±³ kasê z kontenera [%5d] w lokacji [%5d]",
copper,
money_count_copper( ch ),
money_count_copper( ch ) - copper,
obj->value[ 0 ],
obj->value[ 1 ],
obj->value[ 2 ],
obj->value[ 3 ],
container->pIndexData ? container->pIndexData->vnum : 0,
container->in_room ? container->in_room->vnum : 0
);
if
(
container->item_type == ITEM_CORPSE_NPC ||
(
container->item_type == ITEM_CORPSE_PC &&
str_cmp( container->hidden_description, ch->name2 )
)
)
{
money_split_auto( ch, obj );
}
}
else
{
append_file_format_daily
(
ch,
MONEY_LOG_FILE,
"-> S: %ld %ld (%ld) - /%d/%d/%d/%d/ - podniós³ kasê w lokacji [%5d]",
copper,
money_count_copper( ch ),
money_count_copper( ch ) - copper,
obj->value[ 0 ],
obj->value[ 1 ],
obj->value[ 2 ],
obj->value[ 3 ],
ch->in_room ? ch->in_room->vnum : 0
);
}
extract_obj( obj );
}
}
/**
*
*/
void money_from_container( CHAR_DATA *ch, OBJ_DATA *obj, OBJ_DATA *container )
{
if ( obj->item_type == ITEM_MONEY && ( obj->value[ 0 ] > 0 || obj->value[ 1 ] > 0 || obj->value[ 2 ] > 0 || obj->value[ 3 ] > 0 ) )
{
/**
* pojedyncza moneta
*/
if ( obj->value[ 0 ] == 1 && obj->value[ 1 ] == 0 && obj->value[ 2 ] == 0 && obj->value[ 3 ] == 0 )
{
send_to_char( "To tylko jedna miedziana moneta.\n\r", ch );
}
else if ( obj->value[ 0 ] == 0 && obj->value[ 1 ] == 1 && obj->value[ 2 ] == 0 && obj->value[ 3 ] == 0 )
{
send_to_char( "To tylko jedna srebrna moneta.\n\r", ch );
}
else if ( obj->value[ 0 ] == 0 && obj->value[ 1 ] == 0 && obj->value[ 2 ] == 1 && obj->value[ 3 ] == 0 )
{
send_to_char( "To tylko jedna z³ota moneta.\n\r", ch );
}
else if ( obj->value[ 0 ] == 0 && obj->value[ 1 ] == 0 && obj->value[ 2 ] == 0 && obj->value[ 3 ] == 1 )
{
send_to_char( "To tylko jedna mithrilowa moneta.\n\r", ch );
}
/**
* rozne monety
*/
else
{
if ( obj->value[ 0 ] > 0 )
{
print_char( ch, "Naliczy³<&e/a/o>¶ %s.\n\r", money_string_simple( obj->value[ 0 ], NOMINATION_COPPER, TRUE ) );
}
if ( obj->value[ 1 ] > 0 )
{
print_char( ch, "Naliczy³<&e/a/o>¶ %s.\n\r", money_string_simple( obj->value[ 1 ], NOMINATION_SILVER, TRUE ) );
}
if ( obj->value[ 2 ] > 0 )
{
print_char( ch, "Naliczy³<&e/a/o>¶ %s.\n\r", money_string_simple( obj->value[ 2 ], NOMINATION_GOLD, TRUE ) );
}
if ( obj->value[ 3 ] > 0 )
{
print_char( ch, "Naliczy³<&e/a/o>¶ %s.\n\r", money_string_simple( obj->value[ 3 ], NOMINATION_MITHRIL, TRUE ) );
}
}
}
else
{
char buf [ MAX_INPUT_LENGTH ];
send_to_char( "Dziwne, ale nie ma tu zadnych monet.\n\r", ch );
sprintf ( buf, "money_from_container: ITEM_MONEY without any money value vnum %d", obj->pIndexData->vnum );
bug( buf, 0 );
}
}
/**
* funkcja pomocnicza, tylko do autosplita
*/
void money_split_auto ( CHAR_DATA *ch, OBJ_DATA *obj )
{
if ( !IS_NPC( ch ) && EXT_IS_SET( ch->act, PLR_AUTOSPLIT ) )
{
money_split( ch, UMAX( 0, obj->value[ 0 ] ), NOMINATION_COPPER, FALSE, FALSE, TRUE );
money_split( ch, UMAX( 0, obj->value[ 1 ] ), NOMINATION_SILVER, FALSE, FALSE, TRUE );
money_split( ch, UMAX( 0, obj->value[ 2 ] ), NOMINATION_GOLD, FALSE, FALSE, TRUE );
money_split( ch, UMAX( 0, obj->value[ 3 ] ), NOMINATION_MITHRIL, FALSE, FALSE, TRUE );
}
}
/**
* przekazywanie pieniêdzy
*/
bool money_from_char_to_char( CHAR_DATA *ch, CHAR_DATA *victim, long int amount, int nomination )
{
char buf [ MAX_INPUT_LENGTH ];
int multiplier = RATTING_NONE;
switch ( nomination )
{
case NOMINATION_COPPER:
if ( ch->copper < amount )
{
send_to_char( "Przecie¿ nie masz a¿ tylu miedzianych monet.\n\r", ch );
return FALSE;
}
ch->copper -= amount;
victim->copper += amount;
multiplier = RATTING_COPPER;
break;
case NOMINATION_SILVER:
if ( ch->silver < amount )
{
send_to_char( "Przecie¿ nie masz a¿ tylu srebrnych monet.\n\r", ch );
return FALSE;
}
ch->silver -= amount;
victim->silver += amount;
multiplier = RATTING_SILVER;
break;
case NOMINATION_GOLD:
if ( ch->gold < amount )
{
send_to_char( "Przecie¿ nie masz a¿ tylu z³otych monet.\n\r", ch );
return FALSE;
}
ch->gold -= amount;
victim->gold += amount;
multiplier = RATTING_GOLD;
break;
case NOMINATION_MITHRIL:
if ( ch-> mithril < amount )
{
send_to_char( "Przecie¿ nie masz a¿ tylu mithrilowych monet.\n\r", ch );
return FALSE;
}
ch->mithril -= amount;
victim->mithril += amount;
multiplier = RATTING_MITHRIL;
break;
default:
send_to_char( "Ale o co chodzi z tymi wszystkimi monetami?\n\r", ch );
return FALSE;
}
sprintf ( buf, "$n daje ci %s.", money_string_simple( amount, nomination, TRUE ) );
act( buf, ch, NULL, victim, TO_VICT );
act( "$n daje $X trochê monet.", ch, NULL, victim, TO_NOTVICT );
sprintf ( buf, "Dajesz $X %s.", money_string_simple( amount, nomination, TRUE ) );
act( buf, ch, NULL, victim, TO_CHAR );
amount *= multiplier;
append_file_format_daily
(
ch,
MONEY_LOG_FILE,
"-> S: %d %d (%d) - da³ kasê postaci %s",
money_count_copper( ch ) + amount,
money_count_copper( ch ),
-amount,
IS_NPC( victim ) ? victim->short_descr : victim->name
);
append_file_format_daily
(
victim,
MONEY_LOG_FILE,
"-> S: %d %d (%d) - dosta³ kasê od postaci %s",
money_count_copper( victim ) - amount,
money_count_copper( victim ),
amount,
IS_NPC( ch ) ? ch->short_descr : ch->name
);
return TRUE;
}
/**
* wynajdowanie nominalu na podstawie wprowadzonnogo ciagu znakow
*/
int money_nomination_find ( char arg [ MAX_INPUT_LENGTH ] )
{
if
(
!str_prefix( arg, "copper" ) ||
!str_prefix( arg, "mied¼" ) ||
!str_prefix( arg, "miedzi" ) ||
!str_prefix( arg, "miedzianych" )
)
{
return NOMINATION_COPPER;
}
if
(
!str_prefix( arg, "silver" ) ||
!str_prefix( arg, "srebra" ) ||
!str_prefix( arg, "srebrnych" ) ||
!str_prefix( arg, "srebro" )
)
{
return NOMINATION_SILVER;
}
if
(
!str_prefix( arg, "gold" ) ||
!str_prefix( arg, "z³ota" ) ||
!str_prefix( arg, "z³oto" ) ||
!str_prefix( arg, "z³otych" )
)
{
return NOMINATION_GOLD;
}
if
(
!str_prefix( arg, "mithril" ) ||
!str_prefix( arg, "mithrilu" ) ||
!str_prefix( arg, "mitril" ) ||
!str_prefix( arg, "mitryl" ) ||
!str_prefix( arg, "mithrilowych" )
)
{
return NOMINATION_MITHRIL;
}
return NOMINATION_NONE;
}
/**
* kradziez w wykonaniu moba
*/
void money_transfer_spec_nasty ( CHAR_DATA *ch, CHAR_DATA *victim )
{
long int copper = money_count_copper( victim );
ch->copper += victim->copper * RATTING_COPPER;
ch->copper += victim->silver * RATTING_SILVER;
ch->copper += victim->gold * RATTING_GOLD;
ch->copper += victim->mithril * RATTING_MITHRIL;
money_reset_character_money( victim );
append_file_format_daily
(
victim,
MONEY_LOG_FILE,
"-> S: %ld 0 (%ld) - ukradziono przez spec_nasty [%5d]",
copper,
-copper,
ch->pIndexData->vnum
);
}
void money_steal( CHAR_DATA *ch, CHAR_DATA *victim )
{
long int amount;
int nomination = number_range( NOMINATION_COPPER, NOMINATION_MITHRIL ), multiplier = RATTING_NONE;
/**
* 0.001 szansy, ze ukradnie ca³o¶æ miedzianych monet
* 0.0007 szansy, ze ukradnie ca³o¶æ srebrnych monet
* 0.0004 szansy, ze ukradnie ca³o¶æ z³otych monet
* 0.0001 szansy, ze ukradnie ca³o¶æ mithrilowych monet
*/
if ( number_percent() == 1 && number_percent() < ( 11 - 3 * ( nomination - NOMINATION_COPPER ) ) )
{
switch ( nomination )
{
case NOMINATION_COPPER:
amount = victim->copper;
break;
case NOMINATION_SILVER:
amount = victim->silver;
break;
case NOMINATION_GOLD:
amount = victim->gold;
break;
case NOMINATION_MITHRIL:
amount = victim->mithril;
break;
}
}
else
{
/**
* budowanie ilosci kradzionej kasy
* jak widac w zaleznosci od nominalu przyjmujemy
* rozne wartosci mozliwe do ukradzenia
*/
switch ( nomination )
{
case NOMINATION_COPPER:
amount = UMIN( victim->copper, UMAX( number_range( 1, 8 ), number_range( 1, 100 ) * victim->copper / 100 ) );
break;
case NOMINATION_SILVER:
amount = UMIN( victim->silver, UMAX( number_range( 1, 4 ), number_range( 1, 50 ) * victim->silver / 100 ) );
break;
case NOMINATION_GOLD:
amount = UMIN( victim->gold, UMAX( number_range( 1, 1 ), number_range( 1, 10 ) * victim->gold / 100 ) );
break;
case NOMINATION_MITHRIL:
amount = UMIN( victim->mithril, UMAX( 1, number_range( 1, 5 ) * victim->mithril / 100 ) );
break;
}
}
switch ( nomination )
{
case NOMINATION_COPPER:
ch->copper += amount;
victim->copper -= amount;
multiplier = RATTING_COPPER;
break;
case NOMINATION_SILVER:
ch->silver += amount;
victim->silver -= amount;
multiplier = RATTING_SILVER;
break;
case NOMINATION_GOLD:
ch->gold += amount;
victim->gold -= amount;
multiplier = RATTING_GOLD;
break;
case NOMINATION_MITHRIL:
ch->mithril += amount;
victim->mithril -= amount;
multiplier = RATTING_MITHRIL;
break;
}
append_file_format_daily
(
victim,
MONEY_LOG_FILE,
"-> S: %ld %ld (%ld) - ukradziono przez spec_thief [%5d]",
money_count_copper( victim ) + multiplier * amount,
money_count_copper( victim ),
multiplier * amount,
ch->pIndexData->vnum
);
}
char * money_nomination ( int nomination, long int amount )
{
bool first = ( ( amount < 11 || amount > 20 ) && ( amount % 10 == 2 || amount % 10 == 3 || amount % 10 == 4 ) );
switch ( nomination )
{
case NOMINATION_COPPER:
if ( amount > 1 )
{
if ( first )
{
return "miedziane";
}
return "miedzianych";
}
return "miedzian±";
case NOMINATION_SILVER:
if ( amount > 1 )
{
if ( first )
{
return "srebrne";
}
return "srebrnych";
}
return "srebrn±";
case NOMINATION_GOLD:
if ( amount > 1 )
{
if ( first )
{
return "z³ote";
}
return "z³otych";
}
return "z³ot±";
case NOMINATION_MITHRIL:
if ( amount > 1 )
{
if ( first )
{
return "mithrilowe";
}
return "mithrilowych";
}
return "mithrilow±";
}
return "";
}
long int money_copper_from_copper ( long int copper )
{
copper %= RATTING_MITHRIL;
copper %= RATTING_GOLD;
copper %= RATTING_SILVER;
if ( copper < RATTING_COPPER )
{
return 0;
}
copper /= RATTING_COPPER;
return copper;
}
long int money_silver_from_copper ( long int copper )
{
copper %= RATTING_MITHRIL;
copper %= RATTING_GOLD;
if ( copper < RATTING_SILVER )
{
return 0;
}
copper /= RATTING_SILVER;
return copper;
}
long int money_gold_from_copper ( long int copper )
{
copper %= RATTING_MITHRIL;
if ( copper < RATTING_GOLD )
{
return 0;
}
copper /= RATTING_GOLD;
return copper;
}
long int money_mithril_from_copper ( long int copper )
{
if ( copper < RATTING_MITHRIL )
{
return 0;
}
copper /= RATTING_MITHRIL;
return copper;
}
/**
* przelicza podana sume na string.
* uzywac tylko wtedy kiedy mud moze przeliczyc
* pieniadze ustalajc samodzielnie liczbe
* poszczegolnych rodzajow monet, przy konkretnej
* liczbie uzywaj money_string_simple
*/
char * money_string ( long int amount, bool colorize )
{
static char money_str[MAX_INPUT_LENGTH];
long int copper = money_copper_from_copper ( amount );
long int silver = money_silver_from_copper ( amount );
long int gold = money_gold_from_copper ( amount );
long int mithril = money_mithril_from_copper ( amount );
int counter = 0;
bool lots = FALSE;
if ( copper ) { counter++; }
if ( silver ) { counter++; }
if ( gold ) { counter++; }
if ( mithril ) { counter++; }
if ( copper )
{
sprintf
(
money_str,
"%s%ld %s%s",
colorize ? MONEY_COLOR( NOMINATION_COPPER ) : "",
copper,
money_nomination( NOMINATION_COPPER, copper ),
colorize ? "{x" : ""
);
counter--;
amount = copper;
}
if ( silver )
{
if ( copper )
{
sprintf
(
money_str,
"%s%s %s%ld %s%s",
money_str,
counter == 1 ? " i": ",",
colorize ? MONEY_COLOR ( NOMINATION_SILVER ) : "",
silver,
money_nomination( NOMINATION_SILVER, silver ),
colorize ? "{x" : ""
);
}
else
{
sprintf
(
money_str,
"%s%ld %s%s",
colorize ? MONEY_COLOR ( NOMINATION_SILVER ) : "",
silver,
money_nomination( NOMINATION_SILVER, silver ),
colorize ? "{x" : ""