Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Increasing Max Npcs Per Map to 50


Dennys
 Share

Recommended Posts

First of all i must let you know that Spawning a Total of 50 NPCS in a Map will be very Laggy.

Have the option to have 50 npcs in a map Will not lagg, Spawning the 50 Will….

Heres the Tutorial:
[CLIENT SIDE]
In ModTypes Module find:
```
Npc(1 To 15) As Integer
    SpawnX(1 To 15) As Byte
    SpawnY(1 To 15) As Byte
```
And Replace it With:
```
Npc(1 To 51) As Integer
    SpawnX(1 To 51) As Byte
    SpawnY(1 To 51) As Byte
```
Now Download the Attached Form and FRX Files and Add it to your Client Source Folder Replacing your Old Ones.
THis is Just to Show what things were Edited in the FrmMapProperties.

>! In frmMapEditor Find:
```
For X = 1 To 15
        cmbNpcX(X - 1).ListIndex = 0
        cmbNpcY(X - 1).ListIndex = 0
    Next X
```
And Replace it with:
```
For X = 1 To 51
        cmbNpcX(X - 1).ListIndex = 0
        cmbNpcY(X - 1).ListIndex = 0
    Next X
```
Next Find this a few scroll Lower in the same FORM:
```
For X = 1 To 15
        cmbNpc(X - 1).addItem "No NPC"
        cmbNpcX(X - 1).addItem "Rand"
        cmbNpcY(X - 1).addItem "Rand"
    Next X
>!     For y = 1 To MAX_NPCS
        For X = 1 To 15
            cmbNpc(X - 1).addItem y & ": " & Trim$(Npc(y).Name)
        Next X
    Next y
>!     For X = 1 To 15
        cmbNpc(X - 1).ListIndex = Map(GetPlayerMap(MyIndex)).Npc(X)
    Next X
>!     For X = 1 To 15
        For y = 0 To MAX_MAPX
            cmbNpcX(X - 1).addItem y
        Next y
        cmbNpcX(X - 1).ListIndex = Map(GetPlayerMap(MyIndex)).SpawnX(X)
    Next X

    For X = 1 To 15
        For y = 0 To MAX_MAPY
            cmbNpcY(X - 1).addItem y
        Next y
        cmbNpcY(X - 1).ListIndex = Map(GetPlayerMap(MyIndex)).SpawnY(X)
    Next X
```
And Replace it with this:
```
For X = 1 To 51
        cmbNpc(X - 1).addItem "No NPC"
        cmbNpcX(X - 1).addItem "Rand"
        cmbNpcY(X - 1).addItem "Rand"
    Next X
>!     For y = 1 To MAX_NPCS
        For X = 1 To 51
            cmbNpc(X - 1).addItem y & ": " & Trim$(Npc(y).Name)
        Next X
    Next y
>!     For X = 1 To 51
        cmbNpc(X - 1).ListIndex = Map(GetPlayerMap(MyIndex)).Npc(X)
    Next X
>!     For X = 1 To 51
        For y = 0 To MAX_MAPX
            cmbNpcX(X - 1).addItem y
        Next y
        cmbNpcX(X - 1).ListIndex = Map(GetPlayerMap(MyIndex)).SpawnX(X)
    Next X

    For X = 1 To 51
        For y = 0 To MAX_MAPY
            cmbNpcY(X - 1).addItem y
        Next y
        cmbNpcY(X - 1).ListIndex = Map(GetPlayerMap(MyIndex)).SpawnY(X)
    Next X
```
Next Once again a few scrolls lower Find:
```
For i = 1 To 15
        Map(GetPlayerMap(MyIndex)).Npc(i) = cmbNpc(i - 1).ListIndex
        Map(GetPlayerMap(MyIndex)).SpawnX(i) = cmbNpcX(i - 1).ListIndex
        Map(GetPlayerMap(MyIndex)).SpawnY(i) = cmbNpcY(i - 1).ListIndex
    Next i
```
And Replace it with:
```
For i = 1 To 51
        Map(GetPlayerMap(MyIndex)).Npc(i) = cmbNpc(i - 1).ListIndex
        Map(GetPlayerMap(MyIndex)).SpawnX(i) = cmbNpcX(i - 1).ListIndex
        Map(GetPlayerMap(MyIndex)).SpawnY(i) = cmbNpcY(i - 1).ListIndex
    Next i
```

Next Find This in ModHandleData:
```
For X = 1 To 15
            Map(Val(parse(1))).Npc(X) = Val(parse(n))
            Map(Val(parse(1))).SpawnX(X) = Val(parse(n + 1))
            Map(Val(parse(1))).SpawnY(X) = Val(parse(n + 2))
            n = n + 3
        Next X
```
And Replace with:
```
For X = 1 To 51
            Map(Val(parse(1))).Npc(X) = Val(parse(n))
            Map(Val(parse(1))).SpawnX(X) = Val(parse(n + 1))
            Map(Val(parse(1))).SpawnY(X) = Val(parse(n + 2))
            n = n + 3
        Next X
```
Then Find this in the same ModHandleData:
```
For i = 1 To 15
            SaveMapNpc(i).num = Val(parse(n))
            SaveMapNpc(i).X = Val(parse(n + 1))
            SaveMapNpc(i).y = Val(parse(n + 2))
            SaveMapNpc(i).Dir = Val(parse(n + 3))

            n = n + 4
        Next i
```
and Replace with:
```
For i = 1 To 51
            SaveMapNpc(i).num = Val(parse(n))
            SaveMapNpc(i).X = Val(parse(n + 1))
            SaveMapNpc(i).y = Val(parse(n + 2))
            SaveMapNpc(i).Dir = Val(parse(n + 3))

            n = n + 4
        Next i
```
Next Find this in ModConstants:
```
Public Const MAX_MAP_NPCS = 15
```
And Change it to:
```
Public Const MAX_MAP_NPCS = 51
```
[SERVER SIDE]
In ModTypes Module find:
```
Npc(1 To 15) As Integer
    SpawnX(1 To 15) As Byte
    SpawnY(1 To 15) As Byte
```
And Replace it With:
```
Npc(1 To 51) As Integer
    SpawnX(1 To 51) As Byte
    SpawnY(1 To 51) As Byte
```
Next FInd in ModHandleData:
```
NPCIndex = 15
```
Replace it with:
```
NPCIndex = 51
```
And Finally Find This in ModConstants:
```
Public Const MAX_MAP_NPCS = 15
```
And Change to this:
```
Public Const MAX_MAP_NPCS = 51
```
And Thats About it.

UPDATE: @DarkEdge:

> Adding the code below makes it so you can't add drops to NPC's. Atleast for me. I kept it at 18 and it works fine..
>
> ```
>     NPCIndex = 51
> ```
Link to comment
Share on other sites

If anyone can Fix up the Form for me and make all of it under 1 tab instead of it showing on both lol youll see what i mean once you do it.
Actually 50 Npcs in a map isint that laggy But when you add Players If you dont have a fast computer it wil lagg a bit not to mention to log in on it will be hell.
Link to comment
Share on other sites

How can i Explain the Code? Lol i dont know what the code emans i just know what to change and were….

Its easy just change every 15 up there to 51 lol, And Yes it Must be 51 if you want 50 spawns, and Downlaod the FRM and FRX attached and add to Source folder. and your done.
Link to comment
Share on other sites

  • 4 weeks later...
  • 6 months later...
I'm sorry… but I think you just missed the point completely here.

```
Public Const MAX_MAP_NPCS = 15
```
**That is there for a reason.** Do you think that number is just… not doing anything? If you were doing this properly you'd have gone through and change all the 15s you found to MAX_MAP_NPCS.

Then no one has to go through and change all the damn numbers again, they can just change MAX_MAP_NPCS. That's why all the 'Max' constants are there.

Apart from that it'd be much better to simply have a dynamic array of NPCs in the map and allow the developer to change the amount via. the editor.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...