ScummVM API documentation
trigger.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 #ifndef CRAB_TRIGGER_H
32 #define CRAB_TRIGGER_H
33 
34 #include "crab/event/GameEventInfo.h"
35 
36 namespace Crab {
37 
38 namespace pyrodactyl {
39 namespace event {
40 enum RelOp {
41  OP_AND,
42  OP_OR
43 };
44 
45 enum TriggerType {
46  TRIG_OBJ, // Interacting with an object, status of character (hostile, coward etc), state (stand, fight, flee, KO)
47  TRIG_OPINION, // Check opinion of a character (charm / intimidate / respect)
48  TRIG_LOC, // Being in a place on the map
49  TRIG_ITEM, // An item is present or not
50  TRIG_RECT, // A sprite is colliding with a rectangle
51  TRIG_STAT, // Check any stat of an object (health, attack, defense etc)
52  TRIG_DIFF, // Check the game's difficulty
53  TRIG_TRAIT, // See if a character has a certain trait
54  TRIG_VAR // A variable is present or not, or if it's a certain value
55 };
56 
57 struct Trigger {
58  TriggerType _type;
59  Common::String _target, _subject, _operation, _val;
60 
61  // Relation to the next trigger
62  RelOp _rel;
63 
64  // Represents the Boolean ! operator
65  bool _negate;
66 
67  Trigger() {
68  _type = TRIG_VAR;
69  _rel = OP_AND;
70  _negate = false;
71  }
72 
73  Trigger(rapidxml::xml_node<char> *node) {
74  load(node);
75  }
76 
77  void load(rapidxml::xml_node<char> *node);
78  bool evaluate(pyrodactyl::event::Info &info);
79 
80  bool evaluate(int lhs, int rhs);
81 };
82 } // End of namespace event
83 } // End of namespace pyrodactyl
84 
85 } // End of namespace Crab
86 
87 #endif // CRAB_TRIGGER_H
Definition: str.h:59
Definition: GameEventInfo.h:44
Definition: trigger.h:57
Definition: moveeffect.h:37