Author Topic: Please help - my first script!  (Read 4481 times)

0 Members and 1 Guest are viewing this topic.

Offline Ultimafreak77Topic starter

  • Full Member
  • ***
  • Posts: 105
  • Activity:
    0%
  • Reputation Power: 2
  • Ultimafreak77 has no influence.
  • Gender: Male
  • Respect: +14
  • Referrals: 0
    • View Profile
Please help - my first script!
« on: January 19, 2014, 05:14:31 PM »
0

There are 1 attachment(s) in this post. You must register and post an acceptable introduction to download
CommandKiller.txt
The few. The proud. The AFK.

Offline The Ghost

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +245
  • Referrals: 0
    • View Profile
Re: Please help - my first script!
« Reply #1 on: January 19, 2014, 09:46:53 PM »
0
EN have make a BuffBarScanner,  you can utilize this to monitor your hiding and other icon you required.
http://www.scriptuo.com/index.php?topic=1508.0;highlight=buffbarscanner

As for your atl account.  I will used the party msg.   to have your second account to stop attacking and hide.   this way you can have a key stroke command.

Offline camotbik

  • Sr. Member
  • *
  • Posts: 349
  • Activity:
    0%
  • Reputation Power: 3
  • camotbik has no influence.
  • Gender: Male
  • Hello! I'm a UO addict.
  • Respect: +38
  • Referrals: 0
    • View Profile
Re: Please help - my first script!
« Reply #2 on: January 22, 2014, 07:26:51 PM »
0
1) As soon as enemy attacks you your #enemyid changes from N/A To whatever the id is so.
Code: [Select]
if #enemyid <> N/A
  gosub DoWhatYouHaveToDo ; As you stated, Cast invis on yourself.
Take a closer look - http://wiki.easyuo.com/index.php?title=EnemyID

2) There are many options, for example you could use #true #false statements, i'm giving you an example bellow, so you could understand how this works. Use words PEST, VEST, to see the script in action.
Code: [Select]
set %testword1 PEST ; journal testword 1
set %testword2 VEST ; journal testword 2
set %stopword ST    ; journal test stop word
set %testword1_messages #false
set %testword2_messages #false
set %jrnl #jindex
; ----------------------------------------------------------------------------
; ---------------------------------- MAIN LOOP -------------------------------
; ----------------------------------------------------------------------------
repeat
  gosub CheckMessages
  if %testword1_messages = #true
    gosub DoTestword1
  if %testword2_messages = #true
    gosub DoTestword2
until #charghost = yes
stop
; ----------------------------------------------------------------------------
; ---------------------------------- CHECK MESSAGES --------------------------
; ----------------------------------------------------------------------------
Sub CheckMessages
  while #jindex >= %jrnl   ; Changed > to >= so we would not wait for another message to arrive.
  {
    scanjournal %jrnl
    if %testword1 in #journal
    {
      event macro 1 1 GOT 1!!
      set %testword1_messages #true
      set %testword2_messages #false
    }
    if %testword2 in #journal
    {
      event macro 1 1 GOT 2!!
      set %testword1_messages #false
      set %testword2_messages #true
    }
    if %stopword in #journal
    {
      event macro 1 1 Stoping!!
      stop
    }
    set %jrnl %jrnl + 1
  }
return
; ----------------------------------------------------------------------------
; ---------------------------------- WHATEVER1 -------------------------------
; ----------------------------------------------------------------------------
Sub DoTestword1
  while %testword1_messages = #true
  {
    event macro 1 1 test1
    wait 2s
    gosub checkMessages ; in the end just check the messages, if something has changed, and we need to switch to anohter sub
  }
return
; ----------------------------------------------------------------------------
; ---------------------------------- WHATEVER2 -------------------------------
; ----------------------------------------------------------------------------
Sub DoTestword2
  while %testword2_messages = #true
  {
    event macro 1 1 test2
    wait 2s
    ..... do what you got to do
    gosub checkMessages ; in the end just check the messages, if something has changed, and we need to switch to anohter sub
  }
return



3) One step at the time. The bigest problem with people that start writing scripts in euo, is to find the proper logic behind the script. I will break your script a-part, and comment on few things, that might help you in future.
 


a) after the character is dead, we are starting to loop the whole mainloop again, that means, you are trying Heal the character while he is dead. I Doubt that that is intended. a simple "stop", aka "halt" after "until #charGhost = yes", would help, or, we could insert another while loop on top of the mainloop.
while #charghost = yes  ; optional1
 wait 0                  ; optional1

b) Return in your mainloop.  From where are you returning? There is no sub to return from. So we are just wasting space.
c) Well not really a issue, but, you are using so many brackets {} for statements with one line, that really just makes the code alot longer.  you can read about it here http://www.scriptuo.com  /index.php?topic=8759.0
d) That mainloop, looks sick. Dont get me wrong, I had the shitiest nesting structures when i started writing. You really should look in to your
nesting structure, as there are so many not needed elses(I will provide an example latter on).
e) I would add check for mana in CureMe, HealMe, so that your MedMe, would work.
Code: [Select]
if #mana >= 5
{...}
f) CureMe could use a while loop, to try to cure while poisoned and mana is more than 5.
Code: [Select]
while C in #charStatus && #mana > 5
{...}
g) Check your journal sub. You should use while loop not if to read every possible new coming line and not skip some stuff straight away. The bigest problem in this sub is, that you are seting +1 line just before you are reading it. Do you see logic behind it ? You should bring set %jrnl %jrnl + 1 just before the last } and return.
Code: [Select]
   set %jrnl %jrnl + 1
  }
return
h) I see you are using the same code over and over, for the heal and cure. To make your life more easy, why not just copy that code in a sub and use with one line? Shorter code, faster results.
Code: [Select]
Gosub Cure/Heal


Final advice would be, keep your code clean, and add header so after each change, you could write up a version change, to realize fast where you at. I've build something pretty mutch fast here, from the code that i gave you above, as an example, so you would have a cleaner platform to work on. Bare in mind, i havent been writing stuff for a while year, or two, so i might have messed some things up. For the Killing Subroutine, check out a subroutine from my ultimate fisher), called check_serpent  - http://www.scriptuo.com/index.php?topic=8284.0 . Additionally, i would recomend checking another script of mine, with some similar functions that you are trying to implenent.
http://www.scriptuo.com/index.php?topic=8440.0. I will keep an eye on this topic, to see how you are doing. And if you got questions ask, I will be glad to answer.


Code: [Select]
; Script Name: CommandKiller
; Author: Ultimafreak
; Version: 0.01A
; Client Tested with:
; EUO version tested with:
; Shard OSI / FS:
; Revision Date: 2014.01.23
; Public Release: http://www.scriptuo.com/index.php?topic=12065.0
; Global Variables Used: none
;Instructions:
;
;
;
; ----------------------------------------------------------------------------
; ---------------------------------- EDITABLES -------------------------------
; ----------------------------------------------------------------------------
set %testword1 HEALBRO  ; journal testword 1
set %testword2 INVISBRO ; journal testword 2
set %stopword ST        ; journal test stop word
; ----------------------------------------------------------------------------
; ---------------------------------- DO NOT EDIT -----------------------------
; ----------------------------------------------------------------------------
set %heal_cast_timer #scnt2
set %cure_cast_timer #scnt2
set %invis_cast_timer #scnt2
set %testword1_messages #false
set %testword2_messages #false
set %jrnl #jindex
; ----------------------------------------------------------------------------
; ---------------------------------- MAIN LOOP -------------------------------
; ----------------------------------------------------------------------------
repeat
  gosub CheckMessages
  if %testword1_messages = #true
    gosub DoTestword1
  if %testword2_messages = #true
    gosub DoTestword2
until #charghost = yes
stop
; ----------------------------------------------------------------------------
; ---------------------------------- CHECK MESSAGES --------------------------
; ----------------------------------------------------------------------------
Sub CheckMessages
  while #jindex >= %jrnl   ; Changed > to >= so we would not wait for another message to arrive.
  {
    scanjournal %jrnl
    if %testword1 in #journal
    {
      event macro 1 1 GOT 1!!
      set %testword1_messages #true
      set %testword2_messages #false
    }
    if %testword2 in #journal
    {
      event macro 1 1 GOT 2!!
      set %testword1_messages #false
      set %testword2_messages #true
    }
    if %stopword in #journal
    {
      event macro 1 1 Stoping!!
      stop
    }
    set %jrnl %jrnl + 1
  }
return
; ----------------------------------------------------------------------------
; ---------------------------------- HEAL/CURE -------------------------------
; ----------------------------------------------------------------------------
Sub DoTestword1
  while %testword1_messages = #true
  {
    while #charghost = no && C in #charstatus ; while poisoned, cast cure on yourself
    {
      if  #mana > 5 ; how much do you need for a cure? if not 5, change
      {
        event macro 15 10; cast cure
        target
        event macro 23 0 ; targetself
      }
    }
    while #charghost = no && C notin #charstatus && #hits < ( #maxhits - 20 ) ; Cast Heal while less than 20 and not poisoned.
    {
      if #mana > 5 ; #scnt > %heal_cast_timer &&
      {
        event macro 15 3; cast heal
        target
        event macro 23 0 ; targetself
      }
    }
    gosub checkMessages ; in the end just check the messages, if something has changed, and we need to switch to anohter sub
  }
