News:

For links to other Unlimited Adventures web pages, be sure to check the sticky in the General Discussion board.

Main Menu

Opportuntiy attacks from non-combat-ready combatants - fixed?

Started by Andy123, March 01, 2025, 05:23:28 AM

Previous topic - Next topic

Andy123

I noticed combatants who were supposed to be inactive (sleeping, held etc) were getting opportunity attacks. No amount of tinkering with their condition SA would make them sit still.

First off all, to identify these combatants, let's say they're everyone with the "IsCombatReady" SA returning the value "N". Nothing in the entire SA list actually checks for this, and on it's own all it does is make that combatant not have a turn.

My solution was to add some stuff to the "Competing" SA.
http://www.dianneandpaul.net/UAF/Help/SAGuardingScripts.html#1.Guarding-CanGuard|outline

I'm still a fish out of water messing with these scripts, so my solutions aren't the most elegant and I can't promise they won't break as a much as they fix.

First of all, I added this line to the "FreeAttack-CanFreeAttack" script
$IF ($GET_CHARACTER_SA($AttackerContext(),"IsCombatReady") == "N") {$SET_HOOK_PARAM(5,"-1"); $SET_HOOK_PARAM( 8,"-1");};

It looks like this in the script:
$VAR rangeWpn; $VAR par8;
rangeWpn = $GET_ITEM_SA($GET_CHAR_Ready($AttackerContext(), "WEAPON", 0),"item_CombatAim");
par8 = $GET_HOOK_PARAM(8);
$IF ($GET_CHARACTER_SA($AttackerContext(),"IsCombatReady") == "N") {$SET_HOOK_PARAM(5,"-1"); $SET_HOOK_PARAM( 8,"-1");};
$IF (rangeWpn != "-?-?-"){$RETURN "N";};
$RETURN par8;

From what I can tell it makes sure that characters who aren't combat ready don't have any attacks available to use. I'm not sure if that means PCs who are temporarily not-combat-ready will permanently lose all their attacks. That remains to be tested.

Then I went to the "Guarding-CanGuard" script and added this line:
$IF ($GET_CHARACTER_SA($CombatantContext(),"IsCombatReady") == "N") {$RETURN "N";};

Here it is in the script:
$VAR rangeWpn;
rangeWpn = $GET_ITEM_SA($GET_CHAR_Ready($CombatantContext(), "WEAPON",0),"item_CombatAim");
$IF (rangeWpn != "-?-?-"){$RETURN "N";};
$IF ($GET_CHARACTER_SA($CombatantContext(),"IsCombatReady") == "N"){$RETURN "N";};
$IF ($GET_HOOK_PARAM(5) ==# 2){$RETURN "Y";};

That stopped non-combat-ready baddies taking a shot at PCs, but it didn't stop the game from interrupting the PC's turn as though they did. The game stops your movement, highlights the character you're open to opportunity attacks from, checks if they can attack, and then resolves that attack before letting you finish your turn. In this case you're stopped, the bad guy's icon is highlighted, nothing happens and your icon is highlighted once again with your combat options back on the screen.

I don't know how to make that little interruption not happen.

Anyway, I figured this would be relevant to everyone. Somehow this game has been around for decades with sleeping, held, paralyzed, and even petrified baddies taking shots at passing PCs. Happy to hear everyone's thoughts on how it could be implemented more efficiently or thoroughly.