Пример #1
0
  def FlagTouch(me, a, p, fid):
    sets = a.fg_wz_sets
    if sets.carryflags == asss.CARRY_ALL:
      cancarry = MAXFLAGS
    else:
      cancarry = sets.carryflags - 1

    if p.flagscarried >= cancarry:
      return

    if sets.allowpriv == 0 and p.freq >= 100:
      return

    if p.freq >= sets.disallowflagteamstart and p.freq < sets.disallowflagteamend:
      return

    # Lock in ability to win when flag is picked up
    if not check_flag_team_sizes(a):
      chat.SendMessage(p, "Note: Flag game cannot be won until every team has at least %d player(s)." % sets.minplayersperteam)
      a.can_win = False
    else:
      a.can_win = True

    # assign him the flag
    f = asss.flaginfo()
    f.state = asss.FI_CARRIED
    f.carrier = p
    flagcore.SetFlags(a, fid, f)
Пример #2
0
    def FlagTouch(me, a, p, fid):
        sets = a.fg_wz_sets
        if sets.carryflags == asss.CARRY_ALL:
            cancarry = MAXFLAGS
        else:
            cancarry = sets.carryflags - 1

        if p.flagscarried >= cancarry:
            return

        if sets.allowpriv == 0 and p.freq >= 100:
            return

        if p.freq >= sets.disallowflagteamstart and p.freq < sets.disallowflagteamend:
            return

        # Lock in ability to win when flag is picked up
        if not check_flag_team_sizes(a):
            chat.SendMessage(
                p,
                "Note: Flag game cannot be won until every team has at least %d player(s)."
                % sets.minplayersperteam)
            a.can_win = False
        else:
            a.can_win = True

        # assign him the flag
        f = asss.flaginfo()
        f.state = asss.FI_CARRIED
        f.carrier = p
        flagcore.SetFlags(a, fid, f)
Пример #3
0
 def set(me, a, owners):
     # only set owners from persistent data if the setting says so, and
     # if the setting agrees:
     if getattr(a, 'fg_turf_persist', 0) and len(owners) == a.fg_turf_fc:
         f = asss.flaginfo()
         f.state = asss.FI_ONMAP
         for i in xrange(a.fg_turf_fc):
             f.freq = owners[i]
             flagcore.SetFlags(a, i, f)
Пример #4
0
def neut_flag(a, i, x, y, r, rmin, freq):
  # record it as a neut so we can behave differently when spawning it
  a.fg_wz_neuts.append(i)
  # move it to none, but record x, y, freq
  f = asss.flaginfo()
  f.state = asss.FI_NONE
  f.x, f.y = x, y
  f.freq = freq
  f.carrier = None
  flagcore.SetFlags(a, i, f)
Пример #5
0
def neut_flag(a, i, x, y, r, rmin, freq):
    # record it as a neut so we can behave differently when spawning it
    a.fg_wz_neuts.append(i)
    # move it to none, but record x, y, freq
    f = asss.flaginfo()
    f.state = asss.FI_NONE
    f.x, f.y = x, y
    f.freq = freq
    f.carrier = None
    flagcore.SetFlags(a, i, f)
Пример #6
0
def spawn_flag(a, i, cx, cy, r, rmin, freq, fallback=1):
    good = 0
    tries = 0
    while not good and tries < 30:
        # assume this will work
        good = 1
        # pick a random point
        x, y = circular_random(cx, cy, r + tries, rmin + tries)
        # and move off of any tiles
        x, y = mapdata.FindEmptyTileNear(a, x, y)
        # check if it's hitting another flag:
        for j in range(a.fg_wz_current):
            if i != j:
                n2, f2 = flagcore.GetFlags(a, j)
                if n2 == 1 and f2.state == asss.FI_ONMAP and \
                   f2.x == x and f2.y == y:
                    good = 0
        # and check for no-flag regions:
        if good:
            foundnoflags = []

            def check_region(r):
                if mapdata.RegionChunk(r, asss.RCT_NOFLAGS) is not None:
                    foundnoflags.append(1)

            mapdata.EnumContaining(a, x, y, check_region)
            if foundnoflags:
                good = 0
        # if we did hit another flag, bump up the radius so we don't get
        # stuck here.
        tries += 1

    if good:
        f = asss.flaginfo()
        f.state = asss.FI_ONMAP
        f.x, f.y = x, y
        f.freq = freq
        f.carrier = None
        flagcore.SetFlags(a, i, f)
    elif fallback:
        # we have one fallback option: centering it
        lm.LogA(asss.L_WARN, 'flagcore', a,
                ("failed to place a flag at (%d,%d)-%d, "
                 "falling back to center") % (cx, cy, r))
        sets = a.fg_wz_sets
        spawn_flag(a, i, sets.spawnx, sets.spawny, sets.spawnr, sets.spawnrmin,
                   freq, 0)
    else:
        # couldn't place in original location, and couldn't place in
        # center either. this is really bad.
        lm.LogA(asss.L_ERROR, 'flagcore', a,
                ("failed to place a flag at (%d,%d)-%d, "
                 "fallback disabled") % (cx, cy, r))
