Voodoo doll

From ZDoom Wiki
Jump to navigation Jump to search

A voodool doll is a vanilla Doom effect that is supported by source ports, including ZDoom. The effect occurs when multiple player starts for the same players are placed in the map editor. When this is done, multiple PlayerPawn actors are created bound to the same PlayerInfo struct. The player can only directly control the first PlayerPawned spawned for them, while the other PlayerPawn actors will be the voodoo dolls.

Damage and health are transferred between the voodoo dolls and the original PlayerPawn actor. When a voodoo doll receives an inventory item, that item is given to the original PlayerPawn instead.

Voodoo dolls have been commonly used in older map formats (including vanilla) to create various effects. They're described in more detail on the DoomWikiLogoIcon.pngDoom Wiki.

Scripting concerns

Voodoo dolls pose certain concerns in ZScript. When performing operations on PlayerPawn actors, voodoo dolls will be included in the list of those actors and can cause certain scripts to not function correctly, if not accounted for. For example:

  • PlayerSpawned() event is triggered for all PlayerPawn actors, including voodoo dolls.
  • PostBeginplay() of a PlayerPawn will be called for each voodoo doll present on the map for the same player. For example, if this override is used to give the PlayerPawn some items, they'll be given multiple times for each of the PlayerPawns.

Checking for voodoo dolls

ZScript can check if a specific PlayerPawn is a voodoo doll by accessing its PlayerInfo struct, and then checking if the mo pointer of that struct is pointing to the specified PlayerPawn. As such, it's possible to use a simple static function to run the check:

static bool IsVoodooDoll(PlayerPawn mo) 
{
	return !mo.player || !mo.player.mo || mo.player.mo != mo;
}

This will return true if the PlayerPawn instance provided in the function's first argument is a voodoo doll.