chuyiwen_gmsv/magic/magic.c

907 lines
27 KiB
C
Raw Permalink Normal View History

2016-12-24 08:45:52 +08:00
#include "version.h"
#include <stdio.h>
#include <string.h>
#include "common.h"
#include "char_base.h"
#include "char_data.h"
#include "item.h"
#include "battle.h"
#include "magic_base.h"
#include "magic.h"
#include "magic_field.h"
#include "family.h"
#include "handletime.h"
#include "battle_magic.h"
#include "battle_event.h"
#include"lssproto_serv.h"
#ifdef _ITEM_ATTSKILLMAGIC
#include "pet_skill.h"
#endif
//#include "battle_event.h"
// shan add code
#define MP_RATE 0.7
int MAGIC_Use( int charaindex, int haveitemindex, int toindex)
{
int itemindex;
int magicid,marray,mp;
int ret;
MAGIC_CALLFUNC func;
itemindex = CHAR_getItemIndex( charaindex, haveitemindex);
if( !ITEM_CHECKINDEX( itemindex) ) return FALSE;
magicid = ITEM_getInt( itemindex, ITEM_MAGICID);
marray = MAGIC_getMagicArray( magicid);
if( marray == -1 ) return FALSE;
func = MAGIC_getMagicFuncPointer( MAGIC_getChar( marray, MAGIC_FUNCNAME));//MAGIC_NAME
if( (mp = ITEM_getInt( itemindex, ITEM_MAGICUSEMP)) < 0 ){
print("err mp:%d -%s-%d\n", mp, ITEM_getChar( itemindex, ITEM_NAME),
ITEM_getInt( itemindex, ITEM_ID) );
}
2017-01-13 23:37:03 +08:00
if(CHAR_getInt(charaindex,CHAR_LV)<100 && CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)<1){ //CF中指定精灵在0转100级之前不费气
2016-12-24 08:45:52 +08:00
char magictmpbuf[32];
sprintf(magictmpbuf,",%d,",ITEM_getInt( itemindex, ITEM_MAGICID));
if(strstr(getNoMpMagic(),magictmpbuf)!=NULL){
mp = 0;
}
}
// shan add begin
if( CHAR_getInt( charaindex, CHAR_FMINDEX ) >= 1 ){
2017-01-13 23:37:03 +08:00
// 光精
2016-12-24 08:45:52 +08:00
if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 0){
// if( (marray >=0 && marray <=121) || (marray >= 190 && marray <=300 )){
mp *= atof(getFmMagicMpRate(0));
2017-01-13 23:37:03 +08:00
//printf("\n检测到光明家族mp=%d",mp);
2016-12-24 08:45:52 +08:00
// }
2017-01-13 23:37:03 +08:00
//if(strstr(MAGIC_getChar( marray, MAGIC_COMMENT),"[光]")!=NULL){
2016-12-24 08:45:52 +08:00
//mp *= atof(getFmMagicMpRate(0));
// }
}
2017-01-13 23:37:03 +08:00
// 暗精
2016-12-24 08:45:52 +08:00
if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 1){
// if( (marray >=130 && marray <=189) || (marray >= 300 && marray <=500 )){
mp *= atof(getFmMagicMpRate(1));
2017-01-13 23:37:03 +08:00
// printf("\n检测到黑暗家族mp=%d",mp);
2016-12-24 08:45:52 +08:00
// }
2017-01-13 23:37:03 +08:00
// if(strstr(MAGIC_getChar( marray, MAGIC_COMMENT),"[暗]")!=NULL){
2016-12-24 08:45:52 +08:00
// mp *= atof(getFmMagicMpRate(1));
// }
}
}
// shan end
if( func ) {
ret = func( charaindex, toindex, marray, mp );
}else {
ret = FALSE;
}
return ret;
}
int MAGIC_GetArrayNo( int charaindex, int haveitemindex)
{
int itemindex;
int magicid;
itemindex = CHAR_getItemIndex( charaindex, haveitemindex);
if( !ITEM_CHECKINDEX( itemindex) ) return FALSE;
magicid = ITEM_getInt( itemindex, ITEM_MAGICID);
return magicid;
}
int MAGIC_DirectUse(
int charaindex,
int magicid,
int toindex,
int itemnum
)
{
MAGIC_CALLFUNC func;
int mp=0, ret, marray=0;
int itemindex=-1;
2017-01-13 23:37:03 +08:00
#ifdef _MAGIC_NOCAST//沉默状态无法施法
2016-12-24 08:45:52 +08:00
if( CHAR_getWorkInt( charaindex, CHAR_WORKNOCAST ) > 0 ){
2017-01-13 23:37:03 +08:00
CHAR_talkToCli(charaindex, -1, "沉默中无法吟唱咒术", CHAR_COLORYELLOW);
2016-12-24 08:45:52 +08:00
return FALSE;
}
#endif
#ifdef _NO_MAGIC
int nomagicmap = CHAR_getInt(charaindex,CHAR_FLOOR);
int max;
for( max = 0 ; max < 30 ; max++){
if (nomagicmap == getnomagicmap(max)){
2017-01-13 23:37:03 +08:00
CHAR_talkToCli(charaindex, -1, "这里无法使用任何精灵咒术。", CHAR_COLORYELLOW);
2016-12-24 08:45:52 +08:00
return FALSE;
}
}
#endif
if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){
itemindex = CHAR_getItemIndex( charaindex, itemnum);
if( !ITEM_CHECKINDEX( itemindex) ){
//print("ANDY err MAGIC_DirectUse() itemindex:%d !\n", itemindex);
return FALSE;
}
}else{
itemindex = itemnum;
}
marray = MAGIC_getMagicArray( magicid );
func = MAGIC_getMagicFuncPointer( MAGIC_getChar( marray, MAGIC_FUNCNAME ) );
if( (mp = ITEM_getInt( itemindex, ITEM_MAGICUSEMP )) < 0 ){
//return FALSE;
}
// shan add begin
2017-01-13 23:37:03 +08:00
if(CHAR_getInt(charaindex,CHAR_LV)<100 && CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)<1){ //CF中指定精灵在0转100级之前不费气
2016-12-24 08:45:52 +08:00
char magictmpbuf[32];
sprintf(magictmpbuf,",%d,",ITEM_getInt( itemindex, ITEM_MAGICID));
//print("\nid=%s\n",magictmpbuf);
if(strstr(getNoMpMagic(),magictmpbuf)!=NULL){
mp = 0;
}
}
if( CHAR_getInt( charaindex, CHAR_FMINDEX ) >= 1 ){
if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 0){
mp *= atof(getFmMagicMpRate(0));
}
if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 1){
mp *= atof(getFmMagicMpRate(1));
}
}
/*
if( CHAR_getInt( charaindex, CHAR_FMINDEX ) >= 1 ){
2017-01-13 23:37:03 +08:00
// 光精
2016-12-24 08:45:52 +08:00
if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 0){
//if( (marray >=0 && marray <=31) ){
//mp *= MP_RATE;
// }
2017-01-13 23:37:03 +08:00
if(strstr(MAGIC_getChar( marray, MAGIC_COMMENT),"[光]")!=NULL){
2016-12-24 08:45:52 +08:00
mp *= atof(getFmMagicMpRate(0));
}
}
2017-01-13 23:37:03 +08:00
// 暗精
2016-12-24 08:45:52 +08:00
if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 1){
//if( marray >=32 && marray <=81 ){
//mp *= MP_RATE;
// }
2017-01-13 23:37:03 +08:00
if(strstr(MAGIC_getChar( marray, MAGIC_COMMENT),"[暗]")!=NULL){
2016-12-24 08:45:52 +08:00
mp *= atof(getFmMagicMpRate(1));
}
}
}
*/
if( func ) {
ret = func( charaindex, toindex, marray, mp );
}
else {
ret = FALSE;
}
return ret;
}
int MAGIC_Recovery( int charaindex, int toindex, int marray, int mp )
{
int battlemode;
if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE;
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE;
CHAR_setInt( charaindex, CHAR_MP,
CHAR_getInt( charaindex, CHAR_MP ) - mp );
if( IsBATTLING( charaindex ) == TRUE ){
2017-01-13 23:37:03 +08:00
#ifdef _PREVENT_TEAMATTACK //恩惠不得 使用敌方
2016-12-24 08:45:52 +08:00
int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX );
if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER &&
BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){
2017-01-13 23:37:03 +08:00
if( BATTLE_CheckSameSide( charaindex, toindex) == 0 ){//不同边
2016-12-24 08:45:52 +08:00
int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX );
BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) );
2017-01-13 23:37:03 +08:00
CHAR_talkToCli( charaindex, -1, "恩惠精灵..不得施予非玩家敌方。", CHAR_COLORYELLOW);
2016-12-24 08:45:52 +08:00
return FALSE;
}
}
#endif
2017-01-13 23:37:03 +08:00
if (toindex==22){print("jinchao err\n");return FALSE;} // shan(对全体使用魔法的bug)修改者jinchao+2001/12/07
2016-12-24 08:45:52 +08:00
MAGIC_Recovery_Battle( charaindex, toindex, marray, mp );
}else{
2017-01-13 23:37:03 +08:00
if( CHAR_CHECKINDEX( toindex ) == FALSE )return FALSE; // shan(对全体使用魔法的bug)修改者jinchao+2001/12/07
2016-12-24 08:45:52 +08:00
MAGIC_Recovery_Field( charaindex, marray);
}
return TRUE;
}
int MAGIC_OtherRecovery( int charaindex, int toindex, int marray, int mp )
{
int battlemode;
2017-01-13 23:37:03 +08:00
if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; //{撩
2016-12-24 08:45:52 +08:00
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
2017-01-13 23:37:03 +08:00
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // 井匀凶日母丢
2016-12-24 08:45:52 +08:00
CHAR_setInt( charaindex, CHAR_MP,
CHAR_getInt( charaindex, CHAR_MP ) - mp );
if( IsBATTLING( charaindex ) == TRUE ){
2017-01-13 23:37:03 +08:00
#ifdef _PREVENT_TEAMATTACK //滋润 不得使用敌方
2016-12-24 08:45:52 +08:00
int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX );
if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER &&
BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){
2017-01-13 23:37:03 +08:00
if( BATTLE_CheckSameSide( charaindex, toindex) == 0 ){//不同边
2016-12-24 08:45:52 +08:00
int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX );
BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) );
2017-01-13 23:37:03 +08:00
CHAR_talkToCli( charaindex, -1, "滋润精灵..不得施予非玩家敌方。", CHAR_COLORYELLOW);
2016-12-24 08:45:52 +08:00
return FALSE;
}
}
#endif
MAGIC_Recovery_Battle( charaindex, toindex, marray, mp );
}else{
2017-01-18 16:09:08 +08:00
if( CHAR_CHECKINDEX( toindex ) == FALSE )return FALSE; //失敗
2016-12-24 08:45:52 +08:00
MAGIC_OtherRecovery_Field( charaindex, toindex, marray);
}
return TRUE;
}
2017-01-18 16:09:08 +08:00
// フィールドの属性を変化させる魔法
2016-12-24 08:45:52 +08:00
int MAGIC_FieldAttChange( int charaindex, int toindex, int marray, int mp )
{
int battlemode;
2017-01-18 16:09:08 +08:00
// INDEXチェック
if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; //失敗
2016-12-24 08:45:52 +08:00
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
2017-01-18 16:09:08 +08:00
// 戦闘開始時は無視する
2016-12-24 08:45:52 +08:00
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
2017-01-18 16:09:08 +08:00
// MP消費チェック
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // 無かったらダメ
// この魔法は普通にMP消費して良い。マイナスになることは無い
2016-12-24 08:45:52 +08:00
CHAR_setInt( charaindex, CHAR_MP,
CHAR_getInt( charaindex, CHAR_MP ) - mp );
2017-01-18 16:09:08 +08:00
// 戦闘中だったら
2016-12-24 08:45:52 +08:00
if( IsBATTLING( charaindex ) == TRUE ){
return MAGIC_FieldAttChange_Battle( charaindex, toindex, marray, mp );
}else{
2017-01-18 16:09:08 +08:00
// 戦闘中でなかったら
2016-12-24 08:45:52 +08:00
return FALSE;
}
}
int MAGIC_StatusChange( int charaindex, int toindex, int marray, int mp )
{
int battlemode;
if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE;
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE;
CHAR_setInt( charaindex, CHAR_MP, CHAR_getInt( charaindex, CHAR_MP ) - mp );
if( IsBATTLING( charaindex ) == TRUE ){
2017-01-13 23:37:03 +08:00
#ifdef _PREVENT_TEAMATTACK //异常状态不得使用友方
2016-12-24 08:45:52 +08:00
int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX );
if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER &&
BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){
2017-01-13 23:37:03 +08:00
if( BATTLE_CheckSameSide( charaindex, toindex) == 1 ){//同边
2016-12-24 08:45:52 +08:00
int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX );
BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) );
2017-01-13 23:37:03 +08:00
CHAR_talkToCli( charaindex, -1, "异常状态..不得施予友方。", CHAR_COLORYELLOW);
2016-12-24 08:45:52 +08:00
return FALSE;
}
}
#endif
return MAGIC_StatusChange_Battle( charaindex, toindex, marray, mp );
}else{
return FALSE;
}
}
#ifdef _OTHER_MAGICSTAUTS
int MAGIC_MagicStatusChange( int charaindex, int toindex, int marray, int mp )
{
int battlemode;
if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return FALSE;
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE;
CHAR_setInt( charaindex, CHAR_MP, CHAR_getInt( charaindex, CHAR_MP ) - mp );
if( IsBATTLING( charaindex ) == TRUE ){
return MAGIC_MagicStatusChange_Battle( charaindex, toindex, marray, mp );
}else{
return FALSE;
}
}
#endif
2017-01-13 23:37:03 +08:00
#ifdef _MAGIC_DEEPPOISON//新增ver2,主要设定毒状态5回未解时人物会阵亡
2017-01-18 16:09:08 +08:00
// ステータス異常を与える魔法
2016-12-24 08:45:52 +08:00
int MAGIC_StatusChange2( int charaindex, int toindex, int marray, int mp )
{
int battlemode;
2017-01-18 16:09:08 +08:00
// INDEXチェック
2017-01-13 23:37:03 +08:00
if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; //{撩
2016-12-24 08:45:52 +08:00
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
2017-01-18 16:09:08 +08:00
// 戦闘開始時は無視する
2016-12-24 08:45:52 +08:00
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
2017-01-13 23:37:03 +08:00
//扣气
2016-12-24 08:45:52 +08:00
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE;
CHAR_setInt( charaindex, CHAR_MP,
CHAR_getInt( charaindex, CHAR_MP ) - mp );
//call func
if( IsBATTLING( charaindex ) == TRUE ){
return MAGIC_StatusChange_Battle2( charaindex, toindex, marray, mp );
}else{
return FALSE;
}
}
#endif
2017-01-18 16:09:08 +08:00
// ステータス異常回復させる魔法
2016-12-24 08:45:52 +08:00
int MAGIC_StatusRecovery( int charaindex, int toindex, int marray, int mp )
{
int battlemode;
2017-01-18 16:09:08 +08:00
// INDEXチェック
2017-01-13 23:37:03 +08:00
if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; //{撩
2016-12-24 08:45:52 +08:00
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
2017-01-18 16:09:08 +08:00
// 戦闘開始時は無視する
2016-12-24 08:45:52 +08:00
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
2017-01-18 16:09:08 +08:00
// MP消費チェック
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // 無かったらダメ
// この魔法は普通にMP消費して良い。マイナスになることは無い
2016-12-24 08:45:52 +08:00
CHAR_setInt( charaindex, CHAR_MP,
CHAR_getInt( charaindex, CHAR_MP ) - mp );
2017-01-18 16:09:08 +08:00
// 戦闘中だったら
2016-12-24 08:45:52 +08:00
if( IsBATTLING( charaindex ) == TRUE ){
return MAGIC_StatusRecovery_Battle( charaindex, toindex, marray, mp );
}else{
2017-01-18 16:09:08 +08:00
// 戦闘中でなかったら
2016-12-24 08:45:52 +08:00
return FALSE;
}
}
int MAGIC_MagicDef( int charaindex, int toindex, int marray, int mp )
{
int battlemode;
if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE;
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE;
CHAR_setInt( charaindex, CHAR_MP, CHAR_getInt( charaindex, CHAR_MP ) - mp );
if( IsBATTLING( charaindex ) == TRUE ){
2017-01-13 23:37:03 +08:00
#ifdef _PREVENT_TEAMATTACK //光镜守..不得使用敌方
2016-12-24 08:45:52 +08:00
#ifdef _GJS_TYPE
if(getGjsType()==0){
#endif
if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER
/*&& BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P*/ ){
2017-01-13 23:37:03 +08:00
if( BATTLE_CheckSameSide( charaindex, toindex) == 0 ){//不同边
2016-12-24 08:45:52 +08:00
int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX );
BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) );
2017-01-13 23:37:03 +08:00
CHAR_talkToCli( charaindex, -1, "光镜守..不得施予敌方。", CHAR_COLORYELLOW);
2016-12-24 08:45:52 +08:00
return FALSE;
}
}
#ifdef _GJS_TYPE
}
#endif
#endif
return MAGIC_MagicDef_Battle( charaindex, toindex, marray, mp );
}else{
return FALSE;
}
}
2017-01-18 16:09:08 +08:00
// 気絶から復活させる魔法
2016-12-24 08:45:52 +08:00
int MAGIC_Ressurect( int charaindex, int toindex, int marray, int mp )
{
int battlemode;
2017-01-18 16:09:08 +08:00
// INDEXチェック
2017-01-13 23:37:03 +08:00
if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; //{撩
2016-12-24 08:45:52 +08:00
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
2017-01-18 16:09:08 +08:00
// 戦闘開始時は無視する
2016-12-24 08:45:52 +08:00
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
2017-01-18 16:09:08 +08:00
// MP消費チェック
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // 無かったらダメ
// この魔法は普通にMP消費して良い。マイナスになることは無い
2016-12-24 08:45:52 +08:00
CHAR_setInt( charaindex, CHAR_MP,
CHAR_getInt( charaindex, CHAR_MP ) - mp );
2017-01-18 16:09:08 +08:00
// 戦闘中だったら
2016-12-24 08:45:52 +08:00
if( IsBATTLING( charaindex ) == TRUE ){
return MAGIC_Ressurect_Battle( charaindex, toindex, marray, mp );
}else{
2017-01-18 16:09:08 +08:00
// 戦闘中でなかったら
2016-12-24 08:45:52 +08:00
return FALSE;
}
}
2017-01-18 16:09:08 +08:00
// 属性を反転させる魔法
2016-12-24 08:45:52 +08:00
int MAGIC_AttReverse( int charaindex, int toindex, int marray, int mp )
{
int battlemode;
2017-01-18 16:09:08 +08:00
// INDEXチェック
2017-01-13 23:37:03 +08:00
if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; //{撩
2016-12-24 08:45:52 +08:00
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
2017-01-18 16:09:08 +08:00
// 戦闘開始時は無視する
2016-12-24 08:45:52 +08:00
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
2017-01-18 16:09:08 +08:00
// MP消費チェック
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // 無かったらダメ
// この魔法は普通にMP消費して良い。マイナスになることは無い
2016-12-24 08:45:52 +08:00
CHAR_setInt( charaindex, CHAR_MP,
CHAR_getInt( charaindex, CHAR_MP ) - mp );
2017-01-18 16:09:08 +08:00
// 戦闘中だったら
2016-12-24 08:45:52 +08:00
if( IsBATTLING( charaindex ) == TRUE ){
return MAGIC_AttReverse_Battle( charaindex, toindex, marray, mp );
}else{
2017-01-18 16:09:08 +08:00
// 戦闘中でなかったら
2016-12-24 08:45:52 +08:00
return FALSE;
}
}
2017-01-18 16:09:08 +08:00
// 気絶から復活+魔法防御
2016-12-24 08:45:52 +08:00
int MAGIC_ResAndDef( int charaindex, int toindex, int marray, int mp )
{
int battlemode;
2017-01-18 16:09:08 +08:00
// INDEXチェック
2017-01-13 23:37:03 +08:00
if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; //{撩
2016-12-24 08:45:52 +08:00
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
2017-01-18 16:09:08 +08:00
// 戦闘開始時は無視する
2016-12-24 08:45:52 +08:00
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
2017-01-18 16:09:08 +08:00
// MP消費チェック
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // 無かったらダメ
// この魔法は普通にMP消費して良い。マイナスになることは無い
2016-12-24 08:45:52 +08:00
CHAR_setInt( charaindex, CHAR_MP,
CHAR_getInt( charaindex, CHAR_MP ) - mp );
2017-01-18 16:09:08 +08:00
// 戦闘中だったら
2016-12-24 08:45:52 +08:00
if( IsBATTLING( charaindex ) == TRUE ){
return MAGIC_ResAndDef_Battle( charaindex, toindex, marray, mp );
}else{
2017-01-18 16:09:08 +08:00
// 戦闘中でなかったら
2016-12-24 08:45:52 +08:00
return FALSE;
}
}
#ifdef _ATTACK_MAGIC
int MAGIC_AttMagic( int charaindex , int toindex , int marray , int mp )
{
int battlemode;
if( FALSE == CHAR_CHECKINDEX( charaindex ) )
return FALSE;
battlemode = CHAR_getWorkInt( charaindex , CHAR_WORKBATTLEMODE );
if( BATTLE_CHARMODE_INIT == battlemode )
return FALSE;
2017-01-13 23:37:03 +08:00
// 若是宠物魔法,不扣mp
2016-12-24 08:45:52 +08:00
if(CHAR_getInt(charaindex,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER)
{
if( CHAR_getInt( charaindex , CHAR_MP ) < mp )
return FALSE;
CHAR_setInt( charaindex , CHAR_MP , CHAR_getInt( charaindex , CHAR_MP ) - mp );
}
if( TRUE == IsBATTLING( charaindex ) )
return MAGIC_AttMagic_Battle( charaindex , toindex , marray , mp );
return FALSE;
}
#endif
#ifdef _ITEM_METAMO
int MAGIC_Metamo( int charaindex, int toindex, int marray, int mp )
{
int battlemode, haveindex, power, i;
char msg[128];
if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return FALSE;
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
2017-01-18 16:09:08 +08:00
// 戦闘開始時は無視する
2016-12-24 08:45:52 +08:00
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
2017-01-18 16:09:08 +08:00
// 戦闘中だったら
2016-12-24 08:45:52 +08:00
if( IsBATTLING( charaindex ) == TRUE ){
//MAGIC_Recovery_Battle( charaindex, toindex, marray, mp );
//return FALSE;
toindex = BATTLE_No2Index(
CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ), toindex );
//print(" battle_metamo:%d ", toindex);
}
if( CHAR_CHECKINDEX( toindex ) == FALSE ) return FALSE;
if( CHAR_getInt( charaindex, CHAR_RIDEPET ) != -1 ){
2017-01-13 23:37:03 +08:00
CHAR_talkToCli( charaindex, -1, "无法变身,骑乘中不能变身!", CHAR_COLORWHITE );
2016-12-24 08:45:52 +08:00
return FALSE;
}
#ifdef _FIX_METAMORIDE
if( CHAR_CHECKJOINENEMY( charaindex) == TRUE ){
2017-01-13 23:37:03 +08:00
CHAR_talkToCli( charaindex, -1, "无法变身,搭乘中不能变身!", CHAR_COLORYELLOW );
2016-12-24 08:45:52 +08:00
return FALSE;
}
#else
if( CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER) == 100259 ){
2017-01-13 23:37:03 +08:00
CHAR_talkToCli( charaindex, -1, "无法变身,搭乘中不能变身!", CHAR_COLORWHITE );
2016-12-24 08:45:52 +08:00
return FALSE;
}
#endif
#ifdef _FIXBUG_ATTACKBOW
{
int armindex = CHAR_getItemIndex( charaindex, CHAR_ARM);
if( ITEM_CHECKINDEX( armindex) == TRUE ) {
int armtype = BATTLE_GetWepon( charaindex);
if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW ||
armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) {
2017-01-13 23:37:03 +08:00
CHAR_talkToCli( charaindex, -1, "使用远距离武器无法变身!", CHAR_COLORYELLOW );
2016-12-24 08:45:52 +08:00
return FALSE;
}
}
}
#endif
haveindex = -1;
for( i = 0; i < 5; i++ )
{
if( CHAR_getCharPet( charaindex, i) == toindex ) {
haveindex = i;
break;
}
}
if( haveindex == -1 && charaindex != toindex )
{
2017-01-13 23:37:03 +08:00
CHAR_talkToCli( charaindex, -1, "无法变身,只能变成自己的宠物!", CHAR_COLORWHITE );
2016-12-24 08:45:52 +08:00
return FALSE;
}
if( CHAR_getInt( toindex, CHAR_BASEIMAGENUMBER) == 100259 ){
2017-01-13 23:37:03 +08:00
CHAR_talkToCli( charaindex, -1, "不能变身成加美!", CHAR_COLORWHITE );
2016-12-24 08:45:52 +08:00
return FALSE;
}
power = atoi(MAGIC_getChar( marray, MAGIC_OPTION ));
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE;
CHAR_setInt( charaindex, CHAR_MP,
CHAR_getInt( charaindex, CHAR_MP ) - mp );
CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_MP);
if( toindex != charaindex ) {
CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, NowTime.tv_sec +power);
2017-01-13 23:37:03 +08:00
sprintf( msg, "变身成%s", CHAR_getChar( toindex, CHAR_NAME) );
2016-12-24 08:45:52 +08:00
}
else {
CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, 0);
2017-01-13 23:37:03 +08:00
sprintf( msg, "变回自己!");
2016-12-24 08:45:52 +08:00
}
CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORWHITE );
CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER,
CHAR_getInt( toindex, CHAR_BASEBASEIMAGENUMBER) );
CHAR_complianceParameter( charaindex);
CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX ));
CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER);
//#endif
return TRUE;
}
#endif
#ifdef _ITEM_ATTSKILLMAGIC
int MAGIC_AttSkill( int charaindex, int toindex,int marray, int mp )
{
int battlemode;
int battleindex=-1;
char *magicarg, funName[256];
int skillID=-1;
PETSKILL_CALLFUNC func;
if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return FALSE;
if( IsBATTLING( charaindex ) == FALSE ) return FALSE;
battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX );
if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) return FALSE;
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
if( battlemode == BATTLE_CHARMODE_INIT ) return FALSE;
if( toindex < 0 || toindex > 19 ) return FALSE;
if( CHAR_getInt( charaindex, CHAR_MP ) < mp ) return FALSE;
memset( funName, 0, sizeof( char)*256 );
//MAGIC_Recovery_Battle( charaindex, toindex, marray, mp );
magicarg = MAGIC_getChar( marray, MAGIC_OPTION );
if ( magicarg == "\0") return FALSE;
if( strstr( magicarg, ";" ) != NULL ) {
char buff1[256];
if( getStringFromIndexWithDelim( magicarg, ";", 1, buff1, sizeof( buff1)) == FALSE )
return FALSE;
snprintf( funName, sizeof(funName), buff1);
if( getStringFromIndexWithDelim( magicarg, ";", 2, buff1, sizeof( buff1)) == FALSE )
return FALSE;
skillID = atoi( buff1);
}else
return FALSE;
func = PETSKILL_getPetskillFuncPointer( funName);
if( !func ){
print("\n *func not FOUND !!");
return FALSE;
}
if( func( charaindex, toindex, skillID, "MAGICSKILL" ) == FALSE ) return FALSE;
CHAR_setInt( charaindex, CHAR_MP, CHAR_getInt( charaindex, CHAR_MP ) - mp );
return TRUE;
}
#endif
2017-01-13 23:37:03 +08:00
#ifdef _MAGIC_BARRIER// vincent 精灵:魔障
2016-12-24 08:45:52 +08:00
int MAGIC_Barrier( int charaindex, int toindex, int marray, int mp )
{
int battlemode;
int i,turn,perStatus;
int ToList[SIDE_OFFSET*2+1];
char *magicarg;
int attackNo=0;
int battleindex,Success = 0;
char szTurn[] = "turn";
2017-01-13 23:37:03 +08:00
char szSuccess[] = "";
2016-12-24 08:45:52 +08:00
char *pszP;
//check index
if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE;
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
2017-01-18 16:09:08 +08:00
// 戦闘開始時は無視する//??
2016-12-24 08:45:52 +08:00
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
2017-01-13 23:37:03 +08:00
//mp不足
2016-12-24 08:45:52 +08:00
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE;
2017-01-13 23:37:03 +08:00
//消耗mp
2016-12-24 08:45:52 +08:00
CHAR_setInt( charaindex, CHAR_MP,
CHAR_getInt( charaindex, CHAR_MP ) - mp );
2017-01-13 23:37:03 +08:00
//魔法名称
2016-12-24 08:45:52 +08:00
magicarg = MAGIC_getChar( marray, MAGIC_OPTION );
if( magicarg == "\0" ) {
print("\n magicarg == NULL ");
return FALSE;
}
pszP = magicarg;
2017-01-13 23:37:03 +08:00
//读取作用回合数
2016-12-24 08:45:52 +08:00
if( ( pszP = strstr( pszP, szTurn ) ) != NULL){
pszP += sizeof( szTurn );
sscanf( pszP, "%d", &turn );
}
2017-01-18 16:09:08 +08:00
// 成功率設定//命中率
2016-12-24 08:45:52 +08:00
if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){
pszP += sizeof( szSuccess );
sscanf( pszP, "%d", &Success );
}
battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX );
attackNo = BATTLE_Index2No( battleindex, charaindex );
BATTLE_MultiList( battleindex, toindex, ToList );
2017-01-13 23:37:03 +08:00
//施魔法动画效果
2016-12-24 08:45:52 +08:00
BATTLE_MagicEffect(battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_hoshi);
charaindex = BATTLE_No2Index( battleindex, attackNo );
2017-01-13 23:37:03 +08:00
//check是否战斗中
2016-12-24 08:45:52 +08:00
if( IsBATTLING( charaindex ) == TRUE )
{
for( i = 0; ToList[i] != -1; i ++ )
{
toindex = BATTLE_No2Index( battleindex, ToList[i] );
if( BATTLE_StatusAttackCheck( charaindex,toindex, BATTLE_ST_BARRIER, Success, 30, 1.0, &perStatus ) == TRUE )
{
CHAR_setWorkInt( toindex, CHAR_WORKBARRIER, turn+1 );
// BATTLE_BadStatusString( ToList[i], BATTLE_ST_BARRIER );
}
}
return TRUE;
}else{
return FALSE;
}
}
#endif
2017-01-13 23:37:03 +08:00
#ifdef _MAGIC_NOCAST// vincent 精灵:沉默
2016-12-24 08:45:52 +08:00
int MAGIC_Nocast( int charaindex, int toindex, int marray, int mp )
{
int battlemode;
int i,turn,perStatus;
int ToList[SIDE_OFFSET*2+1];
char *magicarg;
int attackNo=0;
int battleindex,Success = 0;
char szTurn[] = "turn";
2017-01-13 23:37:03 +08:00
char szSuccess[] = "";
2016-12-24 08:45:52 +08:00
char *pszP;
//check index
if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE;
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
2017-01-18 16:09:08 +08:00
// 戦闘開始時は無視する//??
2016-12-24 08:45:52 +08:00
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
2017-01-13 23:37:03 +08:00
//mp不足
2016-12-24 08:45:52 +08:00
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE;
2017-01-13 23:37:03 +08:00
//消耗mp
2016-12-24 08:45:52 +08:00
CHAR_setInt( charaindex, CHAR_MP,
CHAR_getInt( charaindex, CHAR_MP ) - mp );
2017-01-13 23:37:03 +08:00
//魔法名称
2016-12-24 08:45:52 +08:00
magicarg = MAGIC_getChar( marray, MAGIC_OPTION );
if( magicarg == "\0" ) {
print("\n magicarg == NULL ");
return FALSE;
}
pszP = magicarg;
2017-01-13 23:37:03 +08:00
//读取作用回合数
2016-12-24 08:45:52 +08:00
if( ( pszP = strstr( pszP, szTurn ) ) != NULL){
pszP += sizeof( szTurn );
sscanf( pszP, "%d", &turn );
}
2017-01-18 16:09:08 +08:00
// 成功率設定//命中率
2016-12-24 08:45:52 +08:00
if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){
pszP += sizeof( szSuccess );
sscanf( pszP, "%d", &Success );
}
// print("\nvincent-->MAGIC_Nocast use");
battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX );
attackNo = BATTLE_Index2No( battleindex, charaindex );
BATTLE_MultiList( battleindex, toindex, ToList );
2017-01-13 23:37:03 +08:00
//施魔法动画效果
2016-12-24 08:45:52 +08:00
BATTLE_MagicEffect(battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_hoshi);
charaindex = BATTLE_No2Index( battleindex, attackNo );
2017-01-13 23:37:03 +08:00
//check是否战斗中
2016-12-24 08:45:52 +08:00
if( IsBATTLING( charaindex ) == TRUE )
{
for( i = 0; ToList[i] != -1; i ++ )
{
toindex = BATTLE_No2Index( battleindex, ToList[i] );
if( BATTLE_StatusAttackCheck( charaindex,toindex, BATTLE_ST_NOCAST, Success, 30, 1.0, &perStatus ) == TRUE
&& CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPET)
{
CHAR_setWorkInt( toindex, CHAR_WORKNOCAST, turn );
2017-01-13 23:37:03 +08:00
//无法展开咒术页
2016-12-24 08:45:52 +08:00
lssproto_NC_send( getfdFromCharaIndex( toindex ), 1);
//print("\nvincent-->NOCASTING2");
// BATTLE_BadStatusString( ToList[i], BATTLE_ST_NOCAST );
}
}
return TRUE;
}else{
return FALSE;
}
}
#endif
2017-01-13 23:37:03 +08:00
#ifdef _MAGIC_WEAKEN// vincent 精灵:虚弱
2016-12-24 08:45:52 +08:00
int MAGIC_Weaken( int charaindex, int toindex, int marray, int mp )
{
int battlemode;
//check index
if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE;
battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE );
2017-01-18 16:09:08 +08:00
// 戦闘開始時は無視する//??
2016-12-24 08:45:52 +08:00
if( battlemode == BATTLE_CHARMODE_INIT ){
return FALSE;
}
2017-01-13 23:37:03 +08:00
//mp不足
2016-12-24 08:45:52 +08:00
if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE;
2017-01-13 23:37:03 +08:00
//消耗mp
2016-12-24 08:45:52 +08:00
CHAR_setInt( charaindex, CHAR_MP,
CHAR_getInt( charaindex, CHAR_MP ) - mp );
2017-01-13 23:37:03 +08:00
//check是否战斗中
2016-12-24 08:45:52 +08:00
if( IsBATTLING( charaindex ) == TRUE ){
return MAGIC_ParamChange_Turn_Battle( charaindex, toindex, marray, mp );
}else{
return FALSE;
}
}
#endif
#ifdef _MAGIC_TOCALL
int MAGIC_ToCallDragon( int charaindex, int toindex,int marray, int mp )
{
int battlemode;
//print("MAGIC_ToCallDragon in .................\n");
if( FALSE == CHAR_CHECKINDEX( charaindex ) )
return FALSE;
battlemode = CHAR_getWorkInt( charaindex , CHAR_WORKBATTLEMODE );
if( BATTLE_CHARMODE_INIT == battlemode )
return FALSE;
if( CHAR_getInt( charaindex , CHAR_MP ) < mp )
return FALSE;
CHAR_setInt( charaindex , CHAR_MP , CHAR_getInt( charaindex , CHAR_MP ) - mp );
if( TRUE == IsBATTLING( charaindex ) )
return MAGIC_ToCallDragon_Battle( charaindex , toindex , marray , mp );
return FALSE;
}
#endif