Ignore:
Timestamp:
07/24/10 14:09:19 (9 years ago)
Author:
beliar
Message:

Patch by Beliar.

  • Items can now be dropped and picked up again
  • Added generic image for items (Made by Q_x, he did the other items too).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/objects/action.py

    r595 r596  
    289289    def __init__(self, controller, map_item, commands = None): 
    290290        super(PickUpAction, self).__init__(controller, commands) 
    291         self.view = controller.view 
    292291        self.map_item = map_item 
    293292 
     
    299298        super(PickUpAction, self).execute() 
    300299         
     300class DropItemAction(Action): 
     301    """Action for dropping an items on a map""" 
     302 
     303    def __init__(self, controller, item, container_gui, commands = None): 
     304        super(DropItemAction, self).__init__(controller, commands) 
     305        self.item = item 
     306        self.container_gui = container_gui 
     307 
     308    def execute(self): 
     309        item_data = self.item.getStateForSaving() 
     310        item_data["type"] = self.item.item_type 
     311        map_name = self.model.game_state.current_map_name 
     312        map_item_values = {} 
     313        map_item_values["ViewName"] = self.item.name 
     314        map_item_values["ObjectType"] = "MapItem" 
     315        map_item_values["ItemType"] = self.item.item_type 
     316        map_item_values["Map"] = map_name 
     317        coords = self.model.game_state.player_character.\ 
     318                                        getLocation().getExactLayerCoordinates() 
     319        map_item_values["Position"] = (coords.x - 1.0, coords.y + 1.0) 
     320        map_item_values["Rotation"] = 0 
     321        map_item_values["item"] = item_data 
     322        agent = {} 
     323        agent[self.item.ID] = map_item_values 
     324        self.model.addAgent("All", agent) 
     325        self.model.placeAgents() 
     326        self.item.in_container.takeItem(self.item)         
     327        self.container_gui.updateImages() 
     328        super(DropItemAction, self).execute() 
     329 
    301330ACTIONS = {"ChangeMap":ChangeMapAction,  
    302331           "OpenBox":OpenBoxAction,  
     
    308337           "Talk":TalkAction, 
    309338           "Use":UseAction, 
    310            "PickUp":PickUpAction} 
     339           "PickUp":PickUpAction, 
     340           "Drop":DropItemAction} 
Note: See TracChangeset for help on using the changeset viewer.