Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ ROM
➜ Running the server
➜ Player Kill/Death Mob Kill/Death Count in score <<problem>>
Player Kill/Death Mob Kill/Death Count in score <<problem>>
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Krypt
(9 posts) Bio
|
Date
| Mon 06 Feb 2006 11:17 PM (UTC) |
Message
| Hi I am quite new to coding and am still learning.So this will likely be rather newbie'ish.
I recently tried adding a pretty basic snippet to add player kills, player deaths, and mob kills/deaths to a players score. I even added this info to the players report command, which works perfectly.
My problem is that the kill count seems to only count and work if a weapon lands the kill on a player. If a spell is used you are okay so long as the spell itself did not land the final killing blow. That has to be done by a weapon for the score count to show/be added. I Tried fixing this myself but like i said I'm still learning and new to this.
the snippet I used changed act_info.c , fight.c, save.c, and merc.h.
my fight.c looks like
In file fight.c
function:
bool damage (CHAR_DATA * ch, CHAR_DATA * victim, long long int dam, int dt, int dam_type, bool show)
scroll down to the raw_kill.
----> raw_kill( victim );
if (IS_NPC(victim) && !IS_NPC(ch)) ch->mkill++;
if (!IS_NPC(victim) && IS_NPC(ch)) victim->mdeath++;
if (!IS_NPC(victim) && !IS_NPC(ch) && ch != victim)
{
ch->pkill++;
victim->pdeath++;
}
/* dump the flags */
if (ch != victim && !IS_NPC(ch) && !is_same_clan(ch,victim))
{
any help or advice be appreciated. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #1 on Tue 07 Feb 2006 12:14 AM (UTC) |
Message
| What kinds of spells fail?
I'm looking through the code and it appears that SMAUG spells also call damage. Basically, anything that does its damage by calling 'damage' should work... So which spells are failing? |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Krypt
(9 posts) Bio
|
Date
| Reply #2 on Tue 07 Feb 2006 04:39 AM (UTC) |
Message
| the spells that "fail" are those from the attack or combat group etc.
If I use magic missile or harm or chilling touch etc they kill the player and do what they should etc, but for some reason a kill count isnt being registered. Yet if a warrior kills the mob or player the count is registered as is for thief type chars. It's just my spellcasters, unless they happen to land a killing blow with their weapon they arent getting credit for the kill.
this is the snippet i used...
You only need to change four files: act_info.c, save.c, fight.c, merc.h
// act_info.c -> do_score
+ if (!IS_NPC(ch))
+ {
+ sprintf(buf, "Mob Kills: %4d. Mob Deaths: %4d.\n\r",
+ ch->mkill, ch->mdeath);
+ send_to_char(buf, ch);
+ sprintf(buf, "Player Kills: %4d. Player Deaths: %4d.\n\r",
+ ch->pkill, ch->pdeath);
+ send_to_char(buf, ch);
+ }
// fight.c -> raw_kill
In file fight.c
function:
bool damage (CHAR_DATA * ch, CHAR_DATA * victim, long long int dam, int dt, int dam_type, bool show)
scroll down to the raw_kill.
raw_kill (victim);
if (IS_NPC(victim) && !IS_NPC(ch)) ch->mkill++;
if (!IS_NPC(victim) && IS_NPC(ch)) victim->mdeath++;
if (!IS_NPC(victim) && !IS_NPC(ch) && ch != victim)
{
ch->pkill++;
victim->pdeath++;
}
// save.c
+ fprintf( fp, "PkPdMkMd %d %d %d %d\n",
+ ch->pkill, ch->pdeath, ch->mkill, ch->mdeath );
fprintf( fp, "HMV %d %d %d %d %d %d\n",
// down more in save.c
ch->pcdata->condition[COND_HUNGER] = 48;
+ ch->pkill = 0;
+ ch->pdeath = 0;
+ ch->mkill = 0;
+ ch->mdeath = 0;
// down even more in save.c
KEY( "Prac", ch->practice, fread_number( fp ) );
+ if ( !str_cmp( word, "PkPdMkMd" ) )
+ {
+ ch->pkill = fread_number( fp );
+ ch->pdeath = fread_number( fp );
+ ch->mkill = fread_number( fp );
+ ch->mdeath = fread_number( fp );
+ fMatch = TRUE;
+ break;
+ }
// merc.h -> struct char_data
int wait;
int daze;
+ int pkill;
+ int pdeath;
+ int mkill;
+ int mdeath;
| Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #3 on Tue 07 Feb 2006 05:23 AM (UTC) |
Message
| I'm not sure why it's not working. What does spell_magic_missile do? Does it call the damage function, or does it do something else?
Also -- I'm looking at this snippet I found with Google:
http://www.mudmagic.com/codes/dl/1241
It says to put the code into raw_kill, not damage. But I'm not sure if it's a snippet for the same code base, since your code base has raw_kill(victim) whereas this one has raw_kill(ch, victim). |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Samson
USA (683 posts) Bio
|
Date
| Reply #4 on Tue 07 Feb 2006 12:02 PM (UTC) |
Message
| As far as I can see, if it's moved to raw_kill where the snippet calls for that section to go, it should work fine. And as an aside, stock Rom only passes *victim to raw_kill. | Top |
|
Posted by
| Krypt
(9 posts) Bio
|
Date
| Reply #5 on Tue 07 Feb 2006 07:23 PM (UTC) |
Message
| Thanks for your help it turns out I made a rather silly mistake. The code and snippet all works as it should.
I took your advice and looked at the code for all the various types of spells that were failing and yes they all call the damage function. Sort of :)(I need to pay more attention)
They all call damage_old, not damage which is where I had dropped the snippet. So only my skills were being rewarded. So I copy'n pasted to damage_old as well and it all works now. My bad, like I said I'm a newbie Lol
next mission now is to make it so all players see the same message Imms do when a player dies, by whom, and room.
thanks for your help
was much appreciated. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #6 on Tue 07 Feb 2006 07:46 PM (UTC) |
Message
| I'm glad to hear that you solved your problem!
Quote: next mission now is to make it so all players see the same message Imms do when a player dies, by whom, and room. You might want to check out the messages that announce reboots. I think they use act with flag ACT_ALL or something like that. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | 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,992 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top