return
; ----------------------------------------------------------------------------
; ---------------------------------- INVISIBILITY ----------------------------
; ----------------------------------------------------------------------------
Sub DoTestword2
  while %testword2_messages = #true
  {
    while #mana >= 20 && H notin #charstatus && #charghost = no
    {
      event macro 15 43
      target 5s
      event macro 22 0
    }
    gosub checkMessages ; in the end just check the messages, if something has changed, and we need to switch to anohter sub
  }
return
; ----------------------------------------------------------------------------
; ---------------------------------- ATTACK ENEMY ----------------------------
; ----------------------------------------------------------------------------
Sub AttackEnemy
return




« Last Edit: January 22, 2014, 07:34:50 PM by camotbik »
What you witness -- is whatver..
uogamers hybrid.

Offline Ultimafreak77Topic starter

  • Full Member
  • ***
  • Posts: 105
  • Activity:
    0%
  • Reputation Power: 2
  • Ultimafreak77 has no influence.
  • Gender: Male
  • Respect: +14
  • Referrals: 0
    • View Profile
Re: Please help - my first script!
« Reply #3 on: January 24, 2014, 01:00:32 PM »
0
Camotbik, thank you for taking the time to help me. I can understand most of what you are trying to tell me and have started putting it to use. Several things I am trying to change to fit my needs. Part of the reason I had the heal/cure everywhere in my old script was because I want it to heal/cure without me having to give the 2nd account a command. Thanks again, ill repost once I have figured some more out! I feel kind of silly, all I have done each evening is try to get this code working.. which means I missed a whole week of playing because I am trying to auto play a 2nd account!
The few. The proud. The AFK.

Offline camotbik

  • Sr. Member
  • *
  • Posts: 349
  • Activity:
    0%
  • Reputation Power: 3
  • camotbik has no influence.
  • Gender: Male
  • Hello! I'm a UO addict.
  • Respect: +38
  • Referrals: 0
    • View Profile
Re: Please help - my first script!
« Reply #4 on: February 01, 2014, 06:38:22 AM »
0
Then you need a different kind of loop, for example.

Code: [Select]
set %jrnl #jindex
repeat
  while C in #charstatus && mana > 10 && #charghost = no
    gosub CastCure
  while #hits > #maxhits && #mana > 10 && C notin #charstatus && charghost = no
    gosub CastHeal
    ; gosub CheckMana
    ; gosub CheckMessages ; for invisbility?
    ; gosub FindAndKillEnemey??
    ; gosub FollowMainCharacter??
    ;
until #charghost = yes  
stop  

ps; it's not really and easy task you want to achive there. for your first script you should build the basic parts of the script so they work flawless seperated and then, try to put it together.

For example. First step should be what? Your character should Cure and Heal right? Then go on write those two subs and put them in your mainloop, see how it goes. Test them two out till you see they work with out any problems. Put as many checks on subs as you can, they wont hurt.Check if your character is not dead while you cast heal/cure/invis, check for mana, in case of heal, check if you are not poisoned again, mortaled or whatever else can go in your mind. These all things are really important for your script to work with out any mistakes. The same goes for any other sub.
« Last Edit: February 01, 2014, 06:55:18 AM by camotbik »
What you witness -- is whatver..
uogamers hybrid.

Offline Ultimafreak77Topic starter

  • Full Member
  • ***
  • Posts: 105
  • Activity:
    0%
  • Reputation Power: 2
  • Ultimafreak77 has no influence.
  • Gender: Male
  • Respect: +14
  • Referrals: 0
    • View Profile
Re: Please help - my first script!
« Reply #5 on: February 02, 2014, 07:27:16 AM »
0
Thanks! With all your help, I do have a working script but it doesn't react as quick as I would like to the chat commands.. It also wasn't meditating like I wanted but it is functioning. As soon as I get it cleaned up I will post it here so you can look it over.
The few. The proud. The AFK.

Offline camotbik

  • Sr. Member
  • *
  • Posts: 349
  • Activity:
    0%
  • Reputation Power: 3
  • camotbik has no influence.
  • Gender: Male
  • Hello! I'm a UO addict.
  • Respect: +38
  • Referrals: 0
    • View Profile
Re: Please help - my first script!
« Reply #6 on: February 10, 2014, 09:10:17 AM »
0
How are you doing with that script of yours?
What you witness -- is whatver..
uogamers hybrid.

Offline Ultimafreak77Topic starter

  • Full Member
  • ***
  • Posts: 105
  • Activity:
    0%
  • Reputation Power: 2
  • Ultimafreak77 has no influence.
  • Gender: Male
  • Respect: +14
  • Referrals: 0
    • View Profile
Re: Please help - my first script!
« Reply #7 on: February 18, 2014, 01:11:41 PM »
0
How are you doing with that script of yours?

Camotbik,

Here is what I have come up with so far. It works but I haven't had a lot of time to make it better.


There are 1 attachment(s) in this post. You must register and post an acceptable introduction to download
CommandKiller 1.3.txt
The few. The proud. The AFK.

Tags: