Exemplo n.º 1
0
 def CalculateCustomDamage(self, victim, info, health, armour):
     assert isinstance(victim, GEPlayer.CGEMPPlayer)
     if victim == None:
         return health, armour
     killer = GEPlayer.ToMPPlayer(info.GetAttacker())
     v_flagindex = self.ft_flagindexbyplayer(victim)
     k_flagindex = self.ft_flagindexbyplayer(killer)
     # ep_shout("[SDCD] %d %d" % (v_flagindex, k_flagindex) )
     if v_flagindex >= 0:
         # Suicide or friendly fire exacerbates but does not trigger escape.
         total_damage = health + armour
         if killer == None or GEEntity.GetUID(victim) == GEEntity.GetUID(
                 killer) or GEMPGameRules.IsTeamplay(
                 ) and victim.GetTeamNumber() == killer.GetTeamNumber():
             self.flaglist[v_flagindex].escape(False, total_damage)
         else:
             self.flaglist[v_flagindex].escape(True, total_damage)
             self.ft_escapebar(self.flaglist[v_flagindex], victim)
     if k_flagindex >= 0:
         # Flag carrier steals a point on successful attack.
         if victim.GetRoundScore() > 0:
             ep_incrementscore(victim, -self.THEFT_DELTA)
             ep_incrementscore(killer, self.THEFT_DELTA)
             GEUtil.PlaySoundTo(killer, "Buttons.beep_ok")
             GEUtil.PlaySoundTo(victim, "Buttons.Token_Knock")
             ep_shout("Point stolen from %s via slap." %
                      victim.GetPlayerName())
             GEUtil.EmitGameplayEvent("ld_flagpoint",
                                      str(killer.GetUserID()),
                                      str(victim.GetUserID()), "flaghit",
                                      "1")
     return health, armour
Exemplo n.º 2
0
 def ft_associate(self, token, player):
     flagindex = self.ft_flagindexbytoken(token)
     if (flagindex >= 0):
         self.flaglist[flagindex].player_id = GEEntity.GetUID(player)
     else:
         ep_shout(
             "[ft_associate] Token %d does not have associated information."
             % (GEEntity.GetUID(token)))
     return flagindex
Exemplo n.º 3
0
    def updateUplinkTimer(
        self, timerMax
    ):  # Handles the capture timers, adding time or removing time based on which players are on the Uplink
        if GEMPGameRules.IsTeamplay():
            if self.owner != GEGlobal.TEAM_MI6 and self.numMI6:
                if not self.numJanus:
                    self.timerMI6 += 1 + self.numMI6
                    if self.timerMI6 >= timerMax:
                        self.timerMI6 = 0
                        self.timerJanus = 0
                        self.pointTimer = 0
                        return GEGlobal.TEAM_MI6
                    elif self.timerJanus:
                        self.timerJanus -= 5
                        if self.timerJanus < 0:
                            self.timerJanus = 0

            elif self.owner != GEGlobal.TEAM_JANUS and self.numJanus:
                if not self.numMI6:
                    self.timerJanus += 1 + self.numJanus
                    if self.timerJanus >= timerMax:
                        self.timerMI6 = 0
                        self.timerJanus = 0
                        self.pointTimer = 0
                        return GEGlobal.TEAM_JANUS
                    elif self.timerMI6:
                        self.timerMI6 -= 5
                        if self.timerMI6 < 0:
                            self.timerMI6 = 0

            else:
                self.timerMI6 -= 2
                if self.timerMI6 < 0:
                    self.timerMI6 = 0

                self.timerJanus -= 2
                if self.timerJanus < 0:
                    self.timerJanus = 0

            return False
        else:
            temp_playerUIDlist = []
            for player in self.playerList:
                temp_playerUIDlist += [GEEntity.GetUID(player)]

            for playerUID in list(self.playerTimers):
                if playerUID not in temp_playerUIDlist:
                    self.playerTimers[playerUID] -= 2
                    if self.playerTimers[playerUID] < 0:
                        del self.playerTimers[playerUID]

            if len(self.playerList) == 1:
                self.playerTimers[GEEntity.GetUID(self.playerList[0])] += 2
                if self.playerTimers[GEEntity.GetUID(
                        self.playerList[0])] >= timerMax:
                    return True
            return False
Exemplo n.º 4
0
    def OnPlayerKilled(self, victim, killer, weapon):
        if victim == None:
            return
        # Disconnecting player_previous to prevent multiple penalties.
        flagindex = self.ft_flagindexbyplayer(victim)
        if flagindex >= 0:
            self.flaglist[flagindex].player_previous = 0
            GEUtil.EmitGameplayEvent("ld_flagdropped", str(victim.GetUserID()),
                                     str(killer.GetUserID()))

        vid = GEEntity.GetUID(victim)
        kid = GEEntity.GetUID(killer)
        ep_shout("[OPK] Victim %d, Killer %d, VFlag Index %d" %
                 (vid, kid, flagindex))
        bounty = min(self.flaglist[flagindex].earnings,
                     self.flaglist[flagindex].LEVEL_LIMIT)

        # Suicide
        if killer == None or killer.GetIndex(
        ) == 0 or vid == kid or GEMPGameRules.IsTeamplay(
        ) and victim.GetTeamNumber() == killer.GetTeamNumber():
            suicide_bounty = -choice(flagindex >= 0, bounty + bounty, 1)
            ep_incrementscore(victim, suicide_bounty)
            if flagindex >= 0:
                GEUtil.EmitGameplayEvent("ld_flagpoint",
                                         str(victim.GetUserID()), "-1",
                                         "suicide", str(suicide_bounty))
            return

        # slap and snatch TODO: Verify
        if weapon != None and weapon.GetClassname(
        ) == "weapon_slappers" and flagindex >= 0:
            delta = choice(flagindex >= 0, bounty, 0)
            if delta > 0:
                ep_incrementscore(victim, -delta)
                GEUtil.HudMessage(
                    victim, _(plural(delta, "#GES_GP_LD_LOSEPOINTS"), delta),
                    -1, -1, EP_SHOUT_COLOR, 2.0)
                ep_incrementscore(killer, delta)
                GEUtil.HudMessage(
                    killer, _(plural(delta, "#GES_GP_LD_STOLEPOINTS"), delta),
                    -1, -1, EP_SHOUT_COLOR, 2.0)
                GEUtil.EmitGameplayEvent("ld_flagpoint",
                                         str(victim.GetUserID()),
                                         str(killer.GetUserID()),
                                         "slapperkill", str(-delta))

        # credit if token will be removed from play. TODO: Verify
        if self.ft_flagdebt() < 0:
            if flagindex >= 0:
                ep_incrementscore(killer, self.flaglist[flagindex].level)
            else:
                ep_shout(
                    "[OPK] No flag index associated with slain carrier whose flag is removed."
                )
Exemplo n.º 5
0
		def addPlayerList(self, player):
			if GEMPGameRules.IsTeamplay():
				self.playerList += [player]
				if player.GetTeamNumber() == GEGlobal.TEAM_JANUS:
					self.numJanus += 1
				elif player.GetTeamNumber() == GEGlobal.TEAM_MI6:
					self.numMI6 += 1
			else:
				self.playerList += [player]
				if not GEEntity.GetUID( player ) in self.playerTimers:
					GEUtil.ClientPrint(GEEntity.GetUID( player ), GEGlobal.HUD_PRINTTALK, str(self.playerTimers))
					self.playerTimers[GEEntity.GetUID( player )] = 0
Exemplo n.º 6
0
 def createObjective(self, area, name, capturing):
     if capturing:
         if GEMPGameRules.IsTeamplay():
             title = str(
                 int((self.areaDictionary[name].timerJanus +
                      self.areaDictionary[name].timerMI6) *
                     (100.0 / self.uplinkTimerMax))) + "%%"
         else:
             if name in self.areaDictionary:
                 tempList = []
                 for player in self.areaDictionary[name].playerList:
                     tempList += [
                         self.areaDictionary[name].playerTimers[
                             GEEntity.GetUID(player)]
                     ]
                 title = str(
                     int(max(tempList) * 100.0 /
                         self.uplinkTimerMax)) + "%%"
     else:
         title = ""
     color = self.getObjColor(self.areaDictionary[name].owner, capturing)
     GEMPGameRules.GetRadar().SetupObjective(area, GEGlobal.TEAM_NONE, "",
                                             title, color,
                                             int(0.6 * self.pointRadius),
                                             capturing)
Exemplo n.º 7
0
 def OnTokenSpawned( self, token ):
     self.ft_registerflag( GEEntity.GetUID( token ) )
     GEMPGameRules.GetRadar().AddRadarContact( token, GEGlobal.RADAR_TYPE_TOKEN, True, "", self.COLOR_COLD )
     GEMPGameRules.GetRadar().SetupObjective( token, GEGlobal.TEAM_NONE, "!%s" % self.TokenClass, "#GES_GP_LD_OBJ_TAKE", GEUtil.CColor( 220, 220, 220, 200 ) )
     token.SetSkin( randint(8, 28) )
     self.ft_teambalancebars()
     self.ft_showteamflags()
