ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Ketchup on April 13, 2015, 06:10:42 PM

Title: Weapon Check & Change script
Post by: Ketchup on April 13, 2015, 06:10:42 PM
I'm wondering if anyone out there has or can write a script that changes a weapon once it's durability hits 0 to another weapon automatically while still using lame3.0 to target mobs?
E.G I'm hitting away at barracoon champ spawn and my weapon durability hits 0, the script then swaps the weapon out for a weapon of the same type and then when the wep I'm using hits 0 it changes to another and so on until all my weapons hits 0 durability
If anyone could please help me out with this I would love you!
Title: Re: Weapon Check & Change script
Post by: Endless Night on April 13, 2015, 06:24:48 PM
I'm wondering if anyone out there has or can write a script that changes a weapon once it's durability hits 0 to another weapon automatically while still using lame3.0 to target mobs?
E.G I'm hitting away at barracoon champ spawn and my weapon durability hits 0, the script then swaps the weapon out for a weapon of the same type and then when the wep I'm using hits 0 it changes to another and so on until all my weapons hits 0 durability
If anyone could please help me out with this I would love you!

Shouldn't that be  "I would love you  .. LONG TIME" !!!  

 Before i can even consider your proposition of love in exchange for scripting I need to know quiet a number of facts..... i need to know where you reside... as obviously love from afar is not worth half as much as local love !!!!    Also I would need to know your gender as that is also relevant for consideration and more... perhpas you should post a full bio along with the request for expediency....  :D ;D


All jesting aside these kind of little costum changes are perfect for you to learn how to tweak a script.   Its not that hard.  I'll start you out fill in the blanks and bits..

Code: [Select]
gosub weaponcheck   ; place this were needed inside the lame script....

; place at end of lame script
sub weaponcheck
   set %thisweapon    <change this to the  weapon u are holding>
   event property  %thisweapon
   ; Some code to extract duarbility from #property and set value to %durability
   if %durability = 0
      {
       ; some code here to find a new weapon that doent have a durability of zero
       }
return




Title: Re: Weapon Check & Change script
Post by: The Ghost on April 13, 2015, 07:13:06 PM
FYI  Don't forget to add
if reforged in #property 

so you can scan the right line for the durability.
Title: Re: Weapon Check & Change script
Post by: Crisis on April 13, 2015, 07:35:16 PM
I'm wondering if anyone out there has or can write a script that changes a weapon once it's durability hits 0 to another weapon automatically while still using lame3.0 to target mobs?
E.G I'm hitting away at barracoon champ spawn and my weapon durability hits 0, the script then swaps the weapon out for a weapon of the same type and then when the wep I'm using hits 0 it changes to another and so on until all my weapons hits 0 durability
If anyone could please help me out with this I would love you!

Shouldn't that be  "I would love you  .. LONG TIME" !!!  

 Before i can even consider your proposition of love in exchange for scripting I need to know quiet a number of facts..... i need to know where you reside... as obviously love from afar is not worth half as much as local love !!!!    Also I would need to know your gender as that is also relevant for consideration and more... perhpas you should post a full bio along with the request for expediency....  :D ;D


All jesting aside these kind of little costum changes are perfect for you to learn how to tweak a script.   Its not that hard.  I'll start you out fill in the blanks and bits..

Code: [Select]
gosub weaponcheck   ; place this were needed inside the lame script....

; place at end of lame script
sub weaponcheck
   set %thisweapon    <change this to the  weapon u are holding>
   event property  %thisweapon
   ; Some code to extract duarbility from #property and set value to %durability
   if %durability = 0
      {
       ; some code here to find a new weapon that doent have a durability of zero
       }
return






I have translated this for everyone

Ketchup: I love you man
EN: You're not getting my bud lite!

Title: Re: Weapon Check & Change script
Post by: TrailMyx on April 13, 2015, 08:55:10 PM
Shouldn't that be  "I would love you  .. LONG TIME" !!!  

+1 for EN!
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 14, 2015, 03:27:54 AM
hah, sadly my scripting knowledge is not good enough to work this out myself, I've tried working it our for a few hours but nothing but thank you for the replies
Title: Re: Weapon Check & Change script
Post by: Endless Night on April 14, 2015, 07:39:29 AM
hah, sadly my scripting knowledge is not good enough to work this out myself, I've tried working it our for a few hours but nothing but thank you for the replies

Well we all have to start someplace.   I know it can seem daunting at first but once you get over the initial hurdle it gets easier and easier.   Wouldn't it be nice to be able to tweak the script you download to have that little more customization to how you want it.

I think you will find that people are much more willing to help you debug a script snippet that you are trying to write/learn than actually write it for you...


Title: Re: Weapon Check & Change script
Post by: Ketchup on April 14, 2015, 01:06:52 PM
I appreciate the posts again, I'm relishing in the dream of being able to edit/write myself, I'll keep trying and maybe one day crack the code!
Title: Re: Weapon Check & Change script
Post by: The Ghost on April 14, 2015, 01:54:23 PM
Just post what you got and we can help you make correction.
Title: Re: Weapon Check & Change script
Post by: Zurg on April 14, 2015, 04:45:39 PM
don't feel bad to post it i promise it can't be no worst than mine scripting.
Title: Re: Weapon Check & Change script
Post by: Crome969 on April 15, 2015, 05:35:44 AM
don't feel bad to post it i promise it can't be no worst than mine scripting.
Even if its more worse, i know atleast 10 persons who not even would be able to copy code together (and i teached them irl a while).
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 16, 2015, 11:51:21 AM
I'm still trying my hardest to get a code together that doesn't offend myself for looking so stupid :)
Title: Re: Weapon Check & Change script
Post by: The Ghost on April 16, 2015, 02:27:06 PM
The cat is out of the bag now, so let the mice out
Title: Re: Weapon Check & Change script
Post by: Zurg on April 16, 2015, 02:32:51 PM
We will keep the snakes in the cages so the mice wont get ate.
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 16, 2015, 03:39:29 PM
I've tried but I've given up, I can't grasp the whole concept, been at it days now.
Title: Re: Weapon Check & Change script
Post by: Crome969 on April 17, 2015, 03:40:16 AM
post what u have and let us do some magic..
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 17, 2015, 11:18:39 AM
I don't suppose anyone could help with this and kinda leave a few blanks in the scripts so I can learn a bit myself and see how scripting works a little please?
Title: Re: Weapon Check & Change script
Post by: TrailMyx on April 17, 2015, 11:22:52 AM
This might give you some ideas.  This set of subs checks your paperdoll to see if you have an item with swordsmanship, if not, then it will equip and senses the requirement of 1-handed or 2-handed.

Code: [Select]
;-------------------------------------------------------------------------------
sub CheckWeapon
  set #RESULT #FALSE
  finditem * C_ , #CHARID
  for #FINDINDEX 1 #FINDCNT
  {
    event property #FINDID
    if swordsmanship in #PROPERTY
    {
      set #RESULT #FINDID
      break
    }
  }
return #RESULT
;-------------------------------------------------------------------------------
sub Disarm
  finditem * C_ , #CHARID
  for #FINDINDEX 1 #FINDCNT
  {
    event property #FINDID
    if swordsmanship in #PROPERTY && two-handed in #PROPERTY
    {
      event macro 24 1 ; 2 handed
      break
    }
    if swordsmanship in #PROPERTY && one-handed in #PROPERTY
    {
      event macro 24 2 ; 1 handed
      break
    }
  }
return #FINDID
;-------------------------------------------------------------------------------
sub EquipSword
  finditem * C_ , #BACKPACKID
  for #FINDINDEX 1 #FINDCNT
  {
    event property #FINDID
    if swordsmanship in #PROPERTY && two-handed in #PROPERTY
    {
      set #LHANDID #FINDID
      event macro 24 1 ; 2 handed
      break
    }
    if swordsmanship in #PROPERTY && one-handed in #PROPERTY
    {
      set #RHANDID #FINDID
      event macro 24 2 ; 1 handed
      break
    }
  }
return
Title: Re: Weapon Check & Change script
Post by: The Ghost on April 17, 2015, 03:07:38 PM
I need to play more with those event property,  you can do wonder.  this is what I use to equip weapon and change the number as needed,  but I will have to borrow TM snippet for my next build.

Code: [Select]
sub equip
finditem %weapon C_ , #Charid
if #findcnt < 1
{
wait 40
finditem %weapon C_ , #backpackid
set #RHandID #findid
wait 20
event macro 24 2 ; 1 = Left hand   2 = Right Hand
}
return
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 17, 2015, 07:46:05 PM
okay, feel free to tease me, laugh at me or whatever but I need to learn some way, am I along any right tracks here?
Code: [Select]
;-------------------------------------------------------------------------------
sub CheckWeapon
  set #RESULT #FALSE
  finditem * C_ , #CHARID
  for #FINDINDEX 1 #FINDCNT
  {
    event property #FINDID
    if %durability in #PROPERTY  = < 1
    {
      set #RESULT #FINDID
      break
    }
  }
return #RESULT
;-------------------------------------------------------------------------------
sub Disarm
  finditem * C_ , #CHARID
  for #FINDINDEX 1 #FINDCNT
  {
    event property #FINDID
    if swordsmanship in #PROPERTY && two-handed in #PROPERTY
    }
    if swordsmanship in #PROPERTY && one-handed in #PROPERTY
    {
      event macro 24 2 ; 1 handed
      break
    }
  }
return #FINDID
;-------------------------------------------------------------------------------
sub EquipSword
  finditem * C_ , #BACKPACKID
  for #FINDINDEX 1 #FINDCNT
  {
    event property #FINDID
    if %durability = > 1 in #PROPERTY && two-handed in #PROPERTY
    {
      set #LHANDID #FINDID
      event macro 24 1 ; 2 handed
      break
    }
    if %durability in #PROPERTY  = > 1 && one-handed in #PROPERTY
    {
      set #RHANDID #FINDID
      event macro 24 2 ; 1 handed
      break
    }
  }
return
Title: Re: Weapon Check & Change script
Post by: TrailMyx on April 17, 2015, 08:09:58 PM
Event property doesn't exactly work that way.  You kinda need to do all the work.  When you use the command "event property #FINDID", it will fill the #PROPERTY string with a bunch of substrings separated by a $.  Take this hatchet for example:


Since this is one long string (contents of #PROPERTY):
Hatchet$Weight: 4 Stones$Physical Damage 100%$Weapon Damage 13 - 16$Weapon Speed 2.75s$Strength Requirement 20$Two-Handed Weapon$Skill Required: Swordsmanship$Durability 49 / 49$

You can just scan it like you would do any string.  Take a look at EasyUO about the "in" and "notin" operator.

So with that in mind, you just need to look for something that's "Durability 0"

Code: [Select]
;-------------------------------------------------------------------------------
sub CheckWeapon
  set #RESULT #FALSE
  finditem * C_ , #CHARID
  for #FINDINDEX 1 #FINDCNT
  {
    event property #FINDID
    set %string durability , #SPC , 0
    if %string in #PROPERTY
    {
      set #RESULT #FINDID
      break
    }
  }
return #RESULT

Title: Re: Weapon Check & Change script
Post by: Ketchup on April 17, 2015, 09:05:24 PM
then how would I go about re-arming a full/higher durability wep?
Title: Re: Weapon Check & Change script
Post by: TrailMyx on April 17, 2015, 09:12:29 PM
then how would I go about re-arming a full/higher durability wep?

I won't do the work for you on this one but think about this:

Code: [Select]
   event property #FINDID
    set %string durability , #SPC , 0
    if %string notin #PROPERTY
    {
      EQUIP IT!
    }

Try applying this logic to the "EquipSword" function.

BTW, single stepping your code is your friend!

Title: Re: Weapon Check & Change script
Post by: The Ghost on April 18, 2015, 03:56:47 AM
You can go have a look to those build and see how the handle the equip.
A few member have some good built that use it.those two pop inti my head.  Raz's , Snicker7 

http://www.scriptuo.com/index.php?topic=10094.0;topicseen
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 18, 2015, 03:58:52 AM
okay thanks for your time guys, I'll give this a try later tonight, see if I can get some ideas flowing
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 18, 2015, 05:29:38 PM
wow did I just edit/write my own little script using bits of others work! I think so!
However I tested this and it just keeps disarming my weapon, it's also very slow at disarming/re-arming,  if anyone can help without giving me the full script that would be great for my learning Thanks!
Quote
set %weapon XFR_
gosub CheckWeapon
;-------------------------------------------------------------------------------
sub CheckWeapon
  set #RESULT #FALSE
  finditem * C_ , #CHARID
  for #FINDINDEX 1 #FINDCNT
  {
    event property #FINDID
    set %string durability , #SPC , 0
    if %string in #PROPERTY
    {
      set #RESULT #FINDID
      break
    }
return #RESULT
 if #RESULT #TRUE
  {
      gosub EquiptNewWeapon
    }

sub EquiptNewWeapon
    finditem %weapon C_ , #backpackid
     if #FINDcnt < 1
      {
         sound
         wait 5
         Display No More Weapons! Script Paused!
         halt
      }
    set #RHANDID #findid
    wait 10
    event macro 24 2
;=========
Title: Re: Weapon Check & Change script
Post by: The Ghost on April 18, 2015, 08:06:17 PM
Using what u had above, I wasn't going anywhere.  So I decide to use the  Equip Last Weapon.    I use this in game build in macro lot.  Using the event 24 it just cycle the same weapon.   I try to add an ignoreitem, but I fail.   So here what I had to offer.

IF you need a third weapon, u will need to set the next weapon. 
Code: [Select]
set %weapon NSF ; Double axe
while #true
{
gosub CheckWeapon
 if #RESULT #TRUE
   {
      event macro 37
   }
}
;-------------------------------------------------------------------------------
sub CheckWeapon
  set #RESULT #FALSE
  finditem %weapon C_ , #CHARID
   for #FINDINDEX 1 #FINDCNT
  {
    event property #FINDID
     set %string durability , #SPC , 0
 ; set %string durability , #SPC , 10
    if %string in #PROPERTY
    {
      set #RESULT #true
      return #RESULT
      break
    }
    }
 return
Title: Re: Weapon Check & Change script
Post by: manwinc on April 20, 2015, 10:05:56 AM
Good Luck
Code: [Select]
; Weapon Maintenance
set %Weapon_Damage 25 ; Lowest Durability
set %Weapons FUO_ADP_DDP_NPO_OPO_RPF_QMH_ZPF_HDP_XRH_ZTO_EDP_BUO_GUO_BFR_MTF_FSF_ZTH_RRH_CFR_KDP_XFR_AUO_IFR_XTH_LPH_TRH_INF_OFR_YSF_BUH_HSF_BNF_CUO_ZCP_GMH_ZRF_UOH_NFR_NSF_HFR_FDP_LSF_JDP_LDP_BPH_YCP_SOH_VRH_NMH_JTF_JPH_ATF_TSF_QMBB_SMBB_EMBB_GMBB_MMBB_GQBB_IMBB_QQBB_IIY_ZHY_KIY_HIY_YMBB_MQBB_EIY_BIY_SQBB_KMBB_ARBB_OIY_OQBB_CIY_WQBB_UQBB_BSF_WER_VER_LMH_JSF_WOH_XCP_GFF_FIY_VTH_LIY_
set %RWeapons FUO_OPO_BFR_ZTH_RRH_CFR_KDP_XFR_AUO_IFR_TRH_INF_YSF_BUH_VTH_BNF_GMH_UOH_NFR_HFR_BPH_YCP_SOH_VRH_NMH_JTF_JPH_ATF_TSF_SMBB_GMBB_GQBB_IMBB_IIY_KIY_KMBB_ARBB_OIY_OQBB_CIY_WQBB_UQBB_AIY_THY_FIY_GIY_BSF_VER_LMH_JSF_WOH_LIY_
set %LWeapons ADP_DDP_NPO_RPF_QMH_ZPF_HDP_XRH_EDP_BUO_GUO_MTF_FSF_XTH_LPH_OFR_RMH_HSF_CUO_ZCP_ZRF_NSF_FDP_LSF_JDP_LDP_QMBB_EMBB_MMBB_QQBB_ZHY_HIY_YMBB_MQBB_OMBB_EIY_BIY_SQBB_WER_QPO_XCP_ZTO_GFF
;=======================================================

set %Class ; ID list for Weapons Here
; I use a global setting from a menu so I can specify which weapon set
; Set %Class !Class_ . #Charid


Sub Weapon_Maint
Finditem %Weapons C_ , #charid
if #Findcnt > 0
{
Gosub Property #Findid Durability
set %Durability #Result
set %Item #Findid
set %W_Type #Findtype
if %Durability < %Weapon_Damage || #Findid Notin %Class
{
Finditem %Class C_ , #backpackid
if #Findcnt > 0
{
For #Findindex 1 #Findcnt
{
Gosub Property #Findid Durability
set %Durability #Result
if %Durability > %Weapon_Damage
Break
}
if %Durability > %Weapon_Damage
{
Exevent Drag %Item
wait 15
Exevent Dropc #backpackid
wait 30
if #Findtype in %RWeapons
{
set #Rhandid #Findid
set %Equip_Macro 2
}
if #Findtype in %LWeapons
{
set %Equip_Macro 1
set #Lhandid #Findid
}
Event Macro 24 %Equip_Macro
set %Object_Timer #Systime + 1500
}
}
}
}
Else
{
Finditem %Class C_ , #backpackid
if #Findcnt > 0
{
if #Findtype in %RWeapons
{
set #Rhandid #Findid
set %Equip_Macro 2
}
if #Findtype in %LWeapons
{
set %Equip_Macro 1
set #Lhandid #Findid
}
Event Macro 24 %Equip_Macro
set %Object_Timer #Systime + 1500
}
Else
{
Finditem %Weapons C_ , #backpackid
if #Findcnt > 0
{
if #Findtype in %RWeapons
{
set #Rhandid #Findid
set %Equip_Macro 2
}
if #Findtype in %LWeapons
{
set %Equip_Macro 1
set #Lhandid #Findid
}
Event Macro 24 %Equip_Macro
set %Object_Timer #Systime + 1500
}
}
}
Finditem %Weapons C_ , #Charid
if #Findcnt > 0
set %Weapon_Maint_Timer #Systime + 60000
Else
set %Weapon_Maint_Timer #Systime + 2000
Return

Sub Property
NameSpace Push
Namespace Local Mwinc_Property
set !Item %1
set !Property %2
For !Attempt 1 10
{
Event Property !Item
if Stone in #property
Break
wait 5
}
Str Count #property !Property
if #Strres > 0
{
set !Cnt #Strres
for !Holder 1 !Cnt
{
set !Value2 0
Str Len !Property
set !Length #Strres
Str Pos #property !Property !Holder
set !Start #Strres + !Length
for !Number 1 4
{
Str Mid #Property !Start !Number
if #Strres > 0
set !Value2 #Strres
}
set !Value !Value + !Value2
}
}
Else
set !Value 0
set #Result !Value
Namespace Clear
Namespace pop
Return #Result
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 20, 2015, 02:32:29 PM
thanks manwinc!!!!
Title: Re: Weapon Check & Change script
Post by: manwinc on April 20, 2015, 05:44:24 PM
I use the Event Macro for Equipping the weapon to the right/left hand because Exevent Droppd doesn't work on gargoyles, so I wanted something generic that would work for any race.

Sub property Will find a string within the property and then get the value for the number After that String. The script uses this to get the Durability.

Might just be some useful tidbits in it.
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 20, 2015, 07:28:57 PM
I cannot get this to work, doesnt seem to disarm and not re-arm 0 durabilty weps.
Title: Re: Weapon Check & Change script
Post by: manwinc on April 20, 2015, 11:55:53 PM
It was meant more as an example than a functional script.


You'd have to implement some sort of Logic for it to actually do what you need to do.

set %Class ; <- you fill this with the ID's for your weapons separated by _'s

You can find this with an item finder script or by picking up the item and looking at your #Lliftedid on the right side of easyuo.

then just a basic logic for this sub you would do


Repeat
Gosub Weapon_Maint
wait 600 ; 30 seconds
Until #False
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 21, 2015, 03:07:25 AM
ah I see, I'll give this a try, thanks!
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 21, 2015, 07:09:38 AM
worked great on first test, thanks very much, can I ask a question if I was to put a Weapon ID that wasn't in my backpack into the %class list would it just skip using that weapon?
the reason I ask is because I run 2 accounts, would I have to save/run this script with 2 different sets of ID's for them to work correctly?
if this would be the case would it fit into the lame script too so that I wouldn't have to run multiple scripts?
Thanks in advance and thanks again manwinc!
Title: Re: Weapon Check & Change script
Post by: manwinc on April 21, 2015, 11:15:32 AM
Yup, if it can't find it. It won't use it.
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 21, 2015, 11:35:13 AM
I ran it in it's own standalone and it crashed, I was using lame and an item insure script
Title: Re: Weapon Check & Change script
Post by: The Ghost on April 21, 2015, 01:45:37 PM
what were you doing when it crash. Explain

  If you try to attack, do special and swap weapon all at the same time,  big chanmce that it will crash. 
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 21, 2015, 01:49:46 PM
yeah, attacks and specials I was doing
Title: Re: Weapon Check & Change script
Post by: manwinc on April 21, 2015, 05:53:58 PM
Yup, the more scripts you run on the same character the more likely you will crash. Have to try to get it all in one.
Title: Re: Weapon Check & Change script
Post by: The Ghost on April 21, 2015, 06:50:46 PM
Where did you insert the addition.
Did u add it after gosub divineFury
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 22, 2015, 04:21:30 AM
In honesty sir, I'd have no idea where to insert it, I was running it on it's own, if anyone could help me with that info I'd really appreciate it
Title: Re: Weapon Check & Change script
Post by: The Ghost on April 22, 2015, 08:56:28 AM
In one tab you are running lame 3.0 and the other tab you are running MwInc build. 
 
 Their is two way you can fix this. 
     First:  will be to add the check weapon into lame.   under gosub divineFury  insert you gosub CheckWeapon. 

     Second:  add a  swap weapon  check into lame so you stop attacking and perform swap.    if result=#true wait until you are done.

 


 
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 22, 2015, 11:04:54 AM
I have the first bit placed already but no idea on how to include the 2nd bit or even write it =(
Title: Re: Weapon Check & Change script
Post by: The Ghost on April 22, 2015, 01:11:04 PM
My bad,  The second is only if you are going to run 2 scripts tab.   if the are build into one you should be fine.
Title: Re: Weapon Check & Change script
Post by: Ketchup on April 22, 2015, 05:46:27 PM
okay I have it working using just the standard "gosub "Script name" would that work like that or do I need something more complicated like this?
Repeat
Gosub Weapon_Maint
wait 600 ; 30 seconds
Until #False
 I also have an issue where my item insurance script not working when running with lame 3.0 with the added weapon change

*UPDATE* I seem to of learnt how to combine and edit a few scripts thanks to you guys, done a few test and been able to merge them! now onto fully writing a script myself! Thanks all!
Title: Re: Weapon Check & Change script
Post by: Endless Night on May 27, 2015, 09:26:08 AM
*UPDATE* I seem to of learnt how to combine and edit a few scripts thanks to you guys, done a few test and been able to merge them! now onto fully writing a script myself! Thanks all!

Congratulations and Well done Ketchup....  look forward to seeing what kind of scripts you come up with...
Title: Re: Weapon Check & Change script
Post by: The Ghost on May 27, 2015, 10:23:52 AM
IT works just fine.
Just not sure if we can posted where the original build is.