OC tutorial archery challenge fix

Hello, there is a smart little fix I made for the OC campaign which I’m proud of so I wanted to share it!

Basically in the tutorial during archery challenge we are allowed to damage bottles with spells, and it counts as a bottle hit with a crossbow (we don’t even have to play as a wizard to be able to do that, Amie has Frost ray or Acid splash). I never liked that idea and I don’t think it goes against the spirit of the game to forbid it from happening - I think I could even be at the liberty of calling this a little “fix” for the game.
So, in the script “0b_target_dmg” we can add an IF command between the last two IFs, that looks like this:


	if (!GetLastSpellHarmful())

Which will prevent the bottle from being counted as hit as long as we do that with a damaging spell. I tried different things like making bottles immune to magic or immune to non-physical damage but in the end simpliest methods are the best ones :smiley:

Here is how my script looks like:

//::///////////////////////////////////////////////////////////////////////////
//::
//::	0b_target_dmg
//::
//::	Handles the targets getting hit during archery trial.
//::
//::///////////////////////////////////////////////////////////////////////////
// DBR 1/2/6

const int TOKEN_TARGETS =  1515;
	
#include "nw_i0_generic"

void AdvanceQuest(string sQuest, int nState, object oPC, int bOverrideHigher=FALSE)
{
	if ((GetGlobalInt(sQuest)<nState)||(bOverrideHigher))
	SetGlobalInt(sQuest,nState);
	object oPCF = GetFirstFactionMember(oPC,FALSE);
	while (GetIsObjectValid(oPCF)) // Setting journal parameters to False as
								   // we're updating for all members using the While loop JYL 09/19/06
	{
		AddJournalQuestEntry(sQuest, nState, oPCF,FALSE,FALSE,bOverrideHigher);	
		oPCF = GetNextFactionMember(oPC,FALSE);
	}
}

void main()
{
	object oAttacker = GetLastDamager();
	object oAttackedWith = GetLastWeaponUsed(oAttacker);

	//code originally from another script, held here for backup
/*	if (GetTag(OBJECT_SELF) == "0_target") // if I'm a contest target, up the attempted shot in the target trial
	{
		int nShotCount = GetLocalInt(GetModule(),"0_ShotCount");
		SetLocalInt(GetModule(),"0_ShotCount",++nShotCount);
		if (nShotCount>=10) //out of shots!
		{
			//remove all bolts
			oItem=GetFirstItemInInventory(oAttacker);
			for (i=0;i<40;i++)
			{
				sTag=GetTag(oItem);
				if (sTag=="NW_WAMBO001")
					DestroyObject(oItem);
				oItem=GetNextItemInInventory(oAttacker);
			}
		}
	}*/

		
	if (!GetWeaponRanged(oAttackedWith)) //first of all, if it's not ranged, ignore damage
		return;

	if (!GetIsPC(oAttacker))	//if the PC isn't hurting me, also quit out
		return;

	if (GetTag(OBJECT_SELF)=="0_practice_target")  //if I'm the practice target, advance quest
	{
		if (GetCurrentHitPoints()<=300)	//hee hee hee. THink you're clever, trying to destroy this target are ya?
			SetPlotFlag(OBJECT_SELF,TRUE);

		if (GetGlobalInt("0_missile")==30)
		{
			AdvanceQuest("0_missile", 40, oAttacker);
			AssignCommand(oAttacker,ClearAllActions(TRUE));
			AssignCommand(GetObjectByTag("0_daeghun"),ClearAllActions(TRUE));
			AssignCommand(GetObjectByTag("0_daeghun"),SpeakOneLinerConversation("0_daeghun_afterpractice"));
		}
		return;
	}

	if (GetTag(OBJECT_SELF) == "0_target") // if I'm a contest target, destroy me, and up destroyed target count.
	{
	
	if (!GetLastSpellHarmful())
	{
		if (GetGlobalInt("0_missile")<80)
		{
			int nTargetCount = GetLocalInt(GetModule(),"0_TargetCount");
			SetLocalInt(GetModule(),"0_TargetCount",++nTargetCount);
			SetCustomToken(TOKEN_TARGETS,IntToString(nTargetCount));
			
			SetAssociateState(NW_ASC_MODE_DEFEND_MASTER,FALSE,GetObjectByTag("npc_bevil"));
			SetAssociateState(NW_ASC_MODE_DEFEND_MASTER,FALSE,GetObjectByTag("0_amie"));
		}	
			ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectNWN2SpecialEffectFile("fx_sparks.sef"),GetLocation(OBJECT_SELF),2.7f);
			DestroyObject(OBJECT_SELF,0.1f);
			AssignCommand(oAttacker,ClearAllActions(TRUE));				
	}	
	}
}
2 Likes