Developer Store
Support
Member Forums

Screenshots
FAQ
Documentation
License
Known Issues
Downloads

MMOWorkshop BACK!

PyTorque
TGB Web Browser


DarkBaneStudios

hallsofvalhalla - Been A while
xapken - Wizards and Champions
J.C. Smith - The Repopulation - 0.5.2 Build Notes
EmpireGames - Elementals in Rise of Heroes
Empire Games - WarPath.
jaidurn - Warcall 0.0.1.0 build notes
medafor - Final detailing of models
Thamior - Presence system GONE! [May 25th 2009)]
... MORE BLOGS!

Building a MMO
Wow I had no idea....
Quest Remnants of Chaos
Checking to see if anyone is sti...
Well here I am again :)
T3D and MMOKit
afx 2.0
Terrain specularity [video]
Torque T3D MMO Kit
[3dFoin] Dragon Bug

This class holds the persistent data for a dropped item. I put it at the end of the item.py:

class ItemDropped(Persistent):
    item = ForeignKey("Item")
    zone = ForeignKey("Zone")
    position = StringCol()
    rotation = StringCol()

    def _init(self,*args,**kw):
        Persistent._init(self, *args, **kw)

    def destroySelf(self):
        Persistent.destroySelf(self)

To create a database table for this persistent class, add this line to Genesis.py:

    DBDict.createRows('ItemDropped')

and import the ItemDropped by adding the name in the import statement near ItemProto and all the others. ItemDropped has to be added to tables in def CreateTables().

While testing I found that table empty from time to time and then I found WorldUpdate copying some data over from the previous one to a new copy of world.db. So that needed some changes as well.

All the dropped items should appear again when the zone is loaded. First there has to be a definition to reach the table in zone.py Zone:

    droppedItems = MultipleJoin('ItemDropped')

This referenced table is handled in ZoneInstance.start():

        try:
            print "Items in this zone:"
            for i in self.zone.droppedItems:
                print i
                itemInst = ItemInstance(i.item)
                itemInst.droppedItem = i
                newpos = (i.position + " " + i.rotation).split()
                self.respawnItem(i, itemInst, newpos)
        except:
            print_exc()

The respawnedItem function works similar to the spawnItem() but does not create another ItemDropped:

    # callback for spawnItem. item is the ItemInstance, simItem is the SimItem, dItem is the ItemDropped
    def respawnedItem(self, simItem, dItem, item):
        self.itemLookup[simItem] = item

    # spawn an item using ItemDropped
    def respawnItem(self, dItem, item, transform):
        self.simAvatar.spawnItem(item.name, transform).addCallback(self.respawnedItem, dItem, item)