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

Thread: number of zaps

  1. #1

    Default number of zaps

    I was wondering, if there is a function, which lets you check, if you have already used a wand to zap something?

    Cheers,
    ki77bot.

  2. #2
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

    There is no such function, but zarqon once wrote an amazing bit of code which I have adapted to my own purposes. Here you go:

    Code:
    boolean zappp(item whatsit) {
       if (item_amount(whatsit) == 0) return false;
       cli_execute("zap 1 "+whatsit);
       return true;
    }
    
    void daily_zap() {
    	print("Looking to zap...");
    	int whichwand = 0;
    	for i from 1268 to 1272
    		if(item_amount(to_item(i)) > 0) whichwand = i;
    	switch {
    	case whichwand == 0:
    		print("You don't have a wand.", "olive");
    		break;
    	case contains_text(visit_url("wand.php?whichwand="+whichwand),"feels warm"):
    		print("Already zapped today. Afraid of Kabloo-ey!", "red");
    		break;
    	case zappp($item[green-frosted astral cupcake]):
    	case zappp($item[orange-frosted astral cupcake]):
    	case zappp($item[purple-frosted astral cupcake]):
    	case zappp($item[33398 scroll]):
    	case zappp($item[ring of aggravate]):
    		break;
    	default:
    		print("You have nothing more to zap.", "olive");
    	}
    }
    Since the cases stop executing once one of them is true, it will only zap one item.
    Last edited by Bale; 05-29-2009 at 04:29 PM.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  3. #3
    Senior Member mredge73's Avatar
    Join Date
    Dec 2008
    Location
    Houston TX
    Posts
    519

    Default

    In summary this is how I use it to check if the wand has been used yet:
    Add these two functions to your script:
    (I created them borrowing portions of Zarqon's script a while back)
    Code:
    //Find Wand
    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
    int FindWand()
    {
    	int wand=0;
    	for i from 1268 to 1272
    	{ 
    		if (haveItem(to_item(i)))
    			wand = i;
    	}
    	return wand;
    }
    
    //checks if the wand was used today
    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
    boolean WandUseable(int wand)
    {
    	if (wand==0)
    		return false;
    	if (contains_text(visit_url("wand.php?whichwand="+wand),"feels warm")) 
    		return false;
    	else
    		return true;
    }
    To use:

    boolean FreshWand = WandUseable(FindWand());

  4. #4
    Senior Member matt.chugg's Avatar
    Join Date
    Nov 2006
    Posts
    630

    Default

    purly for extra variety, heres the one I wrote, not that I really use it much!

    Code:
    // -1   No wand found in inventory
    //  0   wand hasn't been used at all
    //  1   feels warm to the touch (level 1)
    //  2   You should probably be careful. (level 2)
    //  3   You should definitely be careful. (level 3)
    //  4	You should seriously be careful.  (level4)
    //  5   should never be seen in visit_url, because I think at this point the wand is gone
    
    int wandstatus() {
    	int whichwand=0;
    	int retstatus;
    
      	for i from 1268 to 1272 {
    		if (item_amount(to_item(i)) > 0) whichwand = i;
    	}
          	
    	if (whichwand == 0) {
    		retstatus = -1;
    	} else {
    		// we have a wand so can't be -1 preset to 0 then if its still 0
    		// after below checks then it really should be zero.
    		// does ash have elseif ?
    
    		retstatus = 0;
    		string wanddescription = visit_url("wand.php?whichwand="+whichwand);
    		
    		if (contains_text(wanddescription, "feels warm")) {
    			retstatus = 1;
    		} 
    		
    		if (contains_text(wanddescription, "probably be careful")) {
    			retstatus = 2;
    		}
    		
    		if (contains_text(wanddescription, "definitely be careful")) {
    			retstatus = 3;
    		}
    
    		if (contains_text(wanddescription, "seriously be careful")) {
    			retstatus = 4;
    		}
    	}
    	return retstatus;
    }

  5. #5

    Default

    Thanks for all your replies...

    I am using a breakfast script, that sometimes breaks , if the 'Ode to Booze' is not cast fast enough. Needless to mention, that the script also zaps. In case the script breaks, I do not want to risk losing the wand. With this variety of solutions, I should be able to do that.

    Again, thanks a lot...

    Cheers,
    ki77bot.

  6. #6
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

    If Ode to Booze is a problem, try this subroutine:

    Code:
    // shot = 1 for first shot of Ode, or shot = 2 for second shot as a nightcap.
    boolean get_ode(int shot) {
    	if(have_effect($effect[Ode To Booze]) < 1) {
    		if(have_skill($skill[The Ode To Booze])) {
    			if(my_mp()< mp_cost($skill[The Ode To Booze])) {
    				restore_mp(mp_cost($skill[The Ode To Booze]));
    				if(my_mp()< mp_cost($skill[The Ode To Booze]))
    					abort("Can't cast Ode to Booze due to lack of MP!");
    			}
    			use_skill(1, $skill[The Ode To Booze]);
    			if(have_effect($effect[Ode To Booze]) >= 1)
    				return true;
    			else 
    				return false;
    		} else {
    			// lets try to get it from a buffbot
    			print("purchasing Ode to Booze from a few buffbots...", "blue");
    			if(shot == 1) {
    				cli_execute("csend 1 meat to Testudinata");
    				cli_execute("csend 23 meat to Iocainebot");
    			} else {
    				cli_execute("csend 11 meat to Testudinata");
    				cli_execute("csend 80 meat to Iocainebot");
    			}
    			int iterations = 0;
    			while( have_effect($effect[Ode to Booze]) < 1) {
    				if (iterations > (30)) {
    					print("failed to get Ode to Booze", "red");
    					return false;
    				}
    				cli_execute("wait 30");
    				cli_execute("effects refresh");
    				iterations = iterations + 1;
    			}
    		}
    	} 
    	return true;
    }
    Last edited by Bale; 05-31-2009 at 08:26 AM.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  7. #7

    Default

    Perfect, that was exactly what I was looking for.

    I tried to solve it like this, but was not quite satisfied:

    Code:
    		if(have_effect($effect["ode to booze"]) > 0){
    		print("Yes, your favorite song 'Ode to Booze' has been played for you.", "green");
    	} else {
    		print("Need to get 'Ode to Booze' (testudinata @ 1 meat)", "red");
    		cli_execute("csend 1 meat to testudinata");
    		wait(10);
    		cli_execute("status refresh");
    	}
    
    	int i = 0;
    	while( (have_effect($effect["ode to booze"]) <= 0) && i < 4 )
    	{
    	    i = i + 1;
    		wait(30);
    		cli_execute("status refresh");
    		print("...waiting 30 seconds for buff...");
    	}
    
    	if(have_effect($effect["ode to booze"]) > 0){
    		print("Yes, your favorite song 'Ode to Booze' has been played for you.", "green");
    	} else {
    		abort("Well, something didn't work there with your buffbot. Get 'Ode to Booze'!");
    	}
    Cheers,
    ki77bot.

  8. #8
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,679

    Default

    Ooh Bale, I am stealing that switch() mod to my zapping script. Nice.
    Sig by JakAtk
    My scripts: Prefref Plus | Skillref Plus | One-Click Wossna | Om*****st (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mercenary Mood | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | Drag-n-Drop Inventories | CanAdv | Script Registry | Map Manager
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

  9. #9
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

    Ooh Bale, I am stealing that switch() mod to my zapping script. Nice.
    Originally Posted by zarqon View Post
    Glad you liked it. When I looked at the HUGE if() command in your script I thought... that could be a lot prettier to look at. And of course I'm a huge fan of switch to the point that sometimes I over-use it.

    I've already thanked you for the basic work that I merely tinkered with.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  10. #10
    Senior Member matt.chugg's Avatar
    Join Date
    Nov 2006
    Posts
    630

    Default

    And of course I'm a huge fan of switch to the point that sometimes I over-use it.
    Originally Posted by Bale View Post
    Massive tangent, but I know what you mean, i'm actually a .net programmer as part of my job (the other part involves removing the shredded remains of a sheet of A4 after a printer jam), I often use the switch or the vb equivalent of select case for code with only 3 options, just because I prefer it a whole lot to elseif!, plus, it makes future expansion a whole lot easier!

    seriously, thats the best ever thread hijack i've ever pulled off! :P
    Last edited by matt.chugg; 06-03-2009 at 10:29 PM.

Similar Threads

  1. ZapWizard - Automatically zaps for mall profit
    By darkcodelagsniper in forum Item Handling Scripts
    Replies: 59
    Last Post: 10-01-2019, 08:09 PM
  2. Last known item number?
    By caphector in forum Scripting Discussion
    Replies: 5
    Last Post: 03-31-2015, 12:06 PM
  3. Replies: 1
    Last Post: 03-22-2015, 04:24 AM
  4. 15364: Fix a row number
    By RSS Bot in forum Latest SVN Changes
    Replies: 0
    Last Post: 02-07-2015, 03:50 AM
  5. Replies: 0
    Last Post: 09-06-2013, 07:40 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
  •