I want to have a party member where any move commands, player issued or otherwise, will be instantly cancelled.
I was looking at EVENT_TYPE_COMMAND_PENDING, but this seems to just be for attacks and I'm not even sure it goes through the creature script on its way to rules_core.
Preventing the player from issuing move commands
Débuté par
FergusM
, août 21 2010 01:06
#1
Posté 21 août 2010 - 01:06
#2
Posté 24 août 2010 - 09:26
If you give the party member a static command, he will ignore other orders while it is executing. That's not quite the same thing as cancelling them, but it may work for you. You could give a wait command to the party member, and for the duration they won't be able to be ordered around.
If you want the party member to still be able to execute AI orders, that's a little tougher. If you just be sure to assign all commands as static, and when they are doing anything use a short wait command that might do what you want. You'd need a robust custom ai/command complete script.
There may be a way to intercept the commands after they have been issued, but it's not something I've explored.
If you want the party member to still be able to execute AI orders, that's a little tougher. If you just be sure to assign all commands as static, and when they are doing anything use a short wait command that might do what you want. You'd need a robust custom ai/command complete script.
There may be a way to intercept the commands after they have been issued, but it's not something I've explored.
#3
Posté 24 août 2010 - 11:15
Okay, I've tried two ways of doing this and have not been successful.
First was this:
case EVENT_TYPE_PLAYER_COMMAND_ADDED:
{
command added = GetCommandByIndex(OBJECT_SELF,GetCommandQueueSize(OBJECT_SELF) - 1);
//get last command in queue
if (GetCommandType(added) == COMMAND_TYPE_USE_ABILITY)
{
//Do nothing, or possibly clear queue
}
else
{
PrintToLog("Not a move command.");
command wait = CommandWait(0.5);
AddCommand(OBJECT_SELF,wait,TRUE,TRUE);
//ClearAllCommands(OBJECT_SELF,TRUE)
}
break;
}
case EVENT_TYPE_COMMAND_COMPLETE:
{
ClearAllCommands(OBJECT_SELF,TRUE);
}
Basically the problem is that the wait commands get added, but then after they're finished the movement plays anyway. My understanding is that the current command is not in the command queue -- my hope was to push the wait command to the front, and then later clear out the command queue (which would just have the move command). However, doing this clear when the command finishes doesn't work, and as you can see commented out, even putting it right in 'player command added' has no noticeable effect, despite being a hard clear.
The other problem with this is that I think I'm checking if the command is an ability, but it fires the script for ability commands as well (even when in range etc).
My second approach was to use really long wait commands, but call ClearCurrentCommand() when an ability command was added. Unfortunately, ClearAllCommands doesn't appear to clear static commands being executed and there's no parameter for that.
By the way, I'm basically trying to restrict the character's action to using only abilities.
If there's no way to get this working, at least I can just apply a slow effect to them. It means they can turn weirdly but it's functional.
First was this:
case EVENT_TYPE_PLAYER_COMMAND_ADDED:
{
command added = GetCommandByIndex(OBJECT_SELF,GetCommandQueueSize(OBJECT_SELF) - 1);
//get last command in queue
if (GetCommandType(added) == COMMAND_TYPE_USE_ABILITY)
{
//Do nothing, or possibly clear queue
}
else
{
PrintToLog("Not a move command.");
command wait = CommandWait(0.5);
AddCommand(OBJECT_SELF,wait,TRUE,TRUE);
//ClearAllCommands(OBJECT_SELF,TRUE)
}
break;
}
case EVENT_TYPE_COMMAND_COMPLETE:
{
ClearAllCommands(OBJECT_SELF,TRUE);
}
Basically the problem is that the wait commands get added, but then after they're finished the movement plays anyway. My understanding is that the current command is not in the command queue -- my hope was to push the wait command to the front, and then later clear out the command queue (which would just have the move command). However, doing this clear when the command finishes doesn't work, and as you can see commented out, even putting it right in 'player command added' has no noticeable effect, despite being a hard clear.
The other problem with this is that I think I'm checking if the command is an ability, but it fires the script for ability commands as well (even when in range etc).
My second approach was to use really long wait commands, but call ClearCurrentCommand() when an ability command was added. Unfortunately, ClearAllCommands doesn't appear to clear static commands being executed and there's no parameter for that.
By the way, I'm basically trying to restrict the character's action to using only abilities.
If there's no way to get this working, at least I can just apply a slow effect to them. It means they can turn weirdly but it's functional.
#4
Posté 08 octobre 2010 - 02:21
In event COMMAND_ADDED you can use the ClearCurrentCommand() function.





Retour en haut






