Mirage Source

Free ORPG making software.
It is currently Thu Mar 28, 2024 10:47 am

All times are UTC


Forum rules


Make sure your tutorials are kept up to date with the latest MS4 releases.



Post new topic Reply to topic  [ 1626 posts ]  Go to page 1, 2, 3, 4, 5 ... 66  Next
Author Message
PostPosted: Tue Jun 23, 2009 12:51 am 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
Well, NPC spawning is a bit fucked...NPCs can spawn on other NPCs and even other players. Also if an NPC doesn't spawn, it's still created...and won't spawn until you /respawn it. This fix will only spawn an NPC if it's able to and when an open slot becomes available it will spawn there.

Replace:

Code:
Public Sub SpawnNpc(ByVal MapNpcNum As Long, ByVal MapNum As Long)


With:

Code:
Public Sub SpawnNpc(ByVal MapNpcNum As Long, ByVal MapNum As Long)
Dim Packet As String
Dim NpcNum As Long
Dim i As Long
Dim X As Long
Dim Y As Long
Dim Spawned As Boolean

    ' Check for subscript out of range
    If MapNpcNum <= 0 Or MapNpcNum > MAX_MAP_NPCS Or MapNum <= 0 Or MapNum > MAX_MAPS Then Exit Sub
   
    NpcNum = Map(MapNum).Npc(MapNpcNum)
   
    If NpcNum > 0 Then
       
        ' Well try 100 times to randomly place the sprite
        For i = 1 To 100
            X = Random(0, MAX_MAPX)
            Y = Random(0, MAX_MAPY)
           
            ' Check if the tile is walkable
            If NpcTileIsOpen(MapNum, X, Y) Then
                MapNpc(MapNum, MapNpcNum).X = X
                MapNpc(MapNum, MapNpcNum).Y = Y
                Spawned = True
                Exit For
            End If
        Next
       
        ' Didn't spawn, so now we'll just try to find a free tile
        If Not Spawned Then
            For X = 0 To MAX_MAPX
                For Y = 0 To MAX_MAPY
                    If NpcTileIsOpen(MapNum, X, Y) Then
                        MapNpc(MapNum, MapNpcNum).X = X
                        MapNpc(MapNum, MapNpcNum).Y = Y
                        Spawned = True
                    End If
                Next
            Next
        End If
       
        ' If we suceeded in spawning then send it to everyone
        If Spawned Then
       
            MapNpc(MapNum, MapNpcNum).Num = NpcNum
            MapNpc(MapNum, MapNpcNum).Target = 0
           
            MapNpc(MapNum, MapNpcNum).Vital(Vitals.HP) = GetNpcMaxVital(NpcNum, Vitals.HP)
            MapNpc(MapNum, MapNpcNum).Vital(Vitals.MP) = GetNpcMaxVital(NpcNum, Vitals.MP)
            MapNpc(MapNum, MapNpcNum).Vital(Vitals.SP) = GetNpcMaxVital(NpcNum, Vitals.SP)
           
            MapNpc(MapNum, MapNpcNum).Dir = DIR_DOWN
           
            Packet = SSpawnNpc & SEP_CHAR & MapNpcNum & SEP_CHAR & MapNpc(MapNum, MapNpcNum).Num & SEP_CHAR & MapNpc(MapNum, MapNpcNum).X & SEP_CHAR & MapNpc(MapNum, MapNpcNum).Y & SEP_CHAR & MapNpc(MapNum, MapNpcNum).Dir & END_CHAR
            Call SendDataToMap(MapNum, Packet)
        End If
    End If
   
End Sub


Then under that sub add this:

Code:
Public Function NpcTileIsOpen(ByVal MapNum As Long, ByVal X As Long, ByVal Y As Long) As Boolean
Dim LoopI As Long

    NpcTileIsOpen = True
   
    If PlayersOnMap(MapNum) Then
        For LoopI = 1 To MAX_PLAYERS
            If GetPlayerMap(LoopI) = MapNum Then
                If GetPlayerX(LoopI) = X Then
                    If GetPlayerY(LoopI) = Y Then
                        NpcTileIsOpen = False
                        Exit Function
                    End If
                End If
            End If
        Next
    End If
   
    For LoopI = 1 To MAX_MAP_NPCS
        If MapNpc(MapNum, LoopI).Num > 0 Then
            If MapNpc(MapNum, LoopI).X = X Then
                If MapNpc(MapNum, LoopI).Y = Y Then
                    NpcTileIsOpen = False
                    Exit Function
                End If
            End If
        End If
    Next
   
    If Map(MapNum).Tile(X, Y).Type <> TILE_TYPE_NONE Then NpcTileIsOpen = False
   
End Function


And that should be it.

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

Image
Image


Last edited by GIAKEN on Sun Aug 23, 2009 2:45 am, edited 2 times in total.

Top
 Profile  
 
PostPosted: Tue Jun 23, 2009 8:04 am 
Offline
Submit-Happy
User avatar

Joined: Fri Jun 16, 2006 7:01 am
Posts: 2768
Location: Yorkshire, UK
ty

_________________
Quote:
Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?


Image


Top
 Profile  
 
PostPosted: Tue Jun 23, 2009 5:30 pm 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
Nice one, Harold.

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
PostPosted: Sun Jun 28, 2009 9:07 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'm the best.

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

Image
Image


Top
 Profile  
 
PostPosted: Mon Jun 29, 2009 10:19 am 
Offline
Knowledgeable

Joined: Sat Jul 08, 2006 8:24 am
Posts: 339
Loop to MAX_PLAYERS instead of a PlayersOnMap variable is messy though ;p. + npc's cant spawn on item attributes, and other attributes that they should be able to spawn on.


Top
 Profile  
 
PostPosted: Sun Jul 12, 2009 7:18 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 did loop with max_players...

And yeah this isn't a rewrite, I just fixed up the current spawning...which didn't let them spawn on anything but an empty tile.

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

Image
Image


Top
 Profile  
 
PostPosted: Sun Aug 23, 2009 2:44 am 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
Fixed the NpcTileIsOpen function. Wasn't checking if the player was on that specific map.

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

Image
Image


Top
 Profile  
 
PostPosted: Wed Dec 01, 2021 9:05 am 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
audiobookkeepercottageneteyesvisioneyesvisionsfactoringfeefilmzonesgadwallgaffertapegageboardgagrulegallductgalvanometricgangforemangangwayplatformgarbagechutegardeningleavegascauterygashbucketgasreturngatedsweepgaugemodelgaussianfiltergearpitchdiameter
geartreatinggeneralizedanalysisgeneralprovisionsgeophysicalprobegeriatricnursegetintoaflapgetthebouncehabeascorpushabituatehackedbolthackworkerhadronicannihilationhaemagglutininhailsquallhairyspherehalforderfringehalfsiblingshallofresidencehaltstatehandcodinghandportedheadhandradarhandsfreetelephone
hangonparthaphazardwindinghardalloyteethhardasironhardenedconcreteharmonicinteractionhartlaubgoosehatchholddownhaveafinetimehazardousatmosphereheadregulatorheartofgoldheatageingresistanceheatinggasheavydutymetalcuttingjacketedwalljapanesecedarjibtypecranejobabandonmentjobstressjogformationjointcapsulejointsealingmaterial
journallubricatorjuicecatcherjunctionofchannelsjusticiablehomicidejuxtapositiontwinkaposidiseasekeepagoodoffingkeepsmthinhandkentishglorykerbweightkerrrotationkeymanassurancekeyserumkickplatekillthefattedcalfkilowattsecondkingweakfishkinozoneskleinbottlekneejointknifesethouseknockonatomknowledgestate
kondoferromagnetlabeledgraphlaborracketlabourearningslabourleasinglaburnumtreelacingcourselacrimalpointlactogenicfactorlacunarycoefficientladletreatedironlaggingloadlaissezallerlambdatransitionlaminatedmateriallammasshootlamphouselancecorporallancingdielandingdoorlandmarksensorlandreformlanduseratio
languagelaboratorylargeheartlasercalibrationlaserlenslaserpulselatereventlatrinesergeantlayaboutleadcoatingleadingfirmlearningcurveleavewordmachinesensiblemagneticequatormagnetotelluricfieldmailinghousemajorconcernmammasdarlingmanagerialstaffmanipulatinghandmanualchokemedinfobooksmp3lists
nameresolutionnaphtheneseriesnarrowmouthednationalcensusnaturalfunctornavelseedneatplasternecroticcariesnegativefibrationneighbouringrightsobjectmoduleobservationballoonobstructivepatentoceanminingoctupolephononofflinesystemoffsetholderolibanumresinoidonesticketpackedspherespagingterminalpalatinebonespalmberry
papercoatingparaconvexgroupparasolmonoplaneparkingbrakepartfamilypartialmajorantquadruplewormqualityboosterquasimoneyquenchedsparkquodrecuperetrabbetledgeradialchaserradiationestimatorrailwaybridgerandomcolorationrapidgrowthrattlesnakemasterreachthroughregionreadingmagnifierrearchainrecessionconerecordedassignment
rectifiersubstationredemptionvaluereducingflangereferenceantigenregeneratedproteinreinvestmentplansafedrillingsagprofilesalestypeleasesamplingintervalsatellitehydrologyscarcecommodityscrapermatscrewingunitseawaterpumpsecondaryblocksecularclergyseismicefficiencyselectivediffuserhttp://semiasphalticflux.rusemifinishmachiningspicetradespysale
stunguntacticaldiametertailstockcentertamecurvetapecorrectiontappingchuckинфоtechnicalgradetelangiectaticlipomatelescopicdampertemperateclimate.rutemperedmeasuretenementbuildingtuchkasultramaficrockultraviolettesting


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 8:46 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
Econ


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 8:47 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
107


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 8:48 pm 
Online
Mirage Source Lover

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


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 8:49 pm 
Online
Mirage Source Lover

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


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 8:50 pm 
Online
Mirage Source Lover

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


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 8:51 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
Lovi


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 8:52 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
Stam


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 8:54 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
Adam


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 8:55 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
Geor


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 8:56 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
Meni


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 8:57 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
Pola


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 8:58 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
Inge


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 8:59 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
Mich


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 9:00 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
Simp


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 9:02 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
Pian


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 9:03 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
Else


Top
 Profile  
 
PostPosted: Wed Jan 05, 2022 9:04 pm 
Online
Mirage Source Lover

Joined: Sun Jul 04, 2021 4:04 am
Posts: 456142
Dwel


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 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:  
cron
Powered by phpBB® Forum Software © phpBB Group