Jump to content
  • 0

HELP > adding "addrid(6)" on source code


Question

Posted (edited)

Good Day everyone,

I don't know if this script does make sense to you guys but I still hope you could help me achieve what I want to do here. What I am trying here is to attach all RIDs of players that are in the damagelog of the killedrid. I am not sure if I am on the right path. I've been learning source coding on different projects and got familiar with it but most of this code kinda strikes me with a lot of confusion about how it works so I can't solve it myself.

Thank you so much, guys.

BUILDIN_FUNC(addrid)
{
	struct s_mapiterator* iter;
	struct block_list *bl;
	TBL_PC *sd;	//IS THIS THE ATTACHED RID OF CHAR? ????
	TBL_MOB* md = (TBL_MOB*)bl; //NEED TO ADD KILLEDRID DATE HERE????
	
	if(st->rid < 1) {
		st->state = END;
		bl = map_id2bl(st->oid);
	} else
		bl = map_id2bl(st->rid); //if run without rid it'd error,also oid if npc, else rid for map
	iter = mapit_getallusers();

	int type = script_getnum(st,2);
	bool forceflag = (script_hasdata(st,3) ? script_getnum(st,3) != 0 : 0);

	switch(type) {
		case 0:
			for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter)) {
				if(!forceflag || !sd->st)
					if(sd->status.account_id != st->rid) //attached player already runs.
						run_script(st->script,st->pos,sd->status.account_id,st->oid);
			}
			break;
		case 1:
			for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter)) {
				if(!forceflag || !sd->st)
					if((sd->bl.m == bl->m) && (sd->status.account_id != st->rid))
						run_script(st->script,st->pos,sd->status.account_id,st->oid);
			}
			break;
		case 2:
			if(script_getnum(st,4) == 0) {
				script_pushint(st,0);
				mapit_free(iter);
				return SCRIPT_CMD_SUCCESS;
			}
			for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter)) {
				if(!forceflag || !sd->st)
					if((sd->status.account_id != st->rid) && (sd->status.party_id == script_getnum(st,4))) //attached player already runs.
						run_script(st->script,st->pos,sd->status.account_id,st->oid);
			}
			break;
		case 3:
			if(script_getnum(st,4) == 0) {
				script_pushint(st,0);
				mapit_free(iter);
				return SCRIPT_CMD_SUCCESS;
			}
			for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter)) {
				if(!forceflag || !sd->st)
					if((sd->status.account_id != st->rid) && (sd->status.guild_id == script_getnum(st,4))) //attached player already runs.
						run_script(st->script,st->pos,sd->status.account_id,st->oid);
			}
			break;
		case 4:
			map_foreachinallarea(buildin_addrid_sub,
			bl->m,script_getnum(st,4),script_getnum(st,5),script_getnum(st,6),script_getnum(st,7),BL_PC,
			st,forceflag);//4-x0 , 5-y0 , 6-x1, 7-y1
			break;
		case 5:
			if (script_getstr(st, 4) == NULL) {
				script_pushint(st, 0);
				mapit_free(iter);
				return SCRIPT_CMD_FAILURE;
			}
			if (map_mapname2mapid(script_getstr(st, 4)) < 0) {
				script_pushint(st, 0);
				mapit_free(iter);
				return SCRIPT_CMD_FAILURE;
			}
			map_foreachinmap(buildin_addrid_sub, map_mapname2mapid(script_getstr(st, 4)), BL_PC, st, script_getnum(st, 3));
			break;
		case 6:		//ADDITION CODE ADD RID OF CHAR IDS IN DAMAGELOG OF THE KILLEDRID
			for (int i = 0; i < DAMAGELOG_SIZE; i++) { 
				map_session_data* sd = map_charid2sd(md->dmglog[i].id);
				run_script(st->script, st->pos, sd->status.account_id, st->oid);
			}
			break;
		default:
			mapit_free(iter);
			if((map_id2sd(type)) == NULL) { // Player not found.
				script_pushint(st,0);
				return SCRIPT_CMD_SUCCESS;
			}
			if(!forceflag || !map_id2sd(type)->st) {
				run_script(st->script,st->pos,type,st->oid);
				script_pushint(st,1);
			}
			return SCRIPT_CMD_SUCCESS;
	}
	mapit_free(iter);
	script_pushint(st,1);
	return SCRIPT_CMD_SUCCESS;
}

 

Edited by namerpus18

7 answers to this question

Recommended Posts

  • 0
Posted
4 hours ago, pajodex said:

how about just letting `getunits` retrieve the data instead then store the information on a variable.

Actually, I already have a script that does that using addrid(4,.@x1-20,.@y1-20,.@x1+20,.@y1+20);    which add rids of all players within the 20cellx20cell area around the mob. I want to filter out the players who did not damage the mob. 

Thank you

  • 0
Posted

better use getunitarea.. add an if the player has not damaged, then do not attach. I don't know which variable are you using but I assume it should be a temp global var.

  • 0
Posted
3 minutes ago, pajodex said:

better use getunitarea.. add an if the player has not damaged, then do not attach. I don't know which variable are you using but I assume it should be a temp global var.

Hi is there a script command to check if RIDs did damage to the monster? 

  • 0
Posted
1 hour ago, pajodex said:

Oh i thought you were already using one. I think there is a src mod where it logs all the damage taken by monster.

That is what i am trying to achieve here. Using below but i cant figure how I can add rid of char id on the array

for (int i = 0; i < DAMAGELOG_SIZE; i++) { 
				map_session_data* sd = map_charid2sd(md->dmglog[i].id);

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...