Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Loftaris
Adept


Joined: 24 Aug 2004
Posts: 277

PostPosted: Fri Feb 20, 2009 12:57 pm   

Could anyone assist me with this script please?
 
I built a trigger a long time ago to calculate an average gxp gain over a period of 10 rounds, and 70 rounds. The trigger is quite messy, but it doesn't really suit my needs any longer. I need to be able to lengthen it or shorten it sometimes(not too often), but the way I have it set up right now, it takes alot of time to do that. Does anyone have a better suggestion as to how I can accomplish this. Perhaps a little cleaner? I'll paste my script below.


<trigger priority="8420" trigontrig="false" id="6262">
<pattern>~[G2N:(%d)~((%d)~%~)~|RC:(%d)~]</pattern>
<value>#math div (@div+1)
#var aa @bb
#var bb @cc
#var cc @dd
#var dd @ee
#var ee @ff
#var ff @gg
#var gg @hh
#var hh @ii
#var ii @jj
#var jj @kk
#var kk @ll
#var ll @mm
#var mm @nn
#var nn @oo
#var oo @pp
#var pp @qq
#var qq @rr
#var rr @ss
#var ss @tt
#var tt @uu
#var uu @vv
#var vv @ww
#var ww @xx
#var xx @yy
#var yy @zz
#var zz @a
#var a @b
#var b @c
#var c @d
#var d @e
#var e @f
#var f @g
#var g @h
#var h @i
#var i @j
#var j @k
#var k @l
#var l @m
#var m @n
#var n @o
#var o @p
#var p @q
#var q @r
#var r @s
#var s @t
#var t @u
#var u @v
#var v @w
#var w @x
#var x @y
#var y @z
#var z @rnd1
#var rnd1 @rnd2
#var rnd2 @rnd3
#var rnd3 @rnd4
#var rnd4 @rnd5
#var rnd5 @rnd6
#var rnd6 @rnd7
#var rnd7 @rnd8
#var rnd8 @rnd9
#var rnd9 @rnd10
#var rnd10 @rnd11
#var rnd11 @rnd12
#var rnd12 @rnd13
#var rnd13 @rnd14
#var rnd14 @rnd15
#var rnd15 @rnd16
#var rnd16 @rnd17
#var rnd17 @rnd18
#var rnd18 @rnd19
#var rnd19 @rnd20
#var old1 @new1
#var old2 @new2
#var new1 %1
#var new2 %3
#math x1 (@old1 - @new1)
#math x2 (@new2 - @old2)
#math x3 (@x1+@x2)
#var rnd20 @x3
#math avg ((@rnd11 + @rnd12 + @rnd13 + @rnd14 + @rnd15 + @rnd16 + @rnd17 + @rnd18 + @rnd19 + @rnd20) /10)
#math avg2 ((@aa + @bb + @cc + @dd + @ee + @ff + @gg + @hh + @ii + @jj + @kk + @ll + @mm + @nn + @oo + @pp + @qq + @rr + @ss + @tt + @uu + @vv + @ww + @xx + @yy + @z + @a + @b + @c + @d + @e + @f + @g + @h + @i + @j + @k + @l + @m + @n + @o + @p + @q + @r + @s + @t + @u + @v + @w + @x + @y + @z + @rnd1 + @rnd2 + @rnd3 + @rnd4 + @rnd5 + @rnd6 + @rnd7 + @rnd8 + @rnd9 + @rnd10 + @rnd11 + @rnd12 + @rnd13 + @rnd14 + @rnd15 + @rnd16 + @rnd17 + @rnd18 + @rnd19 + @rnd20) /72)
#math rnds1 %1/@avg
#math rnds2 %1/@avg2</value>
</trigger>



G2N is gxp until next guild level
RC is a secondary gxp
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Feb 20, 2009 3:32 pm   
 
Wow. My first suggestion is to use a stringlist instead of all those separate variables. That way you don't have to change umpteen different variables every time (very inefficient). Use %additem() to add the next number onto the end of the list, and when the list is long enough, use %pop() to remove the oldest one from the beginning of the list. That also makes it easier to change how many you want to keep track of. And you can also use a loop to add up the numbers.
Reply with quote
Loftaris
Adept


Joined: 24 Aug 2004
Posts: 277

PostPosted: Fri Feb 20, 2009 3:38 pm   
 
Hrm, I'll have to read those help files. As you can tell, I'm not the most avid scripter ;) .. Thanks, I'll look into this. I don't suppose you have any examples I can mimic do you?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Feb 20, 2009 4:57 pm   
 
If I understand your code correctly, I think this will do what you need:
Code:

#local $newgxp $largenum $smallnum $sum $start $end $number
$largenum = 72
$smallnum = 10
$newgxp = ((@oldg2n - %1) + (%3 - @oldrc))
#var oldg2n %1
#var oldrc %3
#var gxplist %additem($newgxp, @gxplist)
#while (%numitems(@gxplist) > $largenum) {#call %pop(@gxplist)}
$sum = 0
$end = %numitems(@gxplist)
#if ($smallnum > %numitems(@gxplist)) {
  $start = 1
  $number = $end
} {
  $start = $end - $smallnum
  $number = $smallnum
}
#loop $start,$end {$sum = $sum + %i}
#var avg ($sum / $number)
#var rnds1 (%1 / @avg)
$sum = 0
#forall @gxplist {$sum = $sum + %i}
#var avg2 ($sum / %numitems(@gxplist))
#var rnds2 (%1 / @avg2)

In the above, you could change $largenum and $smallnum to anything you want, without changing the rest of the code. Incremental gxp values are appended to the end of the list @gxplist, and if there are more than $largenum in the list it deletes the oldest values. If there are fewer than $largenum or $smallnum in the list, it correctly averages what values it has.

Since you used global variables everywhere, I couldn't be sure which of the intermediate variables you actually wanted to save. I used local variables for some things, but decided that you might want the values @avg, @avg2, @rnd1, and @rnds2.

I haven't actually run this code, so there could be some bugs, but it should show you how you can use the stringlist to do what you want.
Reply with quote
Loftaris
Adept


Joined: 24 Aug 2004
Posts: 277

PostPosted: Fri Feb 20, 2009 9:23 pm   
 
Thanks Rahab, I kinda see what you did, but I still don't fully understand it. However, after seeing what you wrote and what I wrote, I realize I did it in a very dumb way. But, it's still not working.

Maybe this will make a bit more sense. However, now it feels like I'm begging someone to create me a new script, and if that's the case, feel free to tell no. On that note, this is what is going on.

On my hitpoint bar I have this line.

[G2N:369077(64%)|Rc:4114492]

G2N counts down to 0 and restarts(no need to keep track of the reset)
RC counts up to infinity, and occasionally drops to 0(no need to keep track)

Compiling the script above, it spits out the following line

Gain:0 and 0 = 0 Avg: 73 || 246(would normally have real numbers, but it's spitting out 0's atm)

The first 0 is the decreased amount between rounds 1 and 2
The second 0 is the gain of RC
Third 0 is the combined amount
then average over 10 rounds
and average over X rounds(currently about 70)

After compiling all those numbers, I have another trigger that spits out the numbers for me.(I had to have this second trigger because CMud was spitting out the numbers in the middle of my hpbar as soon as it calculated it.)

The other trigger is as follows.

<trigger priority="8450" trigontrig="false" id="845">
<pattern>~[~> Attacks ~<~]</pattern>
<value>#math ttgl @rnds2*2/60+1
#say Gain:@x1 and @x2 = @x3 Avg: @avg || @avg2
//~(@rnds1~) ~(@rnds2~)(~<@ttgl min)

</value>
</trigger>

Again, thanks for all your help Rahab. I appreciate your time!
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Feb 20, 2009 9:39 pm   
 
