RESULT game_cmd_use_skill(GameContext* pGame, GameEventContext* pEvent, int idx) { RESULT ret; //char name[128]; int skill_num; Player* p = CUR_PLAYER(pGame); //const HeroConfig* pHero = get_hero_config(p->hero); //if(pHero == NULL) //{ // MSG_OUT("skill (%d) not exist!\n", idx ); // return R_E_PARAM; //} skill_num = p->hero == HeroID_None ? 0 : hero_skill_num(p->hero); if(idx < 1 || idx > skill_num) { MSG_OUT("无效的技能序号 [%d] !\n", idx ); return R_E_PARAM; } if(YES != can_use_skill(pGame, pEvent)) { MSG_OUT("你当前不能发动技能!\n"); return R_E_STATUS; } if(USE_MANUAL != call_hero_skill_can_use(p->hero, idx, pGame, pEvent, pGame->cur_player)) { MSG_OUT("当前你不能发动技能【%s】!\n", get_hero_skill_name(p->hero, idx) ); return R_E_STATUS; } // todo: trigger event per use skill MSG_OUT("【%s】发动武将技能【%s】。\n", p->name, get_hero_skill_name(p->hero, idx)); ret = call_hero_skill_event(p->hero, idx, pGame, pEvent, pGame->cur_player); // post trigger use skill (void)ret; return R_SUCC; }
RESULT game_cmd_use_armor(GameContext* pGame, GameEventContext* pEvent) { RESULT ret; Player* p = CUR_PLAYER(pGame); VCard vcard; PosCard pcard; //char temp[128]; if(R_SUCC != get_player_card(p, CardWhere_PlayerEquip, EquipIdx_Armor, &vcard)) { MSG_OUT("你没有装备%s!\n", equip_idx_str(EquipIdx_Armor)); return R_E_FAIL; } pcard.card = vcard.vcard; if(YES != can_use_skill(pGame, pEvent)) { MSG_OUT("你当前不能发动技能!\n"); return R_E_STATUS; } pcard.where = CardWhere_PlayerEquip; pcard.pos = EquipIdx_Armor; if(USE_MANUAL != game_card_can_use(pGame, pEvent, get_game_cur_player(pGame), &pcard)) { MSG_OUT("你装备的%s【%s】当前不能使用!\n", equip_idx_str(EquipIdx_Armor), get_card_name(pcard.card.id)); return R_E_FAIL; } MSG_OUT("【%s】发动【%s】的%s效果。\n", p->name, get_card_name(pcard.card.id), equip_idx_str(EquipIdx_Armor)); set_player_card_flag(p, pcard.where, pcard.pos, CardFlag_InUse); ret = call_card_event(pcard.card.id, pGame, pEvent, get_game_cur_player(pGame)); set_player_card_flag(p, pcard.where, pcard.pos, CardFlag_None); (void)ret; return R_SUCC; }
//Command Status: Installed, fairly well tested, near completetion. void do_prayer( CHAR_DATA *ch, char *argument ) { char arg[MIL]; AFFECT_DATA af; one_argument( argument, arg ); if ( IS_NPC( ch ) ) return; if ( IS_AFFECTED( ch, AFF_CHARM ) ) return; if ( !arg || arg[0] == '\0' ) { send_to_char( "Syntax: Prayer start\r\nSyntax: Prayer stop\r\n", ch ); return; } if ( !IS_AWAKE( ch ) ) { send_to_char( "You cant pray while asleep.", ch ); return; } if ( ch->position == POS_MEDITATING ) { send_to_char( "You are already meditating!\r\n", ch ); return; } if ( IS_AFFECTED( ch, AFF_PRAYER ) && !str_cmp( arg, "start" ) ) { send_to_char( "But you're already praying.\r\n", ch ); return; } if ( !str_cmp( arg, "start" ) ) { if ( can_use_skill( ch, number_percent( ), gsn_prayer ) ) { if ( ch->fighting ) { send_to_char( "You cannot start a prayer during combat.\r\n", ch ); return; } send_to_char( "You close your eyes and begin to pray.\r\n", ch ); af.type = gsn_prayer; af.location = APPLY_NONE; af.modifier = 0; af.level = ch->level; af.duration = -1; af.bitvector = meb( AFF_PRAYER ); affect_to_char( ch, &af ); learn_from_success( ch, gsn_prayer ); } else { send_to_char( "You can't seem to concentrate enough to properly pray.\r\n", ch ); learn_from_failure( ch, gsn_prayer ); } return; } if ( !str_cmp( arg, "stop" ) ) { if ( !IS_AFFECTED( ch, AFF_PRAYER ) ) { send_to_char( "But you're not praying.\r\n", ch ); return; } if ( ch->position != POS_STANDING ) set_position( ch, POS_STANDING ); send_to_char( "You come to an end in your prayer and slowly open your eyes.\r\n", ch ); affect_strip( ch, gsn_prayer ); xREMOVE_BIT( ch->affected_by, AFF_PRAYER ); return; } }
/* * Perform the actual attack on a victim -Thoric */ ch_ret ranged_got_target( char_data * ch, char_data * victim, obj_data * weapon, obj_data * projectile, short dist, short dt, const char *stxt, short color ) { /* * added wtype for check to determine skill used for ranged attacks - Grimm */ short wtype = 0; if( ch->in_room->flags.test( ROOM_SAFE ) ) { /* * safe room, bubye projectile */ if( projectile ) { ch->printf( "Your %s is blasted from existance by a godly presense.", projectile->myobj( ).c_str( ) ); act( color, "A godly presence smites $p!", ch, projectile, nullptr, TO_ROOM ); projectile->extract( ); } else { ch->printf( "Your %s is blasted from existance by a godly presense.", stxt ); act( color, "A godly presence smites $t!", ch, aoran( stxt ), nullptr, TO_ROOM ); } return rNONE; } /* if( victim->has_actflag( ACT_SENTINEL ) && ch->in_room != victim->in_room ) { * * letsee, if they're high enough.. attack back with fireballs * long distance or maybe some minions... go herne! heh.. * * For now, just always miss if not in same room -Thoric * if( projectile ) { * check dam type of projectile to determine skill to use - Grimm * switch( projectile->value[4] ) { case PROJ_BOLT: case PROJ_ARROW: ch->learn_from_failure( gsn_archery ); break; case PROJ_DART: ch->learn_from_failure( gsn_blowguns ); break; case PROJ_STONE: ch->learn_from_failure( gsn_slings ); break; } * 50% chance of projectile getting lost * if( number_percent() < 50 ) projectile->extract(); else { if( projectile->in_obj ) projectile->from_obj(); if( projectile->carried_by ) projectile->from_char(); projectile->to_room( victim->in_room, victim ); } } return damage( ch, victim, 0, dt ); } */ /* * check type of projectile to determine value of wtype * * wtype points to same "short" as the skill assigned to that * * range by the code and as such the proper skill will be used. * * Grimm * * Bugfix: Projectile could be nullptr here - Samson */ if( projectile ) { switch ( projectile->value[4] ) { default: case PROJ_BOLT: case PROJ_ARROW: wtype = gsn_archery; break; case PROJ_DART: wtype = gsn_blowguns; break; case PROJ_STONE: wtype = gsn_slings; break; } } if( number_percent( ) > 50 || ( projectile && weapon && can_use_skill( ch, number_percent( ), wtype ) ) ) { if( victim->isnpc( ) ) /* This way the poor sap can hunt its attacker */ victim->unset_actflag( ACT_SENTINEL ); if( projectile ) global_retcode = projectile_hit( ch, victim, weapon, projectile, dist ); else global_retcode = spell_attack( dt, ch->level, ch, victim ); } else { // Bugfix: Projectile could be nullptr here - Samson if( projectile ) { switch ( projectile->value[4] ) { default: case PROJ_BOLT: case PROJ_ARROW: ch->learn_from_failure( gsn_archery ); break; case PROJ_DART: ch->learn_from_failure( gsn_blowguns ); break; case PROJ_STONE: ch->learn_from_failure( gsn_slings ); break; } } global_retcode = damage( ch, victim, 0, dt ); if( projectile ) { /* * 50% chance of getting lost */ if( number_percent( ) < 50 ) projectile->extract( ); else { if( projectile->carried_by ) projectile->from_char( ); projectile->to_room( victim->in_room, victim ); } } } return global_retcode; }