kolpastebin

Cast AT Song.ash

Jan 15th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. //Example code to cast AT songs while removing a buff.
  2. //May need improvement?
  3. //This source code is in the public domain.
  4.  
  5. skill [int] activeATSongs()
  6. {
  7. skill [int] active_songs;
  8. foreach s in $skills[]
  9. {
  10. if (s.class == $class[accordion thief] && s.buff == true && s.to_effect().have_effect() > 0) //FIXME is this test always correct?
  11. {
  12. active_songs[active_songs.count()] = s;
  13. }
  14. }
  15. return active_songs;
  16. }
  17.  
  18. void castATSong(skill at_song_to_cast, int turns_wanted)
  19. {
  20. if (at_song_to_cast.to_effect().have_effect() >= turns_wanted)
  21. return;
  22. //FIXME buy a toy accordion if we don't have a usable accordion?
  23.  
  24. if (at_song_to_cast.to_effect().have_effect() == 0)
  25. {
  26. int at_song_limit = 3;
  27. if ($item[plexiglass pendant].equipped_amount() > 0 || $item[Brimstone Beret].equipped_amount() > 0 || $item[super-sweet boom box].equipped_amount() > 0 || $item[Scandalously Skimpy Bikini].equipped_amount() > 0 || $item[Sombrero De Vida].equipped_amount() > 0 || (my_class() == $class[accordion thief] && $item[Operation Patriot Shield].equipped_amount() > 0))
  28. at_song_limit += 1;
  29. if (my_class() == $class[accordion thief] && $item[La Hebilla del Cinturón de Lopez].equipped_amount() > 0)
  30. at_song_limit += 1;
  31. if (my_class() == $class[accordion thief] && $item[zombie accordion].equipped_amount() > 0)
  32. at_song_limit += 1;
  33. if ($skill[mariachi memory].have_skill())
  34. at_song_limit += 1;
  35.  
  36. skill [int] active_songs = activeATSongs();
  37. int breakout = 100;
  38. while (active_songs.count() + 1 > at_song_limit && breakout > 0)
  39. {
  40. breakout -= 1;
  41. //Remove the song that costs the least MP to replace:
  42. skill song_to_remove = $skill[none];
  43. foreach key, song in active_songs
  44. {
  45. if (song_to_remove == $skill[none] || song_to_remove.mp_cost() * song_to_remove.to_effect().have_effect() > song.mp_cost() * song.to_effect().have_effect())
  46. song_to_remove = song;
  47. }
  48. if (song_to_remove == $skill[none])
  49. break;
  50. cli_execute("uneffect " + song_to_remove.to_effect());
  51. active_songs = activeATSongs(); //there are certain situations where your active song count can go higher than you can currently cast, so double-check
  52. }
  53. }
  54. if (at_song_to_cast.turns_per_cast() == 0)
  55. return;
  56. int breakout = 100;
  57. int casts = ceil((turns_wanted - at_song_to_cast.to_effect().have_effect()).to_float() / at_song_to_cast.turns_per_cast().to_float());
  58. if (casts > 0)
  59. use_skill(casts, at_song_to_cast);
  60. }
  61.  
  62. void main()
  63. {
  64. castATSong($skill[the ode to booze], 20);
  65. }
Advertisement
Add Comment
Please, Sign In to add comment