Set Spawn From class.ini

Since this was buried in another post in the questions sections I decided to re-post my solution here.
Originally from: http://www.touchofdeathforums.com/smf/index.php/topic,73394.msg809052/boardseen.html#new

//This section is from Rithy56 and slightly edited, credits to him.

In modTypes, Private Type ClassRec, Under

    startSpellCount As Long
    StartSpell() As Long

Add

    StartMap As Long
    StartMapX As Long
    StartMapY As Long

In modDatabase, Sub LoadClasses(), Under


        ' continue
        Class(i).Stat(Stats.Strength) = Val(GetVar(filename, "CLASS" & i, "Strength"))
        Class(i).Stat(Stats.Endurance) = Val(GetVar(filename, "CLASS" & i, "Endurance"))
        Class(i).Stat(Stats.Intelligence) = Val(GetVar(filename, "CLASS" & i, "Intelligence"))
        Class(i).Stat(Stats.Agility) = Val(GetVar(filename, "CLASS" & i, "Agility"))
        Class(i).Stat(Stats.Willpower) = Val(GetVar(filename, "CLASS" & i, "Willpower"))

Add


Class(i).StartMap = Val(GetVar(filename, "CLASS" & i, "StartMap"))
Class(i).StartMapX = Val(GetVar(filename, "CLASS" & i, "StartMapX"))
Class(i).StartMapY = Val(GetVar(filename, "CLASS" & i, "StartMapY"))

In modDatabase, Sub SaveClasses() find

Call PutVar(filename, "CLASS" & i, "Willpower", STR(Class(i).Stat(Stats.Willpower)))

Under Add

Call PutVar(filename, "CLASS" & i, "StartMap", STR(Class(i).StartMap))
Call PutVar(filename, "CLASS" & i, "StartMapX", STR(Class(i).StartMapX))
Call PutVar(filename, "CLASS" & i, "StartMapY", STR(Class(i).StartMapY))

In modDatabase, Sub AddChar, Replace

        Player(index).Map = START_MAP
        Player(index).x = START_X
        Player(index).y = START_Y

With


        Player(index).Map = Class(Player(index).Class).StartMap
        Player(index).x = Class(Player(index).Class).StartMapX
        Player(index).y = Class(Player(index).Class).StartMapY

In modPlayer, Sub OnDeath(index), Find

Call PlayerWarp(Index, START_MAP, START_X, START_Y)

Replace with

  Call PlayerWarp(Index, Class(Player(index).Class).StartMap, Class(Player(index).Class).StartMapX, Class(Player(index).Class).StartMapY)

Nice tutorial Scott. Very explained and helpful.
Though, my only concern is the following.

In

Class(i).StartMap = Val(GetVar(filename, "CLASS" & i, "StartMap"))
Class(i).StartMapX = Val(GetVar(filename, "CLASS" & i, "StartMapX"))
Class(i).StartMapY = Val(GetVar(filename, "CLASS" & i, "StartMapY"))

```wouldn't it be more like…

Class(i).StartMap = GetVar(filename, “CLASS” & i, “StartMap”)
Class(i).StartMapX = GetVar(filename, “CLASS” & i, “StartMapX”)
Class(i).StartMapY = GetVar(filename, “CLASS” & i, “StartMapY”)

No the Val function stops reading a string if it encounters any non-numerical characters and since it’s loading from an ini it is possible for the field to get input other than numbers this would prevent an error in that case.

Oh, my bad. Anyways, nice tutorial!

Thank You! 😃

Glad it helped, thanks for the reply.

I followed this on dragon eclipse and now get a subscript out of range on modPlayer upon creation of a new character

'View Current Pets on Map

If PetMapCache(Player(index).Map).UpperBound > 0 Then

For j = 1 To PetMapCache(Player(index).Map).UpperBound

Call NPCCache_Create(index, Player(index).Map, PetMapCache(Player(index).Map).Pet(j))

Next

End If

I can’t imagine how this would mess with pets, it only edits the loadclass, saveclass and ondeath sub.

Try removing it and seeing if the problem still exists.

Hover over each variable and tell which is out of range.

Nice tut, this is really usefull

im new to vb6 and have a noob question is this script client side or server side and one more noob question does it load the player on the start map on every log in thanks in advance

im new to vb6 and have a noob question is this script client side or server side and one more noob question does it load the player on the start map on every log in thanks in advance

It is in the server side. On first login it will spawn to the class.ini points you put for the players class.then when a player dies and no map boot properties are set then it will spawn back to the original class spawn in the classes.ini

Log in to reply