SCRMaps
/
Sign in

Shops, and restricting who can buy

Stand on a pad to buy, and the trap that comes with it.

5 min read

A shop is one location and one trigger: if the player's unit is on the pad and they can afford it, take the money and hand over the item.

Trigger {
	players = {Force1},
	conditions = {
		Bring(CurrentPlayer, AtLeast, 1, "Men", "Buy 1");
		Deaths(CurrentPlayer, AtLeast, 500, "Gold");
	},
	actions = {
		SetDeaths(CurrentPlayer, Subtract, 500, "Gold");
		CreateUnit(1, "Terran Marine", "Player Start", CurrentPlayer);
		MoveUnit(All, "Men", CurrentPlayer, "Buy 1", "Shop Exit");
		DisplayText("\x13\x07구매 완료");
		PreserveTrigger();
	},
}

That MoveUnit is the important line. Without pushing the buyer off the pad, the condition is true again next cycle and their money drains away.

Saying nothing when they cannot afford it looks broken. Write the failure case too.

Trigger {
	players = {Force1},
	conditions = {
		Bring(CurrentPlayer, AtLeast, 1, "Men", "Buy 1");
		Deaths(CurrentPlayer, AtMost, 499, "Gold");
	},
	actions = {
		DisplayText("\x13\x06돈이 부족합니다");
		MoveUnit(All, "Men", CurrentPlayer, "Buy 1", "Shop Exit");
		PreserveTrigger();
	},
}

When restricting a shop by class or tier, gate the entrance rather than each item. One check in one place is far easier to change later.

Trigger { -- 자격이 없으면 입구에서 되돌려보낸다
	players = {Force1},
	conditions = {
		Bring(CurrentPlayer, AtLeast, 1, "Men", "Shop Entrance");
		Deaths(CurrentPlayer, AtMost, 9, "Level");
	},
	actions = {
		DisplayText("\x13\x06레벨 10 이상부터 이용할 수 있습니다");
		MoveUnit(All, "Men", CurrentPlayer, "Shop Entrance", "Town");
		PreserveTrigger();
	},
}
Sign in to track your progress