Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int select_atacker( const Banda *const b ) {
- int pula = 3;
- for( int i=0 ; i<CNT_POSTACI ; i++ ) {
- const Postac *const p = b->postaci + i;
- if( p->live > 0 )
- pula += p->evil * (p->spirit + p->strength);
- }
- for( int i=2 ; 1 ; i++ ) {
- const Postac *const p = b->postaci + i%CNT_POSTACI;
- if( p->live > 0 )
- if( p->evil * (p->spirit + p->strength) > my_rand()%pula )
- return i;
- }
- }
- int is_magick_atack( const Postac *const p ) {
- return p->spirit * p->good + 1 > my_rand() % ( p->spirit * p->good + p->strength * p->evil + 2 );
- }
- int strength_atack( const Postac *const p , int is_magick ) {
- int atack;
- if( is_magick )
- atack = p->spirit * p->evil * bronie[p->id_bron].spritual_atack;
- else
- atack = p->strength * p->evil * bronie[p->id_bron].phisical_atack;
- }
- int select_victim( const Postac *const p ) {
- int pula = 3;
- for( int i=0 ; i<CNT_POSTACI ; i++ ) {
- const Postac *const p = b->postaci + i;
- if( p->live > 0 )
- pula += p->good * p->deftness;
- }
- for( int i=2 ; 1 ; i++ ) {
- const Postac *const p = b->postaci + i%CNT_POSTACI;
- if( p->live > 0 )
- if( p->evil * (p->spirit + p->strength) > my_rand()%pula )
- return i;
- }
- }
- int result( Banda *const b1 , Banda *const b2 , int *res ) {
- int res1=0;
- int res2=0;
- for( int i=0 ; i<CNT_POSTACI && (res1==0 || res2==0) ; i++ ) {
- if( b1->postaci[i].live > 0 ) res1 ++ ;
- if( b2->postaci[i].live > 0 ) res2 ++ ;
- }
- if( res1==0 && res2>0 ) {
- *res = -1;
- return 1;
- }
- if( res1>0 && res2==0 ) {
- *res = +1;
- return 1;
- }
- if( res1==0 && res2==0 ) {
- *res = 0;
- return 1;
- }
- return 0;
- }
- int walka( Banda *const b1 , Banda *const b2 ) {
- int cpy_live1[CNT_POSTACI],cpy_live2[CNT_POSTACI];
- int res;
- for( int i=0 ; i<CNT_POSTACI ; i++ ) {
- cpy_live1[i] = b1->postaci[i].live;
- cpy_live2[i] = b2->postaci[i].live;
- b1->postaci[i].live = (b1->postaci[i].live + 1) * 30;
- b2->postaci[i].live = (b2->postaci[i].live + 1) * 30;
- }
- while( ! result( b1 , b2 , &res ) ) {
- int at1 = select_atacker( b1 );
- int at2 = select_atacker( b2 );
- }
- for( int i=0 ; i<CNT_POSTACI ; i++ ) {
- b1->postaci[i].live = cpy_live1[i];
- b2->postaci[i].live = cpy_live2[i];
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement