Struggling with a duel [SOLVED]

My brother is currently beta testing my third module. It became apparent that there still was a few bugs that I thought I had fixed (Sigh as usual). It concerns a darn duel that I have discussed here at length on the forums before. Now, I just started a new thread because I thought it would be easier to not have to scroll through everything else discussed about this.

So, I have a duel where one of the companions are supposed to fight 3 NPCs, one at a time. When I played myself I used a ranger. My brother has a fighter as his PC. Even though I have “locked away” the PC behind an invisible wall. Apparently I used only walkmesh triggers in the end, so this just means that the PC can’t move to where the companion is. However, when the duels start sometime the NPC runs towards the PC instead of the companion (which didn’t happen I myself played) and the PC can then hurt the NPC, even though I’ve put a spell of “Dominated” on the PC.

So, my thoughts how to deal with this is:

  1. Try (again) an invisible wall using Collision Box
  2. Maybe one can adjust the perception range of the NPCs so that he doesn’t attack the PC. Or maybe one can make it in the script so that the NPCs attack the companion first and foremost (or maybe just the companion, if that can be done?). Which script do I adjust for this and can anyone help me with the code?

Anyway, I’m SOOOOOOO tired of this f*)&%?+g scene, and that it never works the way it’s intended.

want to package something for me to tinker away at ?

Perhaps but…First off: Thanks for always trying to help, @kevL_s!

I have solved half the issue now, I think. The duel is fought on a platform which you can descend from. However, I managed to rebake and remove a walkmesh helper, so now you can’t, neither the companion nor the NPC, escape the platform. At first I tried with walkmesh cutter, but that screwed up the whole walking mesh thing. Now, the NPC won’t, and can’t, attack the PC.

The one thing that still isn’t solved, and I really thought we had solved this before, is that the PC is, when the fight starts, “Dominated”, has the spell dominated cast on him. Weirdly enough he can still attack with ranged weapons, even though I thought that wouldn’t be possible. I could, but I don’t really want to, use paralyzed on him, and that way I don’t think you can make him attack. The reason being that it looks a bit weird if he is paralyzed, but maybe that’s the only spell one can use to make it seem like he is only watching the duel and not be able to participate. What do you think? Last time we spoke about this I remember trying all sorts of spells but…I remember that I liked Dominated the best, but that doesn’t seem to do the trick anymore. Which spell would be suited that you can by scripting cast on the PC right when the fight starts?

Here’s the code for the OnClientEnter of the area, the way it looks now. I think you, kevL_s and travus helped me with this particular script:

#include "nw_i0_generic"
//#include "x0_i0_petrify"
//#include "x0_i0_assoc"

void SetMortal(object oTarget)
{
	object oFM = GetFirstFactionMember(oTarget, FALSE);

	while (GetIsObjectValid(oFM))
	{	
		SetPlotFlag(oFM, FALSE);
    	SetImmortal(oFM, FALSE);
    	AssignCommand(oFM, SetIsDestroyable(FALSE));
		oFM =  GetNextFactionMember(oTarget, FALSE);
	}
}

