Author Topic: Weapon Check & Change script  (Read 14321 times)

0 Members and 1 Guest are viewing this topic.

Offline Crome969

  • Elite
  • *
  • *
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: Weapon Check & Change script
« Reply #15 on: April 17, 2015, 03:40:16 AM »
0
post what u have and let us do some magic..

Offline KetchupTopic starter

  • Full Member
  • ***
  • Posts: 138
  • Activity:
    0%
  • Reputation Power: 3
  • Ketchup has no influence.
  • Respect: +18
  • Referrals: 0
    • View Profile
Re: Weapon Check & Change script
« Reply #16 on: April 17, 2015, 11:18:39 AM »
0
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?

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • 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: Weapon Check & Change script
« Reply #17 on: April 17, 2015, 11:22:52 AM »
0
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
Please read the ScriptUO site RULES
Come play RIFT with me!

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: Weapon Check & Change script
« Reply #18 on: April 17, 2015, 03:07:38 PM »
0
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
« Last Edit: April 19, 2015, 04:55:10 PM by The Ghost »

Offline KetchupTopic starter

  • Full Member
  • ***
  • Posts: 138
  • Activity:
    0%
  • Reputation Power: 3
  • Ketchup has no influence.
  • Respect: +18
  • Referrals: 0
    • View Profile
Re: Weapon Check & Change script
« Reply #19 on: April 17, 2015, 07:46:05 PM »
0
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

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • 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: Weapon Check & Change script
« Reply #20 on: April 17, 2015, 08:09:58 PM »
0
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:

  • 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

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

Please read the ScriptUO site RULES
Come play RIFT with me!

Offline KetchupTopic starter

  • Full Member
  • ***
  • Posts: 138
  • Activity:
    0%
  • Reputation Power: 3
  • Ketchup has no influence.
  • Respect: +18
  • Referrals: 0
    • View Profile
Re: Weapon Check & Change script
« Reply #21 on: April 17, 2015, 09:05:24 PM »
0
then how would I go about re-arming a full/higher durability wep?

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • 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: Weapon Check & Change script
« Reply #22 on: April 17, 2015, 09:12:29 PM »
0
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!

Please read the ScriptUO site RULES
Come play RIFT with me!

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: Weapon Check & Change script
« Reply #23 on: April 18, 2015, 03:56:47 AM »
0
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

Offline KetchupTopic starter

  • Full Member
  • ***
  • Posts: 138
  • Activity:
    0%
  • Reputation Power: 3
  • Ketchup has no influence.
  • Respect: +18
  • Referrals: 0
    • View Profile
Re: Weapon Check & Change script
« Reply #24 on: April 18, 2015, 03:58:52 AM »
0
okay thanks for your time guys, I'll give this a try later tonight, see if I can get some ideas flowing

Offline KetchupTopic starter

  • Full Member
  • ***
  • Posts: 138
  • Activity:
    0%
  • Reputation Power: 3
  • Ketchup has no influence.
  • Respect: +18
  • Referrals: 0
    • View Profile
Re: Weapon Check & Change script
« Reply #25 on: April 18, 2015, 05:29:38 PM »
0
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
;=========

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: Weapon Check & Change script
« Reply #26 on: April 18, 2015, 08:06:17 PM »
0
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
« Last Edit: April 19, 2015, 04:08:14 AM by The Ghost »

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: Weapon Check & Change script
« Reply #27 on: April 20, 2015, 10:05:56 AM »
0
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
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 KetchupTopic starter

  • Full Member
  • ***
  • Posts: 138
  • Activity:
    0%
  • Reputation Power: 3
  • Ketchup has no influence.
  • Respect: +18
  • Referrals: 0
    • View Profile
Re: Weapon Check & Change script
« Reply #28 on: April 20, 2015, 02:32:29 PM »
0
thanks manwinc!!!!

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: Weapon Check & Change script
« Reply #29 on: April 20, 2015, 05:44:24 PM »
0
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.
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"

Tags: