1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 using namespace NLMISC
;
25 NL_INSTANCE_COUNTER_IMPL(IAIEvent
);
26 NL_INSTANCE_COUNTER_IMPL(CAIStunEvent
);
27 NL_INSTANCE_COUNTER_IMPL(CAIStunEndEvent
);
29 //------------------------------IMPORTANT----------------------------------
30 // The EventType isn't read in the serial as it is used in the read process
31 // to get the right event type (in the AI service)
32 //-------------------------------------------------------------------------
36 //--------------------------------------------------------------
37 // CAIStunEvent::serial()
38 //--------------------------------------------------------------
39 void CAIStunEvent::serial(NLMISC::IStream
&f
)
48 if (/*type != CAIEventType("STUN") || */size
!= sizeof(CAIStunEvent
))
50 CreatureId
= NLMISC::CEntityId();
53 // seek takes a param in bytes (8 bits)
54 f
.seek( size
, NLMISC::IStream::current
);
56 catch(const ESeekNotSupported
&)
59 for (uint i
= 0 ; i
< size
; ++i
)
70 CAIEventType
type("STUN");
71 uint16 size
= sizeof(CAIStunEvent
);
77 } // CAIStunEvent::serial //
81 //--------------------------------------------------------------
82 // CAIAggroEvent::serial()
83 //--------------------------------------------------------------
84 void CAIAggroEvent::serial(NLMISC::IStream
&f
)
93 if (/*type != CAIEventType("AGGRO") || */size
!= sizeof(CAIAggroEvent
))
95 CreatureId
= NLMISC::CEntityId();
96 EntityId
= NLMISC::CEntityId();
100 // seek takes a param in bytes (8 bits)
101 f
.seek( size
, NLMISC::IStream::current
);
103 catch(const ESeekNotSupported
&)
106 for (uint i
= 0 ; i
< size
; ++i
)
112 f
.serial(CreatureId
);
114 f
.serial(AggroModifier
);
119 CAIEventType
type("AGGRO");
120 uint16 size
= sizeof(CAIAggroEvent
);
124 f
.serial(CreatureId
);
126 f
.serial(AggroModifier
);
128 } // CAIAggroEvent::serial //
133 //--------------------------------------------------------------
134 // CAIStunEndEvent::serial()
135 //--------------------------------------------------------------
136 void CAIStunEndEvent::serial(NLMISC::IStream
&f
)
140 // CAIEventType type;
145 if (/*type != CAIEventType("STUN_END") ||*/ size
!= sizeof(CAIStunEndEvent
))
147 CreatureId
= NLMISC::CEntityId();
150 // seek takes a param in bytes (8 bits)
151 f
.seek( size
, NLMISC::IStream::current
);
153 catch(const ESeekNotSupported
&)
156 for (uint i
= 0 ; i
< size
; ++i
)
162 f
.serial(CreatureId
);
167 CAIEventType
type("STUN_END");
168 uint16 size
= sizeof(CAIStunEndEvent
);
172 f
.serial(CreatureId
);
174 } // CAIStunEndEvent::serial //
179 //--------------------------------------------------------------
180 // CAISurvivalInstinctEvent::serial()
181 //--------------------------------------------------------------
182 void CAISurvivalInstinctEvent::serial(NLMISC::IStream
&f
)
186 // CAIEventType type;
191 if (/*type != CAIEventType("SURVIE") ||*/ size
!= sizeof(CAISurvivalInstinctEvent
))
193 CreatureId
= NLMISC::CEntityId();
194 EntityId
= NLMISC::CEntityId();
198 // seek takes a param in bytes (8 bits)
199 f
.seek( size
, NLMISC::IStream::current
);
201 catch(const ESeekNotSupported
&)
204 for (uint i
= 0 ; i
< size
; ++i
)
210 f
.serial(CreatureId
);
217 CAIEventType
type("SURVIE");
218 uint16 size
= sizeof(CAISurvivalInstinctEvent
);
222 f
.serial(CreatureId
);
227 } // CAISurvivalInstinctEvent::serial //
231 //--------------------------------------------------------------
232 // CAIFearEvent::serial()
233 //--------------------------------------------------------------
234 void CAIFearEvent::serial(NLMISC::IStream
&f
)
238 // CAIEventType type;
243 if (/*type != CAIEventType("FEAR") ||*/ size
!= sizeof(CAIFearEvent
))
245 CreatureId
= NLMISC::CEntityId();
246 EntityId
= NLMISC::CEntityId();
249 // seek takes a param in bytes (8 bits)
250 f
.seek( size
, NLMISC::IStream::current
);
252 catch(const ESeekNotSupported
&)
255 for (uint i
= 0 ; i
< size
; ++i
)
261 f
.serial(CreatureId
);
267 CAIEventType
type("FEAR");
268 uint16 size
= sizeof(CAIFearEvent
);
272 f
.serial(CreatureId
);
275 } // CAIFearEvent::serial //
278 //--------------------------------------------------------------
279 // CAIFearEndEvent::serial()
280 //--------------------------------------------------------------
281 void CAIFearEndEvent::serial(NLMISC::IStream
&f
)
290 if (/*type != CAIEventType("FEAR_END") ||*/ size
!= sizeof(CAIFearEndEvent
))
292 CreatureId
= NLMISC::CEntityId();
293 EntityId
= NLMISC::CEntityId();
296 // seek takes a param in bytes (8 bits)
297 f
.seek( size
, NLMISC::IStream::current
);
299 catch(const ESeekNotSupported
&)
302 for (uint i
= 0 ; i
< size
; ++i
)
308 f
.serial(CreatureId
);
314 CAIEventType
type("FEAR_END");
315 uint16 size
= sizeof(CAIFearEndEvent
);
319 f
.serial(CreatureId
);
322 } // CAIFearEndEvent::serial //
326 //--------------------------------------------------------------
327 // CAIHungerEvent::serial()
328 //--------------------------------------------------------------
329 void CAIHungerEvent::serial(NLMISC::IStream
&f
)
338 if (/*type != CAIEventType("HUNGER") ||*/ size
!= sizeof(CAIHungerEvent
))
340 CreatureId
= NLMISC::CEntityId();
344 // seek takes a param in bytes (8 bits)
345 f
.seek( size
, NLMISC::IStream::current
);
347 catch(const ESeekNotSupported
&)
350 for (uint i
= 0 ; i
< size
; ++i
)
356 f
.serial(CreatureId
);
362 CAIEventType
type("HUNGER");
363 uint16 size
= sizeof(CAIHungerEvent
);
367 f
.serial(CreatureId
);
370 } // CAIHungerEvent::serial //