Jump to content
  • 0

Help> viewpoint on mob locations


Question

Posted (edited)

Good Day everyone,
 

I just want your help coz I really can't find my old script where I use this command where it marks on minimap all mobs(mobID) available on the map. I am really not quite sure if I used viewpoint or viewpointmap, I think it was couple months ago where I use that method. I used it on OldGlastHeim instance where I put marker on mobs location on minimap so players can see where to go. So now I need it but can't find the old file 😃



Thank you so much

Edited by namerpus18

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

I didn't test it so there might be slight typos or small bugs, but basically you can do it like this:

-	script	MOB_MARKER	-1,{
	OnInit:
		.map$ = "yourmap";

		bindatcmd("markmobs", strnpcinfo(3) + "::OnMarkMobs");
		bindatcmd("unmarkmobs", strnpcinfo(3) + "::OnUnmarkMobs");
		end;

	function unmark_mobs {
		freeloop(1);
		for(.@i = 0; .@i < getarraysize(.@viewpoints_x); .@i++) {
			viewpoint(2, @viewpoints_x[.@i], @viewpoints_y[.@i], (.@i + 1), 0xFF0000);
		}
		freeloop(0);

		deletearray(@viewpoints_x, getarraysize(@viewpoints_x));
		deletearray(@viewpoints_y, getarraysize(@viewpoints_y));

		return;
	}

	OnMarkMobs:
		if(getarraysize(@viewpoints_x) > 0) {
			unmark_mobs();	
		}

		getmapunits(BL_MOB, .map$, .@mobs);

		freeloop(1);
		for(.@i=0; .@i < getarraysize(.@mobs); .@i++) {
			getunitdata(.@mobs[.@i], .@unit_data);
			viewpoint(1, .@unit_data[UMOB_X], .@unit_data[UMOB_Y], (.@i + 1), 0xFF0000);

			@viewpoints_x[.@i] = .@unit_data[UMOB_X];
			@viewpoints_y[.@i] = .@unit_data[UMOB_Y];
		}
		freeloop(0);
		end;

	OnUnmarkMobs:
		if(getarraysize(@viewpoints_x) > 0) {
			unmark_mobs();	
		}
}

 

Edited by Winterfox
  • Upvote 1
  • 0
Posted
21 hours ago, Winterfox said:

I didn't test it so there might be slight typos or small bugs, but basically you can do it like this:

-	script	MOB_MARKER	-1,{
	OnInit:
		.map$ = "yourmap";

		bindatcmd("markmobs", strnpcinfo(3) + "::OnMarkMobs");
		bindatcmd("unmarkmobs", strnpcinfo(3) + "::OnUnmarkMobs");
		end;

	function unmark_mobs {
		freeloop(1);
		for(.@i = 0; .@i < getarraysize(.@viewpoints_x); .@i++) {
			viewpoint(2, @viewpoints_x[.@i], @viewpoints_y[.@i], (.@i + 1), 0xFF0000);
		}
		freeloop(0);

		deletearray(@viewpoints_x, getarraysize(@viewpoints_x));
		deletearray(@viewpoints_y, getarraysize(@viewpoints_y));

		return;
	}

	OnMarkMobs:
		if(getarraysize(@viewpoints_x) > 0) {
			unmark_mobs();	
		}

		getmapunits(BL_MOB, .map$, .@mobs);

		freeloop(1);
		for(.@i=0; .@i < getarraysize(.@mobs); .@i++) {
			getunitdata(.@mobs[.@i], .@unit_data);
			viewpoint(1, .@unit_data[UMOB_X], .@unit_data[UMOB_Y], (.@i + 1), 0xFF0000);

			@viewpoints_x[.@i] = .@unit_data[UMOB_X];
			@viewpoints_y[.@i] = .@unit_data[UMOB_Y];
		}
		freeloop(0);
		end;

	OnUnmarkMobs:
		if(getarraysize(@viewpoints_x) > 0) {
			unmark_mobs();	
		}
}

 

Thank you ill test this out, I figured out 1 method
I tested it out using @command it works but in script it does not work. I remember i used this before and it worked now i dont know why it wont work

atcommand "@showmobs "+ 1002;

  • 0
Posted (edited)
On 3/18/2024 at 6:53 AM, namerpus18 said:

Thank you ill test this out, I figured out 1 method
I tested it out using @command it works but in script it does not work. I remember i used this before and it worked now i dont know why it wont work

atcommand "@showmobs "+ 1002;

Well, what I posted was an example for you to modify yourself to fit your needs.

If you want to be able to only mark one specific mob on a map by mob id you can do it like this:

-	script	MOB_MARKER	-1,{
	OnInit:
		bindatcmd("markmobs", strnpcinfo(3) + "::OnMarkMobs");
		bindatcmd("unmarkmobs", strnpcinfo(3) + "::OnUnmarkMobs");
		end;

	function delete_viewpoints {
		freeloop(1);
		for(.@i = 0; .@i < getarraysize(@viewpoints_x); .@i++) {
			viewpoint(2, @viewpoints_x[.@i], @viewpoints_y[.@i], (.@i + 1), 0xFF0000);
		}
		freeloop(0);
                                                       
		deletearray(@viewpoints_x, getarraysize(@viewpoints_x));
		deletearray(@viewpoints_y, getarraysize(@viewpoints_y));
	}

	OnMarkMobs:
		if(.@atcmd_numparameters != 1) {
			dispbottom("Usage: @markmobs MobID");
			end;
		}

		.@mob_id = atoi(.@atcmd_parameters$[0]);

		if((.@mob_name$ = strmobinfo(1, .@mob_id)) == "") {
			dispbottom("A mob with the Mob ID " + .@mob_id + " does not exist.");
			end;
		}

		getmapxy(.@map$, .@x, .@y);
		getmapunits(BL_MOB, .@map$, .@mobs);

		if(getarraysize(.@mobs) == 0) {
			dispbottom("There are no mobs on this map.");
			end;
		}
                                                       
		if(getarraysize(@viewpoints_x) > 0) {
			delete_viewpoints();
        }

		freeloop(1);
		for(.@i = 0; .@i < getarraysize(.@mobs); .@i++) {
			if(getunitname(.@mobs[.@i]) != .@mob_name$) {
				continue;
			}

			getunitdata(.@mobs[.@i], .@unit_data);
			.@viewpoint_index = getarraysize(@viewpoints_x);

			viewpoint(1, .@unit_data[UMOB_X], .@unit_data[UMOB_Y], (.@viewpoint_index + 1), 0xFF0000);

			@viewpoints_x[.@viewpoint_index] = .@unit_data[UMOB_X];
			@viewpoints_y[.@viewpoint_index] = .@unit_data[UMOB_Y];
		}
		freeloop(0);

		if(getarraysize(@viewpoints_x) == 0) {
			dispbottom("Mob ID " + .@mob_id + " was not found on the map.");
			end;
		}
		end;

	OnUnmarkMobs:
		if(getarraysize(@viewpoints_x) == 0) end;
		delete_viewpoints();
}

 

Edited by Winterfox
  • Upvote 1

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