Author Topic: First script, Doesnt work  (Read 4478 times)

0 Members and 1 Guest are viewing this topic.

Offline TanaTopic starter

  • Jr. Member
  • **
  • Posts: 67
  • Activity:
    0%
  • Reputation Power: 1
  • Tana has no influence.
  • Respect: +6
  • Referrals: 1
    • View Profile
First script, Doesnt work
« on: February 05, 2016, 11:25:58 PM »
0
Hey guys i spent all night trying to research what i was doing and i apparently got it wrong >.< can someone look it over and tell me what i did that was bad? its not finished i dont have the loot or drop off subs written but as bad as ive done i dont think theyd work anyway
Code: [Select]
;------------------------------------
;-- Script Name:Dark Guardian Farm
;-- Author: Tana
;-- Version: 1.0
;-- Client Tested with: 7.0.6.5 (Patch 95)
;-- EUO version tested with:
;-- Shard OSI
;-- Revision Date:
;-- Public Release:
;-- Purpose: Faming TMAPS for clean up/Deamon bones for golden skulls
;-- Copyright: 2016
;-----------------Variables-------------------
;
;
SET %creature WD ;WD
SET %loot POF_XVH
SET %homebook OXGABND
SET %doombook UWVWWQD
SET %secure
SET %backpack CJSXQOD
;-----------------MAINLOOP------------------------
main:
gosub weightcheck
gosub spawn
gosub attack
gosub loot
repeat
;-----------------MAINSUBS------------------------

sub weightcheck
finditem * c_ %backpack
IF #weight > 400 || #findcnt > 120
   {
   gosub gohome
   }
   else
   {
   return
   }
;------------------------------------------------------

sub spawn
FINDITEM %creature G_, 10
IF #FINDKIND = -1
{
event pathfind 366 15
wait 100
event pathfind 362 15
}
else
{
return
}

;----------------------------------------

sub attack
FINDITEM %creature G_, 10
SET #LTARGETID #FINDID
SET %enemy #FINDID
EVENT macro 27
FINDITEM !_enemy G_
IF #FINDKIND <> -1
{
repeat
}
else
{
return
}
;------------------------------------------------

sub loot
wait 200
return
;------------------------------------------------

;--------------TRAVEL SUBS-----------------------

sub gohome
EVENT pathfind 356 14
wait 5
EVENT MACRO 22 0
wait 5
EVENT pathfind 352 14
SET #LTARGETID %homebook
EVENT MACRO 15 210
wait 5
EVENT MACRO 12 0
wait 5
gosub dropoff
;---------------------------------------------------

sub dropoff
    gosub godemons

;---------------------------------------------------
sub godemons
SET #LTARGETID %doombook
EVENT MACRO 15 210
wait 5
EVENT MACRO 22 0
wait 10
EVENT pathfind 355 15
EVENT MACRO 12 0
EVENT pathfind 356 14
  goto main:
;----------------------------------------------------

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: First script, Doesnt work
« Reply #1 on: February 06, 2016, 06:15:48 AM »
0

You can have a look at how dxrom select his attack.   

 http://www.scriptuo.com/index.php?topic=7538.0
 The have many other that can give you the flow. 

TM have build a script syntax,   The checker will pick up those issue.


 
Code: [Select]
;------------------------------------
;-- Script Name:Dark Guardian Farm
;-- Author: Tana
;-- Version: 1.0
;-- Client Tested with: 7.0.6.5 (Patch 95)
;-- EUO version tested with:
;-- Shard OSI
;-- Revision Date:
;-- Public Release:
;-- Purpose: Faming TMAPS for clean up/Deamon bones for golden skulls
;-- Copyright: 2016
;-----------------Variables-------------------
;
;
SET %creature WD ;WD
SET %loot POF_XVH
SET %homebook OXGABND
SET %doombook UWVWWQD
SET %secure
SET %backpack CJSXQOD
;-----------------MAINLOOP------------------------
main:
gosub weightcheck
gosub spawn
gosub attack
gosub loot
repeat
;-----------------MAINSUBS------------------------

sub weightcheck
finditem * c_ %backpack
  IF #weight > 400 || #findcnt > 120
   gosub gohome   <  for one line you dont need the bracket. Nothing wrong off having them
 return

;------------------------------------------------------

sub spawn  < --------------------------------------    Look at other how to build an attack sub.   Spawm and attack should be in the same one
FINDITEM %creature G_10   
IF #FINDKIND = -1
{
event pathfind 366 15
wait 100
event pathfind 362 15
}
else
{
return
}