ah. So you wanted the @x1, @x2, and @x3 values, which I did not try to create in my script. This can be solved. In my script, replace the line:
Code:
$newgxp = ((@oldg2n - %1) + (%3 - @oldrc))

with:
Code:

#var x1 (@old1 - %1)
#var x2 (%3 - @old2)
#var x3 (@x1+@x2)

and replace the line:
Code:
#var gxplist %additem($newgxp, @gxplist)

with:
Code:
#var gxplist %additem(@x3, @gxplist)

I may not be able to respond further until Sunday or Monday. Good luck!
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Fri Feb 20, 2009 9:52 pm   
 
I sort of combined the 2 different sets of outputs since you weren't really clear on what you want. I could probably make this better if you explained more about the relationship between G2N and Rc.
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger priority="10" case="true" trigontrig="false" stop="true" regex="true" copy="yes">
    <pattern>\[G2N:(\d+)\(\d+%\)\|Rc:(\d+)\] </pattern>
    <value>#ADDITEM G2N {%1}
$G2N=%numitems(@G2N)
#IF ($G2N=71) {#DELNITEM G2N 1;$G2N=($G2N-1)}
#ADDITEM Rc {%2}
$Rc=%numitems(@Rc)
#IF ($Rc=71) {#DELNITEM Rc 1;$Rc=($Rc-1)}
#SAYP {Gain:(%item(@G2N,($G2N-1))-%item(@G2N,$G2N)) and }
#SAYP {(%item(@Rc,$Rc)-%item(@Rc,($Rc-1))) Avg: }
#IF ($G2N<10) {
 #SAY {N/A || N/A}
} {
 $Val=(%item(@G2N,($G2N-10))-%item(@G2N,$G2N))
 $Val=$Val+(%item(@Rc,$Rc)-%item(@Rc,($Rc-10)))
 $Val=$val/10
 #SAYP {$Val || }
 #IF ($G2N<70) {
  #SAY {N/A}
 } {
  $Val=(%item(@G2N,1)-%item(@G2N,$G2N))
  $Val=$Val+(%item(@Rc,$Rc)-%item(@Rc,1))
  $Val=$val/70
  #SAY {$Val}
 }
}</value>
  </trigger>
</cmud>
You may have to adjust the priority some since I put the Stop flag on. I recommend this for all triggers to improve performance.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Loftaris
Adept


Joined: 24 Aug 2004
Posts: 277

PostPosted: Fri Feb 20, 2009 9:53 pm   
 
Editing:

Ok, the x1 and x2 are working. However, avg always spits out 73 no matter what

@gxplist populates and pops just fine, however there's always a blank line #73 .. which would be @avg, but I can't seem to grasp why.
Reply with quote
Loftaris
Adept


Joined: 24 Aug 2004
Posts: 277

PostPosted: Fri Feb 20, 2009 10:08 pm   
 
G2N and RC are basically the same, but split into different categories. One is used to gain levels, the other is used to spend on skills. Aside from that, it's just regular guild experience. During combat, I have the choice of allocating any incremement of 10 from 0 to 100 towards each. so 0 G2N and 100 RC, or 20/80 50/50, etc.

clear as mud?

BTW, Do I just copy/paste what you put into a new event?
Reply with quote
Loftaris
Adept


Joined: 24 Aug 2004
Posts: 277

PostPosted: Fri Feb 20, 2009 10:24 pm   
 
EXCELLENT! Vigilante, you did it. Thank you so much. Thank you too Rahab. I appreciate all your efforts.

Vigilante, I pulled out the SAYP and made global variables so that I could use the old trigger to display the results. The SAYP was breaking up my hpbar.

Again, thanks guys! I totally appreciate all your help!
Reply with quote
Loftaris
Adept


Joined: 24 Aug 2004
Posts: 277

PostPosted: Fri Feb 20, 2009 10:30 pm   
 
Nevermind.. Something in CMud snapped... Started doing funky things. Had to delete a Pueblo folder from System. Strange. My CMud doesn't like me.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net