Yoko

All sides of Injection
It is currently 2026-01-18 15:24:52

All times are UTC+02:00




Post new topic  Reply to topic  [ 1 post ] 
Author Message
 Post subject: RunUO magery trainer
PostPosted: 2005-01-25 22:29:40 
Offline

Joined: 2004-09-07 22:36:09
Posts: 22
Location: Poland
Its a pack of few subs.

This one just changes string type spell name to number.

Btw. Feel free to comment it. If I seem to dont know about sth, just tell me :P Im not posting it for ppl who cant script for theirselfs. I post for ppl who can script, so then I hope my scripts will help them, and theyll help me. :)

Code:
#
# (c) ziemniaq - ziemni@risp.pl
#
sub get_spell_id(spell_name)
  dim names[64]
  var i
 
  names[ 1] = "Clumsy"
  names[ 2] = "Create Food"
  names[ 3] = "Feeblemind"
  names[ 4] = "Heal"
  names[ 5] = "Magic Arrow"
  names[ 6] = "Night Sight"
  names[ 7] = "Reactive Armor"
  names[ 8] = "Weaken"
  names[ 9] = "Agility"
  names[10] = "Cunning"
  names[11] = "Cure"
  names[12] = "Harm"
  names[13] = "Magic Trap"
  names[14] = "Magic Untrap"
  names[15] = "Protection"
  names[16] = "Strength"
  names[17] = "Bless"
  names[18] = "Fireball"
  names[19] = "Magic Lock"
  names[20] = "Poison"
  names[21] = "Telekinesis"
  names[22] = "Teleport"
  names[23] = "Unlock"
  names[24] = "Wall of Stone"
  names[25] = "Arch Cure"
  names[26] = "Arch Protection"
  names[27] = "Curse"
  names[28] = "Fire Field"
  names[29] = "Greater Heal"
  names[30] = "Lightning"
  names[31] = "Mana Drain"
  names[32] = "Recall"
  names[33] = "Blade Spirits"
  names[34] = "Dispel Field"
  names[35] = "Incognito"
  names[36] = "Magic Reflection"
  names[37] = "Mind Blast"
  names[38] = "Paralyze"
  names[39] = "Poison Field"
  names[40] = "Summ. Creature"
  names[41] = "Dispel"
  names[42] = "Energy Bolt"
  names[43] = "Explosion"
  names[44] = "Invisibility"
  names[45] = "Mark"
  names[46] = "Mass Curse"
  names[47] = "Paralize Field"
  names[48] = "Reveal"
  names[49] = "Chain Lightning"
  names[50] = "Energy Field"
  names[51] = "Flame Strike"
  names[52] = "Gate Travel"
  names[53] = "Mana Vampire"
  names[54] = "Mass Dispel"
  names[55] = "Meteor Swarm"
  names[56] = "Polymorph"
  names[57] = "Earthquake"
  names[58] = "Energy Vortex"
  names[59] = "Ressurection"
  names[60] = "Air Elemental"
  names[61] = "Summon Daemon"
  names[62] = "Earth Elemental"
  names[63] = "Fire Elemental"
  names[64] = "Water Elemental"

 
  for i = 1 to 64
    if spell_name == names[i] then
      return i
    endif
  next

end sub



That sub stocks ur char, there are 4 arguments here:
- objtype of item to stock
- when to stock, quanity (if count of items in pack gets lower then this script stocks)
- how much items u want to have in ur pack after stock
- where from container

This fucks sometimes for me instead of grabing given amount of items, grabs whole stack. Dunno why, Ill test it someday maybe.

Code:
#
# (c) ziemniaq - ziemni@risp.pl
#
sub uzupelnij(objtype, min_qty, do_ilu, container)
var i
var action_delay = 650
var old_qty
var grab_qty
while UO.Count(objtype) < min_qty
  UO.UseObject(container)
  while STR(container) <> STR(UO.GetSerial('lastcontainer'))
   
    i = 0
    while i < 3500 AND NOT STR(container) == STR(UO.GetSerial('lastcontainer'))
      i = i + 100
      wait(100)
    wend
   if STR(container) <> STR(UO.GetSerial('lastcontainer')) then
      UO.UseObject(container)
   endif
  wend

  wait(action_delay)
 
   old_qty = UO.Count(objtype)
  UO.FindType(objtype,"-1",container)
    if UO.FindCount() > 0 then
    grab_qty = do_ilu - old_qty
#      UO.MoveItem('finditem', grab_qty, 'backpack')
#UO.Grab(do_ilu - old_qty,'finditem')
    UO.Exec("grab " + STR(grab_qty) + " finditem" )
      i = 0
      while i < 1500 AND NOT UO.Count(objtype) == old_qty
        i = i + 100
        wait(100)
      wend
      wait(action_delay)
    endif
    UO.Print("po wszystkim")
wend
end sub


This function is tweaky.. Its called check_regs, but it also gives u mana usage of spell. Otherwise itll return true if there are enough regs. It can also stock regs, just put serial of secure container as ssecond argument.

Btw. Can i use multidimensional arrays in injection scripts?

3 args:
spell_name - self explaining
reg_bag - if you want
zwrocmane - if its set to true, sub will return mana need for spell.

Code:
#
# (c) ziemniaq - ziemni@risp.pl
#
sub check_regs(spell_name,reg_bag,zwrocmane)
  dim id[64], mana[64], reg_bm[64], reg_bp[64], reg_ga[64], reg_gs[64], reg_mr[64], reg_ns[64], reg_sa[64], reg_ss[64]
 
  var graph_ss = 0x0F8D
  var graph_sa = 0x0F8C
  var graph_gs = 0x0F85
  var graph_ga = 0x0F84
  var graph_ns = 0x0F88
  var graph_bp = 0x0F7A
  var graph_bm = 0x0F7B
  var graph_mr = 0x0F86

  var flag = 1
 
  var i
  var f = file("spells.cfg")
  if NOT f.open() then
     return FALSE
  endif
 
  for i = 1 to 64
   id[i] = f.ReadNumber()
   mana[i] =  f.ReadNumber()
   reg_bm[i] = f.ReadNumber()
   reg_bp[i] = f.ReadNumber()
   reg_ga[i] = f.ReadNumber()
   reg_gs[i] = f.ReadNumber()
   reg_mr[i] = f.ReadNumber()
   reg_ns[i] = f.ReadNumber()
   reg_sa[i] = f.ReadNumber()
   reg_ss[i] = f.ReadNumber()
  next

  f.close()
  var spell_id = get_spell_id(spell_name)
 # UO.Print(STR(spell_id) +  spell_name)
  if zwrocmane then

    return (mana[spell_id])
  endif

  if reg_bm[spell_id] then
    if NOT UO.Count(graph_bm) then
      flag = 0
      if reg_bag then
        uzupelnij(graph_bm,50,50,reg_bag)
      endif
    endif
  endif
 
  if reg_bp[spell_id] then
    if NOT UO.Count(graph_bp) then
      flag = 0
      if reg_bag then
        uzupelnij(graph_bp,50,50,reg_bag)
      endif
    endif
  endif
 
  if reg_ga[spell_id] then
    if NOT UO.Count(graph_ga) then
      flag = 0
      if reg_bag then
        uzupelnij(graph_ga,50,50,reg_bag)
      endif
    endif
  endif
 
  if reg_gs[spell_id] then
    if NOT UO.Count(graph_gs) then
      flag = 0
      if reg_bag then
        uzupelnij(graph_gs,50,50,reg_bag)
      endif
    endif
  endif
 
  if reg_mr[spell_id] then
    if NOT UO.Count(graph_mr) then
      flag = 0
      if reg_bag then
        uzupelnij(graph_mr,50,50,reg_bag)
      endif
    endif
  endif
 
  if reg_ns[spell_id] then
    if NOT UO.Count(graph_ns) then
      flag = 0
      if reg_bag then
        uzupelnij(graph_ns,50,50,reg_bag)
      endif
    endif
  endif

  if reg_sa[spell_id] then
    if NOT UO.Count(graph_sa) then
      flag = 0
      if reg_bag then
        uzupelnij(graph_sa,50,50,reg_bag)
      endif
    endif
  endif

  if reg_ss[spell_id] then
    if NOT UO.Count(graph_ss) then
      flag = 0
      if reg_bag then
        uzupelnij(graph_ss,50,50,reg_bag)
      endif
    endif
  endif

 return flag
end sub


This sub tells script what to cast on diffrent magery levels, its quite self explaining on how to modify :P

Next question : is there switch( ) in Injection script language?

Code:
#
# (c) ziemniaq - ziemni@risp.pl
#
sub get_spell()
 var spell_name
 var mag = UO.SkillVal("Magery")
  spell_name = "Fireball"
  if mag > 400 then
    spell_name = "Lightning"
    if mag > 550 then
      spell_name = "Mind Blast"
      if mag > 600 then
        spell_name = "Energy Bolt"
        if mag > 720 then
          spell_name = "Mana Vampire"
        endif
      endif
    endif
  endif
  return spell_name
end sub


Finally the main script:

You have to modify reg_bag variable to change container with regs. Or write get_reg_container sub sth like that. I was too lazy for it, since all my chars're macroing their magery from one bag :P

Code:

sub mag_dfi()
#
# (c) ziemniaq - ziemni@risp.pl
#
var reg_bag = "0x11111111"
var spell

while TRUE
  spell = get_spell()
  while UO.Life > 40 AND UO.Mana > check_regs(spell,0,1) AND check_regs(spell,reg_bag,0)
    UO.Exec("waittargetself")
    UO.Cast(spell)
    wait(4000)
  wend
  while UO.Life < 40 AND UO.Mana > check_regs("Greater Heal",0,1) AND check_regs("Greater Heal",reg_bag,0)
    UO.Exec("waittargetself")
    UO.Cast("Greater Heal")
    wait(2500)
  wend
  if UO.Mana <  check_regs(spell,0,1) then
    UO.UseSkill("Meditation")
    while UO.Mana < UO.Int
      wait(100)
    wend
  endif
wend


Ha.. its not end. Noticed those file operations? Ive put spell reg and mana usage in config file. It's called spells.cfg by default.

First column - spell_id
2nd - mana usage
next 8 ones.. to use reg or not, 8 columes - 8 reg types, in the same order, as they're on title bar (turn on reg counter in Display tab if u cant remember :P)

So here is it:
Code:
 1  4 1 0 0 0 0 1 0 0
 2  4 0 0 1 1 1 0 0 0
 3  4 0 0 0 1 0 1 0 0
 4  4 0 0 1 1 0 0 0 1
 5  4 0 0 0 0 0 0 1 0
 6  4 0 0 0 0 0 0 1 1
 7  4 0 0 1 0 0 0 1 1
 8  4 0 0 1 0 0 1 0 0
 9  6 1 0 0 0 1 0 0 0
10  6 0 0 0 0 1 1 0 0
11  6 0 0 1 1 0 0 0 0
12  6 0 0 0 0 0 1 0 1
13  6 0 0 1 0 0 0 1 1
14  6 1 0 0 0 0 0 1 0
15  6 0 0 1 1 0 0 1 0
16  6 0 0 0 0 1 1 0 0
17  9 0 0 1 0 1 0 0 0
18  9 0 1 0 0 0 0 0 0
19  9 1 0 1 0 0 0 1 0
20  9 0 0 0 0 0 1 0 0
21  9 1 0 0 0 1 0 0 0
22  9 1 0 0 0 1 0 0 0
23  9 1 0 0 0 0 0 1 0
24  9 1 0 1 0 0 0 0 0
25 11 0 0 1 1 1 0 0 0
26 11 0 0 1 1 1 0 1 0
27 11 0 0 1 0 0 1 1 0
28 11 0 1 0 0 0 0 1 1
29 11 0 0 1 1 1 0 0 1
30 11 0 0 0 0 1 0 1 0
31 11 0 1 0 0 1 0 0 1
32 11 1 1 0 0 1 0 0 0
33 14 0 1 0 0 1 1 0 0
34 14 0 1 1 0 0 0 1 1
35 14 1 0 1 0 0 1 0 0
36 14 0 0 1 0 1 0 0 1
37 14 0 1 0 0 1 1 1 0
38 14 0 0 1 0 1 0 0 1
39 14 0 1 0 0 0 1 0 1
40 14 1 0 0 0 1 0 0 1
41 20 0 0 1 0 1 0 1 0
42 20 0 1 0 0 0 1 0 0
43 20 1 0 0 0 1 0 0 0
44 20 1 0 0 0 0 1 0 0
45 20 1 1 0 0 1 0 0 0
46 20 0 0 1 0 1 1 1 0
47 20 0 1 0 1 0 0 0 1
48 20 1 0 0 0 0 0 1 0
49 40 1 1 0 0 1 0 1 0
50 40 0 1 0 0 1 0 1 1
51 40 0 0 0 0 0 0 1 1
52 40 0 1 0 0 1 0 1 0
53 40 1 1 0 0 1 0 0 1
54 40 0 1 1 0 1 0 1 0
55 40 1 0 0 0 1 0 1 1
56 40 1 0 0 0 1 0 0 1
57 50 1 0 0 1 1 0 1 0
58 50 1 1 0 0 1 1 0 0
59 50 1 0 1 1 0 0 0 0
60 50 1 0 0 0 1 0 0 1
61 50 1 0 0 0 1 0 1 1
62 50 1 0 0 0 1 0 0 1
63 50 1 0 0 0 1 0 1 1
64 50 1 0 0 0 1 0 0 1


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1 post ] 

All times are UTC+02:00


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited