Subscribe to RSS feeds from ScriptUO with this LINK
0 Members and 1 Guest are viewing this topic.
set %spellTimerCW #scntwhile #true{if %spellTimerCW < #scnt ) gosub CWep}sub CWep event macro 15 203 set %spelltimer #scnt + 10 ; 10 is for the time to wait before it recast CW again. wait 5 ; this is to help with FCRreturn
gosub AddAction ConcencrateWeapon 15 203 10;gosub AddAction ActionName event1 event2 timelasts;gosub AddAction ActionName event1 event2 timelasts;gosub AddAction ActionName event1 event2 timelastsset !Count 0Repeat set !Count !Count + 1 if !Count > %TotalActions set !Count 1 if #scnt > %ActionTime . !Count { event macro %ActionEvent1 . !Count %ActionEvent1 . !Count set %ActionTime . !Count %ActionTimeLasts . !Count + #scnt wait 5 }until #charghost = yeshaltgosub AddAction ; ActionSubName event1 event2 wait timelasts if %TotalActions = N/A set %TotalActions 0 set %TotalActions %TotalActions + 1 set %ActionSubName . %TotalActions %1 set %ActionEvent1 . %TotalActions %2 set %ActionEvent2 . %TotalActions %3 set %ActionTimeLasts . %TotalActions %4 set %ActionTime . %TotalActions %ActionTimeLasts . %TotalActions - #scnt ; trigger straight awayreturn
Nice job EN. will you be willing to add a few line of explanation beside each line. I'm trying to understand the next level of coding and having a little bit of problem. Like you use "dot" not sure why?
gosub AddAction ConcencrateWeapon 15 203 10;gosub AddAction ActionName event1 event2 timelasts;gosub AddAction ActionName event1 event2 timelasts;gosub AddAction ActionName event1 event2 timelastsset !Count 0Repeat set !Count !Count + 1 if !Count > %TotalActions set !Count 1 if #scnt > %ActionTime . !Count { event macro %ActionEvent1_ . !Count %ActionEvent2_ . !Count set %ActionTime . !Count %ActionTimeLasts . !Count + #scnt wait 5 }until #charghost = yeshaltgosub AddAction ; ActionSubName event1 event2 wait timelasts if %TotalActions = N/A set %TotalActions 0 set %TotalActions %TotalActions + 1 set %ActionSubName . %TotalActions %1 set %ActionEvent1_ . %TotalActions %2 set %ActionEvent2_ . %TotalActions %3 set %ActionTimeLasts . %TotalActions %4 set %ActionTime . %TotalActions %ActionTimeLasts . %TotalActions - #scnt ; trigger straight awayreturn
gosub AddAction ConcencrateWeapon 15 203 10; SUBS are very usful for repeated actions . in this case i want to create; a list of timers. So using a single sub to add items to the list = less code; and easier to use .. I could have just repeated the contents of the add action sub for each of the lines below;; Every time you call this sub is increates the value of %TotalActions by 1. It then sets the varialbes %ActionSubname1 = %1 etc; Add more timers in the this format... doesnt matter how many you add.;gosub AddAction ActionName event1 event2 timelasts;gosub AddAction ActionName event1 event2 timelasts;gosub AddAction ActionName event1 event2 timelastsset !Count 0 ; I am creating a loop !count moves from 1 to the value in %TotalActionsRepeat set !Count !Count + 1 ; increment the loop count if !Count > %TotalActions set !Count 1 ; If the loop count is greater than the Total number of actions set the count back to 1 ; When Count is 1 we look at the First Action when count is 2 we examine the 2nd action ; ie if count is 1 then %ActionTime . !Count becomes %ActionTime1 ; if count is 37 then %ActionTime . !Count becomes %ActionTime37 if #scnt > %ActionTime . !Count ; If the time is greater than the next action { event macro %ActionEvent1_ . !Count %ActionEvent2_ . !Count ; if !count is 99 then above is event macro %ActionEvent1_99 %ActionEvent2_99 set %ActionTime . !Count %ActionTimeLasts . !Count + #scnt ; if !count is 99 then above is set %ActionTime99 %ActionTimeLasts99 + #scnt }until #charghost = yes ; stop looping when the the player is a ghost.halt ; very important that you halt the script. Good script structure is start/initialize Some-Action-Loop Halt Subs (that contain the bulk of the code).gosub AddAction ; ActionSubName event1 event2 wait timelasts if %TotalActions = N/A ; First time you run the code %totalactions = N/a thierfor set it to 0 so can do math set %TotalActions 0 set %TotalActions %TotalActions + 1 ; Increment the count (First time sub is run =1 2nd time = 2 .. 10th time = 10 etc) set %ActionSubName . %TotalActions %1 ; if %Totalactions = 1 then becomes set %ActionSubName1 %1 set %ActionEvent1_ . %TotalActions %2 ; if %Totalactions = 2 then becomes set %ActionEvent1_2 %2 set %ActionEvent2_ . %TotalActions %3 ; if %Totalactions = x then becomes set %ActionEvent1_x %3 set %ActionTimeLasts . %TotalActions %4 ; as above set %ActionTime . %TotalActions %ActionTimeLasts . %TotalActions - #scnt ; trigger straight away - as above sets the next trigger timereturn
Funny EN, I have something very similar in my champ spawn manager. Again, great minds think alike.
Quote from: TrailMyx on October 25, 2015, 02:50:49 PMFunny EN, I have something very similar in my champ spawn manager. Again, great minds think alike. ooo champ spawn manager... that sounds powerful...