Yoko

All sides of Injection
It is currently 2025-11-23 17:01:00

All times are UTC+02:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: 2004-09-27 00:36:34 
Offline

Joined: 2004-06-23 20:56:02
Posts: 7
As a part of my work as a GM I created a bunch of subs which could be useful, not only for GM, use any and all as you wish.
PS: if I made a dupe function to any already implemented in YI, please, tell me :)

Code:
# Waiting and script pauses
;=================
sub setpause(b)  ;sets pause flag 0/1
uo.setglobal("pause",str(b))
end sub

sub getpause()   ;gets current pause status
return val(uo.getglobal("pause"))
end sub

sub hitpause()   ;switches pause status, suitable for hotkey (i.e. PAUSE :)
 setpause(getpause()==0)
end sub

sub pause(total) ;pauses script for 'total' time on until unpaused ;total <=0 means infinite waiting
var a=0,t=UO.timer()
setpause(1)
repeat
 wait(20)
 if (total>0) and ((UO.timer()-t)*10>total) then
  setpause(0)
  return
 end if
until getpause()==0
end sub

sub halt() ;emergency exit from any script
UO.Print("All scripts terminated.")
UO.deletejournal()
UO.moveon()
UO.Exec("terminate all");
end sub

sub lag_test(time) ;checks if server managed to answer all your previous requests and can wait some extra 'time'
var i=0
wait(time)
while UO.injournal(UO.getname("self"))
 UO.setjournalline(UO.injournal(UO.getname("self"))-1,"###")
wend
Uo.click("self")
repeat
 i=i+1
 wait(20)
 if i>250 then
  i=0
  Uo.click("self") ;restore if blocked somehow
  Uo.click("self")
 end if
until UO.injournal(UO.getname("self"))
end sub

# Misc container functions
;=================
sub lock_test() ;quick check for locked conatainer by message
var i=UO.injournal("This item is locked")
if i then
 while i
  UO.setjournalline(i-1,"###")
  i=UO.injournal("This item is locked")
 wend
 return 1
end if
return 0
end sub

sub box_test(item) ;quick check for container by message
while UO.injournal("items)")
UO.setjournalline(UO.injournal("items)")-1,"###")
wend
Uo.click(item)
lag_test(0)
if UO.injournal("items)") then
 return 1
end if
return 0
end sub

sub unlock()  ;unlocks container by TYPE=1
if UO.getglobal("lastunlocked") <> "0" then
 UO.print("Restoring previous lock")
 set(uo.getglobal("lastunlocked"),"type","2")
end if
if NOT lock_test() then
UO.print("Lastobject ain't locked!")
end if
set("lastobject","type","1")
Uo.useobject("lastobject")
UO.setglobal("lastunlocked",UO.getserial("lastobject"))
end sub

sub lock() ;locks container by TYPE=2
if UO.getglobal("lastunlocked") <> "0" then
set(UO.getglobal("lastunlocked"),"type","2")
end if
end sub

# String operations and formatting
;=================

sub Rtrim(n,text)  ;cuts off 'n' chars from the right side of 'text'
var i,ret=""
for i=0 to len(text)-n-1
ret=ret+text[i]
next
return ret
end sub

sub Ltrim(n,text) ;cuts off 'n' chars from the left side of 'text'
var i,ret=""
for i=n to len(text)-1
ret=ret+text[i]
next
return ret
end sub

sub REtrim(n,text) ;cuts or extends 'text' to 'n' charaters at the right side
var i=0,ret=""
while (i<len(text)) and (i<n)
ret=ret+text[i]
i=i+1
wend
while (i<n)
ret=ret+" "
i=i+1
wend
return ret
end sub

sub LEtrim(n,text) ;cuts or extends 'text' to 'n' charaters at the left side
var j=0,i=n-len(text),ret=""
if i>0 then
 for j=1 to i
  ret=ret+" "
 next
 ret=ret+text
else
 i=len(text)
 for j=1 to n
  ret=text[i-j]+ret
 next
endif
return ret
end sub

sub strinstr(what,where)  ;kind of strmatch returns position of occurence of 'what' in 'where'
var i=0,j=0,found=0,end=0
while i<len(where)-len(what) AND NOT found
j=0
end=0
while what[j]==where[i+j] and NOT end
if j==len(what)-1 then
found=i
end=1
else
if (j+1<len(what)) and (1+i+j<len(where)) then
j=j+1
else
end=1
end if
end if
wend
i=i+1
wend
return found
end sub

