Hello, I'm new to the map making scene. I've read many tutorials and think I understand the use of variables, arrays, etc. fairly well. I am getting pretty far into developing my first map and I've run into a few issues along the way that have led me to point towards one common factor - I may not understand how arrays interact as much as I'd hoped. I was hoping someone could look at what I am doing briefly and tell me why/why not it works/doesn't work, etc.
TLDR: I am concerned about my ignorance regarding a specific unit array, a player group, and a unit group & how to use them.
Some examples of these uses:
In this example, a quest has been going on for a long chain of events, all given by a single unit that 'sells' an item that allows for events to progress. Basically, you select the item he sells and the trigger checks the current stage of the quest (Quest2 = ?) and returns the correct response. However, after the chain of quests is over, I want this unit to act as a returning character, but ONLY for players who have chosen the "apprentice path." I decided, for now, to add these feature in as just another part of the chain, where a new counter "ApprenticeCounter[PlayerNumber]" is used to determine if that player has started the first part of the apprentice path quests.
TLDR: A different trigger based on a different unit sets ApprenticeCounter[number] = 1, if it is 1 when interacting with this unit, I want him to set it to 2, but ONLY for the player interacting with him.
I've set a "for each (integer A)" for the range of players from 1 to 'IsPlaying' to check the possible player numbers it could be, and then my hope is that the condition, "if Hero Manipulating Item = PlayerUnit[A]," will work by detecting if the player interacting with this unit is also the PlayerUnit[A] that it is currently checking for, then only increasing the value for that player's ApprenticeCounter[Number] to 2.
Does this sort of system work? Have I just gotten lucky with it in the past? Is there anything I should be concerned about?
Next example:
Here, I again have an array for an integer that is used to detect if a player has already received a very specific reward. This quest can be done multiple times, but I only one each player to be able to get the item one single time at an ideally 70% chance (but I've set it to 80 to help in debugging a little).
My hope is that it will pick each unit in in "AllPlayerHeroes" and give each one the 3k exp, but then require both the 80% dice roll AND that the player's "RewardCounter[PlayerNumber]" for that specific player be 0 and not 1 in order to give the item. If the player does get the item, I their "RewardCounter[PlayerNumber]" to change to 1, and theirs only. Does this work?
Thank you taking the time to read any of what you've chosen to. I don't expect anyone to examine all of it but any feedback I can get it valuable to me.
As a quick clarification, I am aware that many of my uses would be ruined if, for example, 2 players were playing and one changed colors to be teal instead of blue, resulting in the "# of players in IsPlaying" to = 2, but the PlayerNumber needed actually being 3. I am completely okay with this. Thank you again!
TLDR: I am concerned about my ignorance regarding a specific unit array, a player group, and a unit group & how to use them.
1) Hero Selection: The biggest red flag for me all points back to how the game starts. 1-5 players can play, there are currently 5 heroes (eventually more) available for selection. Upon selection, a hero is set as the value for "PlayerUnit[PlayerNumber(of the person selecting)]." That "PlayerUnit" array is 1 of the 3 parts of my design that I am concerned may be causing issues. The other 2:
2) At map initialization, I create a player group called, "IsPlaying," of the players that match both "User" and slot status of "is playing." I use this so the game doesn't generate rewards for players that are computer based or not filled for that game. I am worried that my total lack of understanding on player groups may be leading to some unexpected conflicts later on (examples will come). Oh, I should also mention I use the absolute hell out of this player group, especially in the for all integers A function by setting the range of values as, "1 to (Number of players in group, IsPlaying)."
3) Along with assigning a selected hero to "PlayerUnit[Number]," I also then add them to a unit group, "AllPlayerHeroes." This one is also incredibly useful if it is working the way I am hoping, because it allows for things like global rewards for quests where I don't have to condition which heroes are nearby, involved, etc. In situations where I want all heroes to get a reward, but still need to isolate it to only the ones that have been chosen and are being actively played, I use this unit group to distribute rewards like exp & items.
Some examples of these uses:
In this example, a quest has been going on for a long chain of events, all given by a single unit that 'sells' an item that allows for events to progress. Basically, you select the item he sells and the trigger checks the current stage of the quest (Quest2 = ?) and returns the correct response. However, after the chain of quests is over, I want this unit to act as a returning character, but ONLY for players who have chosen the "apprentice path." I decided, for now, to add these feature in as just another part of the chain, where a new counter "ApprenticeCounter[PlayerNumber]" is used to determine if that player has started the first part of the apprentice path quests.
TLDR: A different trigger based on a different unit sets ApprenticeCounter[number] = 1, if it is 1 when interacting with this unit, I want him to set it to 2, but ONLY for the player interacting with him.
I've set a "for each (integer A)" for the range of players from 1 to 'IsPlaying' to check the possible player numbers it could be, and then my hope is that the condition, "if Hero Manipulating Item = PlayerUnit[A]," will work by detecting if the player interacting with this unit is also the PlayerUnit[A] that it is currently checking for, then only increasing the value for that player's ApprenticeCounter[Number] to 2.
Does this sort of system work? Have I just gotten lucky with it in the past? Is there anything I should be concerned about?
Next example:
Here, I again have an array for an integer that is used to detect if a player has already received a very specific reward. This quest can be done multiple times, but I only one each player to be able to get the item one single time at an ideally 70% chance (but I've set it to 80 to help in debugging a little).
My hope is that it will pick each unit in in "AllPlayerHeroes" and give each one the 3k exp, but then require both the 80% dice roll AND that the player's "RewardCounter[PlayerNumber]" for that specific player be 0 and not 1 in order to give the item. If the player does get the item, I their "RewardCounter[PlayerNumber]" to change to 1, and theirs only. Does this work?
Thank you taking the time to read any of what you've chosen to. I don't expect anyone to examine all of it but any feedback I can get it valuable to me.
As a quick clarification, I am aware that many of my uses would be ruined if, for example, 2 players were playing and one changed colors to be teal instead of blue, resulting in the "# of players in IsPlaying" to = 2, but the PlayerNumber needed actually being 3. I am completely okay with this. Thank you again!