-
Notifications
You must be signed in to change notification settings - Fork 0
/
adr_battle.php
1173 lines (1038 loc) · 49.6 KB
/
adr_battle.php
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
<?php
/***************************************************************************
* adr_battle.php
* ------------------------
* begin : 08/02/2004
* copyright : Malicious Rabbit / Dr DLP
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
***************************************************************************/
define('IN_PHPBB', true);
define('IN_ADR_CHARACTER', true);
define('IN_ADR_BATTLE', true);
define('IN_ADR_SHOPS', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$loc = 'town';
$sub_loc = 'adr_battle';
//
// Start session management
$userdata = session_pagestart($user_ip, PAGE_ADR);
init_userprefs($userdata);
// End session management
//
$user_id = $userdata['user_id'];
$user_points = $userdata['user_points'];
include($phpbb_root_path . 'adr/includes/adr_global.'.$phpEx);
// Sorry , only logged users ...
if ( !$userdata['session_logged_in'] )
{
$redirect = "adr_battle.$phpEx";
$redirect .= ( isset($user_id) ) ? '&user_id=' . $user_id : '';
header('Location: ' . append_sid("login.$phpEx?redirect=$redirect", true));
}
// Get the general config
$adr_general = adr_get_general_config();
adr_enable_check();
adr_ban_check($user_id);
adr_character_created_check($user_id);
adr_levelup_check($user_id);
adr_weight_check($user_id);
if ( !$adr_general['battle_enable'] )
{
adr_previous ( Adr_battle_disabled , adr_character , '' );
}
// Deny access if user is imprisioned
if($userdata['user_cell_time']){
adr_previous(Adr_shops_no_thief, adr_cell, '');}
// Includes the tpl and the header
adr_template_file('adr_battle_body.tpl');
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$equip = isset($_POST['equip']);
$attack = isset($_POST['attack']);
$spell = isset($_POST['spell']);
$potion = isset($_POST['potion']);
$defend = isset($_POST['defend']);
$flee = isset($_POST['flee']);
// Select if the user has a battle in progress or no
$sql = " SELECT * FROM " . ADR_BATTLE_LIST_TABLE . "
WHERE battle_challenger_id = $user_id
AND battle_result = 0
AND battle_type = 1 ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql);
}
$bat = $db->sql_fetchrow($result);
if ( !(is_numeric($bat['battle_id'])) && !$equip )
{
// Moved the equip screen infos into adr_funtions_battle_setup.php
include_once($phpbb_root_path . '/adr/includes/adr_functions_battle_setup.'.$phpEx);
adr_battle_equip_screen($user_id);
}
else if ( !(is_numeric($bat['battle_id'])) && $equip )
{
// Check quota
if($adr_general['Adr_character_limit_enable'] == '1') adr_battle_quota_check($user_id);
// Let's calculate all the statistics now
// Fix the items ids
$armor = intval($_POST['item_armor']);
$buckler = intval($_POST['item_buckler']);
$helm = intval($_POST['item_helm']);
$gloves = intval($_POST['item_gloves']);
$amulet = intval($_POST['item_amulet']);
$ring = intval($_POST['item_ring']);
// Battle start infos gone into adr_functions_battle_setup.php
include_once($phpbb_root_path . '/adr/includes/adr_functions_battle_setup.'.$phpEx);
adr_battle_equip_initialise($user_id, $armor, $buckler, $helm, $gloves, $amulet, $ring);
}
// Select again if the user has a battle in progress or no
$sql = " SELECT * FROM " . ADR_BATTLE_LIST_TABLE . "
WHERE battle_challenger_id = $user_id
AND battle_result = 0
AND battle_type = 1 ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql);
}
$bat = $db->sql_fetchrow($result);
// Get the monster infos
$monster = adr_get_monster_infos($bat['battle_opponent_id']);
// Get character infos
$challenger = adr_get_user_infos($user_id);
$user_ma = $bat['battle_challenger_magic_attack'];
$user_md = $bat['battle_challenger_magic_resistance'];
$monster_ma = $bat['battle_opponent_magic_attack'];
$monster_md = $bat['battle_opponent_magic_resistance'];
$challenger_element = $challenger['character_element'];
$opponent_element = $monster['monster_base_element'];
$battle_round = $bat['battle_round'];
### START armour info arrays ###
// array info: 0=helm, 1=armour, 2=gloves, 3=buckler, 4=amulet, 5=ring, 6=hp_regen, 7=mp_regen
$armour_info = explode('-', $bat['battle_challenger_equipment_info']);
$helm_equip = ($armour_info[0] != '') ? $armour_info[0] : intval(0);
$armour_equip = ($armour_info[1] != '') ? $armour_info[1] : intval(0);
$gloves_equip = ($armour_info[2] != '') ? $armour_info[2] : intval(0);
$buckler_equip = ($armour_info[3] != '') ? $armour_info[3] : intval(0);
$amulet_equip = ($armour_info[4] != '') ? $armour_info[4] : intval(0);
$ring_equip = ($armour_info[5] != '') ? $armour_info[5] : intval(0);
### END armour info arrays ###
### START restriction checks ###
$item_sql = adr_make_restrict_sql($challenger);
### END restriction checks ###
if (( is_numeric($bat['battle_id']) && $bat['battle_type'] == 1) && (($attack) || ($spell) || ($potion) || ($defend) || ($flee) || ($equip)) )
{
// Prefix challenger battle message
$battle_message .= '<font color="blue">['.$challenger['character_name'].$lang['Adr_battle_msg_check'].']: </font>';
if(($bat['battle_round'] == '0') && ($bat['battle_turn'] == '2')){
$battle_message .= $monster['monster_name'].' '.$lang['Adr_battle_msg_monster_start'].'<br>';}
if(($flee) && ($bat['battle_turn'] == '1'))
{
$dice = rand(1,20);
$monster_dice = rand(1,20);
// To flee you must roll higher than opponent or roll straight 20. 1= auto fail
if((($dice > $monster_dice) && ($dice != '1')) || ($dice == '20') )
{
// Update the database
$sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "
SET battle_result = 3,
battle_finish = ".time()."
WHERE battle_challenger_id = '$user_id'
AND battle_result = '0'
AND battle_type = '1'";
if(!($result = $db->sql_query($sql)))
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);
$sql = "UPDATE " . ADR_CHARACTERS_TABLE . "
SET character_flees = (character_flees + 1)
WHERE character_id = '$user_id'";
if(!($result = $db->sql_query($sql)))
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);
// Delete stolen items from users inventory
$sql = " DELETE FROM " . ADR_SHOPS_ITEMS_TABLE . "
WHERE item_monster_thief = '1'
AND item_owner_id = '$user_id'";
if(!($result = $db->sql_query($sql)))
message_die(GENERAL_ERROR, 'Could not delete stolen items', '', __LINE__, __FILE__, $sql);
// Delete broken items from users inventory
$sql = " DELETE FROM " . ADR_SHOPS_ITEMS_TABLE . "
WHERE item_duration < '1'
AND item_in_warehouse = '0'
AND item_owner_id = '$user_id'";
if(!($result = $db->sql_query($sql)))
message_die(GENERAL_ERROR, 'Could not delete broken items', '', __LINE__, __FILE__, $sql);
$message = sprintf($lang['Adr_battle_flee'], $challenger['character_name']);
$message .= '<br /><br />'.sprintf($lang['Adr_battle_return'], "<a href=\"" . 'adr_battle.'.$phpEx . "\">", "</a>");
$message .= '<br /><br />'.sprintf($lang['Adr_character_return'], "<a href=\"" . 'adr_character.'.$phpEx . "\">", "</a>");
message_die(GENERAL_MESSAGE, $message);
}
else{
// If flee attempt fails
// Create failure message
$battle_message .= sprintf($lang['Adr_battle_flee_fail'], $challenger['character_name']).'<br>';
// Update the database
$sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "
SET battle_turn = 2,
battle_round = (battle_round + 1)
WHERE battle_challenger_id = '$user_id'
AND battle_result = '0'
AND battle_type = '1'";
if(!($result = $db->sql_query($sql)))
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);
}
}
else if ( $spell && $bat['battle_turn'] == 1 )
{
// Define the weapon quality and power
$item_spell = intval($_POST['item_spell']);
$power = 0;
$damage = 0;
if ( $item_spell )
{
$sql = "SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "
WHERE item_in_shop = 0
AND item_in_warehouse = 0
AND item_owner_id = $user_id
AND item_duration > 0
$item_sql
AND item_id = $item_spell ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql);
}
$item = $db->sql_fetchrow($result);
if ( $challenger['character_mp'] < ($item['item_mp_use'] + $item['item_power']) || $challenger['character_mp'] < 0 )
{
adr_previous ( Adr_battle_check , 'adr_battle' , '' );
}
$power = ($item['item_power'] + $item['item_add_power']);
$item['item_name'] = adr_get_lang($item['item_name']);
$mp_usage = $item['item_power'] + $item['item_mp_use'];
if ( $mp_usage == '' )
{
adr_previous ( Adr_battle_check , 'adr_battle' , '' );
}
adr_use_item($item_spell , $user_id);
// Substract the magic points
$sql = "UPDATE " . ADR_CHARACTERS_TABLE . "
SET character_mp = character_mp - $mp_usage
WHERE character_id = $user_id ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);
}
}
if ( $item['item_type_use'] == 11 )
{
/*
$dice = rand(1,20);
$diff = (($user_ma + $dice + $challenger['character_level']) >= ($monster_md + $item['item_power'])) ? TRUE : FALSE;
$power = ($power + adr_modifier_calc($challenger['character_intelligence']));
*/
// Sort out magic check & opponents saving throw
$dice = rand(1,20);
$monster['monster_wisdom'] = (10 + (rand(1, $monster['monster_level']) *2)); //temp calc
$magic_check = ceil($dice + $item['item_power'] + adr_modifier_calc($challenger['character_intelligence']));
$fort_save = (11 + adr_modifier_calc($monster['monster_wisdom']));
$diff = ((($magic_check >= $fort_save) && ($dice != '1')) || ($dice == '20')) ? TRUE : FALSE;
$power = ($power + adr_modifier_calc($challenger['character_intelligence']));
// Grab details for Elemental infos
$elemental = adr_get_element_infos($opponent_element);
$element_name = adr_get_element_infos($item['item_element']);
// Here we apply text colour if set
if($element_name['element_colour'] != ''){
$item['item_name'] = '<font color="'.$element_name['element_colour'].'">'.adr_get_lang($item['item_name']).'</font>';}
else{
$item['item_name'] = adr_get_lang($item['item_name']);}
if((($diff === TRUE) && ($dice != '1')) || ($dice == '20')){
$damage = 1;
// Work out attack type
if(($item['item_element']) && ($item['item_element'] === $elemental['element_oppose_strong']) && ($item['item_duration'] > '1') && (!empty($item['item_name']))){
$damage = ceil(($power *($item['item_element_weak_dmg'] /100)));
}
elseif(($item['item_element']) && (!empty($item['item_name'])) && ($item['item_element'] === $opponent_element) && ($item['item_duration'] > '1')){
$damage = ceil(($power *($item['item_element_same_dmg'] /100)));
}
elseif(($item['item_element']) && (!empty($item['item_name'])) && ($item['item_element'] === $elemental['element_oppose_weak']) && ($item['item_duration'] > '1')){
$damage = ceil(($power *($item['item_element_str_dmg'] /100)));
}
else{
$damage = ceil($power);
}
// Fix dmg value
$damage = ($damage < '1') ? rand(1,3) : $damage;
$damage = ($damage > $bat['battle_opponent_hp']) ? $bat['battle_opponent_hp'] : $damage;
// Fix attack msg type
if(($item['item_element'] > '0') && ($element_name['element_name'] != '')){
$battle_message .= sprintf($lang['Adr_battle_spell_success'], $challenger['character_name'], $item['item_name'], adr_get_lang($element_name['element_name']), $damage, $monster['monster_name']).'<br>';}
else{
$battle_message .= sprintf($lang['Adr_battle_spell_success_norm'], $challenger['character_name'], $item['item_name'], $damage, $monster['monster_name']).'<br>';}
}
else{
$damage = 0;
$battle_message .= sprintf( $lang['Adr_battle_spell_failure'], $challenger['character_name'], $item['item_name'], $monster['monster_name']).'<br />';
}
if ( $item['item_duration'] < 2 )
{
$battle_message .= '</span><span class="gensmall">'; // set new span class
$battle_message .= ' > '.sprintf($lang['Adr_battle_spell_dura'], $challenger['character_name'], $item['item_name']).'<br>';
$battle_message .= '</span><span class="genmed">'; // reset span class to default
}
// Update the database
$sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "
SET battle_opponent_hp = battle_opponent_hp - $damage ,
battle_challenger_dmg = $damage ,
battle_turn = 2,
battle_round = (battle_round + 1)
WHERE battle_challenger_id = $user_id
AND battle_result = 0
AND battle_type = 1 ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);
}
}
else if ( $item['item_type_use'] == 12 )
{
// Create battle message
$battle_message .= sprintf($lang['Adr_battle_spell_defensive_success'], $challenger['character_name'], $item['item_name'], $power).'<br>';
if($item['item_duration'] < '2'){
$battle_message .= '</span><span class="gensmall">'; // set new span class
$battle_message .= ' > '.sprintf($lang['Adr_battle_spell_def_dura'], $challenger['character_name'], $item['item_name']).'<br>';
$battle_message .= '</span><span class="genmed">'; // reset span class to default
}
// Update the database
$sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "
SET battle_challenger_att = battle_challenger_att + $power ,
battle_challenger_def = battle_challenger_def + $power ,
battle_turn = 2,
battle_round = (battle_round + 1)
WHERE battle_challenger_id = $user_id
AND battle_result = 0
AND battle_type = 1 ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);
}
}
}
else if ( $potion && $bat['battle_turn'] == 1 )
{
// Define the weapon quality and power
$item_potion = intval($_POST['item_potion']);
$power = 1;
if ( $item_potion )
{
$sql = " SELECT item_name , item_duration , item_power , item_type_use , item_add_power FROM " . ADR_SHOPS_ITEMS_TABLE . "
WHERE item_in_shop = 0
AND item_in_warehouse = 0
AND item_duration > 0
$item_sql
AND item_owner_id = $user_id
AND item_id = $item_potion ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql);
}
$item = $db->sql_fetchrow($result);
if ( $challenger['character_mp'] < 0 )
{
adr_previous ( Adr_battle_check , 'adr_battle' , '' );
}
$power = ($item['item_power'] + $item['item_add_power']);
}
if ( $item['item_type_use'] == 15 )
{
if(($item['item_duration'] > '0') && ($challenger['character_hp'] < $challenger['character_hp_max'])){
$power = ($power < '1') ? rand(1,3) : $power;
$power = (($power + $challenger['character_hp']) > $challenger['character_hp_max']) ? ($challenger['character_hp_max'] - $challenger['character_hp']) : $power;
$battle_message .= sprintf($lang['Adr_battle_potion_hp_success'], $challenger['character_name'], adr_get_lang($item['item_name']), $power).'<br>';
$sql = "UPDATE " . ADR_CHARACTERS_TABLE . "
SET character_hp = (character_hp + $power)
WHERE character_id = '$user_id'";
if(!($result = $db->sql_query($sql))){
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);}
// Use item
adr_use_item($item_potion, $user_id);
}
elseif(($item['item_duration'] > '0') && ($challenger['character_hp'] >= $challenger['character_hp_max'])){
$power = 0;
$battle_message .= sprintf($lang['Adr_battle_potion_hp_success_none'], $challenger['character_name'], adr_get_lang($item['item_name'])).'<br>';
}
// low dura message
if(($item['item_duration'] < '2') && ($power > '0')){
$battle_message .= '</span><span class="gensmall">'; // set new span class
$battle_message .= ' > '.sprintf($lang['Adr_battle_potion_hp_dura_none'], $challenger['character_name'], adr_get_lang($item['item_name']), adr_get_lang($item['item_name'])).'<br>';
$battle_message .= '</span><span class="genmed">'; // reset span class to default
}
// Update the database
$sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "
SET battle_turn = 2,
battle_round = (battle_round + 1)
WHERE battle_challenger_id = '$user_id'
AND battle_result = '0'
AND battle_type = '1'";
if(!($result = $db->sql_query($sql))){
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);}
}
else if ( $item['item_type_use'] == 16 )
{
if(($item['item_duration'] > '0') && ($challenger['character_mp'] < $challenger['character_mp_max'])){
$power = ($power < '1') ? rand(1,3) : $power;
$power = (($power + $challenger['character_mp']) > $challenger['character_mp_max']) ? ($challenger['character_mp_max'] - $challenger['character_mp']) : $power;
$battle_message .= sprintf($lang['Adr_battle_potion_mp_success'], $challenger['character_name'], adr_get_lang($item['item_name']), $power).'<br>';
$sql = "UPDATE " . ADR_CHARACTERS_TABLE . "
SET character_mp = (character_mp + $power)
WHERE character_id = '$user_id'";
if(!($result = $db->sql_query($sql))){
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);}
// Use item
adr_use_item($item_potion, $user_id);
}
elseif(($item['item_duration'] > '0') && ($challenger['character_mp'] >= $challenger['character_mp_max'])){
$power = 0;
$battle_message .= sprintf($lang['Adr_battle_potion_mp_success_none'], $challenger['character_name'], adr_get_lang($item['item_name'])).'<br>';
}
// low dura message
if(($item['item_duration'] < '2') && ($power > '0')){
$battle_message .= '</span><span class="gensmall">'; // set new span class
$battle_message .= ' > '.sprintf($lang['Adr_battle_potion_hp_dura_none'], $challenger['character_name'], adr_get_lang($item['item_name']), adr_get_lang($item['item_name'])).'<br>';
$battle_message .= '</span><span class="genmed">'; // reset span class to default
}
// Update the database
$sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "
SET battle_turn = 2,
battle_round = (battle_round + 1)
WHERE battle_challenger_id = '$user_id'
AND battle_result = '0'
AND battle_type = '1'";
if(!($result = $db->sql_query($sql))){
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);}
}
}
else if ( $attack && $bat['battle_turn'] == 1 )
{
// Define the weapon quality and power
$weap = intval($_POST['item_weapon']);
$power = 1;
$quality = 0;
if ( $weap )
{
$sql = " SELECT * FROM " . ADR_SHOPS_ITEMS_TABLE . "
WHERE item_in_shop = 0
AND item_in_warehouse = 0
AND item_duration > 0
$item_sql
AND item_owner_id = $user_id
AND item_id = $weap ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql);
}
$item = $db->sql_fetchrow($result);
if ( $challenger['character_mp'] < $item['item_mp_use'] || $challenger['character_mp'] < 0 || $item['item_mp_use'] == '' )
{
adr_previous ( Adr_battle_check , 'adr_battle' , '' );
}
if ( $item['item_mp_use'] > 0 )
{
$sql = "UPDATE " . ADR_CHARACTERS_TABLE . "
SET character_mp = character_mp - " . $item['item_mp_use'] . "
WHERE character_id = $user_id ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);
}
}
// Check for magic weap bonuses. Also get better crit threat range later on...
$quality = ($item['item_type_use'] == '6') ? ($item['item_quality'] *2) : $item['item_quality'];
$power = ($item['item_power'] + $item['item_add_power']);
adr_use_item($weap , $user_id);
}
// Let's check if the attack succeeds
$dice = rand(1,20);
$diff = (($bat['battle_challenger_att'] + $quality + $dice + $challenger['character_level']) > ($bat['battle_opponent_def'] + $challenger['character_level'])) ? TRUE : FALSE;
$power = ($power + adr_modifier_calc($challenger['character_might']));
$damage = 1;
// Grab details for Elemental addon
$elemental = adr_get_element_infos($opponent_element);
// Grab item element infos if not bare hands strike
$element_name = ($item['item_name'] != '') ? adr_get_element_infos($item['item_element']) : '';
// Here we apply text colour if set
if($element_name['element_colour'] != ''){
$item['item_name'] = '<font color="'.$element_name['element_colour'].'">'.$item['item_name'].'</font>';
}
else{
$item['item_name'] = $item['item_name'];
}
##=== START: Critical hit code
$threat_range = ($item['item_type_use'] == '6') ? '19' : '20'; // magic weaps get slightly better threat range
$crit_result = adr_battle_make_crit_roll($bat['battle_challenger_att'], $challenger['character_level'], $bat['battle_opponent_def'], $item['item_type_use'], $power, $quality, $threat_range);
##=== END: Critical hit code
// Bare fist strike
if($item['item_name'] == ''){
$monster_def_dice = rand(1,20);
$monster_modifier = rand(1,20); // this is temp. until proper monster characteristics are added to ADR
// Grab modifers
$bare_power = adr_modifier_calc($challenger['character_might']);
if(((($dice + $bare_power) >= ($monster_def_dice + $monster_modifier)) && ($dice != '1')) || ($dice == '20')){
$damage = rand(1,3);
$damage = ($damage > $bat['battle_opponent_hp']) ? $bat['battle_opponent_hp'] : $damage;
$battle_message .= sprintf($lang['Adr_battle_attack_bare'], $challenger['character_name'], $damage, $monster['monster_name']).'<br>';
}
else{
$damage = 0;
$battle_message .= sprintf($lang['Adr_battle_attack_bare_fail'], $challenger['character_name'], $monster['monster_name']).'<br>';
}
}
else{
if((($diff === TRUE) && ($dice != '1')) || ($dice >= $threat_range)){
// Prefix msg if crit hit
$battle_message .= ($crit_result === TRUE) ? '<br>'.$lang['Adr_battle_critical_hit'].'</b><br />' : '';
$damage = 1;
// Work out attack type
if(($item['item_element']) && ($item['item_element'] === $elemental['element_oppose_strong']) && ($item['item_duration'] > '1') && (!empty($item['item_name']))){
$damage = ceil(($power *($item['item_element_weak_dmg'] /100)));
}
elseif(($item['item_element']) && (!empty($item['item_name'])) && ($item['item_element'] === $opponent_element) && ($item['item_duration'] > '1')){
$damage = ceil(($power *($item['item_element_same_dmg'] /100)));
}
elseif(($item['item_element']) && (!empty($item['item_name'])) && ($item['item_element'] === $elemental['element_oppose_weak']) && ($item['item_duration'] > '1')){
$damage = ceil(($power *($item['item_element_str_dmg'] /100)));
}
else{
$damage = ceil($power);
}
// Fix dmg value
$damage = ($damage < '1') ? rand(1,3) : $damage;
$damage = ($damage > $bat['battle_opponent_hp']) ? $bat['battle_opponent_hp'] : $damage;
// Fix attack msg type
if(($item['item_element'] > '0') && ($element_name['element_name'] != '')){
$battle_message .= sprintf($lang['Adr_battle_attack_success'], $challenger['character_name'], $monster['monster_name'], $item['item_name'], adr_get_lang($element_name['element_name']), $damage).'<br>';}
else{
$battle_message .= sprintf($lang['Adr_battle_attack_success_norm'], $challenger['character_name'], $monster['monster_name'], $item['item_name'], $damage).'<br>';}
}
else{
$damage = 0;
$battle_message .= sprintf($lang['Adr_battle_attack_failure'], $challenger['character_name'], $monster['monster_name'], $item['item_name']).'<br>';
}
}
if(($item['item_duration'] < '2') && ($item['item_name'] != '')){
$battle_message .= '</span><span class="gensmall">'; // set new span class
$battle_message .= ' > '.sprintf($lang['Adr_battle_attack_dura'], $challenger['character_name'], adr_get_lang($item['item_name'])).'<br>';
$battle_message .= '</span><span class="genmed">'; // reset span class to default
}
// Update the database
$sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "
SET battle_opponent_hp = battle_opponent_hp - $damage ,
battle_turn = 2,
battle_round = (battle_round + 1),
battle_challenger_dmg = $damage
WHERE battle_challenger_id = $user_id
AND battle_result = 0
AND battle_type = 1 ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);
}
}
else if ( $defend && $bat['battle_turn'] == 1 )
{
$def = TRUE;
$power = floor( ( $monster['monster_level'] * rand(1,3) ) / 2 );
$battle_message .= sprintf($lang['Adr_battle_defend'], $challenger['character_name'], $monster['monster_name']).'<br>';
// Update the database
$sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "
SET battle_turn = 2,
battle_round = (battle_round + 1)
WHERE battle_challenger_id = $user_id
AND battle_result = 0
AND battle_type = 1 ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);
}
}
// Get the user infos
$challenger = adr_get_user_infos($user_id);
##=== START: additional status checks on user ===##
if(($bat['battle_turn'] == '1') && (($attack) || ($item_spell) || ($item_potion) || ($defend) || ($flee) || ($equip))){
$hp_regen = adr_hp_regen_check($user_id, $bat['battle_challenger_hp']);
$challenger['character_hp'] += $hp_regen;
$mp_regen = adr_mp_regen_check($user_id, $bat['battle_challenger_mp']);
$battle_message .= '<span class="gensmall"><font color="#FF0000">'; // prefix new span class
if((($hp_regen > '0') && ($mp_regen == '0')) || (($mp_regen > '0') && ($hp_regen == '0'))){
if($hp_regen > '0'){ $battle_message .= ' > '.sprintf($lang['Adr_battle_regen_xp'], $challenger['character_name'], intval($hp_regen)).'<br />';}
elseif($mp_regen > '0'){ $battle_message .= ' > '.sprintf($lang['Adr_battle_regen_mp'], $challenger['character_name'], intval($mp_regen)).'<br />';}
}
elseif(($hp_regen > '0') && ($mp_regen > '0')){
$battle_message .= ' > '.sprintf($lang['Adr_battle_regen_both'], $challenger['character_name'], intval($hp_regen), intval($mp_regen)).'<br />';
}
$battle_message .= '</font></span>'; // reset span class to default
}
##=== END: additional status checks on user ===##
$sql = " SELECT * FROM " . ADR_BATTLE_LIST_TABLE . "
WHERE battle_challenger_id = $user_id
AND battle_result = 0
AND battle_type = 1 ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql);
}
$bat = $db->sql_fetchrow($result);
// Now sort out monster turn
if(($bat['battle_turn'] == '2') && ($bat['battle_opponent_hp'] > '0'))
{
$monster_name = adr_get_lang($monster['monster_name']);
$character_name = $challenger['character_name'];
$monster['monster_crit_hit_mod'] = intval(2);
$monster['monster_crit_hit'] = intval(20);
$monster['monster_int'] = (10 + (rand(1, $monster['monster_level']) *2)); //temp calc
$monster['monster_str'] = (10 + (rand(1, $monster['monster_level']) *2)); //temp calc
// Prefix monster message
$battle_message .= '<font color="orange">['.$monster_name.$lang['Adr_battle_msg_check'].']: </font>';
if($def != TRUE)
$power = ceil($monster['monster_level'] *rand(1,3));
else
$power = floor(($monster['monster_level'] *rand(1,3)) /2);
// Has the monster the ability to steal from user?
$thief_chance = rand(1,20);
if(($board_config['Adr_thief_enable'] == '1') && ($thief_chance == '20')){
$sql = "SELECT item_id, item_name FROM " . ADR_SHOPS_ITEMS_TABLE . "
WHERE item_monster_thief = '0'
AND item_in_warehouse = '0'
AND item_in_shop = '0'
AND item_duration > '0'
AND item_owner_id = '$user_id'
AND item_id NOT IN ($helm_equip, $armour_equip, $gloves_equip, $buckler_equip, $amulet_equip, $ring_equip)
ORDER BY rand() LIMIT 1";
if(!($result = $db->sql_query($sql))){
message_die(GENERAL_ERROR, 'Could not query items for monster item steal', '', __LINE__, __FILE__, $sql);}
$item_to_steal = $db->sql_fetchrow($result);
// Rand to check type of thief attack
$success_chance = rand(1,20);
$rand = rand(1,20);
##=== START: steal item checks
$challenger_item_spot_check = (20 + adr_modifier_calc($challenger['character_skill_thief']));
$monster_item_attempt = (((($rand + adr_modifier_calc($monster['monster_thief_skill'])) > $challenger_item_spot_check) && ($rand != '1')) || ($rand == '20')) ? TRUE : FALSE;
##=== END: steal item checks
##=== START: steal points checks
$challenger_points_spot_check = (10 + adr_modifier_calc($challenger['character_skill_thief']));
$monster_points_attempt = (((($rand + $monster['monster_thief_skill']) > $challenger_points_spot_check) && ($rand != '1')) || ($rand == '20')) ? TRUE : FALSE;
##=== END: steal points checks
if(($success_chance == '20') && ($monster_item_attempt == TRUE) && ($item_to_steal['item_name'] != '')){
$damage = 0;
// Mark the item as stolen
$sql = "UPDATE " . ADR_SHOPS_ITEMS_TABLE . "
SET item_monster_thief = 1
WHERE item_owner_id = '$user_id'
AND item_id = '" . $item_to_steal['item_id'] . "'";
if(!($result = $db->sql_query($sql))){
message_die(GENERAL_ERROR, 'Could not update stolen item by monster', '', __LINE__, __FILE__, $sql);}
$battle_message .= sprintf($lang['Adr_battle_opponent_thief_success'], $monster_name, adr_get_lang($item_to_steal['item_name']), $character_name);
}
elseif(($success_chance >= '15') && ($success_chance != '20') && ($user_points > '0') && ($monster_points_attempt == TRUE)){
$damage = 0;
$points_stolen = floor(($user_points /100) *$board_config['Adr_thief_points']);
subtract_reward($user_id, $points_stolen);
$battle_message .= sprintf($lang['Adr_battle_opponent_thief_points'], $monster_name, $points_stolen, get_reward_name(), $character_name);
}
else{
$damage = 0;
$battle_message .= sprintf($lang['Adr_battle_opponent_thief_failure'], $monster_name, adr_get_lang($item_to_steal['item_name']), $character_name);
}
}
else{
$attack_type = rand(1,20);
##=== START: Critical hit code
$threat_range = $monster['monster_crit_hit'];
// list($crit_result, $power) = explode('-', adr_battle_make_crit_roll($bat['battle_opponent_att'], $monster['monster_level'], $bat['battle_challenger_def'], 0, $power, 0, $threat_range, 0));
##=== END: Critical hit code
if(($bat['battle_opponent_mp'] > '0') && ($bat['battle_opponent_mp'] >= $bat['battle_opponent_mp_power']) && ($attack_type > '16')){
$damage = 1;
$power = ceil($power + adr_modifier_calc($bat['battle_opponent_mp_power']));
$monster_elemental = adr_get_element_infos($opponent_element);
// Sort out magic check & opponents saving throw
$dice = rand(1,20);
$magic_check = ceil($dice + $bat['battle_opponent_mp_power'] + adr_modifier_calc($monster['monster_int']));
$fort_save = (11 + adr_modifier_calc($challenger['character_wisdom']));
$success = ((($magic_check >= $fort_save) && ($dice != '1')) || ($dice >= $threat_range)) ? TRUE : FALSE;
if($success === TRUE){
// Prefix msg if crit hit
$battle_message .= ($dice >= $threat_range) ? $lang['Adr_battle_critical_hit'].' ' : '';
// Work out attack type
if($challenger_element === $monster_elemental['element_oppose_weak']){
$damage = ceil(($power *($monster_elemental['element_oppose_strong_dmg'] /100)));
}
elseif($challenger_element === $opponent_element){
$damage = ceil(($power *($monster_elemental['element_oppose_same_dmg'] /100)));
}
elseif($challenger_element === $monster_elemental['element_oppose_strong']){
$damage = ceil(($power *($monster_elemental['element_oppose_weak_dmg'] /100)));
}
else{
$damage = ceil($power);
}
// Fix dmg value
$damage = ($damage < '1') ? rand(1,3) : $damage;
$damage = ($dice >= $threat_range) ? ($damage *$monster['monster_crit_hit_mod']) : $damage;
$damage = ($damage > $challenger['character_hp']) ? $challenger['character_hp'] : $damage;
// Fix attack msg type
if($monster['monster_base_custom_spell'] != ''){
$battle_message .= sprintf($lang['Adr_battle_opponent_spell_success'], $monster_name, $monster['monster_base_custom_spell'], $character_name, $damage);}
else{
$battle_message .= sprintf($lang['Adr_battle_opponent_spell_success2'], $monster_name, $character_name, $damage);}
}
else{
$damage = 0;
$battle_message .= sprintf($lang['Adr_battle_opponent_spell_failure'], $monster_name, $character_name);
}
// Remove monster MP
$sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "
SET battle_opponent_mp = (battle_opponent_mp - '" . $bat['battle_opponent_mp_power'] . "')
WHERE battle_challenger_id = '$user_id'
AND battle_result = '0'
AND battle_type = '1'";
if(!($result = $db->sql_query($sql))){
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);}
}
else{
// Let's check if the attack succeeds
$dice = rand(1,20);
$success = (((($bat['battle_opponent_att'] + $dice) >= ($bat['battle_challenger_def'] + adr_modifier_calc($challenger['character_dexterity']))) && ($dice != '1')) || ($dice >= $threat_range)) ? TRUE : FALSE;
$power = ceil(($power /2) + (adr_modifier_calc($monster['monster_str'])));
$damage = 1;
if($success == TRUE){
// Attack success , calculate the damage . Critical dice roll is still success
$damage = ($power < '1') ? rand(1,3) : $power;
$damage = ($dice >= $threat_range) ? ceil($damage *$monster['monster_crit_hit_mod']) : ceil($damage);
$damage = ($damage > $challenger['character_hp']) ? $challenger['character_hp'] : $damage;
$battle_message .= ($dice >= $threat_range) ? $lang['Adr_battle_critical_hit'].' ' : '';
$battle_message .= sprintf($lang['Adr_battle_opponent_attack_success'], $monster_name, $character_name, $damage);
}
else{
$damage = 0;
$battle_message .= sprintf($lang['Adr_battle_opponent_attack_failure'], $monster_name, $character_name);
}
}
// Prevent instant kills at start of battle
if(($bat['battle_round'] == '0') && (($challenger['character_hp'] - $damage) < '1'))
$character_hp = '1';
else{
$character_hp = '(character_hp - '.$damage.')';}
$sql = "UPDATE " . ADR_CHARACTERS_TABLE . "
SET character_hp = $character_hp
WHERE character_id = '$user_id'";
if(!($result = $db->sql_query($sql))){
message_die(GENERAL_ERROR, 'Could not update battle', '', __LINE__, __FILE__, $sql);}
}
// End msg with round number
$round_check = (($bat['battle_round'] == '0') && ($bat['battle_turn'] == '2')) ? 'battle_round = (battle_round + 1), ' : '';
$battle_message .= '<font size="1"><p align="right">[Battle Round: '.($battle_round + 1).']</p></font>';
// Fix battle text
$battle_text = $battle_message.$bat['battle_text'];
$battle_text_format = str_replace('<br />', "<br>", $battle_text);
$battle_text_format = '%BSS%'. str_replace('\'', '%APOS%', $battle_text_format) .'%BSE%';
$sql = "UPDATE " . ADR_BATTLE_LIST_TABLE . "
SET battle_text = '" . str_replace("\'", "''", $battle_text_format) . "',
battle_turn = 1,
$round_check
battle_opponent_dmg = $damage
WHERE battle_challenger_id = '$user_id'
AND battle_result = '0'
AND battle_type = '1'";
if(!($result = $db->sql_query($sql))){
message_die(GENERAL_ERROR, 'Could not update battle at end of user turn', '', __LINE__, __FILE__, $sql);}
}
// Check again after the available actions
$sql = " SELECT * FROM " . ADR_BATTLE_LIST_TABLE . "
WHERE battle_challenger_id = $user_id
AND battle_result = 0
AND battle_type = 1 ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql);
}
$bat = $db->sql_fetchrow($result);
// Check for any stolen items
$sql = " SELECT item_name FROM " . ADR_SHOPS_ITEMS_TABLE . "
WHERE item_owner_id = '$user_id'
AND item_monster_thief = '1'
LIMIT 1";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query battle list', '', __LINE__, __FILE__, $sql);
}
$stolen = $db->sql_fetchrow($result);
// Get the monster infos
$monster = adr_get_monster_infos($bat['battle_opponent_id']);
// Get the user infos
$sql = "SELECT c.* , u.user_avatar , u.user_avatar_type, u.user_allowavatar FROM " . ADR_CHARACTERS_TABLE . " c , " . USERS_TABLE . " u
WHERE c.character_id = $user_id
AND c.character_id = u.user_id ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query user', '', __LINE__, __FILE__, $sql);
}
$challenger = $db->sql_fetchrow($result);
$challenger_hp = $challenger['character_hp'];
$opponent_hp = $bat['battle_opponent_hp'];
// We have to know if one of the opponents is dead
if (( $opponent_hp < 1 && $challenger_hp > 0) || (($opponent_hp < '1') && ($challenger_hp < '1')) )
{
// The monster is dead , give money and xp to the users , then update the database
// Get the experience earned
$exp = rand ( $adr_general['battle_base_exp_min'] , $adr_general['battle_base_exp_max'] );
if (( $monster['monster_level'] - $challenger['character_level'] ) > 1 )
{
$exp = floor( ( ( $monster['monster_level'] - $challenger['character_level'] ) * $adr_general['battle_base_exp_modifier'] ) / 100 );
}
// Get the money earned
$reward = rand ( $adr_general['battle_base_reward_min'] , $adr_general['battle_base_reward_max'] );
if (( $monster['monster_level'] - $challenger['character_level'] ) > 1 )
{
$reward = floor( ( ( $monster['monster_level'] - $challenger['character_level'] ) * $adr_general['battle_base_reward_modifier'] ) / 100 );
}
$sql = " UPDATE " . ADR_BATTLE_LIST_TABLE . "
SET battle_result = 1 ,
battle_opponent_hp = 0,
battle_finish = ".time().",
battle_text = ''
WHERE battle_challenger_id = $user_id
AND battle_result = 0
AND battle_type = 1 ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update battle list', '', __LINE__, __FILE__, $sql);
}
add_reward( $user_id, $reward );
// If $challenger['character_hp'] is < '1' then update sql to hp = 1
$sql_update_hp = ($challenger['character_hp'] < '1') ? 'character_hp = 1' : '';
$sql = " UPDATE " . ADR_CHARACTERS_TABLE . "
SET character_xp = character_xp + $exp ,
character_victories = character_victories + 1 ,
$sql_update_hp
character_sp = character_sp + '" . $bat['battle_opponent_sp'] . "'
WHERE character_id = $user_id ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update character', '', __LINE__, __FILE__, $sql);
}
// Remove item stolen status
$sql = "UPDATE " . ADR_SHOPS_ITEMS_TABLE . "
SET item_monster_thief = 0
WHERE item_owner_id = $user_id ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update stolen item status', '', __LINE__, __FILE__, $sql);
}
// Delete broken items from users inventory
$sql = " DELETE FROM " . ADR_SHOPS_ITEMS_TABLE . "
WHERE item_duration < 1
AND item_owner_id = $user_id ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not delete broken items', '', __LINE__, __FILE__, $sql);
}
$message = sprintf($lang['Adr_battle_won'] , $bat['battle_challenger_dmg'] , $exp , $bat['battle_opponent_sp'] , $reward , get_reward_name() );
if ( $stolen['item_name'] != '' )
{
$message .= '<br />'.sprintf($lang['Adr_battle_stolen_items'] , $monster['monster_name'] ) ;
}
$message .= '<br /><br />'.sprintf($lang['Adr_battle_return'] ,"<a href=\"" . 'adr_battle.'.$phpEx . "\">", "</a>") ;
$message .= '<br /><br />'.sprintf($lang['Adr_character_return'] ,"<a href=\"" . 'adr_character.'.$phpEx . "\">", "</a>") ;
message_die ( GENERAL_MESSAGE , $message );
}
if ( $challenger_hp < 1 && $opponent_hp > 0 )
{
// The character is dead , update the database
$sql = " UPDATE " . ADR_BATTLE_LIST_TABLE . "
SET battle_result = 2,
battle_finish = ".time().",
battle_text = ''
WHERE battle_challenger_id = $user_id
AND battle_result = 0
AND battle_type = 1 ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update battle list', '', __LINE__, __FILE__, $sql);
}
$sql = " UPDATE " . ADR_CHARACTERS_TABLE . "
SET character_hp = 0 ,
character_defeats = character_defeats + 1
WHERE character_id = $user_id ";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update character', '', __LINE__, __FILE__, $sql);
}
// Delete stolen items from users inventory
$sql = " DELETE FROM " . ADR_SHOPS_ITEMS_TABLE . "