Changeset 592


Ignore:
Timestamp:
07/21/10 17:11:48 (9 years ago)
Author:
beliar
Message:

Patch by Beliar.

  • Added basic support for adding items on the map. Currently no interaction with the items are possible.
  • Added a bottle to the "Mall" map, its lying between the wooden crate and the "To farm" "door".
Location:
trunk/game
Files:
11 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/maps/all_agents.yaml

    r582 r592  
    192192    Position: [4.0, 3.0, 0.0] 
    193193    Rotation: 0 
     194--- 
     195Bottle: 
     196    ViewName: Bottle 
     197    ObjectType: "MapItem" 
     198    ItemType: "Empty beer bottle" 
     199    Map: "Mall" 
     200    Position: [-5.0, -11.0, 0.0] 
     201    Rotation: 0 
  • trunk/game/objects/object_database.yaml

    r587 r592  
    110110  name: Empty beer bottle 
    111111  image: /gui/inv_images/inv_beer_bottle_empty.png 
     112  gfx: bottle 
    112113  actions: 
    113114    Look: 
  • trunk/game/scripts/gamemodel.py

    r590 r592  
    317317        if agent_values.has_key("ObjectModel"):  
    318318            object_model =  agent_values["ObjectModel"] 
     319        elif agent_values["ObjectType"] == "MapItem": 
     320            object_model = self.object_db[agent_values["ItemType"]]["gfx"]             
    319321        else: 
    320322            object_model = self.object_db[agent_values["ObjectType"]]["gfx"] 
     
    384386                                else None 
    385387        if object_id == None: 
    386             object_id = self.object_db[object_type]["gfx"] 
     388            if object_type == "MapItem": 
     389                object_id = self.object_db[agent["ItemType"]]["gfx"] 
     390            else: 
     391                object_id = self.object_db[object_type]["gfx"] 
    387392        map_obj = self.fife_model.getObject(str(object_id), "PARPG") 
    388393        if not map_obj: 
     
    464469                items.append(self.createContainerObject(inventory_obj)) 
    465470            inst_dict["items"] = items 
    466  
    467                      
     471             
     472        if agent.has_key("ItemType"): 
     473            inst_dict["item"] = None #TODO: Create item 
     474            inst_dict["item_id"] = agent["ItemType"] 
     475         
    468476        self.createMapObject(self.active_map.agent_layer, inst_dict, inst) 
    469477     
  • trunk/game/scripts/objects/__init__.py

    r584 r592  
    1616#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    1717 
    18 import containers, doors 
     18import containers 
     19import doors 
    1920import actors 
     21import items 
    2022import sys 
    2123 
    22 object_modules = [containers, actors, doors] 
     24OBJECT_MODULES = [containers, actors, doors, items] 
    2325 
    2426def getAllObjects (): 
     
    2628       mapped to the classes themselves""" 
    2729    result = {} 
    28     for module in object_modules: 
     30    for module in OBJECT_MODULES: 
    2931        for class_name in module.__all__: 
    30             result[class_name] = getattr (module,class_name) 
     32            result[class_name] = getattr (module, class_name) 
    3133    return result 
    3234 
    33 def createObject(info, extra = {}): 
     35def createObject(info, extra = None): 
    3436    """Called when we need to get an actual object. 
    3537       @type info: dict 
     
    3941       @return: the object""" 
    4042    # First, we try to get the type and ID, which every game_obj needs. 
     43    extra = extra or {} 
    4144    try: 
    4245        obj_type = info.pop('type') 
  • trunk/game/scripts/objects/base.py

    r590 r592  
    253253        self.is_carryable = True 
    254254        self.in_container = None 
     255        self.on_map = None 
     256        self.agent = None 
    255257        self.weight = weight 
    256258        self.bulk = bulk 
  • trunk/game/scripts/objects/composed.py

    r584 r592  
    9494        super(CarryableItem, self).prepareStateForSaving(state) 
    9595        del state["in_container"] 
     96        del state["on_map"] 
     97        del state["agent"] 
    9698 
    9799    def getStateForSaving(self): 
Note: See TracChangeset for help on using the changeset viewer.