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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Einder
Novice


Joined: 03 Jan 2008
Posts: 48

PostPosted: Tue Dec 27, 2011 6:00 am   

random quest script help
 
I am trying to figure out how to evaluate the next percent and the quests needed to reach that next percent. So far I have the following:

Code:
#CLASS {RQE}
#VAR nquests {}
#VAR perc {%concat( %eval( %1*100/%2), ".", %mod( %1*1000000/%2, 10000), "%")}
#VAR rqerate {@perc( @rqesolved, @rqe)}
#VAR rqesolved {1900}
#VAR rqe {2235}
#TRIGGER {You finished (%d) random quests, failed (%d) and abandoned (%d) of them.} {
  rqesolved = %1
  rqe = %eval( %1+%2+%3)
  #SAY Your RQE Completion Rate is @rqerate~. You need @nquests quests to reach @nextperc~.
 }
#CLASS 0


I've tried using a %eval and I've tried using #while, however I'm unable to get either one to work. All help for this is much appreciated.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Tue Dec 27, 2011 7:45 am   
 
#MATH perc (%1*100.0/%2)
_________________
Discord: Shalimarwildcat
Reply with quote
Einder
Novice


Joined: 03 Jan 2008
Posts: 48

PostPosted: Tue Dec 27, 2011 6:55 pm   
 
My percent completed track is working just fine, and I've got the piece of code for the next whole percent, the trouble I'm having now is tracking the number of quests needed to get to that next percent, what I have so far is:

Code:
#CLASS {RQE}
#ALIAS Locate {#mapquery (%concat( "[Name] = '", %replace( "%-1", "'", "''"), "'"))}
#VAR perc {%concat( %eval( %1*100/%2), ".", %mod( %1*1000000/%2, 10000), "%")}
#VAR rqerate {@perc( @rqesolved, @rqe)}
#VAR rqesolved {1902}
#VAR rqe {2237}
#VAR nrate {%eval( %int( @rqerate)+1)%}
#VAR nquests {}
#TRIGGER {^You finished (%d) random quests, failed (%d) and abandoned (%d) of them.$} {
  rqesolved = %1
  rqe = %eval( %1+%2+%3)
  #ECHO %ansi( grey)Your RQE Completion Rate is @rqerate~. You need @nquests quests to reach @nrate~.
  }
#CLASS 0


I've tried a number of different things, but I'm unable to obtain a relevant amount of quests needed to reach that next percent. I'm not off by only 5 or so, I keep ending up off by hundreds, sometimes even thousands.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Wed Dec 28, 2011 1:01 pm   
 
my bad, i misunderstood, try this?

Change your perc function value to
Code:
%eval( %1*100.0/%2)
you still get the same decimal value, but without the % the number can be tested against

Then add this to your trigger

Code:
nquests=0
#WHILE (%eval( (%1+@nquests)*100.0/(%2+@nquests))<%eval( %int( @rqerate)+1)) {nquests=%eval( @nquests+1)}
_________________
Discord: Shalimarwildcat
Reply with quote
Einder
Novice


Joined: 03 Jan 2008
Posts: 48

PostPosted: Thu Dec 29, 2011 7:36 pm   
 
hmm, your way worked but was rather slow, found a way to do it using math though which is much quicker, ty for your help
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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