;----------------------------------------

sub attack
FINDITEM %creature G_, 10
SET #LTARGETID #FINDID
SET %enemy #FINDID
EVENT macro 27
FINDITEM !_enemy G_
IF #FINDKIND <> -1
{
repeat
}
else
{
return
}
;------------------------------------------------

sub loot               
wait 200
return
;------------------------------------------------

;--------------TRAVEL SUBS-----------------------

sub gohome
EVENT pathfind 356 14
wait 5
EVENT MACRO 22 0
wait 5
EVENT pathfind 352 14
SET #LTARGETID %homebook
EVENT MACRO 15 210
wait 5
EVENT MACRO 12 0
wait 5
gosub dropoff
                                   ; < -------------- Need return here, You are going to sub anyway and it not the proper way to exit a Sub
;---------------------------------------------------

sub dropoff
    gosub godemons
Return :<------------------same need retrun
;---------------------------------------------------
sub godemons
SET #LTARGETID %doombook
EVENT MACRO 15 210
wait 5
EVENT MACRO 22 0
wait 10
EVENT pathfind 355 15
EVENT MACRO 12 0
EVENT pathfind 356 14
  goto main:       ;    < ----------------------  Need a return  you don't exit a sub with a goto
;----------------------------------------------------

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: First script, Doesnt work
« Reply #2 on: February 06, 2016, 10:06:21 AM »
0
Output from the syntax checker run:

Code: [Select]
Method count: 56
Command count: 56
*** Pass 1 - Label accounting:
*** Error - Subroutine dropoff - Line 91 nested without return.
*** Warning - GOTO main: - Line 104 has no matching tag
Subroutine labels = 7
Tag labels = 1
4 Code block(s).
1 Warnings(s) encountered.
*** Pass 2 - Execution [SYNTAXCHECK]

You can download and run it yourself here:
http://www.scriptuo.com/index.php?action=downloads;cat=1

You'll probably have to run the checker, fix and error and run the checker again until you get no more errors and minimal warnings.

But a quick couple hints:

1) Each one of your subs needs to be terminated in a "return".  You should never jump out of a subroutine, or execute past the end into the next subroutine.
2) Your main loop executed down into your subs.  You need to move your "goto main" back up to the very end of you main loop just after your "gosub loot"
3) verify your use of the "repeat" loop.  Looks like you don't need it.  For a repeat loop to work, it needs a corresponding "until" statement.
« Last Edit: February 06, 2016, 10:36:03 AM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline TanaTopic starter

  • Jr. Member
  • **
  • Posts: 67
  • Activity:
    0%
  • Reputation Power: 1
  • Tana has no influence.
  • Respect: +6
  • Referrals: 1
    • View Profile
Re: First script, Doesnt work
« Reply #3 on: February 06, 2016, 01:06:56 PM »
0
hey guys thanks for the replies ill run the checker again myself and start editing it up ill post a revision when its done

Offline TanaTopic starter

  • Jr. Member
  • **
  • Posts: 67
  • Activity:
    0%
  • Reputation Power: 1
  • Tana has no influence.
  • Respect: +6
  • Referrals: 1
    • View Profile
Re: First script, Doesnt work
« Reply #4 on: February 07, 2016, 03:11:58 PM »
0
fixed the attack sub it works perfectly now thanks for your guys' contributions now i was wondering if i could get help with the looting part? like how do you make it the script stop to loot? and how do you put the corpse ids on ignore like TMs CLAw does? thanks!

Updated attack sub

Code: [Select]
;------------------------------------------------------

sub attack
FINDITEM %creature G_5
IF #FINDKIND = -1
{
move 368 15 1
wait 30
move 362 15 1
wait 30
}
IF #FINDKIND <> -1
{
FINDITEM %creature
SET %enemy #FINDID
SET #LTARGETID %enemy
move #FINDX #FINDY a
EVENT macro 27 0
IF #FINDID <> %enemy
{
  set %enemy #FINDID
set #LTARGETID %enemy
event macro 27 0
  }
}
return
;------------------------------------------------


this is what i have written in the loot sub so far

Code: [Select]
sub loot
  FINDITEM %corpse G_4
IF #FINDKIND <> -1
  {
  SET %corpseid #FINDID
  SET #LOBJECTID %corpseid
  event macro 19 0
  }
  return

thanks in advance guys im trying to learn as much as i can by myself but its a little more confussing then i thought it would be

Tags: