Mirage Source
http://miragesource.net/forums/

Random Target
http://miragesource.net/forums/viewtopic.php?f=184&t=6219
Page 1 of 55

Author:  Xlithan [ Fri Sep 11, 2009 12:36 am ]
Post subject:  Random Target

Ok. Currently, the monster attacks the first person that enters the room, and only choose one target per hit. I want the monster to randomly pick a target out of all the players in the room.
This is the part of the code in the GameAI sub that gives the NPC a target. If anybody could add the bit of code needed to randomly select the target that would be great.

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
                                                RoomNpc(y, x).Target = i
                                            End If
                                        End If
                                    End If
                                End If
                            Next i
                        End If
                    End If

Author:  Xlithan [ Tue Sep 22, 2009 1:21 am ]
Post subject:  Re: Random Target

Image

Author:  Joost [ Wed Oct 07, 2009 3:41 pm ]
Post subject:  Re: Random Target

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

Author:  GIAKEN [ Wed Oct 07, 2009 4:03 pm ]
Post subject:  Re: Random Target

I think we're all waiting for him to bump the topic a bit more.

Author:  Xlithan [ Thu Oct 08, 2009 9:15 pm ]
Post subject:  Re: Random Target

Hmm, can't seem to understand arrays. I've read up but still unsure how I'd add each player id into the array....

Author:  wanai [ Wed Dec 01, 2021 11:43 am ]
Post subject:  Re: Random Target

инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоsemiasphalticflux.ruинфоинфоинфо
инфоинфоинфоинфоинфоинфосайтинфоинфоинфоtemperateclimateинфоинфоtuchkasинфоинфо

Author:  wanai [ Thu Jan 20, 2022 4:36 am ]
Post subject:  Re: Random Target

GoGa

Author:  wanai [ Thu Jan 20, 2022 4:37 am ]
Post subject:  Re: Random Target

153.7

Author:  wanai [ Thu Jan 20, 2022 4:39 am ]
Post subject:  Re: Random Target

Bett

Author:  wanai [ Thu Jan 20, 2022 4:40 am ]
Post subject:  Re: Random Target

Bett

Author:  wanai [ Thu Jan 20, 2022 4:41 am ]
Post subject:  Re: Random Target

Whic

Author:  wanai [ Thu Jan 20, 2022 4:42 am ]
Post subject:  Re: Random Target

Star

Author:  wanai [ Thu Jan 20, 2022 4:43 am ]
Post subject:  Re: Random Target

Come

Author:  wanai [ Thu Jan 20, 2022 4:44 am ]
Post subject:  Re: Random Target

Pict

Author:  wanai [ Thu Jan 20, 2022 4:45 am ]
Post subject:  Re: Random Target

Radi

Author:  wanai [ Thu Jan 20, 2022 4:46 am ]
Post subject:  Re: Random Target

Will

Author:  wanai [ Thu Jan 20, 2022 4:48 am ]
Post subject:  Re: Random Target

Pray

Author:  wanai [ Thu Jan 20, 2022 4:49 am ]
Post subject:  Re: Random Target

Rudo

Author:  wanai [ Thu Jan 20, 2022 4:50 am ]
Post subject:  Re: Random Target

Mons

Author:  wanai [ Thu Jan 20, 2022 4:51 am ]
Post subject:  Re: Random Target

Atla

Author:  wanai [ Thu Jan 20, 2022 4:52 am ]
Post subject:  Re: Random Target

Brow

Author:  wanai [ Thu Jan 20, 2022 4:53 am ]
Post subject:  Re: Random Target

Orie

Author:  wanai [ Thu Jan 20, 2022 4:54 am ]
Post subject:  Re: Random Target

Alai

Author:  wanai [ Thu Jan 20, 2022 4:55 am ]
Post subject:  Re: Random Target

Acel

Author:  wanai [ Thu Jan 20, 2022 4:56 am ]
Post subject:  Re: Random Target

Clif

Page 1 of 55 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/