Jump to content
  • 0

Question

Posted

Hello there :)

 

I've been looking for a way to get the gid of a monster when he dies by using the OnNPCDieEvent label but since I'm like really really bad at source stuff none of the things I tried worked out, could you lend me a hand please?

 

I guess I would have to edit this part in the mob.c file :

} else if( mvp_sd && !md->state.npc_killmonster ) {
	pc_setparam(mvp_sd, SP_KILLEDRID, md->mob_id);
	npc_script_event(mvp_sd, NPCE_KILLNPC); // PCKillNPC [Lance]
}

the "killedrid" variable is set to the mob id and I'd like to get its game id, I'd probably name it "killedgid".

 

Thanks in advance  ;)

8 answers to this question

Recommended Posts

  • 0
Posted (edited)

Ahhh, ok I'm an idiot ^^

 

There it goes:

if( md->npc_event[0] && !md->state.npc_killmonster ) {
	if( sd && battle_config.mob_npc_event_type ) {
		++ pc_setglobalreg(sd, add_str("killedgid"), md->bl.id);
		pc_setparam(sd, SP_KILLEDRID, md->mob_id);
		pc_setparam(sd, SP_KILLERRID, sd->bl.id);
		npc_event(sd,md->npc_event,0);
	} else if( mvp_sd ) {
		++ pc_setglobalreg(mvp_sd, add_str("killedgid"), md->bl.id);
		pc_setparam(mvp_sd, SP_KILLEDRID, md->mob_id);
		pc_setparam(mvp_sd, SP_KILLERRID, sd?sd->bl.id:0);
		npc_event(mvp_sd,md->npc_event,0);
	} else
		npc_event_do(md->npc_event);
} else if( mvp_sd && !md->state.npc_killmonster ) {
	++ pc_setglobalreg(mvp_sd, add_str("killedgid"), md->bl.id);
	pc_setparam(mvp_sd, SP_KILLEDRID, md->mob_id);
	npc_script_event(mvp_sd, NPCE_KILLNPC); // PCKillNPC [Lance]
} 

(edited to fit the latest revision)

 

working perfectly.

 

Thanks a lot for this, I'll make good use of that game id  ;)

Edited by Kurofly
  • 0
Posted

Ah nice

} else if( mvp_sd && !md->state.npc_killmonster ) {
	pc_setparam(mvp_sd, SP_KILLEDRID, md->mob_id);
	pc_setglobalreg(mvp_sd, "killedgid", md->bl.id);
	npc_script_event(mvp_sd, NPCE_KILLNPC); // PCKillNPC [Lance]
}

works fine thank you


I just noticed it doesn't work, the variable 'killedgid' is set to a value that corresponds to a game id but that value is different from the one I get from the '$@mobid' var

 

For example when I spawn a mob I get the value 110267231 via the $@mobid variable and I get the value 110157627 via the killedgid variable once I kill it.

  • 0
Posted

No that's not it, even by deleting the array and spawning only one mob I get wrong values.

 

Actually the $@mobid value increments each time a monster is spawned, which is normal..

 

But the killedgid value doesn't increment the way it's supposed to: if I spawn only one monster the value doesn't change and if I spawn a Mvp its value changes but in a weird way, it gains the number of slaves summoned by the Mvp.

 

For example:

  • if I spawn porings the value of 'killedgid' is always the same
  • if I spawn a Moonlight Flower, who summons 3 slaves, I get the value 'killedgid' = n and when I spawn another one the new value is 'killedgid' = n+3

(I'm spawning monsters whith the script commands not via @monster)

 

To me it appears that the 'killedgid' variable is working fine only with Mvp slaves, which is really weird because I placed it in the same place than the 'killerid' in the mob.c file and the 'killedrid' variable is working perfectly fine.

 

also using add_str("killedgid") instead of "killedgid" makes my map-serv crash when one of a Mvp slave dies

  • 0
Posted (edited)

It is (r17726)

 

I'm using this as a test

-	script	vartest	-1,{ // @test <id> will spawn the mob and give you the '$@mobid' and 'killedgid' var upon spawn and death
OnInit:
	bindatcmd "test",strnpcinfo(0)+"::OnTest";
	end;

OnTest:
	deletearray $@mobid; // just to be sure
	getmapxy .@map$,.@x,.@y,0;
	monster .@map$,.@x,.@y,"test",atoi(.@atcmd_parameters$),1,strnpcinfo(0)+"::OnMobDead";
	announce "game id : "+$@mobid,0;
	end;

OnMobDead:
	announce "killedgid : "+killedgid,0;
	end;
}
Edited by Kurofly

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...