Author Topic: Newb, First Script  (Read 9123 times)

0 Members and 1 Guest are viewing this topic.

Offline jwardlaw09Topic starter

  • Jr. Member
  • **
  • Posts: 13
  • Activity:
    0%
  • Reputation Power: 0
  • jwardlaw09 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Newb, First Script
« on: March 12, 2010, 03:02:43 AM »
0
Bear with me guys I have VERY little programming experience but understand logic. This really sparks my creativity because its something i love (computer science) with something i love more (UO) So im learning but, Glad to be here.very newbish though. Hope i dont make you guys mad, I figure to start i will write a simple script that opens new corpses takes the gold and puts it in my pack. sounded easy... But for some reason i feel like I have writers block, I have idea where to begin. I have done quite bit of reading and I think that it should look like this...

Command to open new corpses within 2 tiles
FindID = Whatever gold may be and a drag command
move cursor to coordinates of my bag on paperdoll and drop

LOL so sorry I really am not sure of the right syntax for anything. I just dont know if I am on the right path or if something has gone horribly wrong.. hehe

So, If i have the concept but need the language now what? how would i go about finding the ItemID of things, only way i thought of was to start runuo and use the [props command ingame. There must be a better way to identify itemID's.

How would i get the script to open new corpses... I have a warrior and plan on standing in one spot so range wont be a problem everything tends to die at my feet hehe... but i have no idea how i would get the script to open these corpses....

Other than that if this is way more complicated than that or if i should do even more studying before making a newbish post let me know :(  Thanks for all your help!!!

Offline Petkiller

  • Full Member
  • ***
  • Posts: 112
  • Activity:
    0%
  • Reputation Power: 0
  • Petkiller has no influence.
  • Respect: +7
  • Referrals: 2
    • View Profile
Re: Newb, First Script
« Reply #1 on: March 12, 2010, 04:14:48 AM »
0
When I first started out I would try to find a script that was already posted somewhere that would do what I was trying to do.  I then looked up every command in the easy uo docs and tried to figure out what a script was doing line by line.  Here are some pieces of a farming script I made a last year.  This sub worked but it was far from perfect but it was one of the simplest looting subs I could find.  I tried to add comments so you could understand what this sub is doing.

set %corpseid YFM_FEX_QEX ;I found these IDs posted somewhere a while back

sub loot
finditem %corpseid G_2  ;look on ground for a corpse within 2 tiles
if #findid = X
      return
set %corpse #findid
set #lobjectid %corpse
event macro 17 0;(open the corpse)
wait 20
set %corpseContID #contid
finditem POF C_ , %corpseContID  ;find gold on the corpse
set %gold #findid
     wait 10
     exevent drag %gold #findstack ;grab all the gold if #findstack is not there it will grab 1 coin
     wait 10
     exevent dropc #backpackid     ;drop gold in your backpack
ignoreitem %corpseCondID           ;
ignoreitem %corpse                     ;these will make sure you are not looting same corpse over and over
return




Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: Newb, First Script
« Reply #2 on: March 12, 2010, 04:16:03 AM »
0
First, you want a tool that will help you determine the Types Of things. *Posted Below*

Now, In order to find the ID For things you have to do a finditem and use the Findtype for what you are looking for.

I'd suggest going to Easyuo.com and looking at the Documentation on how to use Finditem Command.

Code: [Select]
; ============================
; Name: Tecmo's Find Item Info (noob helper)
; Author: Tecmo
; Version: 1.02   a
; Tested with: (should work with any version)
; Revision Date: Feb. 21, 2006
; Public Release: September 6, 2003
; Purpse: Assist users in finding item info for EUO.
; ============================

LOOP:
DISPLAY OK Target the item you wish to obtain info from.
SET #TARGCURS 1
WHILE #TARGCURS = 1
      WAIT 5

FINDITEM #LTARGETID
DISPLAY OK ID : #LTARGETID $$
         +Type : #FINDTYPE $$
         +Rep : #Findrep $$
         +COl : #Findcol $$
PAUSE
GOTO LOOP
; ============================
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline jwardlaw09Topic starter

  • Jr. Member
  • **
  • Posts: 13
  • Activity:
    0%
  • Reputation Power: 0
  • jwardlaw09 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Newb, First Script
« Reply #3 on: March 12, 2010, 04:22:56 AM »
0
Awesome!! I was looking for something similiar but every looter seemed to be extremely overcomplicated for my use or comprehension. I did read up on some docs and found a way to get ID's for everything. You certainly have put me on the right path, i will fiddle around and keep you posted THanks!

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Newb, First Script
« Reply #4 on: March 12, 2010, 04:53:22 AM »
0
jward

Glad to see you jumping in :)

I always tell people to start by transcribing some of their UO/UOA/Razor macros to EUO. For example, I have a macro that simply uses an instrument, uses the peace skill, targets myself, waits, and loops. That particular loop is simple enough to do in EUO that it isn't overwhelming but there are a few basics that get covered that are indespensible to most any other script you will write:

1) Itemtype and ItemID (ID is unique)
2) Finditem
3) Event
4) Target
5) Some type of loop (repeat/while/etc)

