func void ZS_AssessThreat ()
{	
	PrintDebug("ZS_AssessThreat");
	if (other.guild != 23 )
	{
		// Far Npc
		if (!Npc_IsNear(self,other))
		{
			PrintDebug("ZS_AssessThreatFar");
			// Far Npc with RangedWeapon
			if (Npc_IsInFightMode (other,FMODE_FAR))
			{
				PrintDebug("ZS_AssessThreatFarWeapon");
				B_LookAt(self,other,0);
				if (Npc_IsAiming (other,self))
				{	
					// Ranged Weapon aiming
					PrintDebug("ZS_AssessThreatFarWeaponAiming");
					if(Npc_GetAttitude (self,other) == ATT_FRIENDLY)
					{
						PrintDebug("ZS_AssessThreatFarWeaponAimingFriend");
						B_Say(self,"$WatchYourAim");
						B_LookAt(self,other,0);
						if (Npc_IsAiming (other,self))
						{
							self.aivar[AIV_ASSESS_THREAT_FARCOUNTER] += 1;
							if (self.aivar[AIV_ASSESS_THREAT_FARCOUNTER] == 3)
							{
								PrintDebug("ZS_AssessThreatFarWeaponAimingFriendChange");
								Npc_SetTempAttitude(self,ATT_NEUTRAL);
								self.aivar[AIV_ASSESS_THREAT_FARCOUNTER] = 0;
							};
						}
						else
						{
							AI_DoState(self,ZS_RemoveWeapon,3);
						};
					}
					else if (Npc_GetAttitude(self,other) == ATT_NEUTRAL)
					{
						PrintDebug("ZS_AssessThreatFarWeaponAimingNeutral");
						B_DrawWeapon (self);
						if (Npc_IsAiming(other,self))
						{
							self.aivar[AIV_ASSESS_THREAT_FARCOUNTER] +=1;
							if (self.aivar[AIV_ASSESS_THREAT_FARCOUNTER] == 1)
							{
								B_Say(self,"$WatchYourAim");
							};
							if (self.aivar[AIV_ASSESS_THREAT_FARCOUNTER] == 2)
							{
								Npc_SetTempAttitude(self,ATT_ANGRY);
								PrintDebug("Npc_SetTempAttitude(self,ATT_ANGRY);");
								self.aivar[AIV_ASSESS_THREAT_FARCOUNTER] =0;
							};
						}
						else
						{
							AI_DoState(self,ZS_RemoveWeapon,0);
							PrintDebug("ZS_AssessThreatFarWeaponNoMoreAimingNeutral");
							B_SheathWeapon(self);
						};
					}
					else if (Npc_GetAttitude(self,other) == ATT_ANGRY)
					{
						PrintDebug("ZS_AssessThreatFarWeaponAimingAngry");
						if (!C_AreWeStronger(self,other))
						{
							PrintDebug("ZS_AssessThreatFarWeaponAimingAngryNotStronger");
							B_GoAway(self);
						}
						else 
						{
							PrintDebug("ZS_AssessThreatFarWeaponAimingAngryStronger");
							if (!Npc_IsInFightMode (self,FMODE_FAR)&&!Npc_IsInFightMode(self,FMODE_MELEE))
							{
								B_DrawWeapon(self);
							};
							B_Say(self,"$YouBrazenBastard");
							Npc_SetTempAttitude(self,ATT_HOSTILE);
							PrintDebug("Npc_SetTempAttitude(self,ATT_HOSTILE);");
							AI_DoState(self,ZS_HelpAttack,0);
						};
					};
				};
			}
			else if (Npc_IsInFightMode (other,FMODE_MAGIC) && Npc_IsAiming (other,self))
			{
				PrintDebug("Npc_IsInFightMode (other,FMODE_MAGIC) && Npc_IsAiming (other,self)");
				if (C_MageTest (self) && Npc_GetActiveSpellCat(other) == SPELL_BAD && Npc_GetAttitude (self,other) == ATT_NEUTRAL)
				{
					B_Say (self,"$ThisSpellIsDangerous");  
					Npc_SetTempAttitude(self,ATT_ANGRY);
				}
				if (C_MageTest (self) && Npc_GetActiveSpellCat(other) == SPELL_BAD && Npc_GetAttitude (self,other) == ATT_FRIENDLY)
				{
					Npc_SetTempAttitude(self,ATT_NEUTRAL);
				}
				else if (C_MageTest (self) && Npc_GetActiveSpellCat(other) == SPELL_BAD && Npc_GetAttitude (self,other) == ATT_NEUTRAL)
				{
					B_Say (self,"$ThisSpellIsDangerous");  
					Npc_SetTempAttitude(self,ATT_HOSTILE);
					AI_DoState(self,ZS_HelpAttack,0);
				}
				else if (Npc_GetAttitude (self,other) == ATT_FRIENDLY)
				{
					Npc_SetTempAttitude(self,ATT_NEUTRAL);
				}
				else if (Npc_GetAttitude (self,other) == ATT_NEUTRAL)
				{
					B_Say (self,"$MagicMakesMeNervous");
					Npc_SetTempAttitude(self, ATT_ANGRY );
				}
				else if (Npc_GetAttitude (self,other) == ATT_ANGRY)
				{
					B_Say (self,"$YouBrazenBastard");
					Npc_SetTempAttitude(self,ATT_HOSTILE);
					AI_DoState(self,ZS_HelpAttack,0);
				};
			};
		}
		// Npc is Near
		else if (B_HasDrawnWeapon(other))
		{
			if (!Npc_IsAiming(other,self))
			{
				if (C_AreWeStronger (self,other))
				{
					if (Npc_GetAttitude(self,other) == ATT_NEUTRAL)
					{
						if ( self.aivar[AIV_ASSESS_THREAT_STRAINED] == 1)
						{
							B_LookAt(self,other,0);
							PrintDebug("...PutYourWeaponAway");
							B_Say(self,"$PutYourWeaponAway");
						}
						else 
						if ( self.aivar[AIV_ASSESS_THREAT_STRAINED] == 3)
						{
							B_LookAt(self,other,0);
							B_Say(self,"$ISaidPutYourWeaponAway");
							PrintDebug("...ISaidPutYourWeaponAway");
							AI_Wait(self,3);
							Npc_SetTempAttitude(self,ATT_ANGRY);
							self.aivar[AIV_ASSESS_THREAT_STRAINED] = 0;
							
						};
						self.aivar[AIV_ASSESS_THREAT_STRAINED] += 1;
					}
					else if (Npc_GetAttitude (self,other) == ATT_FRIENDLY)
					{
						PrintDebug("FriendWIthWeap");
					}
					else if (Npc_GetAttitude (self,other) == ATT_ANGRY)
					{
						self.aivar[AIV_ASSESS_THREAT_STRAINED] += 1; 
						if ( self.aivar[AIV_ASSESS_THREAT_STRAINED] == 3)
						{
							Npc_SetTempAttitude (self,ATT_HOSTILE);
							self.aivar[AIV_ASSESS_THREAT_STRAINED] = 0;
						};
					};
				}
				else 
				{
					AI_DoState(self,ZS_Flee,0);
				};
			}
			else	//Pc is aiming near Npc
			{
				if (Npc_GetAttitude(self,other) == ATT_FRIENDLY)
				{
					PrintDebug("ZS_AssessThreatNearWeaponAImingFriend");
					B_Say (self,"$WatchYourAim");
					Npc_SetTempAttitude (self,ATT_ANGRY);
				}
				else if (Npc_GetAttitude(self,other) == ATT_NEUTRAL)
				{	
					PrintDebug("ZS_AssessThreatNearWeaponAimingFoe");			
					B_Say (self,"$WatchYourAim");
					Npc_SetTempAttitude(self,ATT_ANGRY);
				}
				else if (Npc_GetAttitude(self,other) == ATT_ANGRY)
				{
					PrintDebug("ZS_AssessThreatNearWeaponAimingFoe2");			
					Npc_SetTempAttitude(self,ATT_HOSTILE);
				};
			};
		}
		else if (Npc_IsInFightMode(other,FMODE_MAGIC))
		{
			
			PrintDebug("Magic");
			if( Npc_GetAttitude(self,other) == ATT_NEUTRAL)// Neutraler Magier
			{
				PrintDebug("MagicNeutral");
				if (C_MageTest(self))// selbst Magier
				{	
					PrintDebug("MagicNeutralMage");
					if(Npc_GetActiveSpellCat(other) == SPELL_BAD)// böser Spell
					{
						PrintDebug("MagicNeutralMageBad");
						B_Say(self,"$ThisSpellIsDangerous");
						B_LookAt(self,other,0);
						if (Npc_IsInFightMode(other,FMODE_MAGIC)) // immer noch Spell
						{
							Npc_SetTempAttitude(self,ATT_ANGRY);
						};
					};
				}
				else 
				{
					B_Say (self,"$MagicMakesMeNervous");
					Npc_SetTempAttitude(self,ATT_ANGRY);
				};
			}
			else if (Npc_GetAttitude(self,other) == ATT_ANGRY)
			{
				if (!C_AreWeStronger (self,other))// Böser starker Magier ++
				{
					B_GoAway(self);
				}
				else
				{
					B_LookAt(self,other,0);
					self.aivar[AIV_ASSESS_THREAT_MAGIC] += 1;
					if (self.aivar[AIV_ASSESS_THREAT_MAGIC] == 1)
					{
						B_DrawWeapon(self);
						B_Say(self,"$StopSpellcasting");
					};
					if (self.aivar[AIV_ASSESS_THREAT_MAGIC] == 3)
					{
						B_Say(self,"$ISaidStoppSpellcasting");
						if (self.aivar[AIV_ASSESS_THREAT_MAGIC] ==5)
						{
							Npc_SetTempAttitude(self,ATT_HOSTILE);
							AI_DoState(self,ZS_HelpAttack,0);
							self.aivar[AIV_ASSESS_THREAT_MAGIC] = 0;
						}; 
					};
				};
			};
		}
		// Threat-npc is near and in fistmode
		else
		{
			//B_SheathWeapon(self);
			//B_Say(self,"$WiseMove");
		};
	};
};

func void ZS_AssessThreat_End ()
{	
	PrintDebug("ZS_AssessThreat_End");
};
	
		
		
				
					
						                                                        
                                                         
                                                         
                                                         
                                                         
                                                         
                                                         
                                                         
                                                         