sub err(urg,msg) ;"colored&sounded" UO.print, urg sets mode of displaying message
; sounds are "stolen" from Teamspeak and color 0x3c1 is ment to be shadow-like default one
if urg==4 then
 UO.concolor(0x823)
 Uo.playwav("C:\Progra~1\Teamspeak2_RC2\sounds\49.error.wav")
 wait(500)
end if
if urg==3 then
 UO.concolor(0x823)
end if
if urg==2 then
 UO.concolor(0x825)
 Uo.playwav("C:\Progra~1\Teamspeak2_RC2\sounds\48.warning.wav")
 wait(500)
end if
if urg==1 then
 UO.concolor(0x825)
end if
if urg==0 then
 UO.concolor(0xbb5)
end if
UO.print(msg)
UO.concolor(0x3c1)
end sub

# Server commands
;=================

sub set(item,variable,value)  ;just .set
if UO.hex2int(UO.getserial(item)) then
var itm=ltrim(2,UO.getserial(item))
UO.serverprint(".uid.0"+itm+"."+variable+"="+value)
;UO.print("UID "+itm+" SET "+variable+"="+value)
end if
end sub

sub info(item,variable)  ;variable info via .xshow
var text="",ret="",i=0,j=0
while UO.injournal("Not a valid command or format")
 UO.setjournalline(UO.injournal("Not a valid command or format")-1,"###")
wend
while UO.injournal(" for ")
 UO.setjournalline(UO.injournal(" for ")-1,"###")
wend
repeat
 lag_test(0)
 UO.serverprint(".uid.0"+ltrim(2,UO.getserial(item))+".show "+variable)
 i=0
 repeat
  if UO.injournal("Not a valid command or format") then
   err(4,"Unrecoverable error in .info via .show ! HALTED")
   halt()
  end if
  i=i+1   
  wait(5)
 until (i > 500) or UO.injournal(" for ")
until UO.injournal(" for ")
text=UO.journal(UO.injournal(" for ")-1)
i=strinstr(" is ",text)
if i then
 for j=i+5 to len(text)-3
  ret=ret+text[j]
 next
else
 err(2,variable+" for UID:"+ltrim(2,UO.getserial(item))+" cannot be resolved! PAUSED")
 pause(-1)
 ret=info(item,variable)
end if
return ret
end sub


Applications are currently being purified, I use them in "it just works" messy state :)


Last edited by voyta on 2004-09-27 08:39:07, edited 2 times in total.

Top
   
 Post subject:
PostPosted: 2004-09-27 01:11:04 
Offline

Joined: 2004-06-23 20:56:02
Posts: 7
Code:
# Static building tools 
;===================

sub starttile()   ;select NW corner (your position)
UO.setglobal("x1",UO.getx())
UO.setglobal("y1",UO.gety())
end sub

sub endtile()   ;select SE corner (your position)
UO.setglobal("x2",UO.getx())
UO.setglobal("y2",UO.gety())
end sub

sub tiler() ; places selected tiles randomly over the rectangle
var z=0  ;desired height coordinate
var max=3  ;maximal used position in tiles field
var percent=110 ;probability of placing something/nothing

var i=0,j=0
dim tiles[11]
if 1 then ;1/0 to select
#first way is to put down all needed tilenumbers
tiles[0]="0x4a9" 
tiles[1]="0x4aa"
tiles[2]="0x4ab"
tiles[3]="0x4ac"
tiles[4]="0x4ac"
tiles[5]="0x51d"
else
#or just starting one and following are generated
for i=0 to max
tiles[i]=ltrim(2,UO.int2hex(0x515+i))
next
endif

UO.canceltarget()
for i=val(UO.getglobal("x1")) to val(UO.getglobal("x2")) ;thats why NW and SE, you can play with it
for j=val(UO.getglobal("y1")) to val(UO.getglobal("y2"))
if UO.random(100)<=percent then
UO.waittargettile("0",str(i),str(j),str(z-1))
UO.serverprint(".static "+tiles[UO.random(max)])
lag_test(100)
end if
next
next
err(0,Str((i+1-val(UO.getglobal("x1")))*(j+1-val(UO.getglobal("y1"))))+" tiles done")
end sub


