chuyiwen_gmsv/npc/npc_charm.c

286 lines
6.5 KiB
C
Raw Normal View History

2016-12-24 08:45:52 +08:00
#include "version.h"
#include <string.h>
#include "char.h"
#include "object.h"
#include "char_base.h"
#include "npcutil.h"
#include "lssproto_serv.h"
#include "npc_charm.h"
// ҽë <20>ʻ<EFBFBD>ңֿ<D2A3><D6BF>
//<2F><>ì<EFBFBD><C3AC><EFBFBD><EFBFBD> <20><> <20>ػ<EFBFBD><D8BB><EFBFBD> /
//<2F><><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD>ʣ<EFBFBD>
/*
#define RATE 4 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define CHARMHEAL 5 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define WARU 3 // ë<><C3AB><EFBFBD>°<EFBFBD>
*/
#define RATE 10 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define CHARMHEAL 5 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define WARU 3 // ë<><C3AB><EFBFBD>°<EFBFBD>
static void NPC_Charm_selectWindow( int meindex, int toindex, int num);
int NPC_CharmCost(int meindex,int talker);
void NPC_CharmUp(int meindex,int talker);
/*********************************
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*********************************/
BOOL NPC_CharmInit( int meindex )
{
/*--ƽ<>ҷ¼<D2B7><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ëɬ<C3AB><C9AC>--*/
CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPECHARM );
return TRUE;
}
/*********************************
* <EFBFBD>ƾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><EFBFBD><EFBFBD>
*********************************/
void NPC_CharmTalked( int meindex , int talkerindex , char *szMes ,int color )
{
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD> ɱ<><C9B1><EFBFBD><EFBFBD> */
if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )
{
return;
}
/*-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¾<EFBFBD><C2BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--*/
if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) {
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> */
if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return;
}
NPC_Charm_selectWindow( meindex, talkerindex, 0);
}
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
static void NPC_Charm_selectWindow( int meindex, int toindex, int num)
{
char token[1024];
char escapedname[1024];
int fd = getfdFromCharaIndex( toindex);
int buttontype = 0;
int windowtype = 0;
int windowno = 0;
int cost = 0;
int chartype;
/*--<2D><><EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2BBA5><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD>ƥ<EFBFBD>Ʊ<EFBFBD>ɬ<EFBFBD><C9AC>--*/
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
switch( num) {
case 0:
/*--<2D><> --*/
sprintf(token,"4\n <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ʦ "
"\n\n <20><><EFBFBD><EFBFBD>ӭ<EFBFBD><D3AD><EFBFBD>٣<EFBFBD><D9A3><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ʲ<EFBFBD><CAB2><EFBFBD>أ<EFBFBD>"
"\n "
"\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "
"\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ʲ<><CAB2>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD> <20><> "
);
buttontype = WINDOW_BUTTONTYPE_NONE;
windowtype = WINDOW_MESSAGETYPE_SELECT;
windowno = CHAR_WINDOWTYPE_CHARM_START;
break;
case 1:
cost = NPC_CharmCost( meindex, toindex);
if(cost == -1){
sprintf(token,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ʦ "
"\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
"\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
);
buttontype = WINDOW_BUTTONTYPE_OK;
}else{
sprintf(token,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ʦ "
"\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><C7A7><EFBFBD>ػݼ<D8BB>ʵʩ<CAB5><CAA9>??"
"\n\n Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>"
"\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ%6d<36><64>stoneࡣ<65>"
"\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",cost
);
buttontype = WINDOW_BUTTONTYPE_YESNO;
}
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
windowno = CHAR_WINDOWTYPE_CHARM_END;
break;
case 2:
cost = NPC_CharmCost( meindex, toindex);
chartype = CHAR_getInt( toindex, CHAR_IMAGETYPE);
if(cost > CHAR_getInt( toindex, CHAR_GOLD)) {
sprintf(token,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ʦ "
"\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ѽ!<21><><EFBFBD><EFBFBD>Ǯ<EFBFBD><C7AE><EFBFBD><EFBFBD><EFBFBD>"
"\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>Ǯ<EFBFBD>´<EFBFBD><C2B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>"
);
}else{
NPC_CharmUp( meindex, toindex);
/*--ƽ<>ҷ¼<D2B7><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--*/
switch( chartype) {
case CHAR_IMAGETYPE_GIRL:
sprintf(token,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ʦ "
"\n\n <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޣ<EFBFBD>"
"\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD>"
);
break;
case CHAR_IMAGETYPE_BOY:
sprintf(token,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ʦ "
"\n\n <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޣ<EFBFBD>"
"\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><EFBFBD>DZȸղ<EFBFBD>Ҫ˧<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD>"
);
break;
case CHAR_IMAGETYPE_CHILDBOY:
case CHAR_IMAGETYPE_CHILDGIRL:
sprintf(token,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ʦ "
"\n\n <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޣ<EFBFBD>"
"\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ı<EFBFBD><C4B1>úÿɰ<C3BF><EFBFBD>"
);
break;
case CHAR_IMAGETYPE_MAN:
sprintf(token,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ʦ "
"\n\n <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޣ<EFBFBD>"
"\n\n <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD>"
);
break;
case CHAR_IMAGETYPE_WOMAN:
sprintf(token,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ʦ "
"\n\n <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޣ<EFBFBD>"
"\n\n <20><><EFBFBD><EFBFBD><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD>"
);
break;
}
}
buttontype = WINDOW_BUTTONTYPE_OK;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
windowno = CHAR_WINDOWTYPE_CHARM_END;
break;
}
makeEscapeString( token, escapedname, sizeof( escapedname));
/*-<2D><><EFBFBD><EFBFBD>ƥ˪<C6A5><CBAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--*/
lssproto_WN_send( fd, windowtype,
buttontype,
windowno,
CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX),
escapedname);
}
/*-----------------------------------------
<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߯<EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD>£<EFBFBD>
-------------------------------------------*/
void NPC_CharmWindowTalked( int meindex, int talkerindex,
int seqno, int select, char *data)
{
if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) return;
switch( seqno){
case CHAR_WINDOWTYPE_CHARM_START:
if(atoi( data) == 2) {
NPC_Charm_selectWindow( meindex, talkerindex, 1 );
}
break;
case CHAR_WINDOWTYPE_CHARM_END:
if(select == WINDOW_BUTTONTYPE_YES) {
NPC_Charm_selectWindow( meindex, talkerindex, 2 );
}
break;
}
}
/*-- --*/
void NPC_CharmUp(int meindex,int talker)
{
int cost;
int i;
int petindex;
char petsend[64];
/*--<2D><><EFBFBD><EFBFBD>ëӼ<C3AB><D3BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽﵤ--*/
cost = NPC_CharmCost( meindex, talker);
CHAR_setInt( talker, CHAR_GOLD,
CHAR_getInt( talker, CHAR_GOLD) - cost);
CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD);
/*-- <20><><EFBFBD><EFBFBD><EFBFBD>ߨ߶<DFA8><DFB6><EFBFBD><EFBFBD><EFBFBD>ئ<EFBFBD><D8A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¦<EFBFBD><C2A6><EFBFBD><EFBFBD><EFBFBD>ߨ߱<DFA8><DFB1><EFBFBD><EFBFBD><EFBFBD>--*/
if(CHAR_getInt( talker, CHAR_CHARM) + CHARMHEAL >= 100) {
CHAR_setInt( talker, CHAR_CHARM, 100);
}else{
/*-- ë<><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--*/
CHAR_setInt(talker, CHAR_CHARM,
(CHAR_getInt( talker, CHAR_CHARM) + CHARMHEAL));
}
/*--<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޥ--*/
CHAR_complianceParameter( talker );
CHAR_send_P_StatusString( talker, CHAR_P_STRING_CHARM);
/*--ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɷ¶<C9B7><C2B6><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB>ޥ--*/
for( i = 0 ; i < CHAR_MAXPETHAVE ; i++){
petindex = CHAR_getCharPet( talker, i);
if( petindex == -1 ) continue;
/* ƽ<>ҷ¼<D2B7> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
if( !CHAR_CHECKINDEX( talker ) ) continue;
/*--<2D>ɷ¶<C9B7><C2B6><EFBFBD><EFBFBD><EFBFBD>Ʃ<EFBFBD><C6A9>--*/
CHAR_complianceParameter( petindex );
sprintf( petsend, "K%d", i );
CHAR_sendStatusString( talker , petsend );
}
}
/*--<2D><><EFBFBD>ż<EFBFBD><C5BC><EFBFBD>ң--*/
int NPC_CharmCost(int meindex,int talker)
{
int cost;
int level;
int charm;
int trans;
level = CHAR_getInt( talker, CHAR_LV);
charm = CHAR_getInt( talker, CHAR_CHARM);
trans = CHAR_getInt( talker, CHAR_TRANSMIGRATION);
if(charm >= 100) return -1;
if(charm <= 1) charm = WARU;
/*-- <20><>ңֿ --*/
cost = level * RATE * (charm / WARU) * (trans+1);
return cost;
}