Please check out A Merging of Fates !

Member Discussions

terms



[Previous] [Next] [Post] [Reply] [Topics] [Summary] [Search]


1. Adding Percentage multiplyer Fri Jun 25, 2004 [2:10 AM]
crater
craterburnsyou@verizon.net
member since: May 22, 2003
Reply
Ok, im currently adding in a bounus multiplyer for characters that reach a certain platue. The command is going to be hioigatti but i what i want to know is if there is a way i can make it so instead of me having to write out lines of code for each % they will have, if i can put in one formula to do them all, and how i would go about doing that. Thanks in advance for any help posted.

(Comment added by crater on Fri Jun 25 3:12:49 2004)

The Code is Circlemud BTW.

(Comment added by crater on Fri Jun 25 3:13:24 2004)

command is hioigatti %

(Comment added by crater on Fri Jun 25 3:13:36 2004)

command is hioigatti %


2. RE: Adding Percentage multiplyer Fri Jun 25, 2004 [2:27 AM]
KrayzieK
krayziek@mchsi.com
member since: Mar 10, 2004
In Reply To
Reply
I'm not sure I understand if you could elaborate further I may be able to help.


3. RE: Adding Percentage multiplyer Fri Jun 25, 2004 [2:28 AM]
sarix2
Email not supplied
member since: Mar 3, 2002
In Reply To
Reply
Hrm maybe it's just me but i'm a little confused at what your trying to acompished... Maybe a little more detail?
Realms of the Forgotten
www.rotf.net


4. RE: Adding Percentage multiplyer Fri Jun 25, 2004 [6:42 PM]
crater
Email not supplied
member since: May 22, 2003
In Reply To
Reply
Ok, i will reword it. I want a command that will boost stats based on a formula so that i dont have to set up code for each of the 100%'s they could type in, the command they type will be hyoigatti 100% for example for the highest multiplyer to their stats, but i dont know how exactly to code it to work without me type a formula for every since % they could type.

for example i dont want to have to go through and type if get arg, "1" does this and then if get arg "2" does this. I want something that will take whatever they type in as a percentage and make them get that much of a boost in stats.


5. RE: Adding Percentage multiplyer Fri Jun 25, 2004 [7:57 PM]
Marquoz
Email not supplied
member since: Apr 24, 2000
In Reply To
Reply
You would figure out what the maximum bonus would be (100%) and then multiply by the value you put in.

max_value /* 100 % */ * (arg1 / 100); /* Gets percentage */

What this does is simple, lets say that the maximum bonus is 30, but you only want to give them a 60% bonus. You would end up with 30 * (60 / 100) or 30 * .60 which would give the person a bonus of 18. This is easily expandable upon to give you the desired results.


Make sure that you get a numerical value for arg1. Look at act_wiz.c at a few of the other ways to set values on mobs to ensure that you got a numeral. It would also be good to do a google on atoi and is_number (I think that's the right check).
-----
Coder at Aeonian Dreams
dreams.game-host.org 4000


6. RE: Adding Percentage multiplyer Sat Jun 26, 2004 [2:01 AM]
crater
Email not supplied
member since: May 22, 2003
In Reply To
Reply
Thanks alot, thats exactly what i needed. Really appreciate it. System works like a charm.

(Comment added by crater on Sat Jun 26 3:11:18 2004)

Now all i need to do is make somekind of second equasion to see if they are strong enuff to do the percentage before it lets them get the bonuses, and if they arent spitout the little phrase. Any suggestions on that would help, but i think i can do it.


7. RE: Adding Percentage multiplyer Sat Jun 26, 2004 [3:40 AM]
muir
Email not supplied
member since: Sep 14, 2003
In Reply To
Reply
You know, it may be just the late hour, but I have absolutely no clue whatsoever what happened in this thread. Gah.

.


8. RE: Adding Percentage multiplyer Sat Jun 26, 2004 [4:28 AM]
crater
Email not supplied
member since: May 22, 2003
In Reply To
Reply
Ok nother problem, i set it all up the way that seems correct and im still getting invalid lvalue in assingment when i compile.

I added an int percent and did one_argument(argument, arg) and then set up to see if the argument is a number, then did percent = arg but it doesnt assign and later in the equation percent isnt picked up, and if i use arg in the equation by itself i get the compile error invalid operands to binary / when devision happens in the formula. HELP PLEASE! :-D


9. RE: Adding Percentage multiplyer Sat Jun 26, 2004 [4:44 AM]
kristian_s
Email not supplied
member since: Apr 8, 2001
In Reply To
Reply
Been several years since I coded so this might be wrong.(Still enjoy reading these posts when I am bored :p)
But doing a percent = arg will compare the pointers.
You gotta do something like percent = atoi(arg);

*waits for the real coders to correct and flame my ass :)*

