[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  I need a snippet, exp gain per connected player

I need a snippet, exp gain per connected player

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Zunit1920   (10 posts)  [Biography] bio
Date Sun 11 Dec 2005 07:39 PM (UTC)
Message
I need a snippet of some sort...
I need it to do this:

I wish the increase exp gained .1% for every level of every connected player currently connected.

Example:

3 players connected

Level 3 Human Test1
Level 4 Human Test2
Level 2 Human Test3

Exp Increased by : 1.90%

If someone could help me i would be very happy coder cuz i tried and it didnt work.
I believe it goes in update.c (void gain_exp)

by the way, im running a smaug1.4a dirived MUD.

Thanks, U can ether post the snippet here or email it to me at zunit1920@yahoo.com


Ive tried this...

for( wch = first_char; wch; wch = wch->next)
{
wch_next = wch->next;

if(!IS_NPC(wch))
{
if(!IS_IMMORTAL(wch))
{
iexp += wch->level / 10;
}
}

if(iexp > 15)
{
iexp = 15;
break;
}
}

modgain += (modgain / iexp) + modgain;
[Go to top] top

Posted by Mopop   (115 posts)  [Biography] bio
Date Reply #1 on Sun 11 Dec 2005 07:55 PM (UTC)
Message
I doubt anyone will write it for you, what happened why didnt it work? What kinda errors did you get did you get a core file?
[Go to top] top

Posted by Samson   USA  (683 posts)  [Biography] bio
Date Reply #2 on Sun 11 Dec 2005 08:10 PM (UTC)
Message
Do you want this increased by 0.1%, by 1%, or by 10% ?

Your function is taking the level, dividing it by 10, and using that as your result. Dividing by 10 is 10% of the value. As in 100/10 = 10, 10 is 10% of 100.

What you wrote does not look like it would fail, though it's somewhat inefficient if you only want the bonus to be based on how many live players are logged on. You're looping the entire charlist, when looping the descriptor list would be far less resource intensive.
[Go to top] top

Posted by Zunit1920   (10 posts)  [Biography] bio
Date Reply #3 on Sun 11 Dec 2005 08:20 PM (UTC)
Message
1) I want it increased by .1%
2) Im getting this error update.c:425: warning: `iexp' might be used uninitialized in this function

I seriously cant get it to work... n its really frustrating

I really hate that error cuz it doesnt help me at all :P

line 425 is int iexp;
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #4 on Sun 11 Dec 2005 08:27 PM (UTC)
Message
Do something like this:
int iexp=0;

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Zunit1920   (10 posts)  [Biography] bio
Date Reply #5 on Sun 11 Dec 2005 08:41 PM (UTC)
Message
Ok that fixed the error

And a couple more things

1)Exp Increased by : 0.000000% thats on the who list...
the code looks like this:
sprintf(buf, "Exp Increased by : %f%% &R(currently disabled)&D",iexp);

Thats the first problem the second problem is

2) <Life(100) Mana(124) Exp(414/414)>
You jolt Test1. [6]
You gain 6 exp.

<Life(100) Mana(124) Exp(435/421)>
You decimate Test. [26]
You gain 14 exp.
You jump over Test1's attack. [0]

<Life(100) Mana(124) Exp(479/435)>
You decimate Test1. [27]
You gain 15 exp.

Im gaining 2x what im supposed to and its not raising current exp (base-exp/current exp)

the current is gaining what it should the base is gaining like 2x what it should
[Go to top] top

Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Reply #6 on Sun 11 Dec 2005 08:53 PM (UTC)
Message
1)Exp Increased by : 0.000000% thats on the who list...
the code looks like this:
sprintf(buf, "Exp Increased by : %f%% &R(currently disabled)&D",iexp);

This is because do_who does not know the value of iexp. You would have to make iexp a global variable so that all functions can use its value and not one thats local to the gain_exp function (or whatever its called).

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
[Go to top] top

Posted by Zunit1920   (10 posts)  [Biography] bio
Date Reply #7 on Sun 11 Dec 2005 08:55 PM (UTC)
Message
How would i go about doing that???

Sry im not extremly experienced with all of this
[Go to top] top

Posted by Samson   USA  (683 posts)  [Biography] bio
Date Reply #8 on Sun 11 Dec 2005 10:17 PM (UTC)
Message
You will not get good results at 0.1% by using integers. You would have to take the level and divide by 1000 to acheive this. Or multiply the level by 0.1, either way.

The problem is the value you are working with is an integer and C code rounds integers to the nearest whole number. So you would either need to change everything you're working with to floats ( not good ) or use temp variables to multiply the values by 1000, do your stuff, then return the final value back to normal. I suspect with such a small percentage desired that neither method will end up working out very well.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


21,558 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]