sub tree() #tree placement , arrays can be edited to create your own forrest style :)
dim tree[10]
dim leaves[10]
var maxtree=8
var rand=0
#listnate
tree[0]=0x0ce6
tree[1]=0x0cd3
tree[2]=0x0cda
tree[3]=0x0ce0
tree[4]=0x0ce3
tree[5]=0x0cd0
tree[6]=0x0cd0
leaves[0]=0x0ce7
leaves[1]=0x0cd4
leaves[2]=0x0cdb
leaves[3]=0x0ce1
leaves[4]=0x0ce4
leaves[5]=0x0cd2
leaves[6]=0x0cd1
#jehlicnate
tree[7]=0x0cd8
leaves[7]=0x0cd9
#o-hii
tree[8]=0x0c9e
leaves[8]=0
     rand=UO.random(maxtree)
     UO.print(str(rand))
     UO.serverprint(".static "+Ltrim(2,UO.int2hex(tree[rand])))
     wait(10)
     Uo.serverprint(".self")
     wait(100)
     lag_test(0)
     if leaves[rand] then
      UO.serverprint(".static "+Ltrim(2,UO.int2hex(leaves[rand])))
      wait(10)
      Uo.serverprint(".self")
      wait(100)
     end if
end sub

sub debris() ;the same for debris (rocks, grass, etc.)
var rand=0
dim debris[20]
var maxdebris=19
#ostatni
debris[0]=0x0c84
debris[1]=0x0c85
debris[2]=0x0c89
debris[3]=0x0c97
debris[4]=0x0c9f
debris[5]=0x0ca0
debris[6]=0x0ca1
debris[7]=0x0ca3
debris[8]=0x0d40
debris[9]=0x0cc6
debris[10]=0x0cc4
debris[11]=0x1774
debris[12]=0x0cb7
debris[13]=0x0d11
debris[14]=0x0d40
debris[15]=0x1777
debris[16]=0x0cbd
debris[17]=0x0cc4
debris[18]=0x0cb9
debris[19]=0x0cca
     rand=UO.random(maxdebris)
     UO.serverprint(".static "+Ltrim(2,UO.int2hex(debris[rand])))
     wait(100)
     Uo.serverprint(".self")
     wait(100)
     lag_test(0)
end sub

sub forrest() ;and make it together , again in NW SE rectangle
var i=0,j=0,x=0,y=0,rand=0
var square=3 ;you work on sqared net
var chaos=1 ;how much can objects tilt from their "squared" pattern
var tree_probability=150, debris_probability=100, nothing_probability=100
;relative object probabilities (not necesarilly sum <=100 as you see)

i=val(UO.getglobal("x1"))
while i<=val(UO.getglobal("x2"))
 j=val(UO.getglobal("y1"))
 while j<=val(UO.getglobal("y2"))
   if UO.random(tree_probability+debris_probability+nothing_probability) > nothing_probability then
    x=i+UO.random(2*chaos)-chaos
    y=j+UO.random(2*chaos)-chaos
    UO.serverprint(".go "+str(x)+" "+str(y))
    wait(100)
    UO.serverprint(".fix")
    wait(100)
    UO.serverprint(".resync")
    lag_test(100)
    if UO.random(tree_probability+debris_probability) > debris_probability then
     tree()
    else
     debris()
    end if
   else
   wait(666)
   end if
 j=j+square
 wend
 i=i+square
wend
UO.print("FINITO!")
end sub


Top
   
 Post subject:
PostPosted: 2004-09-27 01:17:37 
Offline

Joined: 2004-06-23 20:56:02
Posts: 7
*** due to presence of Kelevar players on this forum this script is no longer availalble :) ***


Last edited by voyta on 2004-10-05 00:40:13, edited 1 time in total.

Top
   
 Post subject:
PostPosted: 2004-10-04 18:49:56 
Offline

Joined: 2004-10-04 18:17:20
Posts: 5
aaa našel jsem to :-)

vypada to neskutecne zajimave


aaa I found it :-)

it looks incredibly interesting

_________________
The Awakener [Slayer]


Top
   
 Post subject:
PostPosted: 2004-10-05 11:31:04 
Offline

Joined: 2004-10-04 18:17:20
Posts: 5
voyta wrote:
*** due to presence of Kelevar players on this forum this script is no longer availalble :) ***



don´t worry Voyta I´ve already downloaded the script, but I won´t use it......of course I am not using Injection on Kelevar shard, as you know it is strictly forbidden here

I just want to see it through and maybe learn some interesting features of your scripting abilities :)

_________________
The Awakener [Slayer]


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

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:  
Powered by phpBB® Forum Software © phpBB Limited