Mercurial > mm7
comparison NPC.cpp @ 293:27670273a6ff
little fix npc gen
author | Gloval |
---|---|
date | Tue, 19 Feb 2013 01:23:04 +0400 |
parents | 5586bb4e8395 |
children | 72faa54ff319 |
comparison
equal
deleted
inserted
replaced
292:5586bb4e8395 | 293:27670273a6ff |
---|---|
157 pProfessionChance[i].uTotalprofChance=0; | 157 pProfessionChance[i].uTotalprofChance=0; |
158 for (int ii=1; ii<59; ++ii) | 158 for (int ii=1; ii<59; ++ii) |
159 { | 159 { |
160 pProfessionChance[i].uTotalprofChance+=pProfessionChance[i].professionChancePerArea[ii]; | 160 pProfessionChance[i].uTotalprofChance+=pProfessionChance[i].professionChancePerArea[ii]; |
161 } | 161 } |
162 pProfessionChance[i].professionChancePerArea[0]=0; | |
163 pProfessionChance[i].professionChancePerArea[59]=0; | |
162 } | 164 } |
163 | 165 |
164 if (pNPCDistTXT_Raw) | 166 if (pNPCDistTXT_Raw) |
165 { | 167 { |
166 pAllocator->FreeChunk(pNPCDistTXT_Raw); | 168 pAllocator->FreeChunk(pNPCDistTXT_Raw); |
537 signed int gen_attempts; // [sp+14h] [bp-4h]@1 | 539 signed int gen_attempts; // [sp+14h] [bp-4h]@1 |
538 int uPortretMin; // [sp+24h] [bp+Ch]@1 | 540 int uPortretMin; // [sp+24h] [bp+Ch]@1 |
539 int uPortretMax; | 541 int uPortretMax; |
540 | 542 |
541 static const unsigned __int8 NPCSexGenTable[86] ={ | 543 static const unsigned __int8 NPCSexGenTable[86] ={ |
542 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 544 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
543 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, | 545 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, |
544 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, | 546 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, |
545 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 547 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
546 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }; | 548 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 }; |
547 static const unsigned __int8 NPCRaceGenTable[86] ={ | 549 static const unsigned __int8 NPCRaceGenTable[86] ={ |
548 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 1, | 550 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 1, |
549 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 551 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
550 0, 0, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, | 552 0, 0, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, |
551 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 553 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
552 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0}; | 554 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0}; |
553 | |
554 | 555 |
555 unsigned __int8 seed = (unsigned __int8)((double)(npc_uid - 1) * 0.33333334); | 556 unsigned __int8 seed = (unsigned __int8)((double)(npc_uid - 1) * 0.33333334); |
556 uNPCSex = NPCSexGenTable[seed]; | 557 uNPCSex = NPCSexGenTable[seed]; |
557 uRace = NPCRaceGenTable[seed]; | 558 uRace = NPCRaceGenTable[seed]; |
558 pNPCDataBuff->uSex = uNPCSex; | 559 pNPCDataBuff->uSex = uNPCSex; |
561 gen_attempts = 0; | 562 gen_attempts = 0; |
562 break_gen = false; | 563 break_gen = false; |
563 | 564 |
564 do | 565 do |
565 { | 566 { |
566 switch ( uRace ) | 567 switch ( uRace ) |
567 { | 568 { |
568 case 0: | 569 case 0: |
569 if ( uNPCSex == 0 ) | 570 if ( uNPCSex == 0 ) |
570 { | 571 { |
571 uPortretMin = 2; | 572 uPortretMin = 2; |
572 uPortretMax = 100; | 573 uPortretMax = 100; |
573 } | 574 } |
574 else | 575 else |
575 { | 576 { |
576 uPortretMin = 201; | 577 uPortretMin = 201; |
577 uPortretMax = 250; | 578 uPortretMax = 250; |
578 } | 579 } |
579 | 580 case 1: |
580 case 1: | 581 if ( uNPCSex == 0 ) |
581 if ( uNPCSex == 0 ) | 582 { |
582 { | 583 uPortretMin = 400; |
583 uPortretMin = 400; | 584 uPortretMax = 430; |
584 uPortretMax = 430; | 585 } |
585 } | 586 else |
586 else | 587 { |
587 { | 588 uPortretMin = 460; |
588 uPortretMin = 460; | 589 uPortretMax = 490; |
589 uPortretMax = 490; | 590 } |
590 } | 591 break; |
591 break; | 592 case 2: |
592 case 2: | 593 if ( uNPCSex == 0 ) |
593 if ( uNPCSex == 0 ) | 594 { |
594 { | 595 uPortretMin = 500; |
595 uPortretMin = 500; | 596 uPortretMax = 520; |
596 uPortretMax = 520; | 597 } |
597 } | 598 else |
598 else | 599 { |
599 { | 600 uPortretMin = 530; |
600 uPortretMin = 530; | 601 uPortretMax = 550; |
601 uPortretMax = 550; | 602 } |
602 } | 603 break; |
603 break; | 604 case 3: |
604 case 3: | 605 if ( uNPCSex == 0 ) |
605 if ( uNPCSex == 0 ) | 606 { |
606 { | 607 uPortretMin = 300; |
607 uPortretMin = 300; | 608 uPortretMax = 330; |
608 uPortretMax = 330; | 609 } |
609 } | 610 else |
610 else | 611 { |
611 { | 612 uPortretMin = 360; |
612 uPortretMin = 360; | 613 uPortretMax = 387; |
613 uPortretMax = 387; | 614 } |
614 } | 615 |
615 | 616 break; |
616 break; | 617 } |
617 } | 618 |
618 | |
619 uGeneratedPortret = uPortretMin + rand() % (uPortretMax - uPortretMin + 1); | 619 uGeneratedPortret = uPortretMin + rand() % (uPortretMax - uPortretMin + 1); |
620 if ( CheckPortretAgainsSex(uGeneratedPortret, uNPCSex)) | 620 if ( CheckPortretAgainsSex(uGeneratedPortret, uNPCSex)) |
621 break_gen = true; | 621 break_gen = true; |
622 ++gen_attempts; | 622 ++gen_attempts; |
623 if ( gen_attempts >= 4 ) | 623 if ( gen_attempts >= 4 ) |
626 break_gen = true; | 626 break_gen = true; |
627 } | 627 } |
628 } | 628 } |
629 while(!break_gen); | 629 while(!break_gen); |
630 | 630 |
631 pNPCDataBuff->uPortraitID = uGeneratedPortret; | 631 pNPCDataBuff->uPortraitID = uGeneratedPortret; |
632 pNPCDataBuff->uFlags = 0; | 632 pNPCDataBuff->uFlags = 0; |
633 pNPCDataBuff->fame = 0; | 633 pNPCDataBuff->fame = 0; |
634 //generate reputation | 634 //generate reputation |
635 rep_gen = rand() % 100 + 1; | 635 rep_gen = rand() % 100 + 1; |
636 | 636 |
637 if ( rep_gen >= 60 ) | 637 if ( rep_gen >= 60 ) |
638 { | 638 { |
639 if ( rep_gen >= 90 ) | 639 if ( rep_gen >= 90 ) |
640 { | 640 { |
641 if ( rep_gen >= 95 ) | 641 if ( rep_gen >= 95 ) |
642 { | 642 { |
643 if ( rep_gen >= 98 ) | 643 if ( rep_gen >= 98 ) |
644 pNPCDataBuff->rep = -600; | 644 pNPCDataBuff->rep = -600; |
645 else | |
646 pNPCDataBuff->rep = 400; | |
647 } | |
645 else | 648 else |
646 pNPCDataBuff->rep = 400; | 649 pNPCDataBuff->rep = -300; |
647 } | 650 } |
648 else | 651 else |
649 pNPCDataBuff->rep = -300; | 652 pNPCDataBuff->rep = 200; |
650 } | 653 } |
651 else | 654 else |
652 pNPCDataBuff->rep = 200; | 655 pNPCDataBuff->rep = 0; |
653 | 656 |
654 } | 657 max_prof_cap = rand() % pProfessionChance[uMapId].uTotalprofChance+1; |
655 else | 658 test_prof_summ = 0; |
656 pNPCDataBuff->rep = 0; | 659 gen_profession = 0; |
657 | 660 |
658 max_prof_cap = rand() % pProfessionChance[uMapId].uTotalprofChance+1; | 661 if ( max_prof_cap > 0 ) |
659 test_prof_summ = 0; | 662 { |
660 gen_profession = 0; | 663 do |
661 | 664 test_prof_summ += pProfessionChance[uMapId].professionChancePerArea[gen_profession++]; |
662 if ( max_prof_cap > 0 ) | 665 while ( test_prof_summ < max_prof_cap ); |
663 { | 666 } |
664 do | 667 pNPCDataBuff->uProfession = gen_profession - 1; |
665 test_prof_summ += pProfessionChance[uMapId].professionChancePerArea[gen_profession++]; | 668 pNPCDataBuff->Location2D = uLocation2D; |
666 while ( test_prof_summ < max_prof_cap ); | 669 pNPCDataBuff->field_24 = 1; |
667 } | 670 pNPCDataBuff->joins = 1; |
668 pNPCDataBuff->uProfession = gen_profession - 1; | |
669 pNPCDataBuff->Location2D = uLocation2D; | |
670 pNPCDataBuff->field_24 = 1; | |
671 pNPCDataBuff->joins = 1; | |
672 } | 671 } |
673 | 672 |
674 | 673 |
675 //----- (00476387) -------------------------------------------------------- | 674 //----- (00476387) -------------------------------------------------------- |
676 bool PartyHasDragon() | 675 bool PartyHasDragon() |