forked from brycole/gemstone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbigshot1.lic
1792 lines (1552 loc) · 60.7 KB
/
bigshot1.lic
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
=begin
bigshot.lic: the new optimus prime
hunting script for hunting
author: Sheikhh
contributers: SpiffyJr, Tillmen
game: Gemstone
tags: hunting
version: 3.0
changelog:
3.0 (2015-05-30):
stop trying to attack monsters that aren't in the room (wild guess, untested)
bumped version up from 2.12052012 to 3.0, because 2.12052012 is a stupid version format
added message to trust script
3.01 (2015-12-01):by Kalros
Rewrote parts of the targeting section and wander section to remove poaching.
Removed group hunt section as it was part of the poaching issue. Will address later.
Added exec script to account for ambushers.
=end
#Kalros To-Do List
# Add group check back to poach check
# Add familiar/ranger pets to poach check
# Add more regex messaging to ambush portion.
# FIXME: Use new empty_hand(s)/fill_hand(s)
# FIXME: Is poaching?() redundant?
# FIXME: Instead of the head reiterating :ATTACK to tail every 15 seconds, have the tail loop upon :ATTACK until the room id changes
$bigshot_debug = false
$exec_ambush = false
if $SAFE > 0
echo "error: This script needs to be trusted to work. (;trust #{script.name})"
exit
end
require 'drb'
# fixme: these constants and global variables could conflict with other scripts
BIGSHOT_VERSION ||= '3.0'
RALLY_TIME ||= 5
REST_INTERVAL ||= 30
$rest_reason = nil
$not_hunting_reason = nil
$bigshot_status = nil
$bigshot_should_rest = false
def spam
def waitcastrt?
return if Spell[515].active?
if (XMLData.cast_roundtime_end.to_f - Time.now.to_f + XMLData.server_time_offset.to_f) > 0
sleep((XMLData.cast_roundtime_end.to_f - Time.now.to_f + XMLData.server_time_offset.to_f).abs)
end
end
def waitrt?
if (XMLData.roundtime_end.to_f - Time.now.to_f + XMLData.server_time_offset.to_f) > 0
sleep((XMLData.roundtime_end.to_f - Time.now.to_f + XMLData.server_time_offset.to_f).abs)
end
end
end
def unspam
def waitcastrt?
if (XMLData.cast_roundtime_end.to_f - Time.now.to_f + XMLData.server_time_offset.to_f) > 0
sleep((XMLData.cast_roundtime_end.to_f - Time.now.to_f + XMLData.server_time_offset.to_f + "0.6".to_f).abs)
end
end
def waitrt?
if (XMLData.roundtime_end.to_f - Time.now.to_f + XMLData.server_time_offset.to_f) > 0
sleep((XMLData.roundtime_end.to_f - Time.now.to_f + XMLData.server_time_offset.to_f + "0.6".to_f).abs)
end
end
end
before_dying { unspam() }
before_dying { $bigshot.gather_ammo }
class Event
attr_accessor :type, :created_at, :room_id
@@RECOGNIZED = [ :HUNTING_PREP_COMMANDS, :HUNTING_SCRIPTS_START, :CAST_SIGNS, :ATTACK,
:HUNTING_SCRIPTS_STOP, :RESTING_SCRIPTS_START, :RESTING_PREP_COMMANDS, :DISPLAY_WATCH ]
def initialize( type, time_stamp, room_id )
raise "Event type not recognized" unless @@RECOGNIZED.include?(type)
@type = type
@created_at = time_stamp
@room_id = room_id
end
def stale?
if( Room.current.id != @room_id || Time.now.to_i - @created_at > 15 )
return true
else
return false
end
end
def type
return @type
end
end
class Group
include DRbUndumped
attr_accessor :leader, :members
def initialize()
@members = Hash.new
end
def set_leader(leader)
@leader = leader
end
def add_member(member)
@members[member.name()] = member
end
def size()
return @members.size
end
def get_names
return @members.keys + [@leader.name]
end
def room_id()
return @leader.room_id()
end
def add_event(type)
@members.each_pair { |k,v|
begin
v.add_event( type, Time.now.to_i, Room.current.id )
rescue
@leader.message("Error adding #{type.to_s} event to members stack: #{$!}")
@leader.message($!.backtrace.join("\n"))
end
}
end
def add_leader_event(event)
@leader.add_event( Event.new(event) ) unless @leader.event_stack.size > 5
end
def roundtime?()
@members.each_pair { |k,v|
begin
return true if v.rt? > 0
rescue
@leader.message("Error polling member for RT. Removing!")
@members.delete(k)
end
}
return false
end
def should_hunt?()
emergency = @leader.event_stack.size == 0 ? nil : @leader.event_stack.shift
if(emergency)
@leader.clear_events
return false
end
@members.each_pair { |k,v|
begin
return false if !v.should_hunt?
rescue
@leader.message("Error polling member. Removing!")
@members.delete(k)
end
}
$bigshot_status = :hunting
return true
end
def should_rest?()
@members.each_pair { |k,v|
begin
return false if !v.should_rest?
rescue
@leader.message("Error polling member. Removing!")
@members.delete(k)
end
}
return true
end
def emergency_rest?()
@members.each_pair { |k,v|
begin
return true if v.wounded?
rescue
@leader.message("Error polling member. Removing!")
@members.delete(k)
end
}
return false
end
end
class Bigshot
include DRbUndumped
attr_accessor :BIRTH_TIME, :START_TIME, :STORED_TIMES, :FRIED, :OOM,
:SIGNS, :TARGETS, :INVALID_TARGETS, :FLEE_COUNT, :ALWAYS_FLEE_FROM,
:USE_WRACKING, :AMMO, :AMMO_CONTAINER, :HIDE_FOR_AMMO,
:REST_TILL_EXP, :REST_TILL_MANA, :USE_HERBS, :DEAD_MAN_SWITCH,
:RESTING_ROOM_ID, :RESTING_COMMANDS, :RESTING_SCRIPTS, :HUNTING_ROOM_ID,
:HUNTING_BOUNDARIES, :HUNTING_SCRIPTS, :HUNTING_COMMANDS,
:DISABLE_COMMANDS, :HUNTING_STANCE, :HUNTING_PREP_COMMANDS,
:MONITOR_INTERACTION, :FLEE_CLOUDS, :WRACKING_SPIRIT,
:REST_TILL_SPIRIT, :BOUNTY_MODE,
:event_stack, :followers
PRONE = /sleeping|webbed|stunned|kneeling|sitting|^lying|prone/
def add_event( type, time_stamp, room_id )
unless( @event_stack.size > 5 && type == :ATTACK )
@event_stack.push( Event.new( type, time_stamp, room_id ) )
end
end
def grab_event()
@event_stack.shift()
end
def clear_events()
@event_stack.clear
end
def initialize(bounty_mode=nil)
$bigshot = self
if bounty_mode
@BOUNTY_MODE = true
end
UserVars.op ||= Hash.new
CharSettings['targetable'] ||= Array.new
CharSettings['untargetable'] ||= Array.new
@BIRTH_TIME = Time.now.to_i
@START_TIME = 1
@STORED_TIMES = Array.new
@followers = nil
@event_stack = Array.new
load_settings()
dead_man_switch()
# this is mainly for azbounty:
before_dying {
@HUNTING_SCRIPTS.each { |i|
echo "Cleaning up hunting scripts: #{i}."
stop_script(i) if running?(i)
}
}
end
def load_settings()
set_value_required( 'hunting_commands', 'split_xx' )
set_value_required( 'fried', 'to_i' )
set_value_required( 'oom', 'to_i' )
set_value_required( 'rest_till_mana', 'to_i' )
set_value_required( 'rest_till_exp', 'to_i' )
set_value( 'hunting_room_id', 'to_i', 4 )
set_value( 'resting_room_id', 'to_i', 4 )
set_value( 'hunting_boundaries', 'split', Array.new )
set_value( 'hunting_commands_b', 'split_xx', Array.new )
set_value( 'hunting_commands_c', 'split_xx', Array.new )
set_value( 'disable_commands', 'split_xx', Array.new )
set_value( 'targets', 'targets', nil )
set_value( 'dead_man_switch', '', false )
set_value( 'monitor_interaction', '', false )
set_value( 'depart_switch', '', false )
set_value( 'encumbered', 'to_i', 200 )
set_value( 'signs', 'split', Array.new )
set_value( 'spam', '', true )
set_value( 'flee_count', 'to_i', 10 )
set_value( 'wracking_spirit', 'to_i', 0 )
set_value( 'invalid_targets', 'split', Array.new )
set_value( 'always_flee_from', 'split', Array.new )
set_value( 'flee_clouds', '', false )
set_value( 'use_wracking', '', false )
set_value( 'lone_targets_only', '', false )
set_value( 'rest_till_spirit', 'to_i', 0 )
set_value( 'ammo', '', nil )
set_value( 'ammo_container', '', nil )
set_value( 'fresh_wand_container', '', nil )
set_value( 'dead_wand_container', '', nil )
set_value( 'wand', '', nil )
set_value( 'wand_if_oom', '', false )
set_value( 'hide_for_ammo', '', nil )
set_value( 'wounded_eval', '', nil )
set_value( 'resting_scripts', 'split', Array.new )
set_value( 'hunting_scripts', 'split', Array.new )
set_value( 'loot_script', '', nil )
set_value( 'hunting_stance', '', 'defensive')
set_value( 'resting_commands', 'split_xx', Array.new )
set_value( 'hunting_prep_commands', 'split_xx', Array.new )
end
def clean_value( clean, value )
if( clean == 'to_i' )
return value.to_i
elsif( clean == 'split' )
return value.split(/,\s*/)
elsif( clean == 'split_xx' )
cleaned = Array.new
value.split(/,\s*/).each { |i|
rep = 1
cmd = ''
if( i =~ /(.*)\(x(\d+)\)$/ )
rep = $2.to_i
cmd = $1
elsif( i =~ /(.*)\(xx\)/ )
rep = 5
cmd = $1
else
cmd = i
end
and_tokens = cmd.split(/\sand\s/)
cmd = and_tokens.size == 1 ? and_tokens[0] : and_tokens
rep.times do cleaned.push(cmd) end
}
return cleaned
elsif( clean == 'targets' )
targets = Hash.new
tokens = value.split(/,/)
tokens.each do |i|
if( i =~ /(.*)\(([a|b|c|A|B|C])\)/ )
targets[$1.downcase.strip] = $2.downcase.strip
else
targets[i.downcase.strip] = 'a'
end
end
return targets
else
return value
end
end
def set_value( key, clean, default )
if( !UserVars.op[key].nil? && UserVars.op[key] !~ /^\s*$/ )
cleaned = clean_value( clean, UserVars.op[key] )
instance_variable_set( "@#{key.upcase}", cleaned )
else
instance_variable_set( "@#{key.upcase}", default )
end
end
def set_value_required( key, clean )
if( !UserVars.op[key].nil? && UserVars.op[key] !~ /^\s*$/ )
set_value( key, clean, nil )
else
message("ERROR: Missing required setting: #{key}")
message("(fried? is percenthealth and oom is percentmana)")
Script.self.kill
end
end
def cmd( command, npc = nil, stance_dance = true )
command = command.dup
if( command.class.to_s == 'Array' )
stance_dance = false if command.any? { |j| j =~ /stance/ }
command.each do |i|
echo i if $bigshot_debug
cmd( i, npc, stance_dance )
end
return
end
# check mana/stamina
if( command =~ /(.*)\(([s|m])(\d+)\)$/ )
if( $2 == 's' )
return if !checkstamina($3.to_i)
elsif( $2 == 'm' )
return if !checkmana($3.to_i)
end
command = $1
end
if( command =~ /force\s+(.*)\s+(?:till|until)\s+(\d+)/ )
cmd_force( $1, $2.to_i, npc )
return
end
# sub id
command.gsub!( /target/, "##{npc.id}" ) if !npc.nil?
# waitrt/waitcastrt
unless( command =~ /^nudgeweapons?/ )
waitrt?
waitcastrt? if command =~ /^\d+|incant/
end
# change_stance
stand()
unless( command =~ /^(?:\d+|wait|sleep|wand|berserk|script|hide|nudgeweapon)/ )
change_stance(@HUNTING_STANCE) if stance_dance
end
return if npc && !valid_target?(npc)
if( command =~ /^(\d+)(.*)$/ )
cmd_spell( $1.to_i, $2.strip, npc )
elsif( command =~ /^throw/i )
cmd_throw( npc )
elsif( command =~ /^k?weed/i )
cmd_weed( command, npc )
elsif( command =~ /^wand\s+(.*)/i )
cmd_wand(npc)
elsif( command =~ /^hide/i )
cmd_hide()
elsif( command =~ /^mstrike/i )
cmd_mstrike( command, npc )
elsif( command =~ /^fire/i )
cmd_ranged(npc)
elsif( command =~ /^berserk/i )
cmd_berserk()
elsif( command =~ /^script\s+(.*?)(\s|$)(.*)/i )
cmd_run_script( $1, $3 )
elsif( command =~ /^sleep\s+(\d+)/i )
cmd_sleep( $1, npc )
elsif( command =~ /^stance\s+(.*)/i )
change_stance($1)
elsif( command =~ /^wait\s+(\d+)/i )
wait_for_swing( $1.to_i, npc )
elsif( command =~ /^nudgeweapons?\s*/i )
cmd_nudge_weapons
else
return if command =~ /1030/ && checkmana < 10
return if $ambusher_here
echo "inside cmd: #{command}" if $bigshot_debug
bs_put command
end
end
def cmd_throw( npc )
unless npc.status == 'lying down'
empty_hands
dothistimeout "throw ##{npc.id}", 1, /^You attempt to throw a .*\!$/
waitrt?
fill_hands
end
end
def cmd_force( force_this, goal, npc )
start = Time.now
loop {
cmd( force_this, npc )
buffer = reget(20)
buffer.each_with_index { |line, i|
if( line =~ /^You.*(#{checknpcs.join('|')})(\.|!)|^You feint (high|low|(to the (left|right)))/ )
if buffer[i + 1] && buffer[i + 1] =~ /== \+(\d+)/
return if $1.to_i >= goal # spell/swing
elsif buffer[i - 1] && buffer[i - 1] =~ /^\[Roll result: (\d+)/
return if $1.to_i >= goal # cman
elsif buffer[i + 1] =~ /^As you focus on your magic, your vision swims with a swirling haze of crimson/
return
end
elsif( line =~ /^You do not have enough stamina to attempt this maneuver\./ )
return
elsif( line =~ /^Your magic fizzles ineffectually\./ )
return
end
}
if ( force_this =~ /^(\d+) / && !Spell[$1.to_i].affordable? )
message("Force ran out of mana. Giving up."); return;
end
return if GameObj.npcs.size.nil? || GameObj.npcs.size == 0
return if should_flee?
return if should_rest?
return if npc.status =~ /dead|gone/
return if ( Time.now - start ) > 30
}
end
def cmd_weed( command, target )
return if target.status =~ /dead|gone/
return if GameObj.loot.find { |loot| loot.name =~ /vine/ }
return unless Spell[610].known? and Spell[610].affordable?
waitcastrt?
change_stance('offensive') if command == 'kweed'
Spell[610].cast("##{target.id}")
change_stance('guarded') if command == 'kweed'
waitcastrt?
end
def cmd_spell( id, target_id, target )
if ( checkprep != "None" and checkprep != Spell[id].name )
fput 'release'
end
return if id == 506 and Spell[506].active?
return if id == 9605 and Spell[9606].active? # surge cooldown
return if target.status =~ /dead|gone/
unless( Spell[id].affordable? )
if(@WAND_IF_OOM)
cmd_wand(target); return;
end
if(@USE_WRACKING)
wrack()
end
end
if ( !Spell[id].affordable? and id != 9605 and id != 506 )
$bigshot_should_rest = true
$rest_reason = "out of mana"
end
waitcastrt?
Spell[id].cast(target_id)
end
def cmd_wand(target)
if(@FRESH_WAND_CONTAINER)
hands = GameObj.right_hand.name.to_s + GameObj.left_hand.name.to_s
wand = ( @WAND && @WAND !~ /^\s*$/ ) ? @WAND : 'wand'
until( (GameObj.right_hand.name.to_s + GameObj.left_hand.name.to_s) =~ /#{wand}/i )
result = dothistimeout( "get #{wand} from my #{@FRESH_WAND_CONTAINER}", 3, /You remove|You slip|Get what/ )
if( result =~ /Get what/ )
message("ERROR: Couldn't find fresh wand. Gonna rest."); $bigshot_should_rest = true; return;
elsif(result.nil?)
message("ERROR: Timed out looking for wand."); return;
end
end
change_stance('offensive')
result = dothistimeout( "wave my wand at ##{target.id}", 2, /d100|You hurl|is already dead|You do not see that here|You are in no condition|I could not find|Wait/ )
change_stance('defensive')
if( result =~ /You are in no condition/ )
message("ERROR: Wounded. Gonna rest."); $bigshot_should_rest = true; return;
elsif(result.nil?)
if(@DEAD_WAND_CONTAINER)
bs_put "put my wand in my #{@DEAD_WAND_CONTAINER}"
else
bs_put "drop my wand"
end
end
else
message("ERROR: Wand command called but fresh wand container not defined.")
end
end
def cmd_hide()
tries = 0
until(hiding?)
break if tries > 3 || should_flee?
change_stance('defensive')
bs_put 'hide'; tries += 1;
end
end
def cmd_mstrike( command, target )
if( !Spell[9005].active? && Skills.multiopponentcombat >= 30 && GameObj.npcs.all? { |i| i.noun !~ /nest/i } )
if( GameObj.npcs.size > 1 and target.nil? )
bs_put "mstrike"
else
bs_put "mstrike ##{target.id}"
end
else
bs_put "kill ##{target.id}"
end
end
def cmd_ranged(npc)
waitrt?
result = dothistimeout "get 1 my #{@AMMO.sub(/s$/, '')}", 2, /You remove|Get what\?|You already/
if( result =~ /Get what\?/ )
$bigshot_should_rest = true
$rest_reason = "Out of ammo"
return
end
result = dothistimeout(
"fire ##{npc.id}",
2,
/You fire|You cannot|Could not find|seconds|Get what?/
)
if( result =~ /^Could not find/ )
#$bigshot_should_rest = true
#$rest_reason = "Out of ammo"
gather_ammo
elsif( result =~ /You cannot fire/ )
unless GameObj.right_hand.id.nil?
line = dothistimeout "stow ##{GameObj.right_hand.id}", 3, /put|closed/
if line =~ /closed/
fput "open my #{@AMMO_CONTAINER}"
fput "put ##{GameObj.right_hand.id} in my ##{@AMMO_CONTAINER}"
end
end
elsif( result =~ /but it has no effect/ )
$bigshot_should_rest = true
$rest_reason = "Ammo had no effect (need blessed or magical)"
elsif ( result == false )
$bigshot_should_rest = true
$rest_reason = "Unknown result from fire routine: #{result}"
end
end
def cmd_berserk()
if( checkstamina(20) )
put 'stance def'
until( get =~ /^Everything around you turns red|^You scream/ )
bs_put 'berserk'
end
until( get =~ /^The redness fades from the world/ )
break if checkmind(7)
end
else
bs_put 'target random'; bs_put 'kill';
end
end
def cmd_run_script( name, args )
if( args == nil || args =~ /^\s*$/ )
run_script( name, true )
else
args = args.split(/ /)
run_script( name, true, args )
end
end
def cmd_sleep( time, npc )
change_stance('defensive')
time.to_i.times do
sleep 1
break if should_rest?
break if npc && npc.status =~ /dead|gone/
end
end
def cmd_nudge_weapons()
return if checkpaths.size == 0
GameObj.loot.each { |i|
next unless i.noun =~ /axe|scythe|pitchfork|falchion|sword|lance|sword|dagger|estoc|falchion|handaxe|katana|katar|gauche|rapier|scimitar|whip-blade|cudgel|crowbill|whip|mace|star|hammer|claidhmore|flail|flamberge|maul|pick|staff|mattock/
change_stance('defensive')
sheathed = false
unless( righthand.nil? || lefthand.nil? )
sheathed = true
fput 'sheath'
unless( righthand.nil? || lefthand.nil? )
message("Unable to empty hands via sheath.")
return
end
end
dirs = checkpaths
dir = checkpaths.shift
fput "get ##{i.id}"
put dir
put "drop ##{i.id}"
fput reverse_direction(dir)
fput "gird" if sheathed
}
end
def message(text)
string = ''
if $fake_stormfront then string.concat("\034GSL\r\n ") else string.concat("<pushBold\/>") end
if( text.index('\n') )
text.split('\n').each { |line| string.concat("| #{line}") }
else
string.concat('| ' + text)
end
if $fake_stormfront then string.concat("\034GSM\r\n ") else string.concat("<popBold\/>") end
puts string
end
def dead_man_switch()
if @DEAD_MAN_SWITCH
Thread.new {
while( running?('bigshot') )
if( dead? || percenthealth < 40 )
echo 'AUTOBOT ALERT: Your character is in trouble!'
fput 'quit'
end
sleep 2
end
};
elsif @DEPART_SWITCH
start_exec_script( <<-EOF
while( running?('bigshot') );
if(dead?);
stop_script('bigshot');
fput 'depart'; fput 'depart';
fput 'depart confirm'; fput 'depart confirm';
start_script('waggle');
15.times { sleep 60; fput info; };
sleep 1 until percentspirit == 100 && !running?('waggle');
start_script( 'bigshot', ['solo'] );
Script.self.kill;
end;
sleep 5;
end;
EOF
);
else
Thread.new {
loop { Script.self.kill if dead?; sleep 5; }
}
end
end
def keep_awake()
Thread.new {
while( running?('bigshot') )
sleep 150; put 'look';
end
}
end
def monitor_interaction()
if @MONITOR_INTERACTION
start_exec_script( <<-eos
def show_window(line);
window_title = Char.name + ':' + line;
Gtk.queue {
$myWindow = Gtk::Window.new;
$myWindow.title = "Autobot Alert!";
$myWindow.set_size_request(450, 25);
label = Gtk::Label.new window_title;
$myWindow.add(label);
$myWindow.show_all;
};
end;
while(line = get);
break unless running?('bigshot');
if(line =~ /SEND|POLICY|[Rr](\s)*[Ee](\s)*[Pp](\s)*[Oo](\s)*[Rr](\s)*[Tt]|peaking to you|unresponsive|taps you|nods to you|lease respond|not in control|character|violation|lease speak|peak out loud|Y U SHOU D|whispers,|speaking to you|smiles at you|waves to you|grins at you|hugs you|takes hold your hand|grabs your hand|clasps your hand|trying to drag you/);
unless(line =~ /LNet/);
show_window(line);
echo "AUTOBOT ALERT: " + line;
end;
end;
end;
eos
)
end
end
def wrack()
if Spell[9918].known? and not Spell[9012].active?
Spell[9918].cast if checkspirit >= @WRACKING_SPIRIT
elsif Spell[9718].known?
( checkstamina / 50 ).times { Spell[9718].cast }
end
end
def change_stance( new_stance, force = true )
#return unless new_stance =~ /off/ # pookahs/bog
return if Spell[1617].active? || Spell[216].active? || dead?
if( stance() =~ /#{new_stance}/ )
return
elsif( checkcastrt() > 0 && new_stance =~ /def/ )
return if stance() == 'guarded'
end
if(force)
result = dothistimeout( "stance #{new_stance}", 3, /You are now in an?|Cast Round Time in effect|You are unable to change/ )
else
put "stance #{new_stance}"
end
end
def wait_for_swing( seconds, target = nil )
status_tags
start = Time.now
swung = false
while(1)
change_stance( 'defensive', false ) unless target && target.status =~ PRONE
stand()
pcs = checkpcs ? ' you(\.|!|r? )|' + checkpcs.join('|') : 'you(\.|!|r? )'
break if clear.any? { |line| line =~ /#{target.id}.*(#{pcs})/ && line !~ /^<style id=""\/><style id="roomDesc"\/>|<component id='room objs'>|<compDef id='room objs'>/ }
break if GameObj.npcs.size.nil? || GameObj.npcs.size == 0
break if should_flee?
break if target && target.status =~ PRONE
break if ( Time.now - start ) > seconds
sleep 0.50
end
status_tags
end
def croak(message)
message(message);
croak_scripts( ['bigshot'] )
end
def run_script( name, pause_bigshot = false, args = [] )
if Script.running.find { |s| s.name.downcase == name.downcase }.paused or running? name
stop_script name
wait_while { running? name }
end
start_script name, args
if pause_bigshot
wait_until { !running? name }
end
end
def run_scripts( scripts, pause_bigshot = false )
scripts.each do |i|
tokens = i.split(/\s+/)
if( tokens.size > 1 )
run_script( tokens[0], pause_bigshot, tokens[1..-1] )
else
run_script( tokens[0], pause_bigshot )
end
end
end
def croak_script(name)
kill_script(name) if running?(name)
end
def croak_scripts(scripts)
scripts.each { |i| croak_script(i) }
end
def stand()
until(standing?)
change_stance('defensive')
bs_put 'stand'
end
end
def lead( my_group = nil )
monitor_interaction()
@followers = my_group || Group.new()
if(should_rest?)
rest()
else
hunt()
end
end
def find_routine(target)
if( !solo? && fried? )
return @DISABLE_COMMANDS
else
key = @TARGETS.keys.find { |k| target.name =~ /^#{k}$/ or target.noun =~ /^#{k}$/ }
if key.nil?
routine_letter = 'a'
else
routine_letter = @TARGETS[key]
end
if routine_letter == 'c'
return @HUNTING_COMMANDS_C unless @HUNTING_COMMANDS_C.size == 0
elsif routine_letter == 'b'
return @HUNTING_COMMANDS_B unless @HUNTING_COMMANDS_B.size == 0
end
return @HUNTING_COMMANDS
end
end
def solo?
# tails wont have followers
if( @followers && @followers.size == 0 )
return true
else
return false
end
end
def leading?
return !following?
end
def following?
return @followers.nil?
end
def no_players()
return false if GameObj.loot.find { |obj| obj.noun == 'disk' and obj.name !~ /#{Char.name}/}
return false if checkpcs or $ambusher_here
return true
end
def pre_hunt()
# prep/go
@followers.add_event(:HUNTING_PREP_COMMANDS)
@HUNTING_PREP_COMMANDS.each { |i|
if i =~ /^script\s+(.*?)(\s|$)(.*)/i
cmd_run_script( $1, $3 )
else
fput(i)
end
}
@followers.add_event(:CAST_SIGNS)
cast_signs()
@followers.add_event(:HUNTING_SCRIPTS_START)
run_scripts( @HUNTING_SCRIPTS, false )
goto(@HUNTING_ROOM_ID)
if( !solo? && @followers.get_names.any? { |i| !checkpcs.include?(i) } )
@followers.add_event(:CAST_SIGNS) # trigger rubber band
sleep 10 # wait for followers
end
end
def do_hunt()
spam() if UserVars.op['spam']
start_watch()
message('Bigshot hunting')
# loop
target = nil
just_arrived = true
last_attack = 0
$ambusher_here = false
if $exec_ambush == false then
start_exec_script( <<-eos
while(line = get);
break unless running?('bigshot');
$ambusher_here = true if line =~ /^\w+ leaps from hiding to attack/;
end;
eos
)
$exec_ambush = true
end
while true
while( (target = find_target(target, just_arrived)) && !should_rest? && no_players == true)
echo target if $bigshot_debug
if( (Time.now.to_i - last_attack > 15) || just_arrived )
@followers.add_event(:ATTACK)
last_attack = Time.now.to_i
end
attack(target)
just_arrived = false
loot() if $ambusher_here == false
end
echo "Exiting attack loop" if $bigshot_debug
gather_ammo()
if(should_rest?)
break
else
prepare_for_movement()
target = bs_wander()
sleep 1
just_arrived = true
end
end
unspam()
end
# this is a leader method
def hunt()
pre_hunt()
do_hunt()
rest()
end
# this is a leader method
def rest()
message("Bigshot resting: #{$rest_reason}")
$bigshot_should_rest = nil
if @BOUNTY_MODE # bounty script should take over from here
echo "Bounty mode. Killing self. Reason: #{$rest_reason}"
Script.self.kill
end
stop_watch()
# prep/go
goto(@RESTING_ROOM_ID)
@followers.add_event(:DISPLAY_WATCH)
@followers.add_event(:HUNTING_SCRIPTS_STOP)
croak_scripts(@HUNTING_SCRIPTS)