ID:138471
 
Is there an easy way to show icons or icon states based on what mob is looking at the map?

For example, I want to create three basic mob icons - one is the player icon, one is all the other players, and another for all the NPCs. Each player will see the same icon from themsleves, the same icon for other players and the same icon for NPCs

Player One looks like a green dot to himself
Player Two looks like a green dot to herself
Player Two looks like a blue dot to player One
Player One looks like a blue dot to player Two
Player One & Player Two see NPCs as a red dot.
NPCs see all players as a red dot
NPCs see all like-NPCs as green dots
NPCs see all unlike-NPCs as blue dots


On 7/23/00 10:19 pm Gabriel wrote:
Is there an easy way to show icons or icon states based on what mob is looking at the map?

For example, I want to create three basic mob icons - one is the player icon, one is all the other players, and another for all the NPCs. Each player will see the same icon from themsleves, the same icon for other players and the same icon for NPCs

Player One looks like a green dot to himself
Player Two looks like a green dot to herself
Player Two looks like a blue dot to player One
Player One looks like a blue dot to player Two
Player One & Player Two see NPCs as a red dot.
NPCs see all players as a red dot
NPCs see all like-NPCs as green dots
NPCs see all unlike-NPCs as blue dots


The easiest way to do this is to make up a list of mobs that see you as green, a list of mobs that see you as blue, a list of mobs that see you as red. Then image() an icon overtop and show it to mobs on that list. When you need to modify mobs in the list, remove them from the list, delete the overlay, and then reoverlay the image() for the mobs in the list again.

Example:
mob
var
red[0]
blue[0]
green[0]
obj/red_image
obj/blue_image
obj/green_image
proc
OverlayGreen()
var/mob/M
del green_image
green_image = new /obj
green_image.icon = 'color.dmi'
green_image.icon_state = "green-dot"
for(M in green)
M << image(green_image,src)
OverlayRed() //etc.
OverlayBlue() //etc.

Then when you move a mob from one of the lists to another, simply call all of the Overlay#Color#() procs and they'll be updated accordingly. Whenever a new player logs in, they add themselves to their green list, add each player to the blue list, and add each NPC to the red list, in addition to adding himself to all respective lists and refreshing those lists. All players will see him as blue, the player will see himself as green, and all NPCs will see him as red (though that is somewhat, er, pointless, because NPCs don't have client screens). For NPCs, you'd simply have to override the proc, checking for mob type and adding to the lists accordingly. Generally, you'd add all PCs to the red list, all similar NPCs to the green list, and all unlike NPCs to the blue list, but like I said, it has no effect because NPCs don't have screens. If you were to possess an NPC, though, all effects would apply... unless BYOND doesn't do a refresh of the client screen when mobs change keys (and thus making all of the images key in to the same reference but the new owner), in which case that would be a feature request on my part.

I do a similar thing in CATs, which instead uses specific lists of players on a team and checks that list to see what color the speech indicator appears when the player talks.

Hey! I wonder if I can force a library for this out of Guy T. =)


In response to Spuzzum (#1)
I do a similar thing in CATs, which instead uses specific lists of players on a team and checks that list to see what color the speech indicator appears when the player talks.

Hey! I wonder if I can force a library for this out of Guy T. =)

Maybe eventually... but right now, I'm pretty deep into making a game and I want to take advantage of the momentum while it lasts! :)