Author Topic: My first Script: Sampire Hunting Assistance  (Read 8026 times)

0 Members and 1 Guest are viewing this topic.

Offline krustenkrabbeTopic starter

  • Jr. Member
  • **
  • Posts: 16
  • Activity:
    0%
  • Reputation Power: 1
  • krustenkrabbe has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
My first Script: Sampire Hunting Assistance
« on: May 28, 2012, 11:25:02 AM »
0
So this is my first script, I wanted to get some assistance in hunting with my sampire.
I tried out Galeans Sampire Hunter, but it didn't work exactly as I wanted so I took his code to look for enemies, attack them and honor them and then built my own script around it.

I'll try to get it more customizable in the future, but so far it's working good for me.
The comments in the code pretty much explain everything, I hope you can use it=)

Code: [Select]
;***************************************************************************
;** Sampire Hunter Script                                                 **
;** Will do the following:                                                **
;** Search for any specified monsters in range, attacks and               **
;** honors them automatically. Uses Lightning Strike, Armor Ignore        **
;** and Consecrate Weapon during fights. The script will prefer           **
;** Armor Ignore over Lightning Strike. If the enemy is dead or           **
;** lost, will search for new enemies and repeat.                         **
;** This script will use Greater Strength, Agility and Heal potions       **
;** if desired and necessary. It will not Disarm for using potions, so    **
;** better fight with a one-handed weapon.                                **
;** Date: 28.05.2012                                                      **
;** Version 1                                                             **
;***************************************************************************

;User defined variables.
sub setup_variables
set %Consecrate_Weapon_Duration 8                                           ;Bufftime IN SECONDS for Consecrate Weapon
set %creature EJ_DD_DB_VGB_ED_NG_IG_ZF_DN_TC_CO                                   ;Set %creature to the type of creatures you wish to auto attack
set %combatrange 6                                                          ;Range in tiles to honor and attack enemies
set %duration_agility_pots 120                                              ;Duration for Agility Potion effect length IN SECONDS.
set %duration_strength_pots 120                                             ;Duration for Strength Potion effect length IN SECONDS.
set %duration_heal_pots 10                                                  ;Cooldown time between using Heal Potions IN SECONDS.
set %hitpoints_potion_heal 60                                               ;Hitpoints at which healing with potions will be used.
set %mana_ls 7                                                              ;Minimum mana for using Lightning Strike.
set %mana_ai 40                                                             ;Minimum mana for using Armor Ignore.
set %mana_cw 10                                                             ;Minimum mana for using Consecrate Weapon.
set %agility_type YUF                                                       ;Type of Greater Agility Potion.
set %strength_type XUF                                                      ;Type of Greater Strength Potion.
set %heal_type UUF                                                          ;Type of Greater Heal Potion.
set %wait_potions 15                                                        ;Delay for handling with the potion use code. (Wait time between setting potion as last object and drinking it)
set %wait_special_move 2                                                    ;Delay after executing special weapon moves (seems to be a lag issue).
set %delay_cw 20                                                            ;Delay after casting Consecrate Weapon.
;Note: Only uses potions in open containers (like bag in backpack).
;Note: One hand must be free to drink potions, script will not disarm or check for need to disarm.
return
;Checks if setup has been done already, will do if not.
if %setup_done <> 1
 {
  gosub setup
 }


;Checks for enemies in range. If an enemy is found it attacks, honors and goes to the attack sub which does the actual fighting.
for %range 1 %combatrange
 {
  finditem %creature G_ , %range
  if #findkind <> -1
   {
    set #ltargetid #findid
    set #ltargetkind 1
    set %enemy #findid
    wait 1
    event macro 49 1
    target 3s
    event macro 22
    event macro 27
    gosub attack
   }
 }
set %range 0 ;Resets range to search for enemies.

;This sub does the actual fighting.
sub attack
;Sets duration since last cast of CW spell.
set %dauer_cw #time - %casttime_cw
;Casts CW when time since last cast is greater than specified at the beginning in the
;variables.
if %dauer_cw > %Consecrate_Weapon_Duration
 {
  if #mana > %mana_cw
   {
    event macro 15 203
    set %casttime_cw #time
    wait %delay_cw
   }
 }
;Checks if Lightning Strike is active, will activate if necessary.
;Will switch to Armor Ignore if enough mana is available.
cmpPix 1 t
 {
  if #mana > %mana_ls
   {
    if #mana <= %mana_ai
     {
      EVENT MACRO 15 149
      %wait_special_move
     }
   }
 }
;Checks if Armor Ignore is active, will activate if necessary.
cmpPix 2 t
 {
  if #mana > %mana_ai
   {
    event macro 36 0
    %wait_special_move
   }
 }
;Checks for use of Greater Agility Potion.
;Will drink a potion if necessary.
if %use_agility_potions = 1
 {
  set %dauer_agility #time - %timer_agility
  if %dauer_agility > %duration_agility_pots
   {
    finditem %agility_type C
    if findkind <> -1
     {
      set %potion #findid
      set #lobjectid %potion
      wait %wait_potions
      event macro 17 0
      set %timer_agility #time
     }
   }
 }
;Checks for use of Greater Strength Potion.
;Will drink a potion if necessary.
if %use_strength_potions = 1
 {
  set %dauer_strength #time - %timer_strength
  if %dauer_strength > %duration_strength_pots
   {
    finditem %strength_type C
     if findkind <> -1
      {
       set %potion #findid
       set #lobjectid %potion
       wait %wait_potions
       event macro 17 0
       set %timer_strength #time
      }
    }
  }
;Checks for use of Greater Heal Potion.
;Will drink a potion if necessary.
if %use_heal_potions = 1
 {
  if #hits < %hitpoints_potion_heal
   {
    set %dauer_heal #time - %timer_heal
    if %dauer_heal > %duration_heal_pots
     {
      finditem %heal_type C
      if findkind <> -1
       {
        set %potion #findid
        set #lobjectid %potion
        wait %wait_potions
        event macro 17 0
        set %timer_heal #time
       }
     }
   }
 }
;Checks if enemy is still alive. If yes, continues attacking.
;If not, script will end attack sub and look for other enemies.
finditem %enemy G_
if #findkind = 1
 {
  gosub attack
 }
return
;This sub sets the script up, asking the user to specify the features.
sub setup
    ;Calls the setup_variables sub to get the user defined variables.
    gosub setup_variables
    ;Code to setup the pixel coordinates for the Lightning Strike and Armor Ignore buttons.
    ;Saves the Pixel as number 1 for LS and number 2 for AI. Abilities must be NOT ACTIVE:
    display Move the mouse to the Lightning Strike button. LS must be inactive. You have 3 seconds
    wait 3s
    savePix #CURSORX #CURSORY 1
    display Move the mouse to the Armor Ignore button. AI must be inactive. You have 3 seconds
    wait 3s
    savePix #CURSORX #CURSORY 2
    ;Sets the timer for Consecrate Weapon for startup.
    set %casttime_cw #time - %Consecrate_Weapon_Duration
    ;Asks if Greater Agility Potions will be used.
    display yesno Do you want to use Greater Agility Potions?
    if #dispres = yes
    {
    set %use_agility_potions 1
    set %timer_agility #time - %duration_agility_pots
    }
    ;Asks if Greater Strength Potions will be used.
    display yesno Do you want to use Greater Strength Potions?
    if #dispres = yes
    {
    set %use_strength_potions 1
    set %timer_strength #time - %duration_strength_pots
    }
    ;Asks if Greater Heal Potions will be used.
    display yesno Do you want to use Greater Heal Potions?
    if #dispres = yes
    {
    set %use_heal_potions 1
    set %timer_heal #time - %duration_heal_pots
    }
    ;Sets a variable to not run setup again.
    set %setup_done 1
return
« Last Edit: May 28, 2012, 11:27:52 AM by krustenkrabbe »

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: My first Script: Sampire Hunting Assistance
« Reply #1 on: August 01, 2012, 01:46:57 PM »
0
thank you for your script submission.
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Mad Tamer

  • Jr. Member
  • **
  • Posts: 60
  • Activity:
    0%
  • Reputation Power: 2
  • Mad Tamer has no influence.
  • Gender: Male
  • Respect: +5
  • Referrals: 0
    • View Profile
Re: My first Script: Sampire Hunting Assistance
« Reply #2 on: August 01, 2012, 08:02:28 PM »
0
me n my buddy are gonna try it out this weekend :) Thank you!

Offline D

  • Full Member
  • ***
  • Posts: 175
  • Activity:
    0%
  • Reputation Power: 2
  • D has no influence.
  • Respect: +24
  • Referrals: 1
    • View Profile
Re: My first Script: Sampire Hunting Assistance
« Reply #3 on: August 02, 2012, 01:05:15 AM »
0
im looking forward to trying this, ill let you know how i get on, its nice to have a script that honors enemy too

Tags: