How to Lock EnemyID in my script?

Ask for help

Moderators: Murderator+, Murderator

Post Reply
roro4ever
Posts: 8
Joined: 2009-10-16 16:57:23

How to Lock EnemyID in my script?

Post by roro4ever »

We know,use inj's 'laststatus',first spell a lighting on enemy,then use healself,'laststatus' will equal 'self',the next lighting will point self.

So I wanna make a script who can lock EnemyID by 'laststatus'.
But i am confused with Inj Script's var scope.
Below is a piece of my script

Code: Select all

var EnemyID
var EnmMode=1
var Locked

sub LockEnemy()
      Locked=0
      if uo.GetSerial('self')==uo.Getserial('laststatus') then
         uo.print("NO to self")
         return
      endif
      EnemyID=uo.Getserial('laststatus'))
      uo.print("EnemyID Stored!")
      Locked=1
end sub

Sub JPara()
    Var Type='0x1F52'
    Var Color='0x0000'
    if uo.GetSerial('self')==uo.GetSerial('laststatus') then
       uo.print("Dont Point to Self!")       
       return
    endif
    if EnmMode==1 then
       if Locked==1 then
          UO.Set('lasttarget',EnemyID)
       else
          uo.print("Lock Enemy first!")
       endif
    else
       UO.Set('lasttarget','laststatus')
    endif
    UO.FindType(Type,Color,2)
    if uo.findcount()>0 then
       uo.WaitTargetLast()
       UO.UseObject('finditem')     
    else   
       UO.print("No Paralyze Scroll!")
    endif
Endsub

But the "Locked" and "EnemyID" all are temporary var in 1st sub.
How to modify this script to make it work?
Thx a lot.

I already tryed uo.Getglobal() and uo.SetGlobal(),but it's text,especially for uo.Getserial('laststatus'),we need a Hex value,not just string.

So,Please help me!
roro4ever
Posts: 8
Joined: 2009-10-16 16:57:23

Post by roro4ever »

Maybe I have solved ! Haha!

Code: Select all

var LockMode=1
sub LockEnemy()
    uo.SetGlobal('Locked',"0")
    if uo.GetSerial('self')==uo.Getserial('laststatus') then
       uo.print("NO to self")
       return
    endif
    uo.setglobal('EnemyID',uo.Getserial('laststatus'))
    ;uo.print(uo.getglobal('EnemyID'))
    uo.print("EnemyID Stored!")
    uo.setglobal('Locked',"1")
end sub

sub GetTarget()
    if uo.GetSerial('self')==uo.GetSerial('laststatus') then
       uo.print("Dont Point to Self!")       
       return 0
    endif
    if LockMode==1 then
       if val(uo.GetGlobal('Locked'))==1 then
          UO.Set('lasttarget',uo.getglobal('EnemyID'))
     return 1
       else
          uo.print("Lock Enemy first!")
     return 0
       endif
    else
       UO.Set('lasttarget','laststatus')
       return 1
    endif   
endsub

Sub JPara()
    Var Type='0x1F52'
    Var Color='0x0000'
    if GetTarget()==0 then
       return
    endif
    UO.FindType(Type,Color,2)
    if uo.findcount()>0 then
       uo.WaitTargetObject('lasttarget')
       ;uo.WaitTargetLast()
       UO.UseObject('finditem')     
    else   
       UO.print("No Paralyze Scroll!")
       Para()
    endif
Endsub

Anybody has better solution?
AddObject()?
Post Reply