Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: How do i cast a spell at each mob in the room...

  1. #1

    Default How do i cast a spell at each mob in the room...

    I realize this is probably insanely simple but i am still fairly new to coding and I have been trying to write a script that will cast a spell once at each mob in the room and i am getting nowhere and I was hoping somebody could help me out. It will cast at the first target, then exits and doesn't continue on casting at the others.

    Code:
    GameObj.npcs.each { |mob|
    
    if mob.status !=~ /dead|gone/
    	1.times {
    		fput "prep 917"
    		fput "cast ##{mob.id}"
    		waitcastrt?
    		waitrt?
    	}
    end
    }
    If somebody could help me out it would be most appreciated.
    Last edited by Glaves; 07-11-2019 at 01:39 AM.

  2. #2

    Default

    if mob.status !~ /dead|gone/

  3. #3

    Default

    Code:
    GameObj.npcs.each { |mob|
    if (mob.status !~ /dead|gone/)
    	Spell[917].cast("##{mob.id}") if Spell[917].affordable?
    	waitcastrt?
    	waitrt?
    end
    }
    Last edited by Rjex; 07-11-2019 at 02:14 AM.

  4. Default

    Code:
    GameObj.npcs.each { |mob|
    	if mob.status !~ /dead|gone/ and mob.type =~ /\baggressive\b/
    		if Spell[917].affordable?
    			Spell[917].cast mob
    			waitcastrt?
    			waitrt?
    		end
    	end
    }
    Been away a while, so not sure if the aggressive is still needed or not to make sure you don't attack things you don't intend to.

  5. #5

    Default

    THANK YOU BOTH! I added the aggressive tag to the code Rjex provided and it seems to be working great!!!

    I was so close too.
    Last edited by Glaves; 07-11-2019 at 02:42 AM.

  6. #6

    Default

    Now i just need to figure out how to make it not include certain mobs and it'll be perfect

  7. #7

    Default

    I got it! Seriously, thank you! Been trying to get this to work for a couple days now and it was driving me nuts. Very much appreciated.

    Code:
    GameObj.npcs.each { |mob|
    if (mob.status !~ /dead|gone|flying/ && !['raptor'].include?(mob.noun) && mob.type =~ /\baggressive\b/)
    	Spell[917].cast("##{mob.id}") if Spell[917].affordable?
    	waitcastrt?
    	waitrt?
    end
    }
    Last edited by Glaves; 07-11-2019 at 02:59 AM.

  8. #8

    Default

    set a macro to: \xtarget next\rincant 917\r
    tape the key down
    go afk

    come back fried with full wizard juice.

    You're welcome.
    Mithrilschlong, 2015-03-10 to slightly later on 2015-03-10. You will not be forgotten!

  9. #9

    Default

    Incidentally, wouldn't this be cleaner anyway?

    Code:
    GameObj.targets.each { |mob|
    if (mob.status !~ /flying/)
    	Spell[917].cast("##{mob.id}") if Spell[917].affordable?
    	waitcastrt?
    	waitrt?
    end
    }
    targets already filters out everything that's dead, gone, or familiar type

  10. #10

    Default

    Quote Originally Posted by Rjex View Post
    Incidentally, wouldn't this be cleaner anyway?

    Code:
    GameObj.targets.each { |mob|
    if (mob.status !~ /flying/)
    	Spell[917].cast("##{mob.id}") if Spell[917].affordable?
    	waitcastrt?
    	waitrt?
    end
    }
    targets already filters out everything that's dead, gone, or familiar type
    Ohhh i didn't know they auto filtered that stuff. The raptor isn't a familiar it's a mob i ignore in a hunting ground. When did that change? I remember when i was on shattered i had to add the dead/gone and my animal companion to avoid the friendly npc. It would seem the update to ruby 2.0 changed a bunch of stuff. I also have just been gone for a couple years now and am sooo rusty.
    Last edited by Glaves; 07-11-2019 at 05:03 PM.

Posting Permissions

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