Mirage Source

Free ORPG making software.
It is currently Thu Mar 28, 2024 7:04 pm

All times are UTC




Post new topic Reply to topic  [ 1368 posts ]  Go to page 1, 2, 3, 4, 5 ... 55  Next
Author Message
 Post subject: Random Target
PostPosted: Fri Sep 11, 2009 12:36 am 
Offline
Pro
User avatar

Joined: Wed Sep 20, 2006 1:06 pm
Posts: 368
Location: UK
Google Talk: steve.bluez@googlemail.com
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


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Tue Sep 22, 2009 1:21 am 
Offline
Pro
User avatar

Joined: Wed Sep 20, 2006 1:06 pm
Posts: 368
Location: UK
Google Talk: steve.bluez@googlemail.com
Image


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Wed Oct 07, 2009 3:41 pm 
Offline
Knowledgeable

Joined: Sat Jul 08, 2006 8:24 am
Posts: 339
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


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Wed Oct 07, 2009 4:03 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
I think we're all waiting for him to bump the topic a bit more.

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Oct 08, 2009 9:15 pm 
Offline
Pro
User avatar

Joined: Wed Sep 20, 2006 1:06 pm
Posts: 368
Location: UK
Google Talk: steve.bluez@googlemail.com
Hmm, can't seem to understand arrays. I've read up but still unsure how I'd add each player id into the array....


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Wed Dec 01, 2021 11:43 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоsemiasphalticflux.ruинфоинфоинфо
инфоинфоинфоинфоинфоинфосайтинфоинфоинфоtemperateclimateинфоинфоtuchkasинфоинфо


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:36 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
GoGa


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:37 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
153.7


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:39 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Bett


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:40 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Bett


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:41 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Whic


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:42 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Star


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:43 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Come


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:44 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Pict


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:45 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Radi


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:46 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Will


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:48 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Pray


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:49 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Rudo


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:50 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Mons


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:51 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Atla


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:52 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Brow


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:53 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Orie


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:54 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Alai


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:55 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Acel


Top
 Profile  
 
 Post subject: Re: Random Target
PostPosted: Thu Jan 20, 2022 4:56 am 
Offline
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456192
Clif


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1368 posts ]  Go to page 1, 2, 3, 4, 5 ... 55  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group