Page 3 of 7 FirstFirst 12345 ... LastLast
Results 21 to 30 of 70

Thread: Learn how to script with this simple hunting script

  1. #21

    Default

    Quote Originally Posted by Iovan View Post
    I'm guessing the way this script is written, that the first npc that it finds that is on the list at all will become the target. Is a smart targeting setup outside the scope of this tutorial? I'm thinking that a better way would be to make a loop that will check all npcs for the first item on the list before checking for the second.
    Something to possibly tack on to this if you're not already saying it, but something I always thought would be good for ;bigshot would be the ability to make an order you want things killed. It seems pretty random, but let's say you're fighting the Shan in Sol and want to take out those Rangers first that always spike you in the head...

  2. #22

    Default

    Quote Originally Posted by Soulance View Post
    Eh, it 'kinda' works here and there but I think you're right about it just being a timing thing. By the time it's doing what it is supposed to do the person is already out of the stun. Seems like it would start to prepare the spell, then miscast, then prepare it again, miscast. I'll have to go back and test a little more again because I stopped using it. It was nice for bandits though.
    Hmm, try reducing the pause and see if that works. If not I can look at the code again.

    Quote Originally Posted by Iovan View Post
    I'm guessing the way this script is written, that the first npc that it finds that is on the list at all will become the target. Is a smart targeting setup outside the scope of this tutorial? I'm thinking that a better way would be to make a loop that will check all npcs for the first item on the list before checking for the second.
    Code:
    target_names = [ "rolton", "squirrel", "kobold", "orc" ]
    
    $my_target = nil
    
    target_names.each{ |i|
    	$my_target = GameObj.npcs.find{ |npc| npc.name =~ /#{i}/ && npc.type =~ /aggressive/ && npc.status !~ /dead/ }
    	break if $my_target
    }
    Quote Originally Posted by Soulance View Post
    Something to possibly tack on to this if you're not already saying it, but something I always thought would be good for ;bigshot would be the ability to make an order you want things killed. It seems pretty random, but let's say you're fighting the Shan in Sol and want to take out those Rangers first that always spike you in the head...
    Yup, the above code would do that. Just list the critters in the order you want to kill them.

    Of course this is just when you first run the script it will find and kill the first thing listed, if you start the script then a more dangerous critter enters the room while you're killing your current target and you would rather kill the new more dangerous critter before you finish killing your current target then that would require some additional coding.
    Last edited by Tgo01; 05-27-2015 at 01:46 PM.

  3. #23

    Default

    Here is something new:

    Code:
    $silence_targets = /kobold/
    $already_silenced_targets = Array.new
    
    def this_script_silence_them_all
    	GameObj.npcs.each{ |npc|
    		if (npc.name =~ $silence_targets) && (!$already_silenced_targets.include?(npc.id)) && (Spell[210].affordable?) && (Spell[210].known?)
    			Spell[210].cast(npc)
    			$already_silenced_targets.push(npc.id)
    		end
    	}
    	
    end
    In case you want to silence them dangerous kobolds from casting terrible spells at you you could set up your script like this. Define which dangerous critters you want silenced in the $silence_targets then add the this_script_silence_them_all definition to your loop.

    Since silence doesn't show up as a status effect on the critter you have no way of knowing which critters you have already cast silence on, this definition keeps track of that. Every time it is run it will go through the list of critters in the room and if their name matches what you have set in the $silence_targets it will then check to see if that particular critter's id is part of the $already_silenced_targets array. If the id is not part of the array then it will cast silence on that critter then add that critter's id to the array (that's what push basically does). If the script comes along this particular critter again it will see that its id is already part of the $already_silenced_targets array and ignore it.

    This would also check to make sure you have enough mana to cast silence and if you don't then it won't cast silence nor will it add the critter's id to the array of ids to check for.

    Keep in mind every time the script is started it sets the $already_silenced_targets to nothing so it starts over again. You could change this so it doesn't set it to nil so it keeps track of the critters id even if the script stops and you start it again.

    You could even get fancy and have the script automatically remove dead critters from the array.

    Also keep in mind this definition is not setup to see if you were successful in your cast or if the silence wore off the critter, you could set up a script that would automatically check for these things as well.
    Last edited by Tgo01; 05-27-2015 at 04:43 PM.

  4. #24

    Default

    would i be able to have the script target a specific limb with 708?


    def this_script_stay_down
    GameObj.npcs.any? { |npc|
    if (npc.status !~ /prone|sit|lay|kneel|stun|sleep/ && npc.type =~ /aggressive/) && (GameObj.pcs.length == nil)
    (Spell[708].cast left leg) if (Spell[708].known?) && (Spell[708].affordable?)
    end
    }
    end

  5. #25

    Default

    You can use the aim verb for 708 so you could do...

    Code:
    def this_script_stay_down
            fput "aim left leg"
    	GameObj.npcs.any? {|npc|
    		if (npc.status !~ /prone|sit|lay|kneel|stun|sleep/ && npc.type =~ /aggressive/)
    			Spell[708].cast($my_target) if (Spell[708].affordable?) && (Spell[708].known?)
    		end
    	}
    end
    Last edited by Tgo01; 06-07-2015 at 06:39 PM.

  6. #26

    Default

    Awesome, now last question, how would i get target names to be filled with what i enter at the time of the script? i.e ;ld radical combantant

  7. #27

    Default

    Quote Originally Posted by Jawa View Post
    Awesome, now last question, how would i get target names to be filled with what i enter at the time of the script? i.e ;ld radical combantant
    $my_target = "#{script.vars[1]}"

    You would start the script the the critter's noun then, like ;ld combantant
    Last edited by Tgo01; 06-07-2015 at 06:58 PM.

  8. #28

    Default

    I would leave the target_names = [ "rolton", "squirrel", "kobold", "orc" ] part?

  9. #29

    Default

    Quote Originally Posted by Jawa View Post
    I would leave the target_names = [ "rolton", "squirrel", "kobold", "orc" ] part?
    If you're not gonna use that part then it doesn't matter.

  10. #30

    Default

    no no i would remove that and the target_names.each part too right?

Posting Permissions

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