Thread:RottenBlock/@comment-46261745-20200829154721/@comment-31720212-20200830044059

For starters, while array.Find doesn't appear in the manual, it does seem to be built-in, and examples suggest it works  like many an array-searching function in other languages. The first param will indicate the starting index to search, the second param will indicate either the closing index or the number of entries to search (the results would be the same, in this instance; I suspect it's actually the latter because that's how System 4 searches strings with string.GetPart), and the third param indicates the integer you're looking for. - What you're seeing in add1 is Find(0, length, foo). In other words, it's searching the entire array for variable foo. The function returns a negative number if the integer is not found in those bounds, probably -1.

Long story short, all add1 is doing is adding the integer nType to the array if nType is not already in the array. Otherwise, it does nothing.

m_ and g_ are a part of what's called Hungarian Notation, which Alicesoft favours but doesn't use exclusively. m_ indicates that the variable is a member variable, a variable that belongs to the object, while g_ indicates a global variable that should be accessible from anywhere. But they're just labels, and don't confer any special properties. One hopes, whenever reading someone else's code, that their documentation is correct...

I wouldn't worry about the check for cnt being 0. It's true that it shouldn't ever be 0, but that's the point: the programmer just set that check to prevent the game from crashing during an error. Depending on how they programmed, there may have been a warning message at one point in development, or maybe there just wasn't. It's just thoroughness. So far as I can tell, you're right: for the sake of thoroughness, the cnt check should have also applied to random1, but thankfully, since cnt can't be 0, nothing bad ever happened.

Lastly, so far as I can tell, FixSRWiki is correct: add1 is only called during 合戦敵_行動選択. 合戦敵_行動選択 also calls 敵ターゲット_選択, and THAT is the function that calls select. You'll want to look at 合戦敵_行動選択 to see how the functions are related.

I hope that helps. It's a complex subject and if I missed something you were hoping I might be able to explain, please clarify. Good luck!