setpcblock script command (#4052)

* Added setpcblock and getpcblock script commands.
'setpcblock' command prevents/allows the player from doing the given type of action.
'getpcblock' command return the bit-mask value of the currently enabled block flags.

The available type are:
	PCBLOCK_MOVE
	PCBLOCK_ATTACK
	PCBLOCK_SKILL
	PCBLOCK_USEITEM
	PCBLOCK_CHAT
	PCBLOCK_IMMUNE
	PCBLOCK_SITSTAND
	PCBLOCK_COMMANDS
	PCBLOCK_NPCCLICK
	PCBLOCK_EMOTION
	PCBLOCK_ALL

Thanks to @sigtus, @secretdataz, @Lemongrass3110 and @aleos89 for the help and reviews !
Credit to https://github.com/HerculesWS/Hercules/pull/842 for the idea.
This commit is contained in:
Atemo
2019-03-31 18:28:55 +02:00
committed by GitHub
parent cad9678aa6
commit 7dde174c83
14 changed files with 176 additions and 19 deletions

View File

@@ -17245,6 +17245,32 @@ BUILDIN_FUNC(pcblockskill)
return SCRIPT_CMD_SUCCESS;
}
BUILDIN_FUNC(setpcblock)
{
TBL_PC *sd;
if (script_mapid2sd(4, sd)) {
enum e_pcblock_action_flag type = (e_pcblock_action_flag)script_getnum(st, 2);
if (script_getnum(st, 3) > 0)
sd->state.block_action |= type;
else
sd->state.block_action &= ~type;
}
return SCRIPT_CMD_SUCCESS;
}
BUILDIN_FUNC(getpcblock)
{
TBL_PC *sd;
if (script_mapid2sd(2, sd))
script_pushint(st, sd->state.block_action);
else
script_pushint(st, 0);
return SCRIPT_CMD_SUCCESS;
}
BUILDIN_FUNC(pcfollow)
{
TBL_PC *sd;
@@ -24505,6 +24531,8 @@ struct script_function buildin_func[] = {
BUILDIN_DEF2(pcblockmove,"unitblockmove","ii"),
BUILDIN_DEF(pcblockskill,"ii"),
BUILDIN_DEF2(pcblockskill,"unitblockskill","ii"),
BUILDIN_DEF(setpcblock, "ii?"),
BUILDIN_DEF(getpcblock, "?"),
// <--- [zBuffer] List of player cont commands
// [zBuffer] List of unit control commands --->
BUILDIN_DEF(unitexists,"i"),