You must be logged in to do that.

HookEntityRender

HookEntityRender
void HookEntityRender(int entity, string func)

Documentation

This 'hooks' a function to be called each time a set entity is rendered, instead of blitting the entity automatically. This would generally be during a Render() call when the entity is in the viewable area. As with all hook functions, it requires the string of a function name that requires no passed values, and any return value is ignored. If no function matching the name is found, the hook does nothing. The entity value needed is the int value of their index. This is either set on the map, or returned by EntitySpawn(). Also when within the hooked function, event.entity refers to the currently rendered entity. Remember to manually blit the current entity frame if you want to display the entity as normal - this hook OVERRIDES the normal entity render, rather than coming before or after. Be careful about blitting to to correct x,y coords on the screen.

Example Usage

int e;
// Hook all current map entities to PaperDollRender()
for(e = 0; e < entities; e++)
{
	HookEntityRender(e, "PaperDollRender");
}

void PaperDollRender()
// Give everyone cloaks and moustaches
{
	// Work out the x,y coord of the current entity's hotspot on the screen
	int pdr_xh = entity.x[event.entity] - xwin;
	int pdr_yh = entity.y[event.entity] - ywin;
	// Work out the x,y coord of the top left corner of an entity's tile
	int pdr_xb = pdr_xh - entity.hotx[event.entity];
	int pdr_yb = pdr_yh - entity.hoty[event.entity];
	// Blit the cloak tile UNDER the entity 
	TBlit(pdr_xb, pdr_yb, cloak, screen);
	// Blit the entity's current frame
	BlitEntityFrame(pdr_xh, pdr_yh, event.entity, entity.frame[event.entity], screen);
	// Blit the moustache tile OVER the entity
	TBlit(pdr_xb, pdr_yb, moustache, screen);
}

// Note: In practice, you'd probably want to want to use TGrabRegion() based on the 
// entity.frame[event.entity] value to get a tile that matches with the current frame
// of the entity, but this example is already complicated enough :D
Talkback

There are no talkbacks on this documentation page yet. Post the first?

Post a new comment?

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.