-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDuck_Hunt.tcl
4893 lines (4729 loc) · 278 KB
/
Duck_Hunt.tcl
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
##############################################################################
#
# Duck Hunt
# v2.11 (11/04/2016) ©2015-2016 Menz Agitat, IRC: irc.epiknet.org #boulets / #eggdrop
# v2.16.20250102 Worm, IRC: irc.rizon.net #duckhunt
#
#
# My scripts can be downloaded from http://www.eggdrop.fr
# You can also find all the latest news about my releases on
# http://www.boulets.oqp.me/tcl/scripts/index.html
#
# Thanks to Mon for giving me the idea for this script, to Destiny for
# intensive beta-testing and lots of ideas, and to Frédéric for lots of
# ideas and for creating the included background (duck_background.png).
#
##############################################################################
#
# Description
#
# Duck Hunt is an IRC-based FPS game.
# Occasionally, a duck will fly by and players must shoot it down as quickly as possible.
#
# Please ensure that the settings in the configuration section below
# are suitable for your use, as well as the settings contained in the
# Duck_Hunt.cfg file.
#
###############################################################################
#
# This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
# To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to
# Creative Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA.
# You may also view the French version of this license here:
# http://creativecommons.org/licenses/by-nc-sa/3.0/deed.fr
###############################################################################
if {[::tcl::info::commands ::DuckHunt::uninstall] eq "::DuckHunt::uninstall"} { ::DuckHunt::uninstall }
if { [catch { package require Tcl 8.5 }] } { putloglev o * "\00304\[Duck Hunt - erreur\]\003 Duck Hunt n�cessite que Tcl 8.5 (ou plus) soit install� pour fonctionner. Votre version actuelle de Tcl est\00304 ${::tcl_version}\003." ; return }
if { [catch { package require msgcat }] } { putloglev o * "\00304\[Duck Hunt - erreur\]\003 Duck Hunt n�cessite le package msgcat pour fonctionner. Le chargement du script a �t� annul�." ; return }
namespace eval ::DuckHunt {
###############################################################################
### Configuration
###############################################################################
# Emplacement et nom du fichier de configuration.
variable config_file "scripts/duck_hunt/Duck_Hunt.cfg"
##### LANGUE ###############################################################
# Language of script messages ( fr = French / en = english )
# Note: This is a global setting for your Eggdrop; this parameter is
# put here for easy access but you must ensure that it
# is set the same way everywhere.
# Concretely, you cannot set the language of a script to "fr" and
# that of another on "en".
::msgcat::mclocale "en"
# Emplacement des fichiers de langue.
variable language_files_directory "scripts/duck_hunt/language"
# Vous trouverez le reste des param�tres de configuration dans le fichier
# d�sign� par le param�tre config_file (voir plus haut).
###############################################################################
### Fin de la configuration
###############################################################################
#############################################################################
### Initialisation
#############################################################################
variable scriptname "Duck Hunt"
variable version "2.16.20230823"
setudef flag DuckHunt
setudef str DuckHunt-LastDuck
setudef str DuckHunt-PiecesOfBread
# Chargement des fichiers de langue.
::msgcat::mcload [file join $::DuckHunt::language_files_directory]
# Lecture de la configuration.
if { [file exists $::DuckHunt::config_file] } {
eval [list source $::DuckHunt::config_file]
} else {
# Message : "\00304\[%s - erreur\]\003 Le fichier de configuration n'a pas �t� trouv� � l'emplacement indiqu� ( %s ). Le chargement du script est annul�."
putloglev o * [::msgcat::mc m180 $::DuckHunt::scriptname $::DuckHunt::config_file]
namespace delete ::DuckHunt
return
}
# Proc�dure de d�sinstallation : le script se d�sinstalle totalement avant
# chaque rehash ou � chaque relecture au moyen de la commande "source" ou
# autre.
proc uninstall {args} {
# Message : "D�sallocation des ressources de %s..."
putlog [::msgcat::mc m0 $::DuckHunt::scriptname]
foreach binding [lsearch -inline -all -regexp [binds *[set ns [::tcl::string::range [namespace current] 2 end]]*] " \{?(::)?$ns"] {
unbind [lindex $binding 0] [lindex $binding 1] [lindex $binding 2] [lindex $binding 4]
}
foreach running_utimer [utimers] {
if { [::tcl::string::match "*[namespace current]::*" [lindex $running_utimer 1]] } { killutimer [lindex $running_utimer 2] }
}
foreach running_timer [timers] {
if { [::tcl::string::match "*[namespace current]::*" [lindex $running_timer 1]] } { killtimer [lindex $running_timer 2] }
}
if { [::tcl::dict::exists $::msgcat::Msgs [::msgcat::mclocale] [namespace current]] } {
::tcl::dict::unset ::msgcat::Msgs [::msgcat::mclocale] [namespace current]
}
if { $::DuckHunt::method == 2 } {
uplevel #0 [list trace remove execution *dcc:chanset leave ::DuckHunt::chanset_call]
uplevel #0 [list trace remove execution channel leave ::DuckHunt::chanset_call]
}
namespace delete ::DuckHunt
}
set ::DuckHunt::duck_sessions {}
if { $::DuckHunt::max_line_length <= 9 } {
set ::DuckHunt::max_line_length 10
}
set ::DuckHunt::report ""
array set ::DuckHunt::pending_transfers {}
set ::DuckHunt::post_init_done 0
}
###############################################################################
### Hook des commandes DCC et Tcl qui concernent l'activation et la
### d�sactivation d'un flag sur un chan afin de r�ajuster la planification des
### envols si method = 2.
###############################################################################
if { $::DuckHunt::method == 2 } {
uplevel #0 [list trace add execution *dcc:chanset leave ::DuckHunt::chanset_call]
uplevel #0 [list trace add execution channel leave ::DuckHunt::chanset_call]
proc ::DuckHunt::chanset_call {command errorcode result operation} {
if { !$errorcode } {
set lower_command [::tcl::string::tolower $command]
if { [lindex $lower_command 0] eq "*dcc:chanset" } {
lassign [lindex $command 3] chan flag
::DuckHunt::apply_planification_change $chan $flag
} elseif { [lindex $lower_command 1] eq "set" } {
lassign $command {} {} chan flag
::DuckHunt::apply_planification_change $chan $flag
}
}
}
proc ::DuckHunt::apply_planification_change {chan flag} {
if { [::tcl::string::equal -nocase $flag "+DuckHunt"] } {
::DuckHunt::plan_out_flights $chan
} elseif { [::tcl::string::equal -nocase $flag "-DuckHunt"] } {
if { [::tcl::dict::exists $::DuckHunt::binds_tables $chan] } {
foreach current_bind [::tcl::dict::get $::DuckHunt::binds_tables $chan] {
unbind {*}$current_bind
::tcl::dict::unset ::DuckHunt::binds_tables $chan
}
}
}
}
}
###############################################################################
### Chaque minute, on fouille les buissons pour voir si un canard ne s'y cache
### pas. (si method = 1)
###############################################################################
proc ::DuckHunt::check_bushes_for_duck {args} {
foreach chan [channels] {
if { [set num_pieces_of_bread [llength [channel get $chan DuckHunt-PiecesOfBread]]] != 0 } {
set extra_ducks [expr {$num_pieces_of_bread * 2}]
} else {
set extra_ducks 0
}
if {
([channel get $chan DuckHunt])
&& ([strftime "%H" [unixtime]] ni $::DuckHunt::duck_sleep_hours)
&& ([expr {int(rand() * (1440 - ([llength $::DuckHunt::duck_sleep_hours] * 60))) + 1}] <= [expr {$::DuckHunt::number_of_ducks_per_day + $extra_ducks}])
} then {
::DuckHunt::duck_soaring $chan - 0 - - - - - -
}
}
}
###############################################################################
### R�initialisation / planification des heures d'envol (si method = 2).
###############################################################################
proc ::DuckHunt::plan_out_flights {args} {
if {
([llength $args] == 5)
|| ($args eq {})
} then {
set chans_to_process [channels]
} else {
set chans_to_process [lindex $args 0]
}
foreach chan $chans_to_process {
# On supprime les �ventuelles planifications relatives � la journ�e
# pr�c�dente. On le fait aussi sur les chans o� le flag DuckHunt n'est pas
# activ� car il a pu �tre d�sactiv� depuis la derni�re planification.
if { [::tcl::dict::exists $::DuckHunt::binds_tables $chan] } {
foreach current_bind [::tcl::dict::get $::DuckHunt::binds_tables $chan] {
unbind {*}$current_bind
}
::tcl::dict::unset ::DuckHunt::binds_tables $chan
}
::tcl::dict::set ::DuckHunt::binds_tables $chan {}
# On planifie l'heure d'envol des canards.
if { [channel get $chan DuckHunt] } {
set hours_reference_list {00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23}
# On exclut les heures de sommeil des canards.
foreach sleep_hour $::DuckHunt::duck_sleep_hours {
set hours_reference_list [lsearch -all -inline -not -integer $hours_reference_list $sleep_hour]
}
set hours_list $hours_reference_list
if { [set num_pieces_of_bread [llength [channel get $chan DuckHunt-PiecesOfBread]]] != 0 } {
set ducks_per_day [expr {$::DuckHunt::number_of_ducks_per_day + $num_pieces_of_bread}]
} else {
set ducks_per_day $::DuckHunt::number_of_ducks_per_day
}
# En cas d'ajout de pain, on conserve l'heure la plus proche dans la
# planification actuelle pour la nouvelle planification, afin d'�viter
# que le changement fr�quent de planification ait pour effet de rar�fier
# les canards.
set time_to_keep ""
if {
([lindex $args 1] eq "bread_added")
|| (([lindex $args 1] eq "bread_expired")
&& ($num_pieces_of_bread > 0))
&& ($::DuckHunt::post_init_done)
} then {
set current_time [strftime "%H,%M" [unixtime]]
foreach scanned_time [lsort [::tcl::dict::get $::DuckHunt::planned_soarings $chan]] {
if { [regsub {:} $scanned_time {,}] > $current_time } {
set time_to_keep $scanned_time
break
}
}
}
::tcl::dict::set ::DuckHunt::planned_soarings $chan {}
for { set duck_number 1 } { $duck_number <= $ducks_per_day } { incr duck_number } {
if {
($time_to_keep ne "")
&& ($duck_number == 1)
} then {
lassign [split $time_to_keep ":"] chosen_hour chosen_minutes
} else {
set chosen_hour [lindex $hours_list [set hour_index [rand [llength $hours_list]]]]
set hours_list [lreplace $hours_list $hour_index $hour_index]
if { ![llength $hours_list] } {
set hours_list $hours_reference_list
}
set chosen_minutes [lindex {00 01 02 03 04 05 06 07 08 09 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} [rand 60]]
# Si par malchance l'heure s�lectionn�e est 00:00, le bind ne pourra pas
# se d�clencher donc on d�cale d'une minute le cas �ch�ant.
if {
($chosen_hour == 0)
&& ($chosen_minutes == 0)
} then {
set chosen_minutes 01
}
}
set current_bind [list time "-|-" "$chosen_minutes $chosen_hour * * *" [list ::DuckHunt::duck_soaring $chan - 0 -]]
# Si un bind existe d�j� � cette heure, on modifie les minutes.
while { $current_bind in [::tcl::dict::get $::DuckHunt::binds_tables $chan] } {
set current_bind [list time "-|-" "[set chosen_minutes [lindex {00 01 02 03 04 05 06 07 08 09 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} [rand 60]]] $chosen_hour * * *" [list ::DuckHunt::duck_soaring $chan - 0 -]]
}
bind {*}$current_bind
::tcl::dict::lappend ::DuckHunt::binds_tables $chan $current_bind
::tcl::dict::lappend ::DuckHunt::planned_soarings $chan "${chosen_hour}:$chosen_minutes"
}
}
}
}
###############################################################################
### A duck flies away.
### $args receives 4 arguments for a manual launch: {chan is_golden_duck is_fake_duck fake_duck_author}
### or 9 for an auto launch: {chan is_golden_duck is_fake_duck fake_duck_author min hour day month year}
### Is_golden_duck can be 0, 1 or -
### If is_golden_duck is - then we decide randomly.
### Is_fake_duck can be 0 or 1
### Fake_duck_author contains the name of the player who purchased the fake duck.
###############################################################################
proc ::DuckHunt::duck_soaring {args} {
lassign $args chan is_golden_duck is_fake_duck fake_duck_author
# Pr�vention contre les lancements multiples en cas de timer drift de
# l'Eggdrop.
if {
([set current_time [unixtime]] eq [channel get $chan DuckHunt-LastDuck])
&& ([llength $args] == 9)
} then {
return
} else {
# On d�cide s'il s'agit ou non d'un super-canard.
if { $is_golden_duck eq "-" } {
if { [expr {int(rand() * $::DuckHunt::number_of_ducks_per_day) + 1}] <= $::DuckHunt::approx_number_of_golden_ducks_per_day } {
set is_golden_duck 1
} else {
set is_golden_duck 0
}
}
if { $is_golden_duck } {
set HP [expr {int(rand() * ($::DuckHunt::golden_duck_max_HP - $::DuckHunt::golden_duck_min_HP + 1) + $::DuckHunt::golden_duck_min_HP)}]
} else {
set HP 1
}
# On avertit les joueurs qui poss�dent un d�tecteur de canards.
::DuckHunt::read_database
if { [::tcl::dict::exists $::DuckHunt::player_data $chan] } {
set some_players_have_been_warned 0
foreach lower_nick [::tcl::dict::keys [::tcl::dict::get $::DuckHunt::player_data $chan]] {
if { [set item_index [lindex [::DuckHunt::get_item_info $lower_nick $chan "22"] 0]] != -1 } {
::tcl::dict::set ::DuckHunt::player_data $chan $lower_nick "items" [lreplace [::DuckHunt::get_data $lower_nick $chan "items"] $item_index $item_index]
# On v�rifie si le joueur n'a pas un transfert de stats en attente.
foreach pending_transfer_hash [array names ::DuckHunt::pending_transfers] {
lassign $::DuckHunt::pending_transfers($pending_transfer_hash) oldnick newnick
if {
([::tcl::string::tolower $oldnick] eq $lower_nick)
&& ([onchan $newnick $chan])
} then {
::DuckHunt::ckeck_for_pending_rename $chan $newnick [set lower_nick [::tcl::string::tolower $newnick]] $pending_transfer_hash
}
}
set some_players_have_been_warned 1
# Message : "%s > CANARD sur %s"
::DuckHunt::display_output quick NOTICE $lower_nick [::msgcat::mc m351 [::DuckHunt::get_data $lower_nick $chan "nick"] $chan]
}
}
if { $some_players_have_been_warned } {
::DuckHunt::write_database
# Get time and offset 1 min for new launch time
set currentSystemTime [clock seconds]
set currentSystemTimePlus [clock add $currentSystemTime 1 minutes]
set hrPlus1 [clock format $currentSystemTimePlus -format %H]
set minPlus1 [clock format $currentSystemTimePlus -format %M]
set new_bind [list time "-|-" "$minPlus1 $hrPlus1 * * *" [list ::DuckHunt::duck_soaring $chan $is_golden_duck 0 -]]
::DuckHunt::display_output loglev - - "new_bind: $new_bind"
bind {*}$new_bind
return
}
}
::DuckHunt::purge_db_from_memory
if { $::DuckHunt::hl_prevention } {
# Construction d'un canard unique pour d�jouer les tentatives
# d'automatisation (HL, scripts, ...)
# Texte : "-.,��.-��'`'��-.,��.-��'`'��"
set trail [::msgcat::mc m136]
set trail_length [::tcl::string::length $trail]
set quarter_trail_length [expr {int($trail_length / 4)}]
lappend trail_indexes [set index [rand $trail_length]]
lappend trail_indexes [set index [expr {($index + $quarter_trail_length) % $trail_length}]]
lappend trail_indexes [set index [expr {($index + $quarter_trail_length) % $trail_length}]]
lappend trail_indexes [set index [expr {($index + $quarter_trail_length) % $trail_length}]]
set trail_indexes [lsort -integer -decreasing $trail_indexes]
for { set counter 0 } { $counter <= 3 } { incr counter } {
set trail [::tcl::string::replace $trail [lindex $trail_indexes $counter] [lindex $trail_indexes $counter]]
}
# Texte : {"\\_O<" "\\_o<" "\\_�<" "\\_�<" "\\_�<" "\\_�<" "\\_�<" "\\_�<" "\\_�<" "\\_�<" "\\_�<" "\\_�<" "\\_�<" "\\_�<" "\\_0<" "\\_�<" "\\_@<" "\\_�<" "\\_�<" "\\_^<" (...)}
set duck [lindex [::msgcat::mc m137] [rand [llength [::msgcat::mc m137]]]]
# Texte : {"COIN" "COIN" "COIN" "COIN" "COIN" "KWAK" "KWAK" "KWAAK" "KWAAK" "KWAAAK" "KWAAAK" (...)}
set cry [lindex [::msgcat::mc m138] [rand [llength [::msgcat::mc m138]]]]
set output_string "\00314$trail\017 \002$duck\002 \00314$cry\017"
} else {
# Message : "\00314-.,��.-��'`'��-.,��.-��'`'��\017 \002\\_O<\002 \00314COIN\017"
set output_string [::msgcat::mc m135]
}
::DuckHunt::display_output now PRIVMSG $chan $output_string
if { [set num_pieces_of_bread [llength [channel get $chan DuckHunt-PiecesOfBread]]] != 0 } {
set utimer_ID [utimer [expr {$::DuckHunt::escape_time + ($num_pieces_of_bread * 20)}] [list ::DuckHunt::terminate_duck_session $chan 0]]
} else {
set utimer_ID [utimer $::DuckHunt::escape_time [list ::DuckHunt::terminate_duck_session $chan 0]]
}
# Format de duck_sessions : {utimer_ID unixtime_en_ms_heure_envol nombre_tirs_manqu�s super_canard pts_vie_restants pts_vie_total d�j�_signal� faux_canard auteur_du_faux_canard}
::tcl::dict::lappend ::DuckHunt::duck_sessions $chan [list $utimer_ID [::tcl::clock::milliseconds] 0 $is_golden_duck $HP $HP 0 $is_fake_duck $fake_duck_author]
channel set $chan DuckHunt-LastDuck $current_time
if {
($::DuckHunt::hunting_logs)
&& ([llength $args] == 9)
} then {
if { $is_golden_duck } {
::DuckHunt::add_to_log $chan $current_time - - - - "golden_duck_soaring" 0 -
} elseif { $is_fake_duck } {
::DuckHunt::add_to_log $chan $current_time - - - - "fake_duck_soaring" 0 -
} else {
::DuckHunt::add_to_log $chan $current_time - - - - "soaring" 0 -
}
}
}
}
###############################################################################
### Un canard a �t� abattu ou s'est �chapp�.
###############################################################################
proc ::DuckHunt::terminate_duck_session {chan has_been_shot} {
if { [::tcl::dict::exists $::DuckHunt::duck_sessions $chan] } {
if { !$has_been_shot } {
lassign [lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] 0] {} {} {} is_golden_duck {} {} {} is_fake_duck {}
if { [llength [::tcl::dict::get $::DuckHunt::duck_sessions $chan]] > 1 } {
if { $is_golden_duck } {
# Message : "Un super-canard s'�chappe. \00314��'`'�-.,��.��'`\003"
::DuckHunt::display_output now PRIVMSG $chan [::msgcat::mc m247]
} elseif { $is_fake_duck } {
# Message : "Un canard m�canique s'�chappe. \00314��'`'�-.,��.��'`\003"
::DuckHunt::display_output now PRIVMSG $chan [::msgcat::mc m353]
} else {
# Message : "Un canard s'�chappe. \00314��'`'�-.,��.��'`\003"
::DuckHunt::display_output now PRIVMSG $chan [::msgcat::mc m3]
}
} else {
if { $is_golden_duck } {
# Message : "Le super-canard s'�chappe. \00314��'`'�-.,��.��'`\003"
::DuckHunt::display_output now PRIVMSG $chan [::msgcat::mc m248]
} elseif { $is_fake_duck } {
# Message : "Le canard m�canique s'�chappe. \00314��'`'�-.,��.��'`\003"
::DuckHunt::display_output now PRIVMSG $chan [::msgcat::mc m354]
} else {
# Message : "Le canard s'�chappe. \00314��'`'�-.,��.��'`\003"
::DuckHunt::display_output now PRIVMSG $chan [::msgcat::mc m4]
}
if { $::DuckHunt::gun_hand_back_mode == 2 } {
::DuckHunt::hand_back_weapons $chan
}
}
if { $::DuckHunt::hunting_logs } {
if { $is_golden_duck } {
::DuckHunt::add_to_log $chan [unixtime] - - - - "golden_duck_escaped" 0 -
} elseif { $is_fake_duck } {
::DuckHunt::add_to_log $chan [unixtime] - - - - "fake_duck_escaped" 0 -
} else {
::DuckHunt::add_to_log $chan [unixtime] - - - - "escaped" 0 -
}
}
} else {
killutimer [lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] 0 0]
}
::tcl::dict::set ::DuckHunt::duck_sessions $chan [lreplace [::tcl::dict::get $::DuckHunt::duck_sessions $chan] 0 0]
if { [::tcl::dict::get $::DuckHunt::duck_sessions $chan] eq {} } {
::tcl::dict::unset ::DuckHunt::duck_sessions $chan
}
}
}
###############################################################################
### !relay computertech : A player shoots.
###############################################################################
proc ::DuckHunt::shoot_relay {nick host hand chan arg} {
# Make sure the user sending this is the relay bot before doing more
if { $nick != $::DuckHunt::relay_bot_nick } { return }
# Make sure the text sent starts with a cmd before doing more
set relayCMD_chk {}
set relayCMDs "$::DuckHunt::shop_cmd $::DuckHunt::stat_cmd $::DuckHunt::lastduck_pub_cmd $::DuckHunt::reload_cmd $::DuckHunt::shooting_cmd $::DuckHunt::shooting_cmd2 $::DuckHunt::shooting_cmd3 $::DuckHunt::shooting_cmd4 $::DuckHunt::shooting_cmd5 $::DuckHunt::shooting_cmd6"
set s [split $relayCMDs]
foreach e $s {
if {[string first $e $arg] != -1} {
set relayCMD_chk "true"
}
}
if { $relayCMD_chk != "true" } { return }
lassign [set args [split [::tcl::string::trim $arg]]] nick cmdAct shopcmd1 shopcmd2 shopcmd3
set nick [::tcl::string::tolower $nick]
set i 0
set l1 {}
set num 0
set wchop "false"
set chops "~ + @ % &"
set s [split $nick ""]
foreach e $s {
set e [split $e ""]
incr num
}
puts $num
if { [string first "/ENet" $nick ] != -1 } {
set lastnum [ expr {$num - 7}]
} else {
set lastnum [ expr {$num - 2}]
}
foreach e $s {
set e [split $e ""]
if { $i == 1 } {
if { [string first $e $chops ] != -1 } {
set wchop "true"
}
}
if { 4 < $i && $i < $lastnum && $wchop == "true" } {
set l1 "$l1$e"
} elseif { 3 < $i && $i < $lastnum && $wchop == "false" } {
set l1 "$l1$e"
}
incr i
}
set nick $l1
set arg "$shopcmd1 $shopcmd2"
if {$cmdAct == "" } then {
set cmdAct $shopcmd1
set arg "$shopcmd2 $shopcmd3"
}
if {[string first $e $nick] != -1} {
set relayCMD_chk "true"
}
set cmdAct [::tcl::string::trim $cmdAct]
if {($::DuckHunt::shooting_cmd == $cmdAct)
|| ($::DuckHunt::shooting_cmd2 == $cmdAct)
|| ($::DuckHunt::shooting_cmd3 == $cmdAct)
|| ($::DuckHunt::shooting_cmd4 == $cmdAct)
|| ($::DuckHunt::shooting_cmd5 == $cmdAct)
|| ($::DuckHunt::shooting_cmd6 == $cmdAct)
} then {
::DuckHunt::shoot $nick $host $hand $chan $arg
} elseif {$::DuckHunt::reload_cmd == $cmdAct
} then {::DuckHunt::reload_gun $nick $host $hand $chan $arg
} elseif {$::DuckHunt::lastduck_pub_cmd == $cmdAct
} then {::DuckHunt::pub_show_last_duck $nick $host $hand $chan $arg
} elseif {$::DuckHunt::stat_cmd == $cmdAct
} then {::DuckHunt::display_stats $nick $host $hand $chan $arg
} elseif {$::DuckHunt::shop_cmd == $cmdAct
} then {
::DuckHunt::shop $nick $host $hand $chan $arg
} else {return}
}
###############################################################################
### !bang : Un joueur tire.
###############################################################################
proc ::DuckHunt::shoot {nick host hand chan arg} {
set lower_nick [::tcl::string::tolower $nick]
if { [matchattr $hand $::DuckHunt::launch_auth $chan] } then {
variable canNickFlood 0
} else {
variable canNickFlood $::DuckHunt::antiflood
}
if {
(![channel get $chan DuckHunt])
|| ($hand in $::DuckHunt::blacklisted_handles)
|| (($canNickFlood == 1)
&& (([::DuckHunt::antiflood $nick $chan "nick" $::DuckHunt::shooting_cmd $::DuckHunt::flood_shoot])
|| ([::DuckHunt::antiflood $nick $chan "nick" $::DuckHunt::shooting_cmd2 $::DuckHunt::flood_shoot])
|| ([::DuckHunt::antiflood $nick $chan "nick" $::DuckHunt::shooting_cmd3 $::DuckHunt::flood_shoot])
|| ([::DuckHunt::antiflood $nick $chan "chan" "*" $::DuckHunt::flood_global])))
} then {
return
} else {
set lower_nick [::tcl::string::tolower $nick]
if { $::DuckHunt::preferred_display_mode == 1 } {
set output_method "PRIVMSG"
set output_target $chan
} else {
set output_method "NOTICE"
set output_target $nick
}
::DuckHunt::read_database
::DuckHunt::ckeck_for_pending_rename $chan $nick $lower_nick [md5 "$chan,$lower_nick"]
::DuckHunt::initialize_player $nick $lower_nick $chan
if { [::tcl::dict::exists $::DuckHunt::duck_sessions $chan] } {
# On note le cumul du temps de r�action du joueur.
::tcl::dict::set ::DuckHunt::player_data $chan $lower_nick "cumul_reflex_time" [expr {[::DuckHunt::get_data $lower_nick $chan "cumul_reflex_time"] + [expr {[::tcl::clock::milliseconds] - [lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] 0 1]}]}]
set num_ducks_in_flight [llength [::tcl::dict::get $::DuckHunt::duck_sessions $chan]]
} else {
set num_ducks_in_flight 0
}
set current_time [unixtime]
::tcl::dict::set ::DuckHunt::player_data $chan $lower_nick "last_activity" $current_time
# Le joueur n'a pas d'arme (arme confisqu�e).
if { [::DuckHunt::get_data $lower_nick $chan "gun"] <= 0 } {
# Message : "%s > tu n'es pas arm�."
::DuckHunt::display_output help $output_method $output_target [::msgcat::mc m5 $nick]
# Le joueur a re�u un seau d'eau.
} elseif { [lindex [::DuckHunt::get_item_info $lower_nick $chan "16"] 0] != -1 } {
# Message : "%s > � cause de %s, tes v�tements sont tremp�s et tu ne peux pas chasser comme �a. Tu dois encore patienter pendant %s."
::DuckHunt::display_output quick $output_method $output_target [::msgcat::mc m332 $nick [lindex [::DuckHunt::get_item_info $lower_nick $chan "16"] 2] [::DuckHunt::adapt_time_resolution [expr {([lindex [::DuckHunt::get_item_info $lower_nick $chan "16"] 1] - $current_time) * 1000}] 0]]
::DuckHunt::purge_db_from_memory
return
# Le joueur a une arme.
} else {
set sand_effect_msg ""
set sabotage_effect_msg ""
set dazzle_effect_msg ""
lassign [::DuckHunt::get_level_and_grantings [::DuckHunt::get_data $lower_nick $chan "xp"]] level required_xp accuracy deflection defense jamming ammos_per_clip ammo_clips xp_miss xp_wild_fire xp_accident
# Le joueur a du sable dans son arme.
lassign [::DuckHunt::get_item_info $lower_nick $chan "15"] item_index {} author
if { $item_index != -1 } {
set jamming [expr {$jamming * 2}]
::tcl::dict::set ::DuckHunt::player_data $chan $lower_nick "items" [lreplace [::DuckHunt::get_data $lower_nick $chan "items"] $item_index $item_index]
# Texte : " \00304\[ensabl� par %s\]\003"
set sand_effect_msg [::msgcat::mc m333 $author]
}
# Le joueur a graiss� son arme.
if { [lindex [::DuckHunt::get_item_info $lower_nick $chan "6"] 0] != -1 } {
set jamming [expr {int($jamming / 2)}]
}
# L'arme du joueur a �t� sabot�e.
lassign [::DuckHunt::get_item_info $lower_nick $chan "17"] item_index {} sabotage_author
if { $item_index != -1 } {
set has_been_sabotaged 1
::tcl::dict::set ::DuckHunt::player_data $chan $lower_nick "items" [lreplace [::DuckHunt::get_data $lower_nick $chan "items"] $item_index $item_index]
# Texte : " \00304\[sabotage par %s\]\003"
set sabotage_effect_msg [::msgcat::mc m337 $sabotage_author]
} else {
set has_been_sabotaged 0
}
# Le joueur poss�de une assurance responsabilit� civile.
if { [set item_index [lindex [::DuckHunt::get_item_info $lower_nick $chan "19"] 0]] != -1 } {
set xp_accident [expr {int($xp_accident / 3)}]
# Message : " \00303\[assurance resp. civile\]\003"
set liability_insurance_msg [::msgcat::mc m343]
} else {
set liability_insurance_msg ""
}
# L'arme est enray�e.
if { [::DuckHunt::get_data $lower_nick $chan "jammed"] } {
# Message : "%s > \00314*CLAC*\003 \00304ARME ENRAY�E\003"
::DuckHunt::display_output quick $output_method $output_target [::msgcat::mc m7 $nick]
::DuckHunt::purge_db_from_memory
return
# L'arme s'enraye.
} elseif {
($has_been_sabotaged)
|| ([expr {int(rand()*100)+1}] <= $jamming)
} then {
::tcl::dict::set ::DuckHunt::player_data $chan $lower_nick "jammed" 1
::DuckHunt::incr_data $lower_nick $chan "jammed_weapons" +1
# Message : "%s > \00314*CLAC*\003 Ton arme s'est enray�e, tu dois recharger pour la d�coincer... \00314|\003 Mun. : \002%s\002 \00314|\003 Charg. : \002%s\002"
::DuckHunt::display_output quick $output_method $output_target "[::msgcat::mc m8 $nick [::DuckHunt::display_ammo $lower_nick $chan $ammos_per_clip] [::DuckHunt::display_clips $lower_nick $chan $ammo_clips]]${sabotage_effect_msg}$sand_effect_msg"
if { $::DuckHunt::hunting_logs } {
::DuckHunt::add_to_log $chan $current_time $nick $lower_nick - - "jam" 0 -
}
# L'arme du joueur a �t� sabot�e et explose.
if {
($has_been_sabotaged)
&& ($::DuckHunt::kick_when_sabotaged)
} then {
if { $::DuckHunt::kick_method } {
# Message : "\002*BOOM*\002 Ton arme vient d'exploser � cause du sabotage de %s."
putserv "CS kick $chan $nick [::msgcat::mc m338 $sabotage_author]"
} elseif { ![isop $::nick $chan] } {
# Message : "\00314\[%s\]\003 \00304:::\003 Erreur : %s n'a pas pu �tre kick� sur %s car je n'y suis ni halfop�, ni op�."
::DuckHunt::display_output loglev - - [::msgcat::mc m140 $::DuckHunt::scriptname $nick $chan]
} else {
# Message : "\002*BOOM*\002 Ton arme vient d'exploser � cause du sabotage de %s."
putkick $chan $nick [::msgcat::mc m338 $sabotage_author]
}
}
# L'arme ne s'enraye pas.
} else {
# The weapon is not loaded and the ammunition is not unlimited.
if {
([::DuckHunt::get_data $lower_nick $chan "current_ammo_clip"] == 0)
&& !($::DuckHunt::unlimited_ammo_per_clip)
} then {
::DuckHunt::incr_data $lower_nick $chan "empty_shots" +1
# Message : "%s > \00314*CLIC*\003 \00304CHARGEUR VIDE\003 \00314|\003 Mun. : \002%s\002 \00314|\003 Charg. : \002%s\002"
::DuckHunt::display_output quick $output_method $output_target [::msgcat::mc m6 $nick [::DuckHunt::display_ammo $lower_nick $chan $ammos_per_clip] [::DuckHunt::display_clips $lower_nick $chan $ammo_clips]]
if { $::DuckHunt::hunting_logs } {
::DuckHunt::add_to_log $chan $current_time $nick $lower_nick - - "empty_shot" 0 -
}
# L'arme est charg�e.
} else {
# Le joueur poss�de un d�tecteur infrarouge et il n'y a pas de canard.
lassign [::DuckHunt::get_item_info $lower_nick $chan "8"] item_index expiration_date item_uses
if {
!([set duck_present [::tcl::dict::exists $::DuckHunt::duck_sessions $chan]])
&& ($item_index != -1)
} then {
# Message : "%s > \00314*CLIC*\003 G�chette verrouill�e."
::DuckHunt::display_output quick $output_method $output_target [::msgcat::mc m290 $nick]
::DuckHunt::decrement_item_uses $lower_nick $chan "8" $item_index $expiration_date $item_uses
::DuckHunt::write_database
::DuckHunt::purge_db_from_memory
return
}
if { !$::DuckHunt::unlimited_ammo_per_clip } {
::DuckHunt::incr_data $lower_nick $chan "current_ammo_clip" -1
}
set base_accuracy $accuracy
# Le joueur est �bloui.
lassign [::DuckHunt::get_item_info $lower_nick $chan "14"] item_index {} author
if { $item_index != -1 } {
set accuracy [expr {int($accuracy / 2)}]
::tcl::dict::set ::DuckHunt::player_data $chan $lower_nick "items" [lreplace [::DuckHunt::get_data $lower_nick $chan "items"] $item_index $item_index]
# Texte : " \00304\[�bloui par %s\]\003"
set dazzle_effect_msg [::msgcat::mc m334 $author]
}
# Le joueur a install� une lunette de vis�e sur son arme.
if { [set item_index [lindex [::DuckHunt::get_item_info $lower_nick $chan "7"] 0]] != -1 } {
set accuracy [expr {$accuracy + int((100 - $base_accuracy) / 3)}]
::tcl::dict::set ::DuckHunt::player_data $chan $lower_nick "items" [lreplace [::DuckHunt::get_data $lower_nick $chan "items"] $item_index $item_index]
}
set duck_fleed 0
# Le joueur rate son tir ou il n'y a aucun canard en vol.
if {
!($duck_present)
|| ([expr {int(rand()*100)+1}] > $accuracy)
} then {
::DuckHunt::incr_data $lower_nick $chan "missed_shots" +1
if { ![::tcl::info::exists previous_xp] } {
set previous_xp [::DuckHunt::get_data $lower_nick $chan "xp"]
}
::DuckHunt::incr_data $lower_nick $chan "xp" $xp_miss
if { $::DuckHunt::devoice_on_miss } {
pushmode $chan -v $nick
}
# Si des canards sont en vol, on incr�mente le compteur de tirs
# manqu�s effectu�s en leur pr�sence et on voit si certains ont
# atteint leur limite.
if { $duck_present } {
incr duck_fleed [::DuckHunt::ducks_scaring $chan $lower_nick]
set xp_wild_fire_msg ""
} else {
# Texte : "\[tir sauvage : %s xp\] "
set xp_wild_fire_msg [::msgcat::mc m9 $xp_wild_fire]
}
set chances_to_hit_someone_else [::DuckHunt::determine_chances_to_hit_someone_else $chan $duck_present]
set someone_has_been_hit 0
set confiscation_msg_sent 0
set xp_penalty_msg_sent 0
set ricochet_counter 0
set source_nick $nick
# La balle perdue touche un autre joueur.
while {
([expr {int(rand()*100)+1}] <= $chances_to_hit_someone_else)
&& ($ricochet_counter < $::DuckHunt::max_ricochets)
&& ([set victim [::DuckHunt::random_user $chan $source_nick]] ne "@nobody@")
} {
set someone_has_been_hit 1
set source_nick $victim
set lower_victim [::tcl::string::tolower $victim]
::DuckHunt::ckeck_for_pending_rename $chan $victim $lower_victim [md5 "$chan,$lower_victim"]
::DuckHunt::incr_data $lower_nick $chan "humans_shot" +1
if { $::DuckHunt::devoice_on_accident } {
pushmode $chan -v $nick
}
if { ![::tcl::info::exists previous_xp] } {
set previous_xp [::DuckHunt::get_data $lower_nick $chan "xp"]
}
::DuckHunt::incr_data $lower_nick $chan "xp" $xp_accident
::DuckHunt::initialize_player $victim $lower_victim $chan
::DuckHunt::incr_data $lower_victim $chan "bullets_received" +1
# Confiscation �ventuelle de l'arme.
if {
($::DuckHunt::gun_confiscation_when_shooting_someone)
&& !($confiscation_msg_sent)
} then {
::tcl::dict::set ::DuckHunt::player_data $chan $lower_nick "gun" 0
::DuckHunt::incr_data $lower_nick $chan "confiscated_weapons" +1
# Texte : " \00304\[ARME CONFISQU�E : accident de chasse\]\003"
set gun_confiscation1 [::msgcat::mc m10]
# Texte : " ainsi que son arme"
set gun_confiscation2 [::msgcat::mc m11]
} else {
set gun_confiscation1 ""
set gun_confiscation2 ""
}
# On n'affiche qu'une seule fois l'xp perdue pour tir rat�/sauvage.
if { !$xp_penalty_msg_sent } {
if { !$duck_present } {
# Texte : "\[rat� : %s xp\] "
set xp_penalty_msg "[::msgcat::mc m12 $xp_miss]$xp_wild_fire_msg"
set lost_xp [expr {abs($xp_miss) + abs($xp_wild_fire) + abs($xp_accident)}]
} else {
# Texte : "\[rat� : %s xp\] "
set xp_penalty_msg "[::msgcat::mc m12 $xp_miss]"
set lost_xp [expr {abs($xp_miss) + abs($xp_accident)}]
}
if { $::DuckHunt::hunting_logs } {
::DuckHunt::add_to_log $chan $current_time $nick $lower_nick - - "accident" 1 -
}
} else {
set xp_penalty_msg ""
set lost_xp [expr {abs($xp_accident)}]
}
# La victime poss�de une assurance vie.
if { [set item_index [lindex [::DuckHunt::get_item_info $lower_victim $chan "18"] 0]] != -1 } {
::tcl::dict::set ::DuckHunt::player_data $chan $lower_victim "items" [lreplace [::DuckHunt::get_data $lower_victim $chan "items"] $item_index $item_index]
::DuckHunt::incr_data $lower_victim $chan "xp" [set life_insurance_xp [expr {[lindex [::DuckHunt::get_level_and_grantings [::DuckHunt::get_data $lower_victim $chan "xp"]] 0] * 2}]]
# Message : " \00303\[assurance vie : +%s xp pour %s\]\003"
set life_insurance_msg [::msgcat::mc m340 $life_insurance_xp $victim]
# Message : " \00303\[assurance vie : +%s xp\]\003"
set life_insurance_msg2 [::msgcat::mc m341 $life_insurance_xp]
} else {
set life_insurance_msg ""
set life_insurance_msg2 ""
}
lassign [::DuckHunt::get_level_and_grantings [::DuckHunt::get_data $lower_victim $chan "xp"]] {} {} {} victim_deflection victim_defense {} {} {} {} {} {}
# La balle ricoche.
if { [expr {int(rand()*100)+1}] <= $victim_deflection } {
::DuckHunt::incr_data $lower_victim $chan "deflected_bullets" +1
incr ricochet_counter
set confiscation_msg_sent 1
set xp_penalty_msg_sent 1
# Message : "\00314*PIEWWW*\003 La balle de %s ricoche sur %s gr�ce � son modificateur de d�flexion de %s%%. \00304%s\[accident : %s xp\]\003"
::DuckHunt::display_output quick PRIVMSG $chan "[::msgcat::mc m13 $nick $victim $victim_deflection $xp_penalty_msg $xp_accident]${gun_confiscation1}${dazzle_effect_msg}${liability_insurance_msg}$life_insurance_msg"
if { $::DuckHunt::hunting_logs } {
::DuckHunt::add_to_log $chan $current_time $nick $lower_nick $lower_victim - "deflect" 1 -
}
# Un canard est touch� par ricochet.
if {
($duck_present)
&& ([expr {int(rand()*100)+1}] <= $::DuckHunt::chances_to_ricochet_towards_duck)
} then {
::DuckHunt::hit_a_duck $nick $lower_nick $chan 1 $output_method $output_target
break
}
# L'autre joueur r�siste.
} elseif { [expr {int(rand()*100)+1}] <= $victim_defense } {
set confiscation_msg_sent 1
set xp_penalty_msg_sent 1
# Message : "\00314*CHTOK*\003 %s re�oit la balle de %s mais accuse le coup gr�ce � son modificateur d'armure de %s%%. \00304%s\[accident : %s xp\]\003"
::DuckHunt::display_output quick PRIVMSG $chan "[::msgcat::mc m14 $victim $nick $victim_defense $xp_penalty_msg $xp_accident]${gun_confiscation1}${dazzle_effect_msg}${liability_insurance_msg}$life_insurance_msg"
if { $::DuckHunt::hunting_logs } {
if { $::DuckHunt::gun_confiscation_when_shooting_someone } {
::DuckHunt::add_to_log $chan $current_time $nick $lower_nick $lower_victim - "hit" 1 -
::DuckHunt::add_to_log $chan $current_time $nick $lower_nick $lower_victim - "confiscated" 0 -
} else {
::DuckHunt::add_to_log $chan $current_time $nick $lower_nick $lower_victim - "hit" 0 -
}
}
break
# L'autre joueur est abattu.
} else {
::DuckHunt::incr_data $lower_victim $chan "deaths" +1
set confiscation_msg_sent 1
set xp_penalty_msg_sent 1
if { $::DuckHunt::kick_when_shot } {
if { $::DuckHunt::kick_method } {
# Message : "\002*BANG*\002 Tu viens d'�tre victime d'un accident de chasse. %s s'en excuse... et perd %s pts d'xp."
putserv "CS kick $chan $victim [::msgcat::mc m15 $nick $lost_xp]${gun_confiscation2}$life_insurance_msg2"
} elseif { ![isop $::nick $chan] } {
# Message : "\00314\[%s\]\003 \00304:::\003 Erreur : %s n'a pas pu �tre kick� sur %s car je n'y suis ni halfop�, ni op�."
::DuckHunt::display_output loglev - - [::msgcat::mc m140 $::DuckHunt::scriptname $victim $chan]
} else {
# Message : "\002*BANG*\002 Tu viens d'�tre victime d'un accident de chasse. %s s'en excuse... et perd %s pts d'xp."
putkick $chan $victim "[::msgcat::mc m15 $nick $lost_xp]${gun_confiscation2}$life_insurance_msg2"
}
}
# Message : "\00314*BANG*\003 \002\037xO\037'\002 %s vient de se faire descendre par %s par accident. \00304%s\[accident : %s xp\]\003"
::DuckHunt::display_output quick PRIVMSG $chan "[::msgcat::mc m16 $victim $nick $xp_penalty_msg $xp_accident]${gun_confiscation1}${dazzle_effect_msg}${liability_insurance_msg}$life_insurance_msg"
if { $::DuckHunt::hunting_logs } {
if { $::DuckHunt::gun_confiscation_when_shooting_someone } {
::DuckHunt::add_to_log $chan $current_time $nick $lower_nick $lower_victim - "die" 1 -
::DuckHunt::add_to_log $chan $current_time $nick $lower_nick $lower_victim - "confiscated" 0 -
} else {
::DuckHunt::add_to_log $chan $current_time $nick $lower_nick $lower_victim - "die" 0 -
}
}
break
}
}
# Il n'y a actuellement aucun canard en vol sur le chan.
if { !$duck_present } {
::DuckHunt::incr_data $lower_nick $chan "wild_shots" +1
if { ![::tcl::info::exists previous_xp] } {
set previous_xp [::DuckHunt::get_data $lower_nick $chan "xp"]
}
::DuckHunt::incr_data $lower_nick $chan "xp" $xp_wild_fire
if { $::DuckHunt::devoice_on_wild_fire } {
pushmode $chan -v $nick
}
# Confiscation �ventuelle de l'arme.
if {
($::DuckHunt::gun_confiscation_on_wild_fire)
&& ([::DuckHunt::get_data $lower_nick $chan "gun"] == 1)
} then {
::tcl::dict::set ::DuckHunt::player_data $chan $lower_nick "gun" 0
::DuckHunt::incr_data $lower_nick $chan "confiscated_weapons" +1
# Texte : " \00304\[ARME CONFISQU�E : tir sauvage\]\003"
set gun_confiscation [::msgcat::mc m17]
if { $::DuckHunt::hunting_logs } {
::DuckHunt::add_to_log $chan $current_time $nick $lower_nick - - "wild_fire" 1 -
::DuckHunt::add_to_log $chan $current_time $nick $lower_nick - - "confiscated" 0 -
}
} else {
set gun_confiscation ""
if { $::DuckHunt::hunting_logs } {
::DuckHunt::add_to_log $chan $current_time $nick $lower_nick - - "wild_fire" 0 -
}
}
# Si personne n'a �t� touch�, c'est juste un tir sauvage.
if { !$someone_has_been_hit } {
# Message : "%s > Par chance tu as rat�, mais tu visais qui au juste ? Il n'y a aucun canard dans le coin... \00304\[rat� : %s xp\] \[tir sauvage : %s xp\]\003"
::DuckHunt::display_output quick $output_method $output_target "[::msgcat::mc m18 $nick $xp_miss $xp_wild_fire]${gun_confiscation}"
}
# Il y a au moins un canard en vol sur le chan.
} else {
# Si personne n'a �t� touch�, c'est juste un tir manqu�.
if { !$someone_has_been_hit } {
# Message : "%s > Rat�. \00304\[rat� : %s xp\]\003"
::DuckHunt::display_output quick $output_method $output_target "[::msgcat::mc m19 $nick $xp_miss]$dazzle_effect_msg"
if { $::DuckHunt::hunting_logs } {
::DuckHunt::add_to_log $chan $current_time $nick $lower_nick - - "miss" 0 -
}
}
}
# Kick pour tir non-autoris� en l'absence de canard.
if {
(!$duck_present)
&& ($::DuckHunt::kick_on_wild_fire)
} then {
if { $::DuckHunt::kick_method } {
# Message : "Tu vises qui l� ? Je ne vois aucun canard dans le coin. \[%s xp\] \[%s xp\]"
putserv "CS kick $chan $nick [::msgcat::mc m20 $xp_miss $xp_wild_fire]"
} elseif { ![isop $::nick $chan] } {
# Message : "\00314\[%s\]\003 \00304:::\003 Erreur : %s n'a pas pu �tre kick� sur %s car je n'y suis ni halfop�, ni op�."
::DuckHunt::display_output loglev - - [::msgcat::mc m140 $::DuckHunt::scriptname $nick $chan]
} else {
# Message : "Tu vises qui l� ? Je ne vois aucun canard dans le coin. \[%s xp\] \[%s xp\] "
putkick $chan $nick [::msgcat::mc m20 $xp_miss $xp_wild_fire]
}
}
if {
([::tcl::info::exists previous_xp])
&& ([lindex [::DuckHunt::get_level_and_grantings $previous_xp] 0] > [lindex [::DuckHunt::get_level_and_grantings [::DuckHunt::get_data $lower_nick $chan "xp"]] 0])
} then {
# Message "%s est r�trograd�(e) au rang de chasseur niveau %s (%s)."
::DuckHunt::display_output quick PRIVMSG $chan [::msgcat::mc m2 $nick [set level [lindex [::DuckHunt::get_level_and_grantings [::DuckHunt::get_data $lower_nick $chan "xp"]] 0]] [::DuckHunt::lvl2rank $level]]
}
# Le joueur r�ussit son tir.
} else {
::DuckHunt::hit_a_duck $nick $lower_nick $chan 0 $output_method $output_target
incr num_ducks_in_flight -1
if { $::DuckHunt::successful_shots_also_scares_ducks } {
incr duck_fleed [::DuckHunt::ducks_scaring $chan $lower_nick]
}
}
# Le tir manqu� a effray� un ou plusieurs canards qui parviennent �
# s'�chapper.
if { $duck_fleed > 1 } {
if { $duck_fleed == $num_ducks_in_flight } {
# Message : "Effray�s par tout ce bruit, tous les canards s'�chappent. \00314��'`'�-.,��.��'`\003"
::DuckHunt::display_output now PRIVMSG $chan [::msgcat::mc m21]
} else {
# Message : "Effray�s par tout ce bruit, %s canards s'�chappent. \00314��'`'�-.,��.��'`\003"
::DuckHunt::display_output now PRIVMSG $chan [::msgcat::mc m22 $duck_fleed]
}
for { set counter 1 } { $counter <= $duck_fleed } { incr counter } {
if { $::DuckHunt::hunting_logs } {
::DuckHunt::add_to_log $chan $current_time - - - - "frightened" 0 -
}
}
} elseif { $duck_fleed == 1 } {
if { $num_ducks_in_flight == 1 } {
# Message : "Effray� par tout ce bruit, le canard s'�chappe. \00314��'`'�-.,��.��'`\003"
::DuckHunt::display_output now PRIVMSG $chan [::msgcat::mc m23]
} else {
# Message : "Effray� par tout ce bruit, un canard s'�chappe. \00314��'`'�-.,��.��'`\003"
::DuckHunt::display_output now PRIVMSG $chan [::msgcat::mc m24]
}
if { $::DuckHunt::hunting_logs } {
::DuckHunt::add_to_log $chan $current_time - - - - "frightened" 0 -
}
}
}
}
::DuckHunt::recalculate_ammo_on_lvl_change $lower_nick $chan
::DuckHunt::write_database
}
::DuckHunt::purge_db_from_memory
}
return
}
###############################################################################
### A player has shoot, we increment the degree of fear of the ducks.
###############################################################################
proc ::DuckHunt::ducks_scaring {chan lower_nick} {
set duck_fleed 0
# Si le joueur n'a pas install� de silencieux sur son arme...
if {
([::tcl::dict::exists $::DuckHunt::duck_sessions $chan])
&& ([lindex [::DuckHunt::get_item_info $lower_nick $chan "9"] 0] == -1)
} then {
for { set counter 0 } { $counter <= [llength [::tcl::dict::get $::DuckHunt::duck_sessions $chan]] -1 } { incr counter } {
set shots_in_presence [expr {[lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] $counter 2] + 1}]
if {
($shots_in_presence == $::DuckHunt::shots_before_duck_flee)
&& !([lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] $counter 3])
&& !([lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] $counter 7])
} then {
killutimer [lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] $counter 0]
::tcl::dict::set ::DuckHunt::duck_sessions $chan [lreplace [::tcl::dict::get $::DuckHunt::duck_sessions $chan] $counter $counter]
incr duck_fleed
} else {
::tcl::dict::set ::DuckHunt::duck_sessions $chan [lreplace [::tcl::dict::get $::DuckHunt::duck_sessions $chan] $counter $counter [list [lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] $counter 0] [lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] $counter 1] $shots_in_presence [lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] $counter 3] [lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] $counter 4] [lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] $counter 5] [lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] $counter 6] [lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] $counter 7] [lindex [::tcl::dict::get $::DuckHunt::duck_sessions $chan] $counter 8]]]
}
}
if { [::tcl::dict::get $::DuckHunt::duck_sessions $chan] eq {} } {