Пример #7
0
def spawn_flag(a, i, cx, cy, r, rmin, freq, fallback = 1):
  good = 0
  tries = 0
  while not good and tries < 30:
    # assume this will work
    good = 1
    # pick a random point
    x, y = circular_random(cx, cy, r + tries, rmin + tries)
    # and move off of any tiles
    x, y = mapdata.FindEmptyTileNear(a, x, y)
    # check if it's hitting another flag:
    for j in range(a.fg_wz_current):
      if i != j:
        n2, f2 = flagcore.GetFlags(a, j)
        if n2 == 1 and f2.state == asss.FI_ONMAP and \
           f2.x == x and f2.y == y:
          good = 0
    # and check for no-flag regions:
    if good:
      foundnoflags = []
      def check_region(r):
        if mapdata.RegionChunk(r, asss.RCT_NOFLAGS) is not None:
          foundnoflags.append(1)
      mapdata.EnumContaining(a, x, y, check_region)
      if foundnoflags:
        good = 0
    # if we did hit another flag, bump up the radius so we don't get
    # stuck here.
    tries += 1

  if good:
    f = asss.flaginfo()
    f.state = asss.FI_ONMAP
    f.x, f.y = x, y
    f.freq = freq
    f.carrier = None
    flagcore.SetFlags(a, i, f)
  elif fallback:
    # we have one fallback option: centering it
    lm.LogA(asss.L_WARN, 'flagcore', a,
        ("failed to place a flag at (%d,%d)-%d, "
         "falling back to center") % (cx, cy, r))
    sets = a.fg_wz_sets
    spawn_flag(a, i, sets.spawnx, sets.spawny, sets.spawnr, sets.spawnrmin, freq, 0)
  else:
    # couldn't place in original location, and couldn't place in
    # center either. this is really bad.
    lm.LogA(asss.L_ERROR, 'flagcore', a,
        ("failed to place a flag at (%d,%d)-%d, "
         "fallback disabled")% (cx, cy, r))
Пример #8
0
	def FlagTouch(me, a, p, fid):
		sets = a.fg_wz_sets
		if sets.carryflags == asss.CARRY_ALL:
			cancarry = MAXFLAGS
		else:
			cancarry = sets.carryflags - 1

		if p.flagscarried >= cancarry:
			return

		# assign him the flag
		f = asss.flaginfo()
		f.state = asss.FI_CARRIED
		f.carrier = p
		flagcore.SetFlags(a, fid, f)
Пример #9
0
    def FlagTouch(me, a, p, fid):
        sets = a.fg_wz_sets
        if sets.carryflags == asss.CARRY_ALL:
            cancarry = MAXFLAGS
        else:
            cancarry = sets.carryflags - 1

        if p.flagscarried >= cancarry:
            return

        # assign him the flag
        f = asss.flaginfo()
        f.state = asss.FI_CARRIED
        f.carrier = p
        flagcore.SetFlags(a, fid, f)
Пример #10
0
    def Init(me, a):
        # get settings
        a.fg_turf_fc = fc = mapdata.GetFlagCount(a)
        a.fg_turf_persist = cfg.GetInt(a.cfg, "Flag", "PersistentTurfOwners",
                                       1)

        # set up turf game
        flagcore.SetCarryMode(a, asss.CARRY_NONE)
        flagcore.ReserveFlags(a, fc)

        # set up initial flags
        f = asss.flaginfo()
        f.state = asss.FI_ONMAP
        f.freq = -1
        for i in xrange(fc):
            flagcore.SetFlags(a, i, f)