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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  I need a snippet, exp gain per connected player
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

I need a snippet, exp gain per connected player

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Zunit1920   (10 posts)  [Biography] bio
Date Sun 11 Dec 2005 07:39 PM (UTC)  quote  ]
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)  quote  ]
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)  quote  ]
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.

SmaugMuds.org: http://www.smaugmuds.org - The Smaug MUDs Community Center

"The past was erased, the erasure was forgotten, the lie became truth." -- George Orwell, 1984
[Go to top] top

Posted by Zunit1920   (10 posts)  [Biography] bio
Date Reply #3 on Sun 11 Dec 2005 08:20 PM (UTC)  quote  ]
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   Moderator
Date Reply #4 on Sun 11 Dec 2005 08:27 PM (UTC)  quote  ]
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)  quote  ]
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)  quote  ]
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)  quote  ]
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)  quote  ]
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.

SmaugMuds.org: http://www.smaugmuds.org - The Smaug MUDs Community Center

"The past was erased, the erasure was forgotten, the lie became truth." -- George Orwell, 1984
[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.


3,372 views.

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [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.

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Web site powered by FutureQuest.Net]