<aside> ⚠️ Warning: Before beginning this tutorial, you should already be experienced with DECORATE and ACS.

</aside>

When making certain types of projects, it can be highly useful to be able to call a script whenever a certain type of actor spawns or when the player picks up a Circuit Board or Terminator Capsule. Mega Man 8-Bit Deathmatch has a setup that allows you to use ACS to define a scripts to be called in these circumstances.

Adding New Hooks


Adding new hook scripts can be done via two different functions from DTADD.acs, either [AddSpawnFunc](<https://mm8bdm.notion.site/AddSpawnFunc-58042bc1e07b48f1ba8c98268924ddc0>) or [AddArtifactPickupFunc](<https://mm8bdm.notion.site/AddArtifactPickupFunc-f7fc280ac41a446395ccf67fd627b35d>), depending on the situation which you need a hook to be added for.

Let’s imagine that we want to add auto-map icons for weapons, assist items, and buster upgrades, so we’ll want to use AddSpawnFunc to accomplish that. The parameters for this function are as follows:

Parameters

<aside> ⚠️ Note: If defining a spawn function for projectiles to be called on the client-side, you need to call this function in an OPEN CLIENTSIDE script.

</aside>

As you might be able to assume, we’ll want to use the SFT_WEP and SFT_ITEM types, so let’s go ahead and create the spawn functions for those.

#library "AUTOMAP"
#include "zcommon.acs"

#include "DTADD.acs"

script "automap_icons_funcs" OPEN {
	AddSpawnFunc(DTADD_SFT_WEP, "automap_icons_wep");
	AddSpawnFunc(DTADD_SFT_ITEM, "automap_icons_item");
}

script "automap_icons_wep" (void) {
	if(Timer() <= 1) {
		GiveInventory("WeaponIconSpawner",1);
	}
}

script "automap_icons_item" (void) {
	if(Timer() <= 1) {
		GiveInventory("ItemIconSpawner",1);
	}
}

When weapons spawn, they will execute "automap_icons_wep", and when items spawn, they will execute "automap_icons_item". These scripts will execute for the pickup each time they respawn as well, which is why there is a Timer check. These scripts will have the pickup as the activator, so we’ll be giving these inventory items to the pickups when they spawn.

actor WeaponIconSpawner : CustomInventory
{
	States
	{
		Pickup:
			TNT1 A 0 A_SpawnItemEX("WeaponAutomapIcon")
			stop
	}
}

actor ItemIconSpawner : CustomInventory
{
	States
	{
		Pickup:
			TNT1 A 0 A_JumpIf(CheckClass("BaseMM8BDMBusterUpgrade",AAPTR_DEFAULT,true), "BusterSpawn")
			TNT1 A 0 A_JumpIf(CheckClass("BaseMM8BDMUseItem",AAPTR_DEFAULT,true), "AssistSpawn")
			TNT1 A 0 // This is where I'd put my basic ItemAutomapIcon if I had one
			stop
		BusterSpawn:
			TNT1 A 0 A_SpawnItemEX("BusterAutomapIcon")
			stop
		AssistSpawn:
			TNT1 A 0 A_SpawnItemEX("AssistAutomapIcon")
			stop
	}
}

The weapon one is self explanatory, but the item one requires a bit more explaining. The item spawn functions are executed by all types of items, basic pickups, assist items, and buster upgrades. Because of this, any spawn function executed for SFT_ITEM has to make sure it narrows down between those. In this case, we’re only wanting to spawn auto-map icons for buster upgrades and assist items.

The actual actors being spawned from these inventory actors can be seen below.

actor WeaponAutomapIcon : MapMarker
{
	States
	{
		Spawn:
			ATOM A -1
			Stop
	}
}

actor BusterAutomapIcon : MapMarker
{
	States
	{
		Spawn:
			ATOM B -1
			Stop
	}
}

actor AssistAutomapIcon : MapMarker
{
	States
	{
		Spawn:
			ATOM C -1
			Stop
	}
}

With all of this code in place as well as some graphics added, we’ve got a very simple auto-map mod that may be helpful for folks who are new to the game.

A very simple and quick auto-map mod.

A very simple and quick auto-map mod.

Example File


v6b-automapicons-v1a.pk3