Basic but VERY powerful stuff. Use some of the documentation at the EUO Wiki or just use SUO and select a command, right-mouse and select Help.

Good luck and have fun with it! It starts with a peace training loop and next thing you know you won't have to play the game anymore, you'll have your scripts do it for you! ;)

X
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline jwardlaw09Topic starter

  • Jr. Member
  • **
  • Posts: 13
  • Activity:
    0%
  • Reputation Power: 0
  • jwardlaw09 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Newb, First Script
« Reply #5 on: March 12, 2010, 08:06:22 AM »
0
thank you very much for the words of wisdom, I used to use razor all the time, i made my own little macros but eventually built several that i was impressed with. I had a mining macro that would mine an entire cave and leave all the ore on the ground so i could just come pick it up... or a magery macro that would cast spells on myself while running an if loop to check my health and cast g-heal if needed. it also meditated if mana got too low. small pickles for you guys but I was so damned proud. lol.
The day came when my ideas for macros became limited by what razor could do. (or what i could do with razor). then POW i find you guys, and all those ideas i had just became possible. Unfortunately its a litttttle more complicated than razor, Which is also why I am enjoying this so much. I love a great challenge.

Back to my problem at hand.... Im trying to understand the looter that was so kindly posted by petkiller

I understand bits and peices but im going to start at the top and work my way down.

set %corpseid YFM_FEX_QEX

is %corpseid acting as a variable that we are defining? I checked the ID of an ettin corpse and it was YFM.  so I understand why the YFM but whats the FEX and OEX for? maybe different types of monsters have different corpse codes? Sorry if this doesnt make too much sense.

Thanks for everything guys...

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: Newb, First Script
« Reply #6 on: March 12, 2010, 08:20:09 AM »
0
Nothing in EUO is ever as simple as you would like it to be, Its full of weird glitches and actions that often defy logic...

But in this case basically its what you said this script believes their are 3 different corpse types. 
YFM is by far the most frequently used corpse type.

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 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Newb, First Script
« Reply #7 on: March 12, 2010, 08:22:03 AM »
0
set %corpseid YFM_FEX_QEX

is %corpseid acting as a variable that we are defining? I checked the ID of an ettin corpse and it was YFM.  so I understand why the YFM but whats the FEX and OEX for? maybe different types of monsters have different corpse codes? Sorry if this doesnt make too much sense.
You got it, %corpseid is a var and the YFM_FEX_QEX are all potential corpse types. Your ettin corpse may have been YFM but some other corpse, maybe a goat maybe a different ettin, might be FEX or QEX. You put all of these options in a variable with some kind of a seperator, traditionally people use the underscore "_" but I've seen other's such as "|".

X
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline jwardlaw09Topic starter

  • Jr. Member
  • **
  • Posts: 13
  • Activity:
    0%
  • Reputation Power: 0
  • jwardlaw09 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Newb, First Script
« Reply #8 on: March 12, 2010, 08:39:11 AM »
0
mwahahaha you have made me so happy, at least im getting somewhere.... that command alone could prove useful in many situations...... anyways moving onward....

sub loot
finditem %corpseid G_2  ;look on ground for a corpse within 2 tiles

this here starts the sub called loot?
 then it says keep an eye out for any YFM corpses within 2 tiles

if #findid = X
      return

If you cant find any corpses within the 2 tiles then return. (return to where? is it the top of script by default?)

set %corpse #findid
set #lobjectid %corpse
event macro 17 0;

ok starting to get a little lost. i dont even know what to ask... crap... brick wall.....

Anyways sorry if im getting tooo basic for you guys. just wanna make sure i have a concrete understanding of things and THANK YOU. you guy are so descriptive and helpful.

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Newb, First Script
« Reply #9 on: March 12, 2010, 08:57:08 AM »
0
sub loot
finditem %corpseid G_2  ;look on ground for a corpse within 2 tiles

this here starts the sub called loot?
 then it says keep an eye out for any YFM corpses within 2 tiles
Yep, and a sub runs when called using "gosub subname" in this case, "gosub loot"

Quote from: jwardlaw09
if #findid = X
      return

If you cant find any corpses within the 2 tiles then return. (return to where? is it the top of script by default?)
Returns to the line where the sub was called, if the gosub is on line 10 then the next line to run after returning is line 11.

Quote from: jwardlaw09
set %corpse #findid
set #lobjectid %corpse
event macro 17 0;

ok starting to get a little lost. i dont even know what to ask... crap... brick wall.....
That section says "ok, I found a corpse so I'll get it's ID, set it as "Last Object", then Use Last Object (event macro 17). In other words, that section opens the corpse.

Go to the EUO documentation and read a little about "finditem" and "event macro" for some good info.

X
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline jwardlaw09Topic starter

  • Jr. Member
  • **
  • Posts: 13
  • Activity:
    0%
  • Reputation Power: 0
  • jwardlaw09 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Newb, First Script
« Reply #10 on: March 12, 2010, 09:08:38 AM »
0
*bows down* lol ill be back in an hour or so with either more questions or the next chunk of code  ;D

thanks guys!

--- hours later

lol i fell asleep at the keyboard  >:(. good news is i can understand a majority of that little code. Thnx for all the references to wiki and euo docs. I looked over those pages before speaking with you guys and i just couldn't completely comprehend it all on my own. annyyyyways I will be trying to add a weight check and transfer gold to beetle ability. i know its been done many times but its never as glorifying as when you do it yourself. Thanks for all your help everyone. Ill keep you posted....
« Last Edit: March 12, 2010, 03:09:46 PM by jwardlaw09 »

Scrripty

  • Guest
Re: Newb, First Script
« Reply #11 on: March 14, 2010, 09:34:36 PM »
0
We all have spent lots of time staring blankly at code.  You'll get it.  Sometimes it comes in little spurts of divine inspiration.  I have tons of code I wrote that I don't think I understand anymore. :)  It happens to use all.  I promise if you stare at it long enough, it will eventually come to you. 

Offline jwardlaw09Topic starter

  • Jr. Member
  • **
  • Posts: 13
  • Activity:
    0%
  • Reputation Power: 0
  • jwardlaw09 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: Newb, First Script
« Reply #12 on: March 15, 2010, 12:28:49 PM »
0
yeah, thanks guys for all your help. Now that my ball is rolling, everything is so much easier to understand. I'm still dabbling with very simple scripts though. Twinkle McNugget, thank you for pointing out the timer issue, I think it might still be messed up but, for now it works right.  :D Now that the healer works, what to do? I was working on modifying a simple gold looter script and decided to combine the two. Now i feel some laughter coming on because i combined them completely on my own even though im sure its a very simple thing to do, it took the better part of an hour to think of the circumstances to run the subs. I'm sure this may look primitive  :P I threw a variable in there to hide my charid at least i think i did it right lol.

Code: [Select]

set %bandie_time #sCnt
set %bandie ( #maxhits - 10 )
set %corpseid YFM_FEX_QEX

SUO:
repeat


if #hits < %bandie && #sCnt >= %bandie_time
  {
    gosub Healme
    set %bandie_time ( #sCnt + 10 )
  }
wait 5

gosub loot

until #CharGhost = YES
while #CharGhost = YES
  wait 0
GoTo SUO

sub Healme
  wait 5
  findItem %1 C_ , #backpackID
  if #findKind = -1
    return
  set #lobjectID #findID
   set #ltargetKind 1
  event macro 17 0
  target 3s
  event macro 23 0
  wait 3
return


sub loot
finditem %corpseid G_2
set %corpse #findid
set #lobjectid %corpse
event macro 17 0
wait 20
set %corpseContID #contid
finditem POF C_ , %corpseContID
set %gold #findid
     wait 10
     exevent drag %gold #findstack
     wait 10
     exevent dropc #backpackid
ignoreitem %corpseCondID
ignoreitem %corpse
wait 10
return


Script works but still is a little bugged. specifically in the targeting of bandies i think i need to adjust some pause times. Thanks for everyone help on this thing.. I of course take no claim to anything im just learning :D Without your guys words of encouragement i probably would have bombed out by now. I have much respect for what you do.

*one day i'll be worthy of SUO guild*




« Last Edit: March 15, 2010, 12:31:55 PM by jwardlaw09 »

Scrripty

  • Guest
Re: Newb, First Script
« Reply #13 on: March 15, 2010, 01:07:53 PM »
0
There's no reason to have any waits except one wait timer for the bandage + the wait you need for using it.

Offline Petkiller

  • Full Member
  • ***
  • Posts: 112
  • Activity:
    0%
  • Reputation Power: 0
  • Petkiller has no influence.
  • Respect: +7
  • Referrals: 2
    • View Profile
Re: Newb, First Script
« Reply #14 on: March 15, 2010, 03:45:29 PM »
0
A friend of mine showed me this in a healing script he made:
event macro 58
I never even knew about it, but you dont have to double click bandies you dont have to wait for target cursor and dont have to target your self. 

Tags: