void st03::play(){ while(getPoint()){ if(getPoint())increaseHealth(); if(getPoint())increaseSpeed(); } int d=(~0U>>1),x,y; for(int i=1;i<=N;++i) for(int j=1;j<=M;++j) if(askWhat(i,j)==EMPTY){ int t1=abs(i-getX())+abs(j-getY()); if(t1>getSp())continue; for(int k=1;k<=N;++k) for(int l=1;l<=M;++l) if(askWhat(k,l)!=EMPTY){ int tmp=abs(i-k)+abs(j-l); if(tmp<d)d=tmp,x=i,y=j; } } move(x,y); for(int i=-1;i<2;++i) for(int j=-1;j<2;++j){ if(i&&j)continue; if((!i)&&(!j))continue; if(askWhat(x+i,y+j)!=EMPTY){ attack(x+i,y+j); return; } } }
//----------------------------------------------------------------------------- void CCharacter::setHpMpSp( Flt num, DamageType type, ATTACK_RESULT_TYPE resType ) { //死亡 if ( ATTACK_RESULT_TYPE_DEAD == resType ) { setHp(0); } //恢复 if ( ATTACK_RESULT_TYPE_RECOVER == resType ) { if ( type & DT_HP ) { setHp(getHp()+num); } if ( type & DT_MP ) { //mCAttributeSystem.addValue(ATTR_ID_Mp, num); setMp(getMp()+num); } if ( type & DT_SP ) { //mCAttributeSystem.addValue(ATTR_ID_Sp, num); setSp(getSp()+num); } } //伤害 if ( ATTACK_RESULT_TYPE_HURT == resType ) { if ( type & DT_HP ) { //mCAttributeSystem.addValue(ATTR_ID_Hp, -num); setHp(getHp()-num); } if ( type & DT_MP ) { //mCAttributeSystem.addValue(ATTR_ID_Mp, -num); setMp(getMp()-num); } if ( type & DT_SP ) { //mCAttributeSystem.addValue(ATTR_ID_Sp, -num); setSp(getSp()-num); } } }
void ch_att::getInfo() { x=getX(); y=getY(); lev=getLevel(); point=getPoint(); exp=getExp(); hp=getHP(); maxhp=getMaxHP(); att=getAtt(); sp=getSp(); getMap(); }
void testAI::play() { while(getPoint()) { increaseSpeed(); increaseStrength(); increaseHealth(); } int i,j,x,y,flag=0,t1,t2; x=getX(); y=getY(); for(i=1;i<=N;i++) { for(j=1;j<=M;j++) { if(abs(i-x)+abs(j-y)<=getSp()) { if(askWhat(i-1,j)>0 || askWhat(i+1,j)>0 || askWhat(i,j-1)>0 || askWhat(i,j+1)>0) { move(i,j); flag=1; break; } t1=i;t2=j; } } if(flag)break; } if(!flag)move(t1,t2); if(askWhat(i-1,j)>0) { attack(i-1,j); return; } if(askWhat(i+1,j)>0) { attack(i+1,j); return; } if(askWhat(i,j-1)>0) { attack(i,j-1); return; } if(askWhat(i,j+1)>0) { attack(i,j+1); return; } }
void Player::save(){ char sql[10000]; sprintf_s(sql, 10000, "update keymap set "); for(int i=0; i<90; i++){ char temp[100]; if(i!=89) sprintf_s(temp, 100, "pos%d=%d, ", i, keys[i]); else sprintf_s(temp, 100, "pos%d=%d where charid=%d; ", i, keys[i], getPlayerid()); strcat_s(sql, 10000, temp); } MySQL::insert(sql); sprintf_s(sql, 10000, "update characters set level=%d, job=%d, str=%d, dex=%d, intt=%d, luk=%d, chp=%d, mhp=%d, cmp=%d, mmp=%d, ap=%d, sp=%d, exp=%d, fame=%d, map=%d, gender=%d, skin=%d, eyes=%d, hair=%d, mesos=%d where id=%d", getLevel(), getJob(), getStr(), getDex(), getInt(), getLuk(), getHP(), getRMHP(), getMP(), getRMMP(), getAp(), getSp(), getExp(), getFame(), getMap(), getGender(), getSkin(), getEyes(), getHair(), inv->getMesos() ,getPlayerid()); MySQL::insert(sql); char temp[1000]; sprintf_s(sql, 10000, "delete from equip where charid=%d;", getPlayerid()); MySQL::insert(sql); bool firstrun = true; for(int i=0; i<inv->getEquipNum(); i++){ if(firstrun == true){ sprintf_s(sql, 10000, "INSERT INTO equip VALUES (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", inv->getEquip(i)->id, Drops::equips[inv->getEquip(i)->id].type ,getPlayerid(), inv->getEquipPos(i), inv->getEquip(i)->slots, inv->getEquip(i)->scrolls, inv->getEquip(i)->istr, inv->getEquip(i)->idex, inv->getEquip(i)->iint, inv->getEquip(i)->iluk, inv->getEquip(i)->ihp, inv->getEquip(i)->imp, inv->getEquip(i)->iwatk, inv->getEquip(i)->imatk, inv->getEquip(i)->iwdef, inv->getEquip(i)->imdef, inv->getEquip(i)->iacc, inv->getEquip(i)->iavo, inv->getEquip(i)->ihand, inv->getEquip(i)->ijump, inv->getEquip(i)->ispeed); firstrun = false; } else{ sprintf_s(temp, 1000, ",(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", inv->getEquip(i)->id, Drops::equips[inv->getEquip(i)->id].type ,getPlayerid(), inv->getEquipPos(i), inv->getEquip(i)->slots, inv->getEquip(i)->scrolls, inv->getEquip(i)->istr, inv->getEquip(i)->idex, inv->getEquip(i)->iint, inv->getEquip(i)->iluk, inv->getEquip(i)->ihp, inv->getEquip(i)->imp, inv->getEquip(i)->iwatk, inv->getEquip(i)->imatk, inv->getEquip(i)->iwdef, inv->getEquip(i)->imdef, inv->getEquip(i)->iacc, inv->getEquip(i)->iavo, inv->getEquip(i)->ihand, inv->getEquip(i)->ijump, inv->getEquip(i)->ispeed); strcat_s(sql, 10000, temp); } } MySQL::insert(sql); sprintf_s(sql, 10000, "delete from skills where charid=%d;", getPlayerid()); MySQL::insert(sql); firstrun = true; for(int i=0; i<skills->getSkillsNum(); i++){ if(firstrun == true){ sprintf_s(sql, 10000, "INSERT INTO skills VALUES (%d, %d, %d)", getPlayerid(), skills->getSkillID(i), skills->getSkillLevel(skills->getSkillID(i))); firstrun = false; } else{ sprintf_s(temp, 1000, ",(%d, %d, %d)", getPlayerid(), skills->getSkillID(i), skills->getSkillLevel(skills->getSkillID(i))); strcat_s(sql, 10000, temp); } } MySQL::insert(sql); sprintf_s(sql, 10000, "DELETE FROM items WHERE charid=%d;", getPlayerid()); MySQL::insert(sql); firstrun = true; for(int i=0; i<inv->getItemNum(); i++){ if(firstrun == true){ sprintf_s(sql, 10000, "INSERT INTO items VALUES (%d, %d, %d, %d, %d)", inv->getItem(i)->id, getPlayerid() ,inv->getItem(i)->inv, inv->getItem(i)->pos, inv->getItem(i)->amount); firstrun = false; } else{ sprintf_s(temp, 1000, ",(%d, %d, %d, %d, %d)", inv->getItem(i)->id, getPlayerid() ,inv->getItem(i)->inv, inv->getItem(i)->pos, inv->getItem(i)->amount); strcat_s(sql, 10000, temp); } } MySQL::insert(sql); }