-k
Krynn's Peak
Portent.genesismuds.com port 9800
http://www.youtube.com/watch?v=5urK3BLju60


10. RE: Adding Percentage multiplyer Sat Jun 26, 2004 [5:14 AM]
crater
Email not supplied
member since: May 22, 2003
In Reply To
Reply
Yea i have tried atoi(arg) on a few diffrent lines and such, still didnt work.


11. RE: Adding Percentage multiplyer Sat Jun 26, 2004 [6:14 AM]
muir
Email not supplied
member since: Sep 14, 2003
In Reply To
Reply
Post your code. It'll save you the trouble of explaining and us the trouble of guessing.

.


12. RE: Adding Percentage multiplyer Sat Jun 26, 2004 [8:30 AM]
crater
Email not supplied
member since: May 22, 2003
In Reply To
Reply
OK this is the toned down version of the code, removed thing i know arent causing the problem and that have nothing really to do with it that are just for cosmetics. Plus i was fooling with it to get it to work so its kinda edited at theis moment.

ACMD(do_hyoigattai)
{
int percent;
one_argument(argument, arg);

if (!IS_SHAMAN(ch))
{
act("Your not a Shaman!", TRUE, ch, 0, 0, TO_CHAR);
return;
}

if (percent = atoi(arg) && !PRF_FLAGGED(ch, PRF_HYOI)) {
do_say(ch, "&09Hyoi Gattai!!!!", 0, 0);
act("&14You achieve Hyoi Gattai!&00", TRUE, ch, 0, 0, TO_CHAR);
act("&14$n achieves hyoi gattai!&00", TRUE, ch, 0, 0, TO_ROOM);

GET_SPIRITLVL(ch) *= 10*(percent/100);
SET_BIT(PRF_FLAGS(ch), PRF_HYOI);

} else if (PRF_FLAGGED(ch, PRF_HYOI)) {

act("&09You let out a breath, as you let your spirit from your body, ending Hyoi Gattai.&00", TRUE, ch, 0, 0, TO_CHAR);
act("&09$n lets out a breath, as $e lets their spirit escape from $s body, ending Hyoi Gattai.&00", TRUE, ch, 0, 0, TO_ROOM$

GET_SPIRITLVL(ch) /= 10*(percent/100);
REMOVE_BIT(PRF_FLAGS(ch), PRF_HYOI);
}
}
}


13. RE: Adding Percentage multiplyer Sat Jun 26, 2004 [9:05 AM]
Razzer_9
Email not supplied
member since: Mar 5, 2001
In Reply To
Reply
if (percent = atoi(arg) && !PRF_FLAGGED(ch, PRF_HYOI))

A rewrite should be in order:

long percent = strtol(arg, NULL, 10);
if( errno == ERANGE )
{
     act('That is not a valid number', TRUE, ch, 0, 0, TO_CHAR);
     return;
}

if(PRF_FLAGGED(ch, PRF_HYOI)) {
   //Various messages here...

   //Here was a major flaw in your program.
   //You must change the 100 to 100.0
   //Otherwise, you will perform integer division
   //Which is not what you want.
   GET_SPIRITLVL(ch) *= 10*(percent/100.0);
   //The rest of the code...


I hope you can understand what I mean. Note that you have to change the equation in both places which it occurs.


14. RE: Adding Percentage multiplyer Sat Jun 26, 2004 [9:30 AM]
dataw0lf
Email not supplied
member since: Mar 4, 2000
In Reply To
Reply

percent = atoi(arg)

If you are comparing these two, then it should be

percent == atoi(arg)

dataw0lf
Hoover, he was a body remover
I'll give ya a dose
But it'll never come close
To the rage built up inside of me
Fist in the air, in the land of hypocrisy
-Rage Against the Machine 'Wake Up'




[Previous] [Next] [Post] [Reply] [Topics] [Summary] [Search]