I am trying to make a creature that can not attack or be attacked by the player (or if I can just make the player not be able to attack anything at all that would work too if that can be done).
I made a creature and removed all its scripts, then made this script for the onphysicalattack event:
For some reason though, the script does not fire when I attack. If I change GetLastAttacker to GetFirstPC and stick the script in onDamaged, it works, but even then the player gets at least one attack in.
I thought I remembered that there was some way to do this, but so far I am not having much luck. Can anyone help?
If you just want the creature to ignore attacks, set the Plot flag.
Otherwise, you have to immobilize the PC. EffectCutsceneParalyze applied as a supernatural effect stops the PC from all actions, including melee, ranged fire and spell casting. Despite the name, it works whether you’re in a cutscene or not.
I don’t think there’s any other way, because the creature’s scripts can only react to actual attacks, so one attack will occur no matter what you do there.
If you want to allow PC to move around but prevent it from doing specific actions, you can use a very short-timed pseudo-heartbeat (i.e. 0.1s) to issue CAA when a certain ACTION_* is detected. For instance, you can use this method to prevent combat, although the battlecry voice chat may be sometimes heard.
There are projects in the vault which provide this functionality.
Be advised however that this approach is a resource hog and should be used sparingly - turned on only when needed.