Page 7 of 7 FirstFirst ... 567
Results 61 to 70 of 70

Thread: Learn how to script with this simple hunting script

  1. #61

    Default

    target_names = /gnoll|hobgoblin|snowcat/

    $my_target = GameObj.npcs.find{ |npc| npc.name =~ target_names && npc.type =~ /aggressive/
    }


    if $my_target == nil
    echo "No target found!"
    exit
    end

    def this_script_hide_me
    until hidden?
    waitrt?
    fput "hide"
    end
    end

    def this_script_stand_me
    until standing?
    waitrt?
    fput "stand"
    end
    end

    def this_script_keep_haste
    Spell[506].cast if (!Spell[506].active?) && (Spell[506].affordable?) && (Spell[506].known?)
    end

    def this_script_stun_target
    Spell[505].cast($my_target) if (Spell[505].affordable?) && (Spell[505].known?) && ($my_target.status !~

    /stun/)
    end

    def this_script_kill_target
    Spell[901].cast($my_target) if (Spell[901].affordable?) && (Spell[901].known?)
    end

    def this_script_ambush_target
    critter_needs_to_be_legged = true
    waitrt?
    if ($my_target.status =~ /prone|sit|lay|kneel|stun|sleep/i)
    result = dothistimeout "ambush ##{$my_target.id} head", 2, /round(time)?|You cannot aim that high|

    does not have a/i
    if result =~ /round(time)?/i
    critter_needs_to_be_legged = nil
    elsif result =~ /does not have a/
    critter_needs_to_be_legged = nil
    fput "attack ##{$my_target.id}"
    elsif result =~ /You cannot aim that high/
    nil
    elsif result.nil?
    nil
    end
    end
    if (critter_needs_to_be_legged)
    result = dothistimeout "ambush ##{$my_target.id} left leg", 2, /round(time)?|does not have a/i
    if result =~ /round(time)?/i
    nil
    elsif result =~ /does not have a/
    fput "attack ##{$my_target.id}"
    elsif result.nil?
    fput "attack ##{$my_target.id}"
    end
    end
    end

    start_script "sloot" if !running? "sloot"

    loop{
    break if ($my_target.status =~ /dead|gone/)
    this_script_keep_haste
    this_script_stand_me
    this_script_stun_target
    this_script_kill_target
    sleep 1
    }

    if $my_target.status =~ /dead/
    echo "Target dead!"
    waitrt?
    start_script "waitloot"
    wait_while { running?('waitloot') }
    elsif $my_target.status =~ /gone/
    echo "Target gone!"
    end


    thanks!
    Last edited by Intel; 10-31-2015 at 02:38 PM.

  2. #62

    Default

    Code:
    loop{
    	break if ($my_target.status =~ /dead|gone/)
    	this_script_keep_haste
    	this_script_stand_me
    	this_script_stun_target
    	this_script_kill_target
    	sleep 1
    }
    Going by the name of your script I assume you want to use the ambushing portion of the script but you aren't calling that part. You should change the above to:

    Code:
    loop{
    	break if ($my_target.status =~ /dead|gone/)
    	this_script_stand_me
    	this_script_ambush_target
    	sleep 1
    }
    Last edited by Tgo01; 10-31-2015 at 02:54 PM.

  3. #63

    Default

    That worked, thank you.

  4. #64

    Default

    Code:
    def cmd_fire(target)
    	critter_needs_to_be_legged = true
    	waitrt?
    	if (target.status =~ /prone|sit|lay|kneel|stun|sleep/i)
    		fput "get 1 my arrow"
    		result = dothistimeout "fire ##{target.id} right eye", 2, /round(time)?/i
    		if result =~ /round(time)?/i
    			critter_needs_to_be_legged = nil
    		elsif result.nil?
    			nil
    		end
    	end				
    	if (critter_needs_to_be_legged)
    		fput "get 1 my arrow"
    		result = dothistimeout "fire ##{target.id} right leg", 2, /round(time)?/i
    		if result =~ /round(time)?/i
    			nil
    		elsif result.nil?
    			fput "fire ##{$my_target.id} right leg"
    		end
    	end
    end
    >
    [bigshot]>get 1 my arrow
    You already have that.
    >
    [bigshot]>fire #19445912 right leg
    I do not understand, please rephrase that.

    Changing FIRE to AMBUSH:

    [bigshot]>get 1 my arrow
    You already have that.
    >
    [bigshot]>ambush #19451339 right leg
    You thrust with an arrow at a XXX!
    AS: +101 vs DS: +141 with AvD: +4 + d100 roll: +26 = -10
    A clean miss.
    Roundtime: 6 sec.

    Why does it work differently for ranged?
    Last edited by SashaFierce; 02-10-2016 at 07:25 AM.

  5. #65

    Default

    Since we're reviving this thread (which is amazing, and much appreciated):

    How would I get a script to constantly monitor the game and only trigger on a series of specified incoming strings of text (from all sources; Room labels, player names, objects in the room)?

    For instance:

    loop {
    #### Monitor the incoming feed at all times, assigning it to variable 'get'... is this the right way to do this?
    get = server.string
    if get == /GM/
    fput "beg for RPA"
    elsif get == /Scripting Lounge/
    fput "say It was an accident"
    elsif get == /keg/
    fput "pour keg"
    end
    }

    I feel like I'm in the general ballpark, but I wasn't able to get it to work the other day when tinkering, and I'm sure there are about a million more elegant ways to accomplish the same thing.

    Thanks!
    Last edited by 0zymandius; 02-10-2016 at 09:44 AM.

  6. Default

    Code:
    while (line = get)
         if line =~ /GM/
              fput "beg for RPA"
         elsif line =~ /Scripting Lounge/
              fput "say It was an accident"
         elsif line =~ /keg/
              fput "pour keg" # this will probably cause the word keg to show up again, which is probably bad
         end
    end
    Get Lich - Vote for Gemstone (topmudsites.com)

  7. #67

    Default

    So... without current access to the game, but wanting to capitalize on the opportunity, is this the correct method for this sort of script? I bastardized something together based off of my memories of the ice sculpting game from BMC. (And it's not meant to run unattended, so I don't care about going for more silvers or containers filling up.)

    Edited to add: Obviously I'd need the actual string where it would only trigger on my creations, not every one in the room, or anyone who mentioned one. I'm more curious if this is the right 'way' to go about it, to include waiting until something appears in the hand before proceeding to the next step.

    Code:
    def go
    	empty_right_hand
    	empty_left_hand
    	waitrt?
    	fput "get chisel"
    	waitrt?
    end
    
    while (line = get)
    	if line =~ /crushed ice/
    		go
    	elsif line =~ /carved ice sword/
    		waitrt?
    		wait_until (checkright)
    		fput "put right in crate"
    		go
    	elsif line =~ /carved ice tree/
    		waitrt?
    		wait_until (checkright)
    		fput "put right in crate"
    		go
    	elsif line =~ /carved ice rolton/
    		waitrt?
    		wait_until (checkright)
    		fput "put right in my pack"
    		go
    	elsif line =~ /majestic ice dragon/
    		waitrt?
    		wait_until (checkright)
    		fput "put right in my pouch"
    		go
    	end
    end
    Last edited by 0zymandius; 02-10-2016 at 02:13 PM.

  8. #68

    Default

    Quote Originally Posted by SashaFierce View Post
    Code:
    def cmd_fire(target)
    	critter_needs_to_be_legged = true
    	waitrt?
    	if (target.status =~ /prone|sit|lay|kneel|stun|sleep/i)
    		fput "get 1 my arrow"
    		result = dothistimeout "fire ##{target.id} right eye", 2, /round(time)?/i
    		if result =~ /round(time)?/i
    			critter_needs_to_be_legged = nil
    		elsif result.nil?
    			nil
    		end
    	end				
    	if (critter_needs_to_be_legged)
    		fput "get 1 my arrow"
    		result = dothistimeout "fire ##{target.id} right leg", 2, /round(time)?/i
    		if result =~ /round(time)?/i
    			nil
    		elsif result.nil?
    			fput "fire ##{$my_target.id} right leg"
    		end
    	end
    end
    >
    [bigshot]>get 1 my arrow
    You already have that.
    >
    [bigshot]>fire #19445912 right leg
    I do not understand, please rephrase that.

    Changing FIRE to AMBUSH:

    [bigshot]>get 1 my arrow
    You already have that.
    >
    [bigshot]>ambush #19451339 right leg
    You thrust with an arrow at a XXX!
    AS: +101 vs DS: +141 with AvD: +4 + d100 roll: +26 = -10
    A clean miss.
    Roundtime: 6 sec.

    Why does it work differently for ranged?
    I'm not sure to be honest, I've never used ranged

    Quote Originally Posted by 0zymandius View Post
    So... without current access to the game, but wanting to capitalize on the opportunity, is this the correct method for this sort of script? I bastardized something together based off of my memories of the ice sculpting game from BMC. (And it's not meant to run unattended, so I don't care about going for more silvers or containers filling up.)

    Edited to add: Obviously I'd need the actual string where it would only trigger on my creations, not every one in the room, or anyone who mentioned one. I'm more curious if this is the right 'way' to go about it, to include waiting until something appears in the hand before proceeding to the next step.

    Code:
    def go
    	empty_right_hand
    	empty_left_hand
    	waitrt?
    	fput "get chisel"
    	waitrt?
    end
    
    while (line = get)
    	if line =~ /crushed ice/
    		go
    	elsif line =~ /carved ice sword/
    		waitrt?
    		wait_until (checkright)
    		fput "put right in crate"
    		go
    	elsif line =~ /carved ice tree/
    		waitrt?
    		wait_until (checkright)
    		fput "put right in crate"
    		go
    	elsif line =~ /carved ice rolton/
    		waitrt?
    		wait_until (checkright)
    		fput "put right in my pack"
    		go
    	elsif line =~ /majestic ice dragon/
    		waitrt?
    		wait_until (checkright)
    		fput "put right in my pouch"
    		go
    	end
    end
    Nothing jumps out at me as being wrong.

  9. #69

    Default

    For ranged, you'll have to:

    >AIM RIGHT LEG
    >FIRE

    Can't do it in one line.

  10. Default

    Hey. You can learn how to write code using some online tutorials. In the modern world, this training format is very popular. As for me, with the help of tutorials in which they teach how to write essays from companies like website, you can learn how to write not only essays but also term papers, just as with the help of tutorials in which they teach how to write code, you can learn how to write code of whole programs and think like a programmer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •