Ok everyone, great news!
I have posted the v4.2.3 python library up on my GitHub repository. I will be pushing all future updates to this repository so that plugin authors can keep track of our API.
Feel free to submit bugs, pull requests, or anything else to this repo and I will incorporate them into GES build.
Please note, the GES Python Library is now licensed under the GNU GPL v3, please read the LICENSE file for more information.
https://github.com/droidmonkey/ges-python
I've had a look at Arsenal on GitHub. There's two things that I've noticed:
1. Line 77 can be changed to this:
if weaponList != weaponListCopy
(I highly doubt someone is going to change the CVar value of ar_randomweapons to 1 in the code itself. If they did, all that would happen when the admin reloaded the game mode is it would revert to the default list and then when re-shuffle the weapons on round begin. The same thing would happen if a game mode other than Arsenal was being played and then it was loaded in.)
2. Line 326 can be changed to this:
for i in range( self.GetLevel( player ) + 1, maxLevel ):
Also, I don't like the fact that you're showing the final weapon if the player presses g after they've won the round. The Arsenal box shouldn't come up at all. Even though the player's weapon hasn't changed, they have already completed that level.
I've made a change to Arsenal's PrintWeapon function:
def PrintWeapons( self, player ):
if not player or self.GetLevel( player ) > maxLevel:
return
arWeapons = ""
for i in range( self.GetLevel( player ), maxLevel ):
name = GEWeapon.WeaponPrintName( weaponList[i][0] )
arWeapons += "Level %i: #%s\n" % ( i + 1, name )
if arWeapons.count( ":" ) == 5:
break
arWeapons += "\nFinal level %i: #%s\n" % ( len( weaponList ), GEWeapon.WeaponPrintName( weaponList[-1][0] ) )
GEUtil.PopupMessage( player, "#GES_GP_ARSENAL_NAME", arWeapons )
I do not like the function you made because it shows the next 5 levels and always the final level. This doesn't work because if you're on the final level, and press g, it shows that one. I've corrected that by always showing the current level, the next four levels and the final level. The reason I've chosen this route is because you have not bypassed your weapon, so it should show it in the popup window as you're still on it. This could be good for if you've joined a game late and you're wanting to know which level you're been given or if you've been stuck on a level and want to refresh your memory which it is. With my way, a return statement is only needed when the player wins the round. If you were to always show what's in the future, a return statement would have to be written for when the player's on the final weapon and when he has won the game. Also, if a player is on the final weapon, they're hitting g trying to find out what's left, and they're not seeing anything, they might get confused and wonder why nothing is happening.
I'd also like to note that making final weapon all capitalized like so "FINAL WEAPON" looked like hell. You've already drawn enough attention to that line with a double line break. That is plenty.
I settled with this compromise solution, it looks great in game too:
def PrintWeapons( self, player ):
# Player's at the max level don't see this message
if not player:
return
curr_level = self.GetLevel( player )
if curr_level == maxLevel:
GEUtil.PopupMessage( player, "#GES_GP_ARSENAL_NAME", "You are on the final level!" )
return
# Start with the player's current level
arWeapons = "Current Level %i: #%s\n\n" % ( curr_level + 1, GEWeapon.WeaponPrintName( weaponList[curr_level][0] ) )
# Output up to the next 4 weapons for this player, not including the final weapon
count = 0
for i in range( curr_level + 1, maxLevel ):
count += 1
arWeapons += "Level %i: #%s\n" % ( i + 1, GEWeapon.WeaponPrintName( weaponList[i][0] ) )
if count == 4:
break
# Tack on the final weapon
arWeapons += "\nFinal Level %i: #%s\n" % ( len( weaponList ), GEWeapon.WeaponPrintName( weaponList[-1][0] ) )
GEUtil.PopupMessage( player, "#GES_GP_ARSENAL_NAME", arWeapons )
I've tested your code. In my opinion, some adjustments need to be made. We can't have a double line break after the current level. The reason being is this:
(http://img585.imageshack.us/img585/6363/uglyq.jpg)
I think it's best to make Current Level x and Final Level x a lower case l. Also, I don't think a double line break needed if there isn't a gap between the levels. Lastly, you forgot a return statement for when the player wins.
def PrintWeapons( self, player ):
if not player:
return
lvl = self.GetLevel( player )
if lvl > maxLevel:
return
if lvl < maxLevel:
# Start with the player's current level
arWeapons = "Current level %i: #%s\n" % ( lvl + 1, GEWeapon.WeaponPrintName( weaponList[lvl][0] ) )
# Output up to the next 4 weapons excluding the final weapon
count = 0
for i in range( lvl + 1, maxLevel ):
count += 1
arWeapons += "Level %i: #%s\n" % ( i + 1, GEWeapon.WeaponPrintName( weaponList[i][0] ) )
if count == 4:
break
# Tack on the final weapon
if lvl + 5 < maxLevel:
arWeapons += "\nFinal level %i: #%s\n" % ( len( weaponList ), GEWeapon.WeaponPrintName( weaponList[-1][0] ) )
else:
arWeapons += "Final level %i: #%s\n" % ( len( weaponList ), GEWeapon.WeaponPrintName( weaponList[-1][0] ) )
GEUtil.PopupMessage( player, "#GES_GP_ARSENAL_NAME", arWeapons )
else:
GEUtil.PopupMessage( player, "#GES_GP_ARSENAL_NAME", "You are on the final level!" )
Gapped
(http://img90.imageshack.us/img90/188/finalkp.png)
Not Gapped
(http://img829.imageshack.us/img829/8067/notgapped.png)