Changed: #1304: Instanciation of guild missions.

This commit is contained in:
Fabien_HENON 2011-06-20 15:15:07 +02:00
parent 7264e6c1bf
commit 3479178476
5 changed files with 69 additions and 11 deletions

View file

@ -184,6 +184,7 @@ public:
{ {
// To Do // To Do
} }
void addMission(CMissionGuild* guildMission) {}
//@} //@}
/// inventory management /// inventory management

View file

@ -99,6 +99,12 @@ public:
/// user wanna pick a mission /// user wanna pick a mission
CMissionGuild * pickMission( TAIAlias alias ); CMissionGuild * pickMission( TAIAlias alias );
// Function to check if the member can pick a mission. By default only Officer and above can pick a guild mission
virtual bool canPickMission(TAIAlias alias)
{
return false;
}
/// set the version of last sent info of items in guild inventory /// set the version of last sent info of items in guild inventory
void setLastSentInfoVersion(uint32 slot, uint8 infoVersion) void setLastSentInfoVersion(uint32 slot, uint8 infoVersion)
{ {

View file

@ -34,6 +34,14 @@ public:
:CGuildMemberModule(proxy,guildMember){} :CGuildMemberModule(proxy,guildMember){}
virtual bool canAffectGrade(EGSPD::CGuildGrade::TGuildGrade grade)const; virtual bool canAffectGrade(EGSPD::CGuildGrade::TGuildGrade grade)const;
virtual bool canInvite()const; virtual bool canInvite()const;
// Function to check if the member can pick a mission.
// By default only Officers and above can pick a guild mission.
// So we don't need to implement this function for the other grades
virtual bool canPickMission(TAIAlias alias)
{
return true;
}
}; };
; ;

View file

@ -32,6 +32,7 @@ public:
CMissionGuild() : _Chained(false) { } CMissionGuild() : _Chained(false) { }
inline void setGuild( uint16 guildId );
/// override /// override
void updateUsersJournalEntry(); void updateUsersJournalEntry();
/// override /// override
@ -58,6 +59,10 @@ private:
bool _Chained; bool _Chained;
}; };
void CMissionGuild::setGuild( uint16 guildId )
{
_GuildId = guildId;
}
#endif // RY_MISSION_GUILD_H #endif // RY_MISSION_GUILD_H

View file

@ -836,29 +836,68 @@ void CMissionManager::instanciateMission(CCharacter* user,TAIAlias alias, TAIAl
} }
else if ( templ->Type == MISSION_DESC::Guild ) else if ( templ->Type == MISSION_DESC::Guild )
{ {
/// todo guild mission /// Check to see if we can pick the mission
CGuildMemberModule * module; CGuildMemberModule * module;
if ( !user->getModuleParent().getModule( module ) ) if ( !user->getModuleParent().getModule( module ) )
{ {
MISDBG("%s user not in a guild", sDebugPrefix.c_str()); MISDBG("%s user not in a guild", sDebugPrefix.c_str());
return; return;
} }
inst = module->pickMission( templ->Alias ); /* /// This is already checked in the prerequisites
if (!inst) if (!module->pickMission( templ->Alias ))
{
/// Todo : error message for the member
return; return;
}*/
CGuild * guild = CGuildManager::getInstance()->getGuildFromId( user->getGuildId() );
if (!guild)
{
nlwarning( "<MISSIONS>cant find guild ID : %d", _GuildId );
return;
}
if ( !templ->Tags.NoList && guild->getMissions().size() >= MaxGuildMissionCount)
{
CCharacter::sendDynamicSystemMessage(user->getId(), "MISSION_MAX_GUILD_REACHED" );
return;
}
CMissionGuild * guildMission = EGS_PD_CAST<CMissionGuild*>( EGSPD::CMissionGuildPD::create( templ->Alias ) );
if ( !guildMission )
{
MISDBG("%s could not create guild mission", sDebugPrefix.c_str());
return;
}
guildMission->onCreation( giver );
guildMission->setGuild(user->getGuildId());
// Find a suitable client index (for non-invisible missions)
if ( templ->Tags.NoList == false )
{
uint8 idx = 0;
for ( uint i = MaxGroupMissionCount; i < MaxGroupMissionCount + MaxGuildMissionCount; i++ )
{
if ( ! CBankAccessor_PLR::getGROUP().getMISSIONS().getArray(i).getTITLE(user->_PropertyDatabase))
{
idx = i;
break;
}
}
guildMission->setClientIndex( idx );
}
// Add mission
guild->addMission( guildMission );
inst = guildMission;
/// /!\ Do the same thing that the team missions but with the loop: for ( uint i = MaxGroupMissionCount; i < MaxGroupMissionCount + MaxGuildMissionCount; i++ ) /// /!\ Do the same thing that the team missions but with the loop: for ( uint i = MaxGroupMissionCount; i < MaxGroupMissionCount + MaxGuildMissionCount; i++ )
/// Instead of for ( uint i = 0; i < MaxGroupMissionCount; i++ ), so that we use available space for guild missions /// Instead of for ( uint i = 0; i < MaxGroupMissionCount; i++ ), so that we use available space for guild missions
/// todo guild mission : see solo /*//teamMission->initBasics( giver );
/* //soloMission->setTeam( user->getTeamId() );
todo guild mission : implement that in module
teamMission->initBasics( giver );
soloMission->setTeam( user->getTeamId() );
CGuild * guild = user->getGuild(); CGuild * guild = user->getGuild();
if ( guild ) if ( guild )
{ {
mission->getguild
if ( guild->getMissions().size() >= MaxGuildMissionCount) if ( guild->getMissions().size() >= MaxGuildMissionCount)
{ {
CCharacter::sendDynamicSystemMessage(user->getId(), "MISSION_MAX_GUILD_REACHED" ); CCharacter::sendDynamicSystemMessage(user->getId(), "MISSION_MAX_GUILD_REACHED" );
@ -884,8 +923,7 @@ void CMissionManager::instanciateMission(CCharacter* user,TAIAlias alias, TAIAl
else else
{ {
} }*/
*/
} }
else else
{ {