~ubuntu-branches/ubuntu/trusty/enigma/trusty-proposed

« back to all changes in this revision

Viewing changes to src/floors/ThiefFloor.cc

  • Committer: Package Import Robot
  • Author(s): Erich Schubert
  • Date: 2013-04-06 14:54:02 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20130406145402-jgjrtk7hac8gtvza
Tags: 1.20-dfsg.1-1
* New upstream release (Closes: #704595)
  (Repacked: dropped zipios++ source and main menu music)
* Update watch file, sf.net again.
* Fix documentation links (Closes: #653508)
* Conflict with enigma-level-previews to encourage deinstallation
  (Pregenerated level previews were only used with version 1.01)
* Use dh7 for building instead of CDBS
* Update to policy 3.9.4.0 (no changes)
* Register documentation with doc-base

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * modify it under the terms of the GNU General Public License
8
8
 * as published by the Free Software Foundation; either version 2
9
9
 * of the License, or (at your option) any later version.
10
 
 *  
 
10
 *
11
11
 * This program is distributed in the hope that it will be useful,
12
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
29
 
30
30
namespace enigma {
31
31
    ThiefFloor::ThiefFloor() : Floor("fl_thief", 4.5, 1.5), victimId (0), bag (NULL) {
32
 
        
 
32
 
33
33
    }
34
 
    
 
34
 
35
35
    ThiefFloor::~ThiefFloor() {
36
36
        if (bag != NULL)
37
37
            delete bag;
40
40
    std::string ThiefFloor::getClass() const {
41
41
        return "fl_thief";
42
42
    }
43
 
    
 
43
 
44
44
    Value ThiefFloor::message(const Message &m) {
45
 
        if (m.message == "_capture" && (state == IDLE || state == DRUNKEN) && isDisplayable()) {            
 
45
        if (m.message == "_capture" && (state == IDLE || state == DRUNKEN) && isDisplayable()) {
46
46
            // add items on grid pos that can be picked up to our bag
47
47
            Item * it =  GetItem(get_pos());
48
48
            if (it != NULL && !(it->get_traits().flags & itf_static) && bag != NULL) {
59
59
        }
60
60
        return Floor::message(m);
61
61
    }
62
 
   
 
62
 
63
63
    void ThiefFloor::setState(int extState) {
64
64
        // block all state writes
65
65
    }
66
 
    
 
66
 
67
67
    void ThiefFloor::on_creation(GridPos p) {
68
68
        objFlags |= (IntegerRand(0, 3) << 24);
69
69
        Floor::on_creation(p);
70
70
    }
71
 
    
 
71
 
72
72
    std::string ThiefFloor::getModelName() const {
73
73
        return ecl::strf("fl_thief%d", ((objFlags & OBJBIT_MODEL) >> 24) + 1);
74
74
    }
75
 
    
 
75
 
76
76
    void ThiefFloor::init_model() {
77
77
        std::string basename = getModelName();
78
78
        switch (state) {
79
79
            case IDLE:
80
80
            case CAPTURED:
81
 
                set_model(basename); 
 
81
                set_model(basename);
82
82
                break;
83
83
            case EMERGING:
84
84
                set_anim(basename + "_emerge");
97
97
                break;
98
98
        }
99
99
    }
100
 
    
 
100
 
101
101
    void ThiefFloor::actor_enter(Actor *a) {
102
102
        if (state == IDLE && a->is_on_floor()) {
103
103
            state = EMERGING;
130
130
 
131
131
    void ThiefFloor::doSteal() {
132
132
        bool didSteal = false;
133
 
        
 
133
 
134
134
        // the actor that hit the thief may no longer exist!
135
135
        if (Actor *victim = dynamic_cast<Actor *>(Object::getObject(victimId))) {
136
136
            if (Value owner = victim->getAttr("owner")) {
158
158
            if (!(it->get_traits().flags & itf_static)) {
159
159
                if (bag == NULL) {
160
160
                    bag = MakeItem("it_bag");
161
 
                    bag->setOwnerPos(get_pos());                
 
161
                    bag->setOwnerPos(get_pos());
162
162
                }
163
 
                Item *it = YieldItem(get_pos());
164
 
                dynamic_cast<ItemHolder *>(bag)->add_item(it);
 
163
                Item *theit = YieldItem(get_pos());
 
164
                dynamic_cast<ItemHolder *>(bag)->add_item(theit);
165
165
                didSteal = true;
166
166
                if (it->getKind() == "it_bottle_idle")
167
167
                    state = DRUNKEN;
170
170
        if (didSteal)
171
171
            sound_event("thief");
172
172
    }
173
 
        
 
173
 
174
174
    BOOT_REGISTER_START
175
175
        BootRegister(new ThiefFloor(), "fl_thief");
176
176
    BOOT_REGISTER_END