EasyRPG / Player

RPG Maker 2000/2003 and EasyRPG games interpreter
https://easyrpg.org/player/
GNU General Public License v3.0
991 stars 186 forks source link

Investigate Troop::appear_randomly #2141

Closed fmatthew5876 closed 4 years ago

fmatthew5876 commented 4 years ago

In liblcf we have a flag called Troop::appear_randomly.

In DynRPG, there is a DBMonsterGroup::randomizeHidden with a comment saying "50% chance for hidden flag"

I guess that means if you enable this flag, each monster has a 50% chance of being hidden?

There are no controls in the RPG Maker Editor for setting this.

fmatthew5876 commented 4 years ago

Ok this is in 2k3 editor but hard to find.

You have to right click on the troop name in the troops list. Then there will be an "Appear Randomly" button you can select.

Ghabry commented 4 years ago

See #987

fmatthew5876 commented 4 years ago

Well it may not truly be 50%

  FUN_00475584(param_1);
  *(int *)(param_1 + 0x24) = troop_id;
  num_not_hidden = 0;
  monsterGroup = LookupDBMonsterGroup(*(undefined **)&RPG::dbMonsterGroups,troop_id);
  num_monsters = FUN_00475714((int)monsterGroup->monsterList);
  if (-1 < num_monsters + -1) {
    mgp_id = 0;
    do {
      FUN_004755b8(param_1,mgp_id + 1);
      monGroup = LookupDBMonsterGroup(*(undefined **)&RPG::dbMonsterGroups,*(int *)(param_1 + 0x24))
      ;
      monsterGroupPosition = (MonsterGroupPosition *)FUN_0047a8dc((int)monGroup->monsterList,mgp_id)
      ;
      monster_pre = LookupMonster(param_1,mgp_id);
      FUN_004bd5f8((int *)monster_pre,monsterGroupPosition->monster_id);
      monster = LookupMonster(param_1,mgp_id);
      (monster->battler).notHidden = monsterGroupPosition->hidden ^ 1;
      if (((0 < num_not_hidden) &&
          (local_EAX_146 = LookupMonster(param_1,mgp_id),
          (local_EAX_146->battler).notHidden != false)) &&
         (pDVar1 = LookupDBMonsterGroup
                             (*(undefined **)&RPG::dbMonsterGroups,*(int *)(param_1 + 0x24)),
         pDVar1->randomizeHidden != false)) {
        pMVar2 = LookupMonster(param_1,mgp_id);
        pbVar8 = &(pMVar2->battler).notHidden;
        iVar3 = Rand(0xf);
        *pbVar8 = iVar3 < 9;
      }
      pMVar2 = LookupMonster(param_1,mgp_id);
      if ((pMVar2->battler).notHidden != false) {
        num_not_hidden = num_not_hidden + 1;
      }
      mgp_id = mgp_id + 1;
      num_monsters = num_monsters + -1;
    } while (num_monsters != 0);
  }

Ghidra dissassembly showing we draw a random number from [0, 14] inclusive. And then if our number >= 9 we hide. That Rand call happens at 004be9a4

So there is only a 40% chance of hiding a enemy with this.