Example #1
0
void handle_use_skill(Client *client, PKTIN_12 *msg)
{
	char *params;
	unsigned int skillnum = (int)strtoul( (char *) msg->data, &params, 10);

	if ( skillnum < SKILLID__CLIENT_LOWEST || skillnum > uoclient_general.maxskills )
		return;

	const UOSkill& uoskill = GetUOSkill(skillnum);
	const Attribute* attrib = uoskill.pAttr;

	// Shouldn't most these checks be left to the scripts? - Austin
	if ( !CanUseSkill(client) )
		return;
	else if ( !attrib->script_.empty() )
	{
		if ( StartSkillScript(client, attrib) )
			return;
	}
	
	Log("Client#%lu: (%s, acct:%s) No handler for skill %d\n",
			client->instance_, client->chr->name().c_str(), client->acct->name(), int(skillnum));
	cerr << "Character " << client->chr->name() << " (acct: " << client->chr->acct->name() << "): No handler for skill " << int(skillnum) << endl;
	send_sysmessage(client, "That skill is not implemented.");
}
Example #2
0
void send_skillmsg( Network::Client* client, const Mobile::Character* chr )
{
  Network::PktHelper::PacketOut<Network::PktOut_3A> msg;
  msg->offset += 2;
  if ( settingsManager.ssopt.core_sends_caps )
    msg->Write<u8>( PKTBI_3A_VALUES::FULL_LIST_CAP );
  else
    msg->Write<u8>( PKTBI_3A_VALUES::FULL_LIST );

  for ( unsigned short i = 0; i <= networkManager.uoclient_general.maxskills; ++i )
  {
    const UOSkill& uoskill = GetUOSkill( i );
    msg->WriteFlipped<u16>( static_cast<u16>( i + 1 ) );  // for some reason, we send this 1-based
    if ( uoskill.pAttr )
    {
      const Mobile::AttributeValue& av = chr->attribute( uoskill.pAttr->attrid );
      int value;
      value = av.effective_tenths();
      if ( value > 0xFFFF )
        value = 0xFFFF;
      msg->WriteFlipped<u16>( static_cast<u16>( value ) );

      value = av.base();
      if ( value > 0xFFFF )
        value = 0xFFFF;
      msg->WriteFlipped<u16>( static_cast<u16>( value ) );
      msg->Write<u8>( av.lock() );
      if ( settingsManager.ssopt.core_sends_caps )
        msg->WriteFlipped<u16>( av.cap() );
    }
    else
    {
      msg->offset += 4;  // u16 value/value_unmod
      msg->Write<u8>( PKTBI_3A_VALUES::LOCK_DOWN );
      if ( settingsManager.ssopt.core_sends_caps )
        msg->WriteFlipped<u16>( settingsManager.ssopt.default_attribute_cap );
    }
  }
  if ( !settingsManager.ssopt.core_sends_caps )
    msg->offset += 2;  // u16 nullterm
  u16 len = msg->offset;
  msg->offset = 1;
  msg->WriteFlipped<u16>( len );
  msg.Send( client, len );
}
Example #3
0
void handle_skill_lock( Network::Client* client, PKTBI_3A_LOCKS* msg )
{
  if ( settingsManager.ssopt.core_handled_locks )
  {
    unsigned int skillid = cfBEu16( msg->skillid );
    if ( skillid > networkManager.uoclient_general.maxskills )
      return;

    const UOSkill& uoskill = GetUOSkill( skillid );
    if ( !uoskill.pAttr )  // tried to set lockstate for a skill that isn't defined
      return;

    if ( msg->lock_mode < 3 )
      client->chr->attribute( uoskill.pAttr->attrid ).lock( msg->lock_mode );
    else
      INFO_PRINT << "Client " << client->chr->name() << " tried to set an illegal lock state.\n";
  }
}