Exemplo n.º 8
0
    def OnTokenPicked(self, token, player):
        ID = str(GEEntity.GetUID(token))
        self.caseDict[ID] = Case(player)
        self.displayHold(player)

        GEUtil.PlaySoundToPlayer(player, "GEGamePlay.Token_Grab", True)
        GEUtil.HudMessage(player, self.pickText, -1, 0.67, self.colorMsg, 2.5,
                          1)

        GEMPGameRules.GetRadar().DropRadarContact(token)
        GEMPGameRules.GetRadar().AddRadarContact(player,
                                                 GEGlobal.RADAR_TYPE_PLAYER,
                                                 True, "sprites/hud/radar/run",
                                                 self.getColor(player))
        GEMPGameRules.GetRadar().SetupObjective(player, GEGlobal.TEAM_NONE,
                                                "!" + self.TokenClass, "",
                                                self.getColor(player), 0,
                                                False)

        player.SetScoreBoardColor(self.scoreboardOwner)

        GEUtil.PostDeathMessage(
            self.getTextColor(player) + player.GetCleanPlayerName() +
            self.grabText)

        GEUtil.EmitGameplayEvent("hb_casepicked", "%i" % player.GetUserID())
Exemplo n.º 9
0
 def ft_zot_token(self, token):
     j = self.ft_flagindexbytoken(token)
     if j >= 0:
         self.flaglist[j].zot()
     else:
         ep_shout("[Zot Token] Attempted to remove unregistered token %d" %
                  GEEntity.GetUID(token))
Exemplo n.º 10
0
 def Clear(self, player=None):
     '''Forcibly clear the player list, you will have to manually re-register players!'''
     if not player:
         self._players = {}
     else:
         uid = GEEntity.GetUID(player)
         if uid in self._players:
             self._players[uid] = {}
Exemplo n.º 11
0
 def ft_flagindexbyplayerprevious(self, player):
     uid = GEEntity.GetUID(player)
     rtn_j = -1
     for j in range(self.FLAGLIST_LIMIT):
         if (self.flaglist[j].player_previous == uid):
             rtn_j = j
             break
     return rtn_j
Exemplo n.º 12
0
 def ft_flagindexbytoken(self, token):
     uid = GEEntity.GetUID(token)
     rtn_j = -1
     for j in range(self.FLAGLIST_LIMIT):
         if (self.flaglist[j].token_id == uid):
             rtn_j = j
             break
     return rtn_j
Exemplo n.º 13
0
    def _Drop(self, player):
        if player == None:
            return

        uid = GEEntity.GetUID(player)
        if uid not in self._players:
            return

        del self._players[uid]
Exemplo n.º 14
0
    def _Track(self, player):
        if player == None:
            return

        uid = GEEntity.GetUID(player)
        if uid in self._players:
            return

        self._players[uid] = {}
	def OnTokenRemoved( self, token ):
		GEMPGameRules.GetRadar().DropRadarContact( token )
		ID = str( GEEntity.GetUID( token ) )
		if ID in self.caseDict:
			if self.caseDict[ ID ].owner:
				self.hideHold( self.caseDict[ ID ].owner )
				GEMPGameRules.GetRadar().DropRadarContact( self.caseDict[ ID ].owner )
				GEMPGameRules.GetRadar().ClearObjective( self.caseDict[ ID ].owner )
				self.caseDict[ ID ].owner.SetScoreBoardColor( self.scoreboardDefault )
			del self.caseDict[ ID ]
Exemplo n.º 16
0
    def __getitem__(self, player_or_uid):
        if not player_or_uid:
            return None

        try:
            uid = player_or_uid
            if type(uid) is not int:
                uid = GEEntity.GetUID(uid)
            return self._players[uid]
        except:
            raise KeyError("Invalid player passed to GEPlayerTracker!")
Exemplo n.º 17
0
 def updateBar(self, playerList, areaName):
     for player in playerList:
         if GEMPGameRules.IsTeamplay():
             if player.GetTeamNumber() == GEGlobal.TEAM_MI6:
                 num = self.areaDictionary[areaName].timerMI6
             else:
                 num = self.areaDictionary[areaName].timerJanus
             GEUtil.UpdateHudProgressBar(player, self.barIndex, num)
         else:
             tempPlayerTimers = self.areaDictionary[areaName].playerTimers
             num = tempPlayerTimers[GEEntity.GetUID(player)]
             GEUtil.UpdateHudProgressBar(player, self.barIndex, num)
	def OnTokenDropped( self, token, player ):
		ID = str( GEEntity.GetUID( token ) )
		self.caseDict[ ID ] = Case( None )
		self.hideHold(player)

		GEMPGameRules.GetRadar().AddRadarContact( token, GEGlobal.RADAR_TYPE_TOKEN, True, "", self.colorCase )
		GEMPGameRules.GetRadar().SetupObjective( token, GEGlobal.TEAM_NONE, "!" + self.TokenClass, self.caseName, self.colorCase )

		GEMPGameRules.GetRadar().DropRadarContact( player )
		GEMPGameRules.GetRadar().ClearObjective( player )

		player.SetScoreBoardColor( self.scoreboardDefault )
		
		GEUtil.PostDeathMessage( self.getTextColor(player) + player.GetCleanPlayerName() + self.dropText )
		
		GEUtil.EmitGameplayEvent( "hb_casedropped", "%i" % player.GetUserID() )