void main()
{

	object oPC = GetFirstPC();
	
	SetMortal(oPC);
	
	//SetAssociateState(NW_ASC_MODE_STAND_GROUND, TRUE, oPC);
	AssignCommand(oPC, ClearAllActions());
	effect eFX = EffectDominated();
	
	eFX = SetEffectSpellId(eFX, 9997);
	
	ApplyEffectToObject(DURATION_TYPE_PERMANENT, eFX, oPC);
	//AssignCommand(oPC,ActionWait(30.0f));
	object oWP = GetObjectByTag("pit_pc");
	object oWPt = GetObjectByTag("pit_tai");

	location lWP = GetLocation(oWP);
	
	AssignCommand(oPC,ActionJumpToLocation(lWP));
	object oTaik = GetObjectByTag("taik");
	
	AssignCommand(oTaik, JumpToObject(GetWaypointByTag("pit_tai")));
	SetOwnersControlledCompanion(oPC, oTaik);
	
	object oElvera = GetObjectByTag("elvera");
	object oCelestine = GetObjectByTag("celestine");
	object oLoreen = GetObjectByTag("loreen");
	object oAnto = GetObjectByTag("anto");
	
	
	object oFactionPig = GetObjectByTag("facpigobs");
	
	ChangeFaction(oElvera,oFactionPig);
	ChangeFaction(oCelestine,oFactionPig);
	ChangeFaction(oLoreen,oFactionPig);
	ChangeFaction(oAnto,oFactionPig);
	
	//AssignCommand(oPC, ClearAllActions(TRUE));
	//SetCommandable(FALSE, oPC);  		
	//Petrify(oPC);
	
	object oNPC = GetNearestObjectByTag("thondarion",oFactionPig); 
	
	if(GetIsObjectValid(oNPC))
	{
	ChangeToStandardFaction(oNPC,STANDARD_FACTION_HOSTILE);
	
	SetIsTemporaryEnemy(oTaik, oNPC);
	AssignCommand(oNPC, ActionAttack(oTaik));
	AssignCommand(oNPC, DetermineCombatRound(oTaik));
	}
	

}

Maybe I fixed it!

Turns out there was a tag error in the script here, a leftover from previous attempts, and when correcting this everything seems to work!

I was going to suggest you my solution to test, but ok.

#include "nw_i0_generic"

void SetPartyMortal(object oTarget)
{
	object oFM = GetFirstFactionMember(oTarget, FALSE);
	while (GetIsObjectValid(oFM))
	{	
		SetPlotFlag(oFM, FALSE);
    	SetImmortal(oFM, FALSE);
    	AssignCommand(oFM, SetIsDestroyable(FALSE));
		oFM =  GetNextFactionMember(oTarget, FALSE);
	}
}

void SetCreatureDominated(object oTarget) 
{
	AssignCommand(oTarget, ClearAllActions());
	effect eFX = EffectDominated();
		   eFX = SetEffectSpellId(eFX, 9997);
	
	ApplyEffectToObject(DURATION_TYPE_PERMANENT, eFX, oTarget);	
}

void main()
{
	object oPC = GetFirstPC();
	object oTaik = GetObjectByTag("taik");

	SetPartyMortal(oPC);
	SetCreatureDominated(oPC);

	object oPlayerWP = GetObjectByTag("pit_pc");
	object oTaiWP = GetObjectByTag("pit_tai");
	
	AssignCommand(oPC, JumpToObject(oPlayerWP));
	AssignCommand(oTaik, JumpToObject(oTaiWP));

	SetOwnersControlledCompanion(oPC, oTaik);
	
	object oElvera = GetObjectByTag("elvera");
	object oCelestine = GetObjectByTag("celestine");
	object oLoreen = GetObjectByTag("loreen");
	object oAnto = GetObjectByTag("anto");
	object oFactionPig = GetObjectByTag("facpigobs");
	
	ChangeFaction(oElvera, oFactionPig);
	ChangeFaction(oCelestine, oFactionPig);
	ChangeFaction(oLoreen, oFactionPig);
	ChangeFaction(oAnto, oFactionPig);
	
	object oNPC = GetNearestObjectByTag("thondarion", oFactionPig); 
	if (GetIsObjectValid(oNPC))
	{
		SetCombatOverrides(oNPC, OBJECT_INVALID, -1, -1, OVERRIDE_ATTACK_RESULT_DEFAULT, -1, -1, TRUE, TRUE, FALSE, FALSE);
		ChangeToStandardFaction(oNPC, STANDARD_FACTION_HOSTILE);
		SetIsTemporaryEnemy(oTaik, oNPC);
		AssignCommand(oNPC, ActionAttack(oTaik));
		AssignCommand(oNPC, DetermineCombatRound(oTaik));
	}
}

Thanks for trying to help, @Aqvilinus!

My brother tested it and confirmed that everything works great there now.

2 Likes