On Tue, 30 Sep 1997, Kareem Glover wrote: > I was reading somewhere about how this mud was having their character > skills based off the name they enter. (in you name lies your true > power). I wanted to add this feature to my mud. I need some ideas on > how to convert a string to get a numeric value. It depends. What do you want the output to be? /* convert a name to an int representing the average ascii value */ int find_power(char *name) { int power = 0, count = 1; char *p = name; for(; *p; p++, power += (int) *p) count++; return(power / count); } /* turn power into a number from 1 to x */ int power_one_to_X(int power, int x) { return(power % x); } /* turn power into a bonus/penalty based on a random number */ void affect_dex_with_power(struct char_data *ch) { ch->real_abils.dex += power_one_to_X(find_power(GET_NAME(ch)), 3) - number(1, 3); } Now you've got a possible bonus/penalty from -3 to +3 dex based on the player's name choice and a random number. Of course, if you want the same bonus with no random chance: /* turn power into a bonus/penalty with no random chance */ void affect_dex_with_power(struct char_data *ch) { ch->real_abils.dex += power_one_to_X(find_power(GET_NAME(ch)), 6) - 3; } Neat idea, but I'd hate to see the syslog spam if players can see the results of their name choice at level 1. Sam +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST