3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef CONTENT_SAO_HEADER
21 #define CONTENT_SAO_HEADER
23 #include "serverobject.h"
24 #include "content_object.h"
26 class TestSAO : public ServerActiveObject
29 TestSAO(ServerEnvironment *env, v3f pos);
31 {return ACTIVEOBJECT_TYPE_TEST;}
32 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
33 const std::string &data);
34 void step(float dtime, bool send_recommended);
40 class ItemSAO : public ServerActiveObject
43 ItemSAO(ServerEnvironment *env, v3f pos,
44 const std::string inventorystring);
46 {return ACTIVEOBJECT_TYPE_ITEM;}
47 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
48 const std::string &data);
49 void step(float dtime, bool send_recommended);
50 std::string getClientInitializationData();
51 std::string getStaticData();
52 InventoryItem* createInventoryItem();
53 void punch(ServerActiveObject *puncher);
54 float getMinimumSavedMovement(){ return 0.1*BS; }
56 std::string m_inventorystring;
58 v3f m_last_sent_position;
59 IntervalLimiter m_move_interval;
62 class RatSAO : public ServerActiveObject
65 RatSAO(ServerEnvironment *env, v3f pos);
67 {return ACTIVEOBJECT_TYPE_RAT;}
68 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
69 const std::string &data);
70 void step(float dtime, bool send_recommended);
71 std::string getClientInitializationData();
72 std::string getStaticData();
73 void punch(ServerActiveObject *puncher);
76 IntervalLimiter m_inactive_interval;
79 v3f m_last_sent_position;
84 bool m_touching_ground;
87 class Oerkki1SAO : public ServerActiveObject
90 Oerkki1SAO(ServerEnvironment *env, v3f pos);
92 {return ACTIVEOBJECT_TYPE_OERKKI1;}
93 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
94 const std::string &data);
95 void step(float dtime, bool send_recommended);
96 std::string getClientInitializationData();
97 std::string getStaticData();
98 InventoryItem* createPickedUpItem(){return NULL;}
99 void punch(ServerActiveObject *puncher);
100 bool isPeaceful(){return false;}
102 void doDamage(u16 d);
105 IntervalLimiter m_inactive_interval;
108 v3f m_last_sent_position;
113 bool m_touching_ground;
115 float m_after_jump_timer;
118 class FireflySAO : public ServerActiveObject
121 FireflySAO(ServerEnvironment *env, v3f pos);
123 {return ACTIVEOBJECT_TYPE_FIREFLY;}
124 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
125 const std::string &data);
126 void step(float dtime, bool send_recommended);
127 std::string getClientInitializationData();
128 std::string getStaticData();
129 InventoryItem* createPickedUpItem();
132 IntervalLimiter m_inactive_interval;
135 v3f m_last_sent_position;
140 bool m_touching_ground;
145 class MobV2SAO : public ServerActiveObject
148 MobV2SAO(ServerEnvironment *env, v3f pos,
149 Settings *init_properties);
152 {return ACTIVEOBJECT_TYPE_MOBV2;}
153 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
154 const std::string &data);
155 std::string getStaticData();
156 std::string getClientInitializationData();
157 void step(float dtime, bool send_recommended);
158 InventoryItem* createPickedUpItem(){return NULL;}
159 void punch(ServerActiveObject *puncher);
163 void setPropertyDefaults();
164 void readProperties();
165 void updateProperties();
166 void doDamage(u16 d);
168 std::string m_move_type;
170 v3f m_last_sent_position;
176 bool m_touching_ground;
179 float m_walk_around_timer;
180 bool m_next_pos_exists;
182 float m_shoot_reload_timer;
184 float m_shooting_timer;
188 float m_disturb_timer;
189 std::string m_disturbing_player;
190 float m_random_disturb_timer;
193 Settings *m_properties;
196 struct LuaEntityProperties;
198 class LuaEntitySAO : public ServerActiveObject
201 LuaEntitySAO(ServerEnvironment *env, v3f pos,
202 const std::string &name, const std::string &state);
205 {return ACTIVEOBJECT_TYPE_LUAENTITY;}
206 virtual void addedToEnvironment();
207 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
208 const std::string &data);
209 void step(float dtime, bool send_recommended);
210 std::string getClientInitializationData();
211 std::string getStaticData();
212 InventoryItem* createPickedUpItem();
213 void punch(ServerActiveObject *puncher);
214 void rightClick(ServerActiveObject *clicker);
215 void setPos(v3f pos);
216 void moveTo(v3f pos, bool continuous);
217 float getMinimumSavedMovement();
218 /* LuaEntitySAO-specific */
219 void setVelocity(v3f velocity);
220 void setAcceleration(v3f acceleration);
221 v3f getAcceleration();
222 void setTextureMod(const std::string &mod);
223 void setSprite(v2s16 p, int num_frames, float framelength,
224 bool select_horiz_by_yawpitch);
226 void sendPosition(bool do_interpolate, bool is_movement_end);
228 std::string m_init_name;
229 std::string m_init_state;
231 struct LuaEntityProperties *m_prop;
236 float m_last_sent_yaw;
237 v3f m_last_sent_position;
238 v3f m_last_sent_velocity;
239 float m_last_sent_position_timer;
240 float m_last_sent_move_precision;