Beispiel #1
0
bool CanUseSkill(Client* client)
{
	Character* chr = client->chr;

	if ( chr->dead() )
	{
		private_say_above(chr, chr, "I am dead and cannot do that.");
		return false;
	}
	else if ( chr->skill_ex_active() || chr->casting_spell() )
	{
		private_say_above(chr, chr,"I am already performing another action.");
		return false;
	}
	else if ( poltime() < chr->disable_skills_until )
	{
		send_sysmessage(client, "You must wait to perform another action.");
		return false;
	}
	else if ( chr->frozen() || chr->paralyzed() )
	{
		private_say_above(chr, chr, "I am frozen and cannot do that.");
		return false;
	}

	return true;
}
Beispiel #2
0
void TargetCursor::handle_target_cursor( Mobile::Character* chr, PKTBI_6C* msg )
{
  if ( msg->selected_serial != 0 )   // targetted something
  {

    if ( chr->dead() )            // but is dead
    {
      if ( chr->client != NULL ) send_sysmessage( chr->client, "I am dead and cannot do that." );
      cancel( chr );
      return;
    }

    if ( ( chr->frozen() || chr->paralyzed() ) && !chr->setting_enabled( "freemove" ) )
    {
      if ( chr->client != NULL )
      {
        if ( chr->frozen() )
          private_say_above( chr, chr, "I am frozen and cannot do that." );
        else if ( chr->paralyzed() )
          private_say_above( chr, chr, "I am paralyzed and cannot do that." );
      }
      cancel( chr );
      return;
    }

    u32 selected_serial = cfBEu32( msg->selected_serial );
    UObject* obj = system_find_object( selected_serial );
    if ( obj != NULL && obj->script_isa( POLCLASS_MOBILE ) &&
         !obj->script_isa( POLCLASS_NPC ) )
    {
      Mobile::Character* targeted = find_character( selected_serial );
      // check for when char is not logged on
      if ( targeted != NULL )
      {
        if ( !chr->is_visible_to_me( targeted ) )
        {
          cancel( chr );
          return;
        }

        if ( msg->cursor_type == 1 )
        {
          if ( ( JusticeRegion::RunNoCombatCheck( chr->client ) == true )
               || ( JusticeRegion::RunNoCombatCheck( targeted->client ) == true ) )
          {
            send_sysmessage( chr->client, "Combat is not allowed in this area." );
            cancel( chr );
            return;
          }
        }
      }
    }
  }

  if ( msg->x != 0xffff || msg->selected_serial != 0 )
    on_target_cursor( chr, msg );
  else
    cancel( chr );
}
Beispiel #3
0
void UDoor::builtin_on_use( Client *client )
{
    if (locked_)
    {
        private_say_above( client->chr, this, "That is locked." );
    }
    else
    {
        toggle();
    }
}
Beispiel #4
0
    void USpell::speak_power_words( Mobile::Character* chr, unsigned short font, unsigned short color )
	{
	  if ( chr->client != NULL && chr->hidden() )
	  {
		private_say_above( chr, chr, power_words_.c_str(), font, color );
	  }
	  else if ( !chr->hidden() )
	  {
		say_above( chr, power_words_.c_str(), font, color );
	  }
	}
Beispiel #5
0
void doubleclick( Network::Client* client, PKTIN_06* msg )
{
  u32 serial = cfBEu32( msg->serial );
  u32 paperdoll_macro_flag = serial & 0x80000000Lu;
  serial &= ~0x80000000Lu;  // keypress versus doubleclick switch?

  // the find_character would find this, but most of the time it's your own paperdoll.
  // this is special-cased for two reasons:
  //    1) it's commonly done
  //    2) ghosts can doubleclick ONLY their paperdoll.
  if ( serial == client->chr->serial )
  {
    if ( !paperdoll_macro_flag )
    {
      ScriptDef sd;
      sd.quickconfig( "scripts/misc/dblclickself.ecl" );
      if ( sd.exists() )
      {
        ref_ptr<Bscript::EScriptProgram> prog;
        prog = find_script2( sd, false, Plib::systemstate.config.cache_interactive_scripts );
        if ( prog.get() != nullptr && client->chr->start_script( prog.get(), false ) )
        {
          return;
        }
      }
    }
    send_paperdoll( client, client->chr );
    return;
  }

  if ( client->chr->dblclick_wait() > read_gameclock() )
  {
    private_say_above( client->chr, client->chr, "You must wait to use something again." );
    return;
  }
  else
    client->chr->dblclick_wait( read_gameclock() + settingsManager.ssopt.dblclick_wait );

  if ( IsCharacter( serial ) )
  {
    if ( client->chr->dead() )
      return;
    Mobile::Character* chr = find_character( serial );
    if ( !chr )
      return;

    if ( chr->isa( UOBJ_CLASS::CLASS_NPC ) )
    {
      Mobile::NPC* npc = static_cast<Mobile::NPC*>( chr );
      if ( npc->can_accept_event( EVID_DOUBLECLICKED ) )
      {
        npc->send_event( new Module::SourcedEvent( EVID_DOUBLECLICKED, client->chr ) );
        return;
      }
    }

    bool script_ran = false;
    ScriptDef sd;
    sd.quickconfig( "scripts/misc/dblclickother.ecl" );
    if ( sd.exists() )
    {
      ref_ptr<Bscript::EScriptProgram> prog;
      prog = find_script2( sd, false, Plib::systemstate.config.cache_interactive_scripts );
      if ( prog.get() != nullptr )
        script_ran =
            client->chr->start_script( prog.get(), false, new Module::ECharacterRefObjImp( chr ) );
    }
    if ( !script_ran && inrange( client->chr, chr ) )
    {
      // MuadDib Changed from a large if || || || to switch case. 1/4/2007
      switch ( chr->graphic )
      {
      case UOBJ_HUMAN_MALE:
      case UOBJ_HUMAN_FEMALE:
      case UOBJ_HUMAN_MALE_GHOST:
      case UOBJ_HUMAN_FEMALE_GHOST:
      case UOBJ_ELF_MALE:
      case UOBJ_ELF_FEMALE:
      case UOBJ_ELF_MALE_GHOST:
      case UOBJ_ELF_FEMALE_GHOST:
      case UOBJ_GARGOYLE_MALE:
      case UOBJ_GARGOYLE_FEMALE:
      case UOBJ_GARGOYLE_MALE_GHOST:
      case UOBJ_GARGOYLE_FEMALE_GHOST:
      case UOBJ_GAMEMASTER:
      case 0x3de:
      case 0x3df:
      case 0x3e2:
        send_paperdoll( client, chr );
        break;
      }
    }
    return;
  }
  else  // doubleclicked an item
  {
    // next, search worn items, items in the backpack, and items in the world.
    Items::Item* item = find_legal_item( client->chr, serial );

    // next, check people's backpacks. (don't recurse down)
    //    (not done yet)

    if ( item != nullptr )
    {
      const Items::ItemDesc& id = item->itemdesc();

      if ( !id.ghosts_can_use && client->chr->dead() )
      {
        private_say_above( client->chr, client->chr, "I am dead and cannot do that." );
        return;
      }
      if ( !id.can_use_while_frozen && client->chr->frozen() )
      {
        private_say_above( client->chr, client->chr, "I am frozen and cannot do that." );
        return;
      }
      if ( !id.can_use_while_paralyzed && client->chr->paralyzed() )
      {
        private_say_above( client->chr, client->chr, "I am paralyzed and cannot do that." );
        return;
      }

      unsigned short dst = pol_distance( client->chr, item );
      if ( dst > id.doubleclick_range && !client->chr->can_dblclickany() )
      {
        private_say_above( client->chr, item, "That is too far away." );
        return;
      }
      UObject* obj = item->toplevel_owner();
      obj = obj->self_as_owner();
      if ( id.use_requires_los && !client->chr->realm->has_los( *client->chr, *obj ) )  // DAVE
                                                                                        // 11/24
      {
        private_say_above( client->chr, item, "I can't see that." );
        return;
      }

      ScriptDef sd;
      sd.quickconfig( "scripts/misc/dblclickitem.ecl" );
      if ( sd.exists() )
      {
        ref_ptr<Bscript::EScriptProgram> prog;
        prog = find_script2( sd, false, Plib::systemstate.config.cache_interactive_scripts );
        if ( prog.get() != nullptr )
          client->chr->start_script( prog.get(), false, new Module::EItemRefObjImp( item ) );
      }

      item->double_click( client );
      return;
    }

    // allow looking into containers being traded
    if ( client->chr->is_trading() )
    {
      UContainer* cont = client->chr->trade_container()->find_container( serial );
      if ( cont != nullptr )
      {
        cont->builtin_on_use( client );
        if ( !cont->locked() )
        {
          if ( client->chr->trading_with->client != nullptr )
            cont->builtin_on_use( client->chr->trading_with->client );
        }
        return;
      }
    }
  }
}
Beispiel #6
0
	void do_cast( Network::Client *client, u16 spellid )
	{
	  if ( system_hooks.on_cast_hook != NULL )
	  {
		if ( system_hooks.on_cast_hook->call( make_mobileref( client->chr ), new Bscript::BLong( spellid ) ) )
		  return;
	  }
	  // CHECKME should this look at spellnum, instead? static_cast behavior undefined if out of range.
	  if ( spellid > spells2.size() )
		return;

	  USpell *spell = spells2[spellid];
	  if ( spell == NULL )
	  {
        ERROR_PRINT << "Spell " << spellid << " is not implemented.\n";
		send_sysmessage( client, "That spell does not function." );
		return;
	  }

	  // Let scripts handle this.
	  //	if (client->chr->hidden())
	  //		client->chr->unhide();

	  if ( client->chr->frozen() )
	  {
		private_say_above( client->chr, client->chr, "I am frozen and cannot cast spells" );
		return;
	  }

	  if ( client->chr->paralyzed() )
	  {
		private_say_above( client->chr, client->chr, "I am paralyzed and cannot cast spells" );
		return;
	  }

	  if ( client->chr->skill_ex_active() )
	  {
		send_sysmessage( client, "You are already doing something else." );
		return;
	  }

	  if ( client->chr->casting_spell() )
	  {
		send_sysmessage( client, "You are already casting a spell." );
		return;
	  }

	  if ( nocast_here( client->chr ) )
	  {
		send_sysmessage( client, "Spells cannot be cast here." );
		return;
	  }

	  if ( config.require_spellbooks )
	  {
		if ( !knows_spell( client->chr, spellid ) )
		{
		  send_sysmessage( client, "You don't know that spell." );
		  return;
		}
	  }

#if 1
	  client->chr->schedule_spell( spell );
#else
	  spell->cast( client );
	  client->restart();
#endif
	}