ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Paulonius on January 26, 2010, 01:43:24 PM

Title: Trouble with Exevent DropPD Command
Post by: Paulonius on January 26, 2010, 01:43:24 PM
So I built a melee trainer that re-equips your weapon, among other things.  Everything else seems to be working as intended, but I am having problems getting the weapon to equip once it breaks.  Here is the code I am using.  Anyone have a suggestion?

Code: [Select]
Event Macro 8 1
Wait 5
Finditem %WeaponType C_ , #CharID
If #FindCnt = 0
   Gosub Equip %WeaponType



Code: [Select]
Sub Equip
Finditem %1 C_ , %Secure
ExEvent Drag #Findid
Wait 10
ExEvent DropPD #CharID
Wait 20
Return
Title: Re: Trouble with Exevent DropPD Command
Post by: Endless Night on January 26, 2010, 01:45:19 PM
make sure your paperdoll is open.   it can be minimized but if must be open.

Also in the equip sub i note you dont have a check to make sure if actually found something to equip.
Title: Re: Trouble with Exevent DropPD Command
Post by: Paulonius on January 26, 2010, 01:47:52 PM
Pretty sure it is open. The "Event Macro 8 1" I dropped in front of the FindItem should open it before it does that check.  I put that in because it wasn't working consistently, but it didn't seem to help.
Title: Re: Trouble with Exevent DropPD Command
Post by: Paulonius on January 26, 2010, 01:50:15 PM
I thought about putting that check in, but it seemed to run fine without it.  Might be a good spot to trouble shoot though...

I have the same script equipping armor and the weapon, but only the weapon seems to be giving me trouble.
Title: Re: Trouble with Exevent DropPD Command
Post by: Paulonius on January 26, 2010, 01:53:23 PM
I am going to see how it runs if I drop the #CharID after the DropPD.  Looks from the documentation like it doesn't need it.
Title: Re: Trouble with Exevent DropPD Command
Post by: Khameleon on January 26, 2010, 01:53:58 PM
hrm.. I was unaware that any of the other ExEvent Drop's worked except for DropC...
Title: Re: Trouble with Exevent DropPD Command
Post by: Paulonius on January 26, 2010, 01:59:05 PM
It definitely works and is smmoooth -- when it doesn't just stop working for me.  I can't tell if its something buggy about doing a finditem in a paperdoll or if its the DropPD command.  When the script starts it chucks a suit of armor and a weapon onto the paperdoll in about four seconds.
Title: Re: Trouble with Exevent DropPD Command
Post by: Endless Night on January 26, 2010, 02:07:16 PM
yes a patch about 4/5months back fixed the drop paperdoll... not that they actually realized they fixed it.
Title: Re: Trouble with Exevent DropPD Command
Post by: manwinc on January 26, 2010, 02:58:34 PM
That Deserves a LOL
Title: Re: Trouble with Exevent DropPD Command
Post by: Paulonius on January 26, 2010, 03:06:35 PM
Now of course the script is working perfectly and I can't reproduce the problem...
Title: Re: Trouble with Exevent DropPD Command
Post by: Paulonius on January 27, 2010, 09:01:11 AM
I believe I have fixed the DropPD problem. I tested it a bunch and it works maybe 50% of the time. I made it more consistent by putting it into a REPEAT. 


Code: [Select]
;==========================================================
Sub EquipWeapon
;event exmsg #charid 3 4 TEST MESSAGE In EquipWeaponSub looking for WeaponType %1
Finditem %1 C_ , #CharID
If #FindCnt = 1
   Return
Finditem %1 C_ , #BackpackID
If #FindCnt >= 1
   {
   ;event exmsg #charid 3 4 TEST MESSAGE Found weapon in backpack, attempting to equip %1
   REPEAT
   ExEvent Drag #Findid
   Wait 20
   ExEvent DropPD
   Wait 20
   Finditem %1 C_ , #CharID
   UNTIL #FindCnt = 1
   Return
   }
Finditem %1 C_ , %Secure
If #FindCnt >= 1
   {
   ;event exmsg #charid 3 4 TEST MESSAGE Found weapon in secure, attempting to equip
   REPEAT
   ExEvent Drag #Findid
   Wait 20
   ExEvent DropPD
   Wait 20
   Finditem %1 C_ , #CharID
   UNTIL #FindCnt = 1
   Return
   }
Display You are out of weapon type %1. Stock more in your secure and restart.
Halt




I am leaving in some of my test lines for now, but the trainer script is almost finished.  http://www.scriptuo.com/index.php?topic=4080.msg33847#msg33847
Title: Re: Trouble with Exevent DropPD Command
Post by: Endless Night on January 27, 2010, 09:12:28 AM
logical errors in your code.
You use findid as the item to equip right logically after issuing a finditem that returns finditem as x ie nothing found.

logical flow .. means if fails on first drag drop will fail on all future ones as well
 executes
 Finditem %1 C_ , #CharID   ; not found #findid is x
 UNTIL #FindCnt = 1
 repeat
   exevent drag #findid    ; <-- findid is still x drags nothing.



Code: [Select]
Sub EquipWeapon
  set !EquipType %1
  Finditem !EquipType C_ , #CharID
  while #findcnt = 0
     {
     Finditem !EquipType C_ , #backpackid
     If #findcnt = 0  
        {
        Display You are out of weapon type %1. Stock more in your secure and restart.
        Halt  ; this is a sad way to end a script imho should be only ONE halt command in the entire script
        }
     set !ToEquip #findid
     ExEvent Drag !ToEquip
     ExEvent DropPD
     Wait 25
     Finditem !EquipType C_ , #CharID
     }
return  
Title: Re: Trouble with Exevent DropPD Command
Post by: Paulonius on January 27, 2010, 09:54:37 AM
Thanks EN, I see what you mean. I think it works because the finditems are working correctly enough that they have overcome the flaw. The key seems to be to attempt the DropPD until it works correctly and I was only doing it once in my earlier version.

I am not super familiar with the "While" command. Based on your post I am guessing that it runs the following bracket until the condition is met.  Nice lesson for me. How about this modification to include the secure check as well as the backpack check?

Code: [Select]
Sub EquipWeapon
  set !EquipType %1
  Finditem !EquipType C_ , #CharID
  while #findcnt = 0
     {
     Finditem !EquipType C_ , #backpackid
     If #findcnt = 0  
        {
          Finditem !EquipType C_ , %Secure
              If #findcnt = 0
                {  
        Display You are out of weapon type %1. Stock more in your secure and restart. You made EN SAD by not making more weapons when you set up the script.
        Halt  ; this is a sad way to end a script imho should be only ONE halt command in the entire script
                 }
        }
     set !ToEquip #findid
     ExEvent Drag !ToEquip
     ExEvent DropPD
     Wait 25
     Finditem !EquipType C_ , #CharID
     }
return



Any suggestions for what I do when I hit this dead end?   maybe a pause instead? I don't want to keep my toons wrestling, chewing up resources for no gain...
Title: Re: Trouble with Exevent DropPD Command
Post by: Paulonius on January 27, 2010, 10:00:37 AM
One more question from looking at your code.  The documentation on EUO suggests a wait is required after the Exevent Drag and before the Exevent DropPD.  The example has a wait 10 after each statement.  Do you generally only use the wait 25 after the drop?

 
Title: Re: Trouble with Exevent DropPD Command
Post by: manwinc on January 27, 2010, 10:03:32 AM
I do believe everything Is Lagg Based. In my experience with all exevent drags and drops THe minimum Time requirement between dragging/Dropping and object, and being able to perform another action is 1s.


So, think you can do it.

Exevent drag #findid
wait 10
exevent droppd
wait 10

or


Exevent Drag #findid
exevent droppd
wait 20

I Wish Event drag worked with Exevent dropc, that would make life so much easier. 
Title: Re: Trouble with Exevent DropPD Command
Post by: manwinc on January 27, 2010, 10:13:48 AM
WELL APPARENTLY IT DOES WORK WITH IT AND ITS AWESOME!!!

Only Problem is it creates a ghost Item on your Cursor that I'm still trying to figure out how to get rid of. Think I have it too!!!!!!!
Title: Re: Trouble with Exevent DropPD Command
Post by: Endless Night on January 27, 2010, 12:11:35 PM
Paulo ... you mods are good.

While loop... examines the condition and then runs the loop if condition = true if false it exits proir to running loop
Its the logical reverse of
Repeat loop .. executes loop and then evaluates condition .. if condition is True it exits.. false it loops.

Wait times on exevent drag drop..
ive seen it done both ways... a post drag delay and a post drop delay.  I think it doesnt really matter which you do as long as the total delay is a min of 20.