ActionAttack

I am assigning an NPC to attack a door, but he’s just standing there.
I set the door as plot, but didn’t change HP or hardness or anything else.
I don’t want NPC to break the door, just “fake” attack it.

void main()
{
	object okev = GetObjectByTag("m107_keverek_01");
	object oDoor = GetObjectByTag("m107_to_m107c");

	AssignCommand(okev, ActionAttack(oDoor));

}

I’m not sure, but maybe you have to make the door hostile if you haven’t already done so.

@THughes281,

Where and how are you calling your script?

I will state the obvious and say ensure you have all tags correct and unique.

Lastly, try …

void main()
{
	object okev = GetObjectByTag("m107_keverek_01");
	object oDoor = GetObjectByTag("m107_to_m107c");


AssignCommand(oKev, ClearAllActions(TRUE));
	AssignCommand(okev, ActionAttack(oDoor));

}
1 Like

@andgalf - The door was hostile originally, by default I believe. And I thought maybe because the creature is hostile too, he wouldn’t attack it, so changed door to Commoner as a test. I’ve tried both Hostile and Commoner on the door, but same result.

@Lance_Botelle script is in the on exit of a trigger, and I’ve put SendMessage calls in there so I do know it’s triggering. Tags are all good and unique.

Also, I tried the ClearAllActions call, as you show, both with FALSE and TRUE, but the keverek does not want to attack the door.

Can creatures generally be made to attack on placeables, or does ActionAttack only work when target is a creature? I tried googling this, but did not find any good results.

Thanks both for your help!

@THughes281

Try it “On Enter”.

Will offer more advise after trying that.

Also have your debug code confirm both the tags being used and the objects being “detected” are “valid” using said tags.

No, it’s fine being used on placeables. here is a snippet of code I use somewhere in one of my own scripts:

void TryRestart(object oArcher);
void TryRestart(object oArcher)
{
	object oInTrigger = GetFirstInPersistentObject(OBJECT_SELF, OBJECT_TYPE_CREATURE);

	if(oInTrigger != OBJECT_INVALID){DelayCommand(3.0, TryRestart(oArcher));}
	
	else
	{
		SetLocalInt(oArcher, "DUMMY", 1);		
		
		object oDummy = GetNearestObjectByTag("alb_dummy_practice", oArcher);
		
		AssignCommand(oArcher, ActionAttack(oDummy, 1));
		
		DeleteLocalInt(oArcher, "STOPRANDOMWALK");
	}
}
1 Like

Make sure the door is in walkable terrain.
Make sure the ‘current hit points’ property of the door is not zero.

2 Likes

@travus A good point. I have that in my own notes! :+1:

1 Like

i think ActionAttack() causes only one attack to happen

1 Like

@Lance_Botelle - I’ll try those suggestions. I’m about to start BBQing though, I’ll have to run through that tonight!

@travus - I remember that thing about setting to environmental, then undoing it and the HP resetting to zero, so I definitely checked and door has HP.
The door can be opened by a PC, and checking the baked, it sure looks like enough room to reach the door and beat it.
Maybe this creature just isn’t in the mood…

oooooh, that’s interesting…

I did a cutscene of a battlefield back in NWN1 and had everybody kungfu fighting but never dying, but I cannot find the module I did it in. That was probably 10+ yrs ago

How do I get people to go through motions of fight, but not really hurting each other?

void SetCombatOverrides( object oCreature, object oTarget, int nOnHandAttacks, int nOffHandAttacks, int nAttackResult, int nMinDamage, int nMaxDamage, int bSuppressBroadcastAOO, int bSuppressMakeAOO, int bIgnoreTargetReaction, int bSuppressFeedbackText );
void ClearCombatOverrides( object oCreature );
2 Likes

@THughes281 How did it go? Did you manage to get it to work?

Yes, it will work!
But now the poor keverek focuses solely on attacking the door, even as I beat him silly with an axe.
Next I need to clear his combat overrides so that creature fights back on person who just attacked him.

SetCombatOverrides(oKev, oDoor, OVERRIDE_ATTACK_RESULT_HIT_SUCCESSFUL, -1,-1,-1,-1,TRUE, TRUE, TRUE, TRUE);
In my case I made the door PLOT, so I don’t care so much about what some of these arguments are, I just want keverek to pound on the door.

One thing, SetCombatOverrides has another parameter in there, it’s between oTarget and nOnHandAttacks and defines how you want the attacks to happen, to hit, to crit, to be parried, etc. I believe it is using OVERRIDE_ATTACK_RESULT* constants. It’s in the description but not in the prototype

void SetCombatOverrides(object oCreature,object oTarget,int nOnHandAttacks,int nOffHandAttacks,int nMinDamage,int nMaxDamage,int bSuppressBroadcastAOO,int bSuppressMakeAOO,int bIgnoreTargetReaction,int bSuppressFeedbackText )