Page 1 of 1

Re: Modifying the spawn point

PostPosted: Thu Apr 22, 2010 2:02 pm
by Aloys
That sounds very much like the Journeys; so yes it sounds definitely possible.

Re: Modifying the spawn point

PostPosted: Fri Apr 23, 2010 7:32 am
by diafero
The journeys however do the link-in point magic BEFORE the link, so the age you come from (Relto) checks which spawn point you need to go to. The fan age integration system of the Offline KI (and all the others we have) is not flexible enough to allow for that, it always uses either LinkInPointDefault or whatever I wrote into AvailableLinks.inf.
However, IIRC, Jalak actually makes you arrive in a different corner each time you link there, even though the spawn point is always the same. There must be some Python magic there. However I don't have the Python sources on this machine, so I can't tell.

Re: Modifying the spawn point

PostPosted: Fri Apr 23, 2010 9:23 am
by Branan
If no one pops up with an answer in the next 4 hours, I'll dig through the jalak sources.

Re: Modifying the spawn point

PostPosted: Fri Apr 23, 2010 9:53 am
by D'Lanor
I have been digging through the source and did a quick extraction. I *think* I got everything but keep in mind that this was not tested. It looks simple enough. An object list holds the warp points. The number for the current list item is stored in an sdl variable (byte). At each player link-in the warp point changes and is stored in the sdl. Of course you'll have to adapt the change mechanism if you want to trigger it with a clickable.

Code: Select all
from Plasma import *
from PlasmaTypes import *
import xRandom
warpPlayers = ptAttribSceneobjectList(1, 'obj: player warps')
sdlStartPt = 'warpPlayerStartPt'
listWarpPlayers = []
class warpMagic(ptResponder,):

    def __init__(self):
        ptResponder.__init__(self)
        self.version = 1



    def OnServerInitComplete(self):
        global byteStartPt
        LocalAvatar = PtGetLocalAvatar()
        ageSDL = PtGetAgeSDL()
        ageSDL.setFlags(sdlStartPt, 1, 1)
        ageSDL.sendToClients(sdlStartPt)
        ageSDL.setNotify(self.key, sdlStartPt, 0.0)
        byteStartPt = ageSDL[sdlStartPt][0]
        print 'warpMagic.OnServerInitComplete():  byteStartPt = ',
        print byteStartPt

        for warp in warpPlayers.value:
            pt = warp.getName()
            listWarpPlayers.append(pt)

        if (not len(PtGetPlayerList())):
            print 'warpMagic.OnServerInitComplete(): on link-in, am only player here.  Will reset player start point'
            newPoint = byteStartPt
            while (newPoint == byteStartPt):
                newPoint = xRandom.randint(0, (len(listWarpPlayers) - 1))

            byteStartPt = newPoint
        elif (len(PtGetPlayerList()) == 1):
            print 'warpMagic.OnServerInitComplete(): on link-in, 1 player already here.  Will warp 2 points away (across from previous point)'
            byteStartPt = (byteStartPt + 2)
            if (byteStartPt == 4):
                byteStartPt = 0
            elif (byteStartPt >= 5):
                byteStartPt = 1
        else:
            print 'warpMagic.OnServerInitComplete(): on link-in, 2 or more players already here.  Will warp to next point'
            if (byteStartPt == 0):
                byteStartPt = 2
            elif (byteStartPt == 1):
                byteStartPt = 0
            elif (byteStartPt == 2):
                byteStartPt = 3
            elif (byteStartPt == 3):
                byteStartPt = 1
        print 'warpMagic.OnServerInitComplete(): player start point = ',
        print byteStartPt
        warpPt = warpPlayers.value[byteStartPt].getKey()
        LocalAvatar.physics.warpObj(warpPt)
        ageSDL[sdlStartPt] = (byteStartPt,)



    def OnSDLNotify(self, VARname, SDLname, playerID, tag):
        global byteStartPt
        ageSDL = PtGetAgeSDL()
        PtDebugPrint(('warpMagic.OnSDLNotify():\t VARname: %s, SDLname: %s, tag: %s, value: %d' % (VARname,
         SDLname,
         tag,
         ageSDL[VARname][0])))
        if (VARname == sdlStartPt):
            byteStartPt = ageSDL[sdlStartPt][0]
            print 'warpMagic.OnSDLNotify(): byteStartPt = ',
            print byteStartPt




In your SDL file you put this:

Code: Select all
    VAR BYTE    warpPlayerStartPt[1]      DEFAULT=0 DISPLAYOPTION=red


Edit: And in case you are wondering how to create a pythonfilemod for an object list:
Code: Select all
<object name>:
    logic:
        actions:
          - type: pythonfile
            pythonfile:
                file: warpMagic
                parameters:
                  - type: sceneobjectlist
                    refs: ['scnobj:LinkInPointOne', 'scnobj:LinkInPointTwo', 'scnobj:LinkInPointThree', 'scnobj:LinkInPointFour']