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 void rightClick(ServerActiveObject *clicker);
55 float getMinimumSavedMovement(){ return 0.1*BS; }
57 std::string m_inventorystring;
59 v3f m_last_sent_position;
60 IntervalLimiter m_move_interval;
63 class RatSAO : public ServerActiveObject
66 RatSAO(ServerEnvironment *env, v3f pos);
68 {return ACTIVEOBJECT_TYPE_RAT;}
69 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
70 const std::string &data);
71 void step(float dtime, bool send_recommended);
72 std::string getClientInitializationData();
73 std::string getStaticData();
74 void punch(ServerActiveObject *puncher);
77 IntervalLimiter m_inactive_interval;
80 v3f m_last_sent_position;
85 bool m_touching_ground;
88 class Oerkki1SAO : public ServerActiveObject
91 Oerkki1SAO(ServerEnvironment *env, v3f pos);
93 {return ACTIVEOBJECT_TYPE_OERKKI1;}
94 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
95 const std::string &data);
96 void step(float dtime, bool send_recommended);
97 std::string getClientInitializationData();
98 std::string getStaticData();
99 InventoryItem* createPickedUpItem(){return NULL;}
100 void punch(ServerActiveObject *puncher);
101 bool isPeaceful(){return false;}
103 void doDamage(u16 d);
106 IntervalLimiter m_inactive_interval;
109 v3f m_last_sent_position;
114 bool m_touching_ground;
116 float m_after_jump_timer;
119 class FireflySAO : public ServerActiveObject
122 FireflySAO(ServerEnvironment *env, v3f pos);
124 {return ACTIVEOBJECT_TYPE_FIREFLY;}
125 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
126 const std::string &data);
127 void step(float dtime, bool send_recommended);
128 std::string getClientInitializationData();
129 std::string getStaticData();
130 InventoryItem* createPickedUpItem();
133 IntervalLimiter m_inactive_interval;
136 v3f m_last_sent_position;
141 bool m_touching_ground;
146 class MobV2SAO : public ServerActiveObject
149 MobV2SAO(ServerEnvironment *env, v3f pos,
150 Settings *init_properties);
153 {return ACTIVEOBJECT_TYPE_MOBV2;}
154 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
155 const std::string &data);
156 std::string getStaticData();
157 std::string getClientInitializationData();
158 void step(float dtime, bool send_recommended);
159 InventoryItem* createPickedUpItem(){return NULL;}
160 void punch(ServerActiveObject *puncher);
164 void setPropertyDefaults();
165 void readProperties();
166 void updateProperties();
167 void doDamage(u16 d);
169 std::string m_move_type;
171 v3f m_last_sent_position;
177 bool m_touching_ground;
180 float m_walk_around_timer;
181 bool m_next_pos_exists;
183 float m_shoot_reload_timer;
185 float m_shooting_timer;
189 float m_disturb_timer;
190 std::string m_disturbing_player;
191 float m_random_disturb_timer;
194 Settings *m_properties;
197 struct LuaEntityProperties;
199 class LuaEntitySAO : public ServerActiveObject
202 LuaEntitySAO(ServerEnvironment *env, v3f pos,
203 const std::string &name, const std::string &state);
206 {return ACTIVEOBJECT_TYPE_LUAENTITY;}
207 virtual void addedToEnvironment();
208 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
209 const std::string &data);
210 void step(float dtime, bool send_recommended);
211 std::string getClientInitializationData();
212 std::string getStaticData();
213 InventoryItem* createPickedUpItem();
214 void punch(ServerActiveObject *puncher);
215 void rightClick(ServerActiveObject *clicker);
216 void setPos(v3f pos);
217 void moveTo(v3f pos, bool continuous);
218 float getMinimumSavedMovement();
219 /* LuaEntitySAO-specific */
220 void setVelocity(v3f velocity);
221 void setAcceleration(v3f acceleration);
222 v3f getAcceleration();
223 void setTextureMod(const std::string &mod);
224 void setSprite(v2s16 p, int num_frames, float framelength,
225 bool select_horiz_by_yawpitch);
227 void sendPosition(bool do_interpolate, bool is_movement_end);
229 std::string m_init_name;
230 std::string m_init_state;
232 struct LuaEntityProperties *m_prop;
237 float m_last_sent_yaw;
238 v3f m_last_sent_position;
239 v3f m_last_sent_velocity;
240 float m_last_sent_position_timer;
241 float m_last_sent_move_precision;