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/>.
21 #include "client_message.h"
22 #include "ai_bot_npc.h"
23 #include "ai_grp_npc.h"
26 #include "ai_player.h"
27 #include "nel/misc/entity_id.h"
29 using namespace NLMISC
;
30 using namespace NLNET
;
32 // a big bad global var !
33 extern CAIEntityPhysical
*TempSpeaker
;
34 extern CBotPlayer
*TempPlayer
;
37 void cbClientFollowTarget( NLNET::CMessage
& msgin
, const std::string
& serviceName
, NLNET::TServiceId serviceId
)
42 if (eId
.getType()!=RYZOMID::player
)
46 CAIEntityPhysical
*entityPhys
=CAIS::instance().getEntityPhysical(TheDataset
.getDataSetRow(eId
));
51 CBotPlayer
*player
=NLMISC::safe_cast
<CBotPlayer
*>(entityPhys
);
52 player
->setFollowMode(true);
54 if ( ((CAIEntityPhysical
*)player
->getTarget())
55 || ((CAIEntityPhysical
*)player
->getVisualTarget()) )
57 // generate the follow event
58 CSpawnBotNpc
*bnpc
= dynamic_cast<CSpawnBotNpc
*>(((CAIEntityPhysical
*)player
->getTarget()));
60 bnpc
= dynamic_cast<CSpawnBotNpc
*>(((CAIEntityPhysical
*)player
->getVisualTarget()));
65 // set the temporary speaker
70 CGroupNpc
&grpNpc
= bnpc
->getPersistent().grp();
71 // generate en event on this bot group
72 // grpNpc.getEventContainer().EventPlayerTargetNpc.processStateEvent(&grpNpc);
73 grpNpc
.processStateEvent(grpNpc
.getEventContainer().EventPlayerTargetNpc
);
75 // if player is in follow mode, then generate an suplementary event
76 if (player
->getFollowMode())
77 grpNpc
.processStateEvent(grpNpc
.getEventContainer().EventPlayerFollowNpc
);
78 // grpNpc.getEventContainer().EventPlayerFollowNpc.processStateEvent(&grpNpc);
81 // reset the temp speaker
88 void cbClientNoFollowTarget( NLNET::CMessage
& msgin
, const std::string
& serviceName
, NLNET::TServiceId serviceId
)
93 if (eId
.getType()!=RYZOMID::player
)
97 CAIEntityPhysical
*const entityPhys
=CAIS::instance().getEntityPhysical(TheDataset
.getDataSetRow(eId
));
102 CBotPlayer
*const player
=NLMISC::safe_cast
<CBotPlayer
*>(entityPhys
);
103 player
->setFollowMode(false);
107 //----------------------------
109 //----------------------------
110 TUnifiedCallbackItem CbClientArray
[]=
112 { "CLIENT:TARGET:FOLLOW", cbClientFollowTarget
},
113 { "CLIENT:TARGET:NO_FOLLOW", cbClientNoFollowTarget
},
116 void CAIClientMessages::init()
118 // setup the callback array
119 CUnifiedNetwork::getInstance()->addCallbackArray( CbClientArray
, sizeof(CbClientArray
)/sizeof(CbClientArray
[0]) );
122 void CAIClientMessages::release()
126 #include "event_reaction_include.h"