07-10-2009, 03:41 PM
Code:
If NpcNum > 0 Then
' If the npc is a attack on sight, search for a player on the Room
If Npc(NpcNum).Behavior = NPC_BEHAVIOR_ATTACKONSIGHT Or Npc(NpcNum).Behavior = NPC_BEHAVIOR_GUARD Then
For i = 1 To MAX_PLAYERS
If IsPlaying(i) Then
If GetPlayerRoom(i) = y Then
If RoomNpc(y, x).Target = 0 Then
If Npc(NpcNum).Behavior = NPC_BEHAVIOR_ATTACKONSIGHT Or GetPlayerPK(i) = YES Then
If LenB(Trim$(Npc(NpcNum).AttackSay)) Then
PlayerMsg i, "A " & Trim$(Npc(NpcNum).Name) & " says, '" & Trim$(Npc(NpcNum).AttackSay) & "' to you."
End If
Insert Array here that holds the results
End If
End If
End If
End If
Next i
Using the array you inserted above, randomize for 0 to the Ubound of the array, select a target, and attack it
End If
End If