Добро пожаловать на форумы Боевого Народа (бывший форум Live.CNews.ru)!

ВАЖНЫЕ ТЕМЫ: FAQ по переезду и восстановлению учеток | Ошибки и глюки форума.
О проблемах с учетными записями писать СЮДА.
ищу baserape под сервер 1.5,win32 - Форумы Боевого Народа
IPB

Здравствуйте, гость ( Вход | Регистрация )

2 страниц V  < 1 2  
Ответить в данную темуНачать новую тему
ищу baserape под сервер 1.5,win32
сообщение 8.9.2012, 5:09
Сообщение #21





Группа:
Сообщений: 0
Регистрация: --
Пользователь №:



sorry can i ask which anti baserape script that works for punish attacker who use infantry and vehicle?

the second script just works for vehicle is that right?
the first script can work to vehicle and infantry?
Перейти в начало страницы
Вставить ник
+Цитировать сообщение
сообщение 8.9.2012, 6:05
Сообщение #22





Группа:
Сообщений: 0
Регистрация: --
Пользователь №:



i cant use the edit feature cry.gif it was said sorry bla bla.. so im gonna double post im sorry here.

i found a good anti baserape script
can someone found it's working?

Раскрывающийся текст
# Module: AntiBaseRape 2 for Battlefield 2 Server bf2.wildpark.net(closed server only for WildPark users).
# Author: orion.
# Tester: Skuuka (thx)
#
# Version 1.4
#
# Description:
# Server side only admin script.
#
# This script will punish players who kill enemy within the area of a safe base.
#
# Requirements:
# modmanager
#
# ATTENTION!!!
# You must add string
# def getnoVehicles(self): return host.ss_getParam('noVehicles')
# in file /python/bf2/GameLogic.py for class ServerSettings.
#
#
# Have fun
#

import bf2
import host
import mm_utils
from bf2.stats.constants import *
from bf2 import g_debug
import math
import time


# Set the version of your module here
__version__ = 1.4

# Set the required module versions here
__required_modules__ = {
'modmanager': 1.0
}

# Does this module support reload ( are all its reference closed on shutdown? )
__supports_reload__ = False

# Set the description of your module here
__description__ = "AntiBaseRape 2 v%s" % __version__


class fStt(object):
def __init__(self, player):
self.timedeath = 0
self.warning = 0
self.enterVeh = 0

class new_baserape_maps(object):
def __init__(self, map, num_cp, army):
if map == "daqing_oilfields":
if army == 1:
self.tch_x = [ {'x':-246, 'y':380.5, 'z':165, 'h':25, 'r':85}, {'x':-110, 'y':533, 'z':155, 'h':18, 'r':90} ] # PLA(NB, VPP)
else:
self.tch_x = [ {'x':346, 'y':-578, 'z':120, 'h':38, 'r':150} ] # USA(NB)
if map == "dalian_plant":
if army == 1:
self.tch_x = [ {'x':-707, 'y':-367, 'z':180, 'h':25, 'r':115}, {'x':-796, 'y':-125.5, 'z':180, 'h':25, 'r':30} ] # PLA(NB, VPP)
else:
self.tch_x = [ {'x':763, 'y':-13, 'z':155, 'h':35, 'r':50} ] # USA(NB)
if map == "gulf_of_oman":
if army == 1:
self.tch_x = [ {'x':310, 'y':240, 'z':24, 'h':25, 'r':50}, {'x':127.5, 'y':250, 'z':23, 'h':25, 'r':40} ] # MEC(NB, heli)
else:
self.tch_x = [ {'x':-677, 'y':-490, 'z':38, 'h':35, 'r':60} ] # USA(NB)
if map == "operation_clean_sweep":
if army == 1:
self.tch_x = [ {'x':-121, 'y':-555, 'z':31, 'h':8, 'r':16, 'point':'smallairstrip', 'owner':1, 'c':13}, {'x':703.5, 'y':83, 'z':29, 'h':15, 'r':25, 'point':'mecairfield', 'owner':1, 'c':13}, {'x':256.3, 'y':-397.8, 'z':37, 'h':15, 'r':9, 'point':'communicationcentral', 'owner':1, 'c':13} ] # MEC(VPP, VPP(base), heli)
else:
self.tch_x = [ {'x':-552, 'y':544, 'z':29, 'h':15, 'r':50}, {'x':-428, 'y':667.5, 'z':36, 'h':20, 'r':48}, {'x':-328, 'y':682, 'z':36, 'h':25, 'r':50} ] # USA(NB, VPP, VPP)
if map == "kubra_dam":
if army == 1:
self.tch_x = [ {'x':-496.5, 'y':-730, 'z':66, 'h':10, 'r':40, 'point':'intake', 'owner':1, 'c':13}, {'x':-458.5, 'y':-584, 'z':65, 'h':25, 'r':25, 'point':'intake', 'owner':1, 'c':13} ] # MEC(VPP, heli)
else:
self.tch_x = [ {'x':158.5, 'y':125.5, 'z':60, 'h':20, 'r':65}, {'x':519, 'y':332.5, 'z':75, 'h':30, 'r':85} ] # USA(NB, VPP)
if map == "wake_island_2007":
if army == 1:
self.tch_x = [ {'x':408, 'y':-374, 'z':100, 'h':10, 'r':15, 'point':'airfield', 'owner':1, 'c':9}, {'x':373, 'y':-350, 'z':100, 'h':15, 'r':15, 'point':'airfield', 'owner':1, 'c':9} ] # PLA(VPP, heli)
else:
self.tch_x = [ {'x':-745.5, 'y':633.5, 'z':98, 'h':30, 'r':55} ] # USA(NB)
if map == "zatar_wetlands":
if army == 1:
self.tch_x = [ {'x':727, 'y':-401, 'z':60, 'h':17, 'r':75}, {'x':795, 'y':-510, 'z':60, 'h':25, 'r':45} ] # MEC(NB, VPP)
else:
if num_cp == 7:
self.tch_x = [ {'x':-772, 'y':102, 'z':41, 'h':20, 'r':80}, {'x':-849, 'y':153.5, 'z':38, 'h':25, 'r':40} ] # USA(NB, NB(VPP))
else:
self.tch_x = [ {'x':-386, 'y':921, 'z':48, 'h':25, 'r':60}, {'x':-565, 'y':482, 'z':30, 'h':15, 'r':85} ] # USA(NB(VPP), NB)
if map == "fushe_pass":
if army == 1:
if num_cp == 6:
self.tch_x = [ {'x':-531.5, 'y':231.7, 'z':90, 'h':30, 'r':70} ] # PLA(NB)
else:
self.tch_x = [ {'x':-668, 'y':-493.8, 'z':115, 'h':40, 'r':130} ] # PLA(NB)
else:
if num_cp == 6:
self.tch_x = [ {'x':302, 'y':-203, 'z':80, 'h':30, 'r':60} ] # USA(NB)
else:
self.tch_x = [ {'x':608.5, 'y':576.8, 'z':85, 'h':25, 'r':80}, {'x':734.5, 'y':712, 'z':87, 'h':35, 'r':65} ] # USA(NB, VPP)
if map == "dragon_valley":
if army == 1:
if num_cp == 6:
self.tch_x = [ {'x':92.5, 'y':-679, 'z':100, 'h':25, 'r':30, 'point':'refinery', 'owner':1, 'c':13} ] # PLA(Heli)
else:
self.tch_x = [ {'x':92.5, 'y':-679, 'z':100, 'h':25, 'r':30, 'point':'refinery', 'owner':1, 'c':13}, {'x':185.5, 'y':-647, 'z':100, 'h':20, 'r':35, 'point':'refinery', 'owner':1, 'c':13} ] # PLA(Heli, VPP)
else:
if num_cp == 6:
self.tch_x = [ {'x':116, 'y':314, 'z':51, 'h':25, 'r':40} ] # USA(NB)
else:
self.tch_x = [ {'x':338.5, 'y':846, 'z':67, 'h':30, 'r':55} ] # USA(NB)
if map == "highway_tampa":
if army == 1:
self.tch_x = [ {'x':-493, 'y':636.5, 'z':25, 'h':25, 'r':105} ] # MEC(NB)
else:
self.tch_x = [ {'x':608, 'y':-526, 'z':25, 'h':15, 'r':50},{'x':706, 'y':-466.5, 'z':26, 'h':25, 'r':50} ] # USA(NB, VPP)
if map == "taraba_quarry":
if army == 1:
if num_cp == 5:
self.tch_x = [ {'x':18.5, 'y':186.4, 'z':120, 'h':25, 'r':35} ] # MEC(NB)
else:
self.tch_x = [ {'x':-489, 'y':-553, 'z':155, 'h':25, 'r':70}, {'x':-645.5, 'y':-525, 'z':160, 'h':20, 'r':50} ] # MEC(NB, VPP)
else:
if num_cp == 7:
self.tch_x = [ {'x':427, 'y':-461.5, 'z':155, 'h':20, 'r':60}, {'x':575.5, 'y':-420, 'z':160, 'h':20, 'r':45} ] # EURO(NB, VPP)
if map == "operationsmokescreen":
if army == 1:
self.tch_x = [ {'x':72.5, 'y':-522, 'z':96, 'h':15, 'r':60}, {'x':108, 'y':-629, 'z':87, 'h':30, 'r':70} ] # MEC(NB, VPP)
else:
self.tch_x = [ {'x':7, 'y':430.5, 'z':96, 'h':15, 'r':55}, {'x':87, 'y':528.5, 'z':97, 'h':30, 'r':80} ] # EURO(NB, VPP)
if map == "road_to_jalalabad":
if army == 2:
self.tch_x = [ {'x':-205.4, 'y':7.7, 'z':40, 'h':15, 'r':45} ] # USA(NB)
if map == "sharqi_peninsula":
if army == 1:
if num_cp == 4:
self.tch_x = [ {'x':-316.3, 'y':-226.2, 'z':78, 'h':6, 'r':25} ] # MEC(NB)
else:
self.tch_x = [ {'x':-647, 'y':205, 'z':90, 'h':15, 'r':27}, {'x':-605, 'y':-201, 'z':90, 'h':15, 'r':35}, {'x':-288.5, 'y':-597, 'z':70, 'h':15, 'r':25}, {'x':-247.5, 'y':-585, 'z':75, 'h':20, 'r':18} ] # MEC(NB, NB, NB, Heli)
else:
if num_cp > 4:
self.tch_x = [ {'x':-98.25, 'y':-144.25, 'z':128, 'h':15, 'r':15, 'point':'tvstation', 'owner':2, 'c':13} ] # USA(Heli)
if map == "strike_at_karkand":
if army == 2:
self.tch_x = [ {'x':-160, 'y':-282, 'z':159, 'h':10, 'r':40} ] # USA(NB)
if map == "operation_blue_pearl":
if num_cp > 4:
if army == 2:
self.tch_x = [ {'x':282, 'y':-123, 'z':15, 'h':20, 'r':58} ] # USA(island)
if map == "midnight_sun":
if num_cp > 4:
if army == 2:
self.tch_x = [ {'x':533, 'y':-40, 'z':110, 'h':25, 'r':65}, {'x':607, 'y':61, 'z':110, 'h':25, 'r':75} ] # USA()
else:
self.tch_x = [ {'x':-735, 'y':-382, 'z':96, 'h':20, 'r':75}, {'x':-664, 'y':-346, 'z':103, 'h':20, 'r':82} ] # PLA()
if map == "operationharvest":
if army == 2:
if num_cp == 5:
self.tch_x = [ {'x':471.7, 'y':436, 'z':30, 'h':20, 'r':59} ] # USA(NB)
if num_cp == 8:
self.tch_x = [ {'x':-405, 'y':-561, 'z':32, 'h':25, 'r':47}, {'x':-455, 'y':-495, 'z':28, 'h':25, 'r':51} ] # USA(NB, heli)
if num_cp == 9:
self.tch_x = [ {'x':-405, 'y':-561, 'z':32, 'h':25, 'r':47}, {'x':-442, 'y':-483, 'z':28, 'h':25, 'r':42}, {'x':340, 'y':-486, 'z':48, 'h':25, 'r':31} ] # USA(NB, heli)
else:
if num_cp == 8:
self.tch_x = [ {'x':245, 'y':678, 'z':35, 'h':25, 'r':42}, {'x':215, 'y':560, 'z':28, 'h':25, 'r':48} ] # MEC(heli,NB)
if num_cp == 9:
self.tch_x = [ {'x':245, 'y':678, 'z':35, 'h':25, 'r':42} ] # MEC(heli)
if map == "operationroadrage":
if army == 2:
if num_cp == 5:
self.tch_x = [ {'x':329, 'y':127.5, 'z':50, 'h':15, 'r':57} ] # USA()
if num_cp == 7:
self.tch_x = [ {'x':-130, 'y':818, 'z':50, 'h':20, 'r':47}, {'x':45, 'y':808, 'z':45, 'h':20, 'r':35} ] # USA()
else:
if num_cp == 5:
self.tch_x = [ {'x':-169, 'y':-188, 'z':40, 'h':20, 'r':62} ] # MEC()
if num_cp == 7:
self.tch_x = [ {'x':32, 'y':-738, 'z':45, 'h':20, 'r':67}, {'x':-148.5, 'y':-738, 'z':45, 'h':20, 'r':43} ] # MEC(heli,NB)

class old_baserape_maps(object):
def __init__(self, map, army):
self.r = 0
if map == "greatwall" and army==1:
self.r = 50
if map == "greatwall" and army==2:
self.r = 30
if map == "jibbel_city" and army==2:
self.r = 30
if map == "bocage_2005" and army==1:
self.r = 65
if map == "bocage_2005" and army==2:
self.r = 40
if map == "strike_at_karkand_2" and army==2:
self.r = 40
if map == "berlin" and army==2:
self.r = 18
if map == "heliwar" and army==2:
self.r = 125
if map == "heliwar" and army==1:
self.r = 115
if map == "rising_city" and army==2:
self.r = 30
if map == "vulcan_island" and army==2:
self.r = 35


check_new_maps = { "daqing_oilfields":[7,9], "gulf_of_oman":[7,9], "dalian_plant":[6,8], "operation_clean_sweep":[4,6,8], "kubra_dam":[8,9],
"wake_island_2007":[6],"zatar_wetlands":[7,9],"dragon_valley":[6,11],"fushe_pass":[6,10],"highway_tampa":[6,8],"taraba_quarry":[5,7],
"operationsmokescreen":[7],"road_to_jalalabad":[7,8],"sharqi_peninsula":[4,8,9], "strike_at_karkand":[7,9],"operation_blue_pearl":[7,8],
"midnight_sun":[6,8],"operationharvest":[5,8,9],"operationroadrage":[5,7]
}

check_old_maps = ["greatwall","jibbel_city","stream","bocage_2005","strike_at_karkand_2","berlin","cp_abadan","vulcan_island","rising_city", "heliwar"]

check_noVeh_maps = ["greatwall","sharqi_peninsula","road_to_jalalabad","jibbel_city","berlin"]

mapName = ""
noVehicles = 0
num_cp = 0


class new_baserape2( object ):
def __init__( self, modManager ):
self.mm = modManager
self.__state = 0

def onEnterVehicle( self, player, vehicle, freeSoldier):
plVehicle = player.getVehicle()
pl_Vehicle = bf2.objectManager.getRootParent(plVehicle)
if ((getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_HELICOPTER) or (getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_AVIATOR)):
player.faa.enterVeh = int(time.time())


def onExitVehicle(self, player, vehicle):
if not player.isAlive():
player.faa.enterVeh = 0
return

if player.faa.enterVeh > 0:
plVehicle = player.getVehicle()
pl_Vehicle = bf2.objectManager.getRootParent(plVehicle)
if (getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_SOLDIER):
player.faa.enterVeh = 0


def onPlayerKilled(self, victim, attacker, weapon, assists, object):
if (attacker == None) or (attacker.getTeam() == victim.getTeam()) or (victim == None) or (weapon == None):
return

if int(noVehicles) == 1:
if mapName not in check_noVeh_maps:
return

if (mapName == "sharqi_peninsula") and (victim.getTeam() == 2):
return
else:
if(victim.faa.enterVeh>0):
delta = int(time.time()) - victim.faa.enterVeh
if int(delta) > 20:
return

victimVehicle = victim.getVehicle()
vic_Vehicle = bf2.objectManager.getRootParent(victimVehicle)
attackerVehicle = attacker.getVehicle()
att_Vehicle = bf2.objectManager.getRootParent(attackerVehicle)

attackerVehicle = bf2.objectManager.getRootParent(weapon)
if (attackerVehicle.isPlayerControlObject and attackerVehicle.getIsRemoteControlled()): # AOIE AOOEIIAOEN, OI DOIЃ~AONAI
pass
else: # AOIE OIIAAO EIE Ѓ~ AA OI Ѓ~UEIA
if (getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_SOLDIER) or (getVehicleType(vic_Vehicle.templateName) == VEHICLE_TYPE_AIRDEFENSE):
return

if check_new_maps.has_key(mapName) and num_cp in check_new_maps[mapName]:
self.checkForSafeBase(victim, attacker, mapName, num_cp)

if mapName in check_old_maps:
tx = old_baserape_maps(mapName, victim.getTeam())
if tx.r > 0:
victimVehicle = victim.getVehicle()
controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
for cp in controlPoints:
if cp.cp_getParam('unableToChangeTeam') != 0 and cp.cp_getParam('team') != attacker.getTeam():
distanceTo = self.getVectorDistance(victimVehicle.getPosition(), cp.getPosition())
if float(distanceTo) < tx.r:
mm_utils.msg_server("Ѓ˜3" + attacker.getName() + " - is punished for violating of the no kill rules within Ѓ˜C1001safe base areaЃ˜C1001")
self.mm.info("BASERAPE! att=" + str(attacker.getName()) + " vic=" + str(victim.getName()) +" Radius=" + str(tx.r) + " Distance=" + str(distanceTo) )
self.justify(attacker, victim)


def checkForSafeBase(self, victim, attacker, mapName, num_cp):
victimVehicle = victim.getVehicle()
coor_X = victimVehicle.getPosition()[0]
coor_Y = victimVehicle.getPosition()[2]
coor_Z = victimVehicle.getPosition()[1]

tx = new_baserape_maps(mapName, num_cp, victim.getTeam())
for cp in tx.tch_x:
if (float(coor_Z) > cp['z']) and (float(coor_Z) < (cp['z'] + cp['h'])):
dist = math.sqrt( (float(coor_X) - float(cp['x']))**2 + (float(coor_Y) - float(cp['y']))**2 )
if float(dist) < cp['r']:
if cp.has_key('point'):
attackerVehicle = attacker.getVehicle()
att_Vehicle = bf2.objectManager.getRootParent(attackerVehicle)
if ((getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_ARMOR) or (getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_TRANSPORT)):
return

for obj in bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint'):
namepoint = obj.templateName.lower()[cp['c']:]
if (namepoint == cp['point']):
ownerteam = int(obj.cp_getParam('team'))
if (ownerteam != cp['owner']):
return

mm_utils.msg_server("Ѓ˜3" + attacker.getName() + " - is punished for violating of the no kill rules within Ѓ˜C1001safe base areaЃ˜C1001")
self.mm.info("BASERAPE! att=" + str(attacker.getName()) + " vic=" + str(victim.getName()) +" Radius=" + str(cp['r']) + " Distance=" + str(dist) )
self.justify(attacker, victim)


def justify(self, attacker, victim):
victim.timedeath = int(time.time())
victim.score.deaths += -1
attacker.score.kills += -1
attacker.score.score += -4
# attacker.score.TKs += 1
attacker.faa.warning += 1
if attacker.isAlive():
vehicle = attacker.getVehicle()
rootVehicle = getRootParent(vehicle)
if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
rootVehicle.setDamage(0)
else:
rootVehicle.setDamage(1)
if attacker.isCommander():
team = attacker.getTeam()
enemyteam = 3 - team
attacker.setTeam(enemyteam)
attacker.setTeam(team)
if attacker.faa.warning > 3:
host.rcon_invoke('game.sayall "Player %s kicked for violating of the no kill rules within safe base area"' % (attacker.getName() ) )
host.rcon_invoke('pb_sv_kick "%s" %i "You kicked for violating of the no kill rules within safe base area"' % (attacker.getName(), 15) )


def getVectorDistance(self, pos1, pos2):
diffVec = [0.0, 0.0, 0.0]
diffVec[0] = math.fabs(pos1[0] - pos2[0])
diffVec[1] = math.fabs(pos1[1] - pos2[1])
diffVec[2] = math.fabs(pos1[2] - pos2[2])

return math.sqrt(diffVec[0] * diffVec[0] + diffVec[1] * diffVec[1] + diffVec[2] * diffVec[2])


def onGameStatusChanged( self, status ):
if status == bf2.GameStatus.Playing:
global num_cp, mapName, noVehicles
controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
num_cp = len(controlPoints)
mapName = bf2.gameLogic.getMapName()
noVehicles = int(bf2.serverSettings.getnoVehicles())
for player in bf2.playerManager.getPlayers():
player.faa.timedeath = 0
player.faa.warning = 0
player.faa.enterVeh = 0


def onPlayerRevived(self, attacker, victim):
if int(attacker.timedeath) > 0:
timex = int(time.time()) - int(attacker.timedeath)
if int(timex) < 16:
attacker.score.deaths += 1
attacker.timedeath = 0


def onPlayerConnect(self, player):
player.faa = fStt(player)


def init( self ):
host.registerGameStatusHandler( self.onGameStatusChanged )

if 0 == self.__state:
host.registerHandler('PlayerConnect', self.onPlayerConnect, 1 )
host.registerHandler('PlayerKilled', self.onPlayerKilled )
host.registerHandler('PlayerRevived', self.onPlayerRevived )
host.registerHandler('EnterVehicle', self.onEnterVehicle )
host.registerHandler('ExitVehicle', self.onExitVehicle )

self.__state = 1


def mm_load( modManager ):
"""Creates and returns your object."""
return new_baserape2( modManager )


and here is my mmmanager.log
Раскрывающийся текст

[2012-09-08 09:53:44] Info: Module 'mm_logger' initialised
[2012-09-08 09:53:44] Info: Creating Multiplay, ModManager v2.0 for Battlefield 2 (www.multiplay.co.uk)
[2012-09-08 09:53:44] Info: Starting ModManager Rcon v5.8 on 0.0.0.0:4711
[2012-09-08 09:53:44] Info: Rcon command handler 'login' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'logout' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'users' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'kick' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'ban' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'banby' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'banlist' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'unban' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'clearbans' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'list' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'profileid' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'profileids' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'listlocked' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'maplist' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'map' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'exec' registered
[2012-09-08 09:53:44] Info: Rcon command handler 'help' registered
[2012-09-08 09:53:44] Info: Rcon command handler '?' registered (alias)
[2012-09-08 09:53:44] Info: ModManager Rcon started
[2012-09-08 09:53:44] Info: Module 'mm_rcon' v5.8 loaded
[2012-09-08 09:53:44] Info: Module 'mm_rcon' initialised
[2012-09-08 09:53:44] Info: Module 'mm_banmanager' v3.6 loaded
[2012-09-08 09:53:44] Info: Rcon command handler 'bm' registered
[2012-09-08 09:53:44] Info: Module 'mm_banmanager' initialised
[2012-09-08 09:53:44] Info: Module 'mm_tk_punish' v2.2 loaded
[2012-09-08 09:53:44] Warn: Legacy module 'mm_baserape' v1.4 detected assuming 'Battlefield 2' support
[2012-09-08 09:53:44] Info: Module 'mm_baserape' v1.4 loaded
[2012-09-08 09:53:44] Info: Module 'mm_kicker' v2.5 loaded
[2012-09-08 09:53:44] Info: Module 'mm_announcer' v1.7 loaded
[2012-09-08 09:53:44] Info: Module 'mm_bf2cc' v6.8 loaded
[2012-09-08 09:53:44] Info: Module 'mm_autobalance' v2.3 loaded
[2012-09-08 09:53:44] Info: Loaded 6 additional modules
[2012-09-08 09:53:44] Info: Rcon command handler 'mm' registered
[2012-09-08 09:53:44] Info: Module 'mm_tk_punish' initialised
[2012-09-08 09:53:44] Info: Module 'mm_baserape' initialised
[2012-09-08 09:53:44] Info: Rcon command handler 'kicker' registered
[2012-09-08 09:53:44] Info: Module 'mm_kicker' initialised
[2012-09-08 09:53:44] Info: Rcon command handler 'announcer' registered
[2012-09-08 09:53:44] Info: Module 'mm_announcer' initialised
[2012-09-08 09:53:44] Info: Rcon command handler 'bf2cc' registered
[2012-09-08 09:53:44] Info: Module 'mm_bf2cc' initialised
[2012-09-08 09:53:44] Info: Module 'mm_autobalance' initialised
[2012-09-08 09:53:44] Info: Initialised 6 modules
[2012-09-08 09:53:53] Info: Validating maplist...
[2012-09-08 09:53:53] Info: No maplist changes required


it was said
[2012-09-08 09:53:44] Warn: Legacy module 'mm_baserape' v1.4 detected assuming 'Battlefield 2' support
warn? is it works i couldnt test it for now.

Сообщение отредактировал seanman - 8.9.2012, 6:24
Перейти в начало страницы
Вставить ник
+Цитировать сообщение
сообщение 8.9.2012, 9:37
Сообщение #23





Группа:
Сообщений: 0
Регистрация: --
Пользователь №:



mm_baserape_v3.py
Описание
Запрещено убивать противника артиллерией и любой техникой, кроме противника находящегося
в противовоздушной технике(стационарной или передвижной), на НТ, вертолетных площадках,
самолетных ангарах и просто точек респа самолетов, если хотя бы у одной стороны на карте есть НТ.
Т.е. не работает, к примеру, на daqing 16x, dragon16x на вертолетных площадках,
но работает на Operation Clean Sweep 16x в ангаре у меков.

Дополнительно
-n/a-

Параметры
-n/a-

p.s: скприт настроин на конкретно точки(радиус/зоны), если надумайти эти точки изменить то сперва подумайти сможите или нет, размижения радиуса можно посмотреть чере bf2editer, там будут эти точки показыватся, для этого вам нужно будит загрузить карту для редактирования...
Скрипт
Код
# Module: AntiBaseRape 2 for Battlefield 2 Server bf2.wildpark.net(closed server only for WildPark users).
# Author: orion.
# Tester: Skuuka (thx)
#
# * Описание:
# Запрещено убивать противника артиллерией и любой техникой, кроме противника находящегося
# в противовоздушной технике(стационарной или передвижной), на НТ, вертолетных площадках,
# самолетных ангарах и просто точек респа самолетов, если хотя бы у одной стороны на карте есть НТ.
# Т.е. не работает, к примеру, на daqing 16x, dragon16x на вертолетных площадках,
# но работает на Operation Clean Sweep 16x в ангаре у меков.
#
# * Важные моменты:
#
# - работает в режиме с техникой и без
#
# - возможны разные правила для карт 16x, 32x, 64x.
#
# - элементарно добавляются карты для "классического" определения атаки на НТ(радиус от НТ),
# для способа привязки к координатам тоже не сложно но уже надо приложить усилия.
#
# - скрипт покрывает точки респа самолетов и вертолетов также на картах 1. Op. Clean Sweep(mec),
# 2. Dragon Valley(pla), 3. Sharqi Peninsula(mec), 4. Wake Island 2007(pla), у сторон(указаны в скобках)
# которых нет НТ, но работает только в том случае если ближайшие точки 1. Small Airstrip и
# Communication central, 2. Refinery, 3. Intake, 4. TV Station не заняты противником!
#
# - запрет убивать артиллерией, но разрешено пехотинцем
#
# - скрипт не действует, если враг находится в Air Defense.
#
# - скрипт не действует, если самолет/вертолет вернулся в зону его обычного действия, точнее не действует по прошествии 20 секунд(тут 1 косячок есть, если вертолетчик пересаживается с пилота на стрелка, то будет действовать, ситуация довольно редкая - влом фиксить )
#
# - есть также карты из EF и некоторые не стандартные.
#
# Version 1.4
#
# Description:
#   Server side only admin script
#
#   This script will punish players who kill enemy within the area of a safe base.
#
# Requirements:
#   modmanager
#
# ATTENTION!!!
#   You must add string
#          def getnoVehicles(self): return host.ss_getParam('noVehicles')
#   in file /python/bf2/GameLogic.py for class ServerSettings.
#
#
# Please play fair.
#



import bf2
import host
import mm_utils
from bf2.stats.constants import *
from bf2 import g_debug
import math
import time


# Set the version of your module here
__version__ = 1.4

# Set the required module versions here
__required_modules__ = {
    'modmanager': 1.0
}

# Does this module support reload ( are all its reference closed on shutdown? )
__supports_reload__ = False

# Set the description of your module here
__description__ = "AntiBaseRape 2 v%s" % __version__


class fStt(object):
    def __init__(self, player):
        self.timedeath = 0
        self.warning = 0
    self.enterVeh = 0

class new_baserape_maps(object):
    def __init__(self, map, num_cp, army):
    if map == "daqing_oilfields":
        if army == 1:
        self.tch_x = [ {'x':-246, 'y':380.5, 'z':165, 'h':25, 'r':85}, {'x':-110, 'y':533, 'z':155, 'h':18, 'r':90} ]        # PLA(NB, VPP)
        else:
        self.tch_x = [ {'x':346, 'y':-578, 'z':120, 'h':38, 'r':150} ]                                # USA(NB)
    if map == "dalian_plant":
        if army == 1:
        self.tch_x = [ {'x':-707, 'y':-367, 'z':180, 'h':25, 'r':115}, {'x':-796, 'y':-125.5, 'z':180, 'h':25, 'r':30} ]    # PLA(NB, VPP)
        else:
        self.tch_x = [ {'x':763, 'y':-13, 'z':155, 'h':35, 'r':50} ]                                # USA(NB)
    if map == "gulf_of_oman":
        if army == 1:
        self.tch_x = [ {'x':310, 'y':240, 'z':24, 'h':25, 'r':50}, {'x':127.5, 'y':250, 'z':23, 'h':25, 'r':40} ]        # MEC(NB, heli)
        else:
        self.tch_x = [ {'x':-677, 'y':-490, 'z':38, 'h':35, 'r':60} ]                                # USA(NB)
    if map == "operation_clean_sweep":
        if army == 1:
        self.tch_x = [ {'x':-121, 'y':-555, 'z':31, 'h':8, 'r':16, 'point':'smallairstrip', 'owner':1, 'c':13}, {'x':703.5, 'y':83, 'z':29, 'h':15, 'r':25, 'point':'mecairfield', 'owner':1, 'c':13}, {'x':256.3, 'y':-397.8, 'z':37, 'h':15, 'r':9, 'point':'communicationcentral', 'owner':1, 'c':13} ]        # MEC(VPP, VPP(base), heli)
        else:
        self.tch_x = [ {'x':-552, 'y':544, 'z':29, 'h':15, 'r':50}, {'x':-428, 'y':667.5, 'z':36, 'h':20, 'r':48}, {'x':-328, 'y':682, 'z':36, 'h':25, 'r':50} ] # USA(NB, VPP, VPP)
    if map == "kubra_dam":
        if army == 1:
        self.tch_x = [ {'x':-496.5, 'y':-730, 'z':66, 'h':10, 'r':40, 'point':'intake', 'owner':1, 'c':13}, {'x':-458.5, 'y':-584, 'z':65, 'h':25, 'r':25, 'point':'intake', 'owner':1, 'c':13} ]        # MEC(VPP, heli)
        else:
        self.tch_x = [ {'x':158.5, 'y':125.5, 'z':60, 'h':20, 'r':65}, {'x':519, 'y':332.5, 'z':75, 'h':30, 'r':85} ]        # USA(NB, VPP)
    if map == "wake_island_2007":
        if army == 1:
        self.tch_x = [ {'x':408, 'y':-374, 'z':100, 'h':10, 'r':15, 'point':'airfield', 'owner':1, 'c':9}, {'x':373, 'y':-350, 'z':100, 'h':15, 'r':15, 'point':'airfield', 'owner':1, 'c':9} ]        # PLA(VPP, heli)
        else:
        self.tch_x = [ {'x':-745.5, 'y':633.5, 'z':98, 'h':30, 'r':55} ]                            # USA(NB)
    if map == "zatar_wetlands":
        if army == 1:
        self.tch_x = [ {'x':727, 'y':-401, 'z':60, 'h':17, 'r':75}, {'x':795, 'y':-510, 'z':60, 'h':25, 'r':45} ]        # MEC(NB, VPP)
        else:
        if num_cp == 7:
            self.tch_x = [ {'x':-772, 'y':102, 'z':41, 'h':20, 'r':80}, {'x':-849, 'y':153.5, 'z':38, 'h':25, 'r':40} ]        # USA(NB, NB(VPP))
        else:
            self.tch_x = [ {'x':-386, 'y':921, 'z':48, 'h':25, 'r':60}, {'x':-565, 'y':482, 'z':30, 'h':15, 'r':85} ]        # USA(NB(VPP), NB)
    if map == "fushe_pass":
        if army == 1:
        if num_cp == 6:
            self.tch_x = [ {'x':-531.5, 'y':231.7, 'z':90, 'h':30, 'r':70} ]                            # PLA(NB)
        else:
            self.tch_x = [ {'x':-668, 'y':-493.8, 'z':115, 'h':40, 'r':130} ]                            # PLA(NB)
        else:
        if num_cp == 6:
            self.tch_x = [ {'x':302, 'y':-203, 'z':80, 'h':30, 'r':60} ]                            # USA(NB)
        else:
            self.tch_x = [ {'x':608.5, 'y':576.8, 'z':85, 'h':25, 'r':80}, {'x':734.5, 'y':712, 'z':87, 'h':35, 'r':65} ]    # USA(NB, VPP)
    if map == "dragon_valley":
        if army == 1:
        if num_cp == 6:
            self.tch_x = [ {'x':92.5, 'y':-679, 'z':100, 'h':25, 'r':30, 'point':'refinery', 'owner':1, 'c':13} ]        # PLA(Heli)
        else:
            self.tch_x = [ {'x':92.5, 'y':-679, 'z':100, 'h':25, 'r':30, 'point':'refinery', 'owner':1, 'c':13}, {'x':185.5, 'y':-647, 'z':100, 'h':20, 'r':35, 'point':'refinery', 'owner':1, 'c':13} ]    # PLA(Heli, VPP)
        else:
        if num_cp == 6:
            self.tch_x = [ {'x':116, 'y':314, 'z':51, 'h':25, 'r':40} ]                                # USA(NB)
        else:
            self.tch_x = [ {'x':338.5, 'y':846, 'z':67, 'h':30, 'r':55} ]                            # USA(NB)
    if map == "highway_tampa":
        if army == 1:
        self.tch_x = [ {'x':-493, 'y':636.5, 'z':25, 'h':25, 'r':105} ]                                # MEC(NB)
        else:
        self.tch_x = [ {'x':608, 'y':-526, 'z':25, 'h':15, 'r':50},{'x':706, 'y':-466.5, 'z':26, 'h':25, 'r':50} ]        # USA(NB, VPP)
    if map == "taraba_quarry":
        if army == 1:
        if num_cp == 5:
            self.tch_x = [ {'x':18.5, 'y':186.4, 'z':120, 'h':25, 'r':35} ]                            # MEC(NB)
        else:
            self.tch_x = [ {'x':-489, 'y':-553, 'z':155, 'h':25, 'r':70}, {'x':-645.5, 'y':-525, 'z':160, 'h':20, 'r':50} ]    # MEC(NB, VPP)
          else:
        if num_cp == 7:
            self.tch_x = [ {'x':427, 'y':-461.5, 'z':155, 'h':20, 'r':60}, {'x':575.5, 'y':-420, 'z':160, 'h':20, 'r':45} ]    # EURO(NB, VPP)
    if map == "operationsmokescreen":
        if army == 1:
        self.tch_x = [ {'x':72.5, 'y':-522, 'z':96, 'h':15, 'r':60}, {'x':108, 'y':-629, 'z':87, 'h':30, 'r':70} ]        # MEC(NB, VPP)
        else:
        self.tch_x = [ {'x':7, 'y':430.5, 'z':96, 'h':15, 'r':55}, {'x':87, 'y':528.5, 'z':97, 'h':30, 'r':80} ]        # EURO(NB, VPP)
    if map == "road_to_jalalabad":
        if army == 2:
        self.tch_x = [ {'x':-205.4, 'y':7.7, 'z':40, 'h':15, 'r':45} ]                                # USA(NB)
    if map == "sharqi_peninsula":
        if army == 1:
        if num_cp == 4:
            self.tch_x = [ {'x':-316.3, 'y':-226.2, 'z':78, 'h':6, 'r':25} ]                            # MEC(NB)
        else:
            self.tch_x = [ {'x':-647, 'y':205, 'z':90, 'h':15, 'r':27}, {'x':-605, 'y':-201, 'z':90, 'h':15, 'r':35}, {'x':-288.5, 'y':-597, 'z':70, 'h':15, 'r':25}, {'x':-247.5, 'y':-585, 'z':75, 'h':20, 'r':18} ]    # MEC(NB, NB, NB, Heli)
        else:
        if num_cp > 4:
            self.tch_x = [ {'x':-98.25, 'y':-144.25, 'z':128, 'h':15, 'r':15, 'point':'tvstation', 'owner':2, 'c':13} ]        # USA(Heli)
    if map == "strike_at_karkand":
        if army == 2:
        self.tch_x = [ {'x':-160, 'y':-282, 'z':159, 'h':10, 'r':40} ]                                # USA(NB)


class old_baserape_maps(object):
    def __init__(self, map, army):
    self.r = 0
    if map == "greatwall" and army==1:
        self.r = 50
    if map == "greatwall" and army==2:
        self.r = 30
    if map == "jibbel_city" and army==2:
        self.r = 30
    if map == "bocage_2005" and army==1:
        self.r = 65
    if map == "bocage_2005" and army==2:
        self.r = 40
    if map == "strike_at_karkand_2" and army==2:
        self.r = 40
    if map == "berlin" and army==2:
        self.r = 18
    if map == "heliwar" and army==2:
        self.r = 125
    if map == "heliwar" and army==1:
        self.r = 115
    if map == "cp_abadan" and army==2:
        self.r = 20
    if map == "rising_city" and army==2:
        self.r = 30
    if map == "vulcan_island" and army==2:
        self.r = 35


check_new_maps = { "daqing_oilfields":[7,9], "gulf_of_oman":[7,9], "dalian_plant":[6,8], "operation_clean_sweep":[4,6,8], "kubra_dam":[8,9],
        "wake_island_2007":[6],"zatar_wetlands":[7,9],"dragon_valley":[6,11],"fushe_pass":[6,10],"highway_tampa":[6,8],"taraba_quarry":[5,7],
        "operationsmokescreen":[7],"road_to_jalalabad":[7,8],"sharqi_peninsula":[4,8,9], "strike_at_karkand":[7,9]
        }

check_old_maps = ["greatwall","jibbel_city","stream","bocage_2005","strike_at_karkand_2","berlin","cp_abadan","vulcan_island","rising_city", "heliwar"]

check_noVeh_maps = ["greatwall","sharqi_peninsula","road_to_jalalabad","jibbel_city","berlin","cp_abadan"]

mapName = ""
noVehicles = 0
num_cp = 0


class new_baserape2( object ):
    def __init__( self, modManager ):
        self.mm = modManager
        self.__state = 0

        def onEnterVehicle( self, player, vehicle, freeSoldier):
        plVehicle = player.getVehicle()
        pl_Vehicle = bf2.objectManager.getRootParent(plVehicle)
            if ((getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_HELICOPTER) or (getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_AVIATOR)):
            player.faa.enterVeh = int(time.time())


    def onExitVehicle(self, player, vehicle):
        if not player.isAlive():
            player.faa.enterVeh = 0
        return

            if player.faa.enterVeh > 0:
            plVehicle = player.getVehicle()
        pl_Vehicle = bf2.objectManager.getRootParent(plVehicle)
                if (getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_SOLDIER):
                    player.faa.enterVeh = 0


    def onPlayerKilled(self, victim, attacker, weapon, assists, object):
        if (attacker == None) or (attacker.getTeam() == victim.getTeam()) or (victim == None) or (weapon == None):
        return

        if int(noVehicles) == 1:                                        
        if mapName not in check_noVeh_maps:                                
            return

        if (mapName == "sharqi_peninsula") and (victim.getTeam() == 2):                    
            return
        else:
        if(victim.faa.enterVeh>0):
                delta = int(time.time()) - victim.faa.enterVeh
            if int(delta) > 20:
            return

        victimVehicle = victim.getVehicle()                            
        vic_Vehicle = bf2.objectManager.getRootParent(victimVehicle)
            attackerVehicle = attacker.getVehicle()
        att_Vehicle = bf2.objectManager.getRootParent(attackerVehicle)

            attackerVehicle = bf2.objectManager.getRootParent(weapon)
        if (attackerVehicle.isPlayerControlObject and attackerVehicle.getIsRemoteControlled()):        # ЕУМЙ БТФЙММЕТЙС, ФП РТПЧЕТСЕН
            pass
        else:                                                # ЕУМЙ УПМДБФ ЙМЙ Ч AA ФП ЧЩИПД
            if (getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_SOLDIER) or (getVehicleType(vic_Vehicle.templateName) == VEHICLE_TYPE_AIRDEFENSE):
            return

        if check_new_maps.has_key(mapName) and num_cp in check_new_maps[mapName]:
        self.checkForSafeBase(victim, attacker, mapName, num_cp)

        if mapName in check_old_maps:
        tx = old_baserape_maps(mapName, victim.getTeam())
        if tx.r > 0:
            victimVehicle = victim.getVehicle()
                controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
                for cp in controlPoints:
                if cp.cp_getParam('unableToChangeTeam') != 0 and cp.cp_getParam('team') != attacker.getTeam():
                    distanceTo = self.getVectorDistance(victimVehicle.getPosition(), cp.getPosition())
                    if float(distanceTo) < tx.r:
                    mm_utils.msg_server("§3" + attacker.getName() + " - is punished for violating of the no kill rules within §C1001safe base area§C1001")
                    self.mm.info("BASERAPE! att=" + str(attacker.getName()) + " vic=" + str(victim.getName()) +" Radius=" + str(tx.r) + " Distance=" + str(distanceTo) )
                        self.justify(attacker, victim)


    def checkForSafeBase(self, victim, attacker, mapName, num_cp):
        victimVehicle = victim.getVehicle()
        coor_X = victimVehicle.getPosition()[0]
        coor_Y = victimVehicle.getPosition()[2]
        coor_Z = victimVehicle.getPosition()[1]

        tx = new_baserape_maps(mapName, num_cp, victim.getTeam())
        for cp in tx.tch_x:
            if (float(coor_Z) > cp['z']) and (float(coor_Z) < (cp['z'] + cp['h'])):
                dist = math.sqrt( (float(coor_X) - float(cp['x']))**2 + (float(coor_Y) - float(cp['y']))**2 )
                if float(dist) < cp['r']:
                if cp.has_key('point'):
                    attackerVehicle = attacker.getVehicle()
                att_Vehicle = bf2.objectManager.getRootParent(attackerVehicle)
                  if ((getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_ARMOR) or (getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_TRANSPORT)):
                return

                for obj in bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint'):
                namepoint = obj.templateName.lower()[cp['c']:]
                if (namepoint == cp['point']):
                    ownerteam = int(obj.cp_getParam('team'))
                    if (ownerteam != cp['owner']):
                    return

                mm_utils.msg_server("§3" + attacker.getName() + " - is punished for violating of the no kill rules within §C1001safe base area§C1001")
                self.mm.info("BASERAPE! att=" + str(attacker.getName()) + " vic=" + str(victim.getName()) +" Radius=" + str(cp['r']) + " Distance=" + str(dist) )
                    self.justify(attacker, victim)


    def justify(self, attacker, victim):
            victim.timedeath = int(time.time())
        victim.score.deaths += -1
        attacker.score.kills += -1
        attacker.score.score += -4
#        attacker.score.TKs += 1
        attacker.faa.warning += 1
        if attacker.isAlive():
            vehicle = attacker.getVehicle()
            rootVehicle = getRootParent(vehicle)
            if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
                rootVehicle.setDamage(0)
        else:
                rootVehicle.setDamage(1)
        if attacker.isCommander():
            team = attacker.getTeam()
        enemyteam = 3 - team
        attacker.setTeam(enemyteam)
        attacker.setTeam(team)
        if attacker.faa.warning > 3:
            host.rcon_invoke('game.sayall "Player %s kicked for violating of the no kill rules within safe base area"' % (attacker.getName() ) )
            host.rcon_invoke('pb_sv_kick "%s" %i "You kicked for violating of the no kill rules within safe base area"' % (attacker.getName(), 15) )
        

    def getVectorDistance(self, pos1, pos2):
        diffVec = [0.0, 0.0, 0.0]
        diffVec[0] = math.fabs(pos1[0] - pos2[0])
        diffVec[1] = math.fabs(pos1[1] - pos2[1])
        diffVec[2] = math.fabs(pos1[2] - pos2[2])

            return math.sqrt(diffVec[0] * diffVec[0] + diffVec[1] * diffVec[1] + diffVec[2] * diffVec[2])


    def onGameStatusChanged( self, status ):
        if status == bf2.GameStatus.Playing:
        global num_cp, mapName, noVehicles
            controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
        num_cp = len(controlPoints)
        mapName = bf2.gameLogic.getMapName()
            noVehicles = int(bf2.serverSettings.getnoVehicles())
        for player in bf2.playerManager.getPlayers():
                player.faa.timedeath = 0
                player.faa.warning = 0
                player.faa.enterVeh = 0


    def onPlayerRevived(self, attacker, victim):
        if int(attacker.timedeath) > 0:
            timex = int(time.time()) - int(attacker.timedeath)
        if int(timex) < 16:
            attacker.score.deaths += 1
            attacker.timedeath = 0


    def onPlayerConnect(self, player):
        player.faa = fStt(player)


    def init( self ):
        host.registerGameStatusHandler( self.onGameStatusChanged )

        if 0 == self.__state:
                host.registerHandler('PlayerConnect', self.onPlayerConnect, 1 )
                host.registerHandler('PlayerKilled', self.onPlayerKilled )
        host.registerHandler('PlayerRevived', self.onPlayerRevived )
                host.registerHandler('EnterVehicle', self.onEnterVehicle  )
                host.registerHandler('ExitVehicle', self.onExitVehicle )

        self.__state = 1


def mm_load( modManager ):
    """Creates and returns your object."""
    return new_baserape2( modManager )
Перейти в начало страницы
Вставить ник
+Цитировать сообщение
сообщение 8.9.2012, 14:03
Сообщение #24





Группа:
Сообщений: 0
Регистрация: --
Пользователь №:



errr.. i cant read well with Russian language so i used translate google, im sorry im not introducing myself, that im from Indonesia.

btw i've try that mm_baserape_v3.py and it's only for vehicle, rite?


Can you show how to make anti baserape script for both infantry and vehicle?
i was try it and always failed with infantry. Vehicle always works but infantry nope.
Перейти в начало страницы
Вставить ник
+Цитировать сообщение
сообщение 8.9.2012, 15:33
Сообщение #25





Группа:
Сообщений: 0
Регистрация: --
Пользователь №:



oh ya i run your script, i modified your script here is the script so much thx smile.gif, it can works on infant and vehicle

Раскрывающийся текст
# ------------------------------------------------------------------------
# Module: AntiBaseRape.py
# Author: SHAnders
# Port to bf2cc/mm: graag42
#
# Version 1.2
#
# Changes:
# v1.11 -> 1.2
# Big improvements by REW (http://maxigame.by/bf2/)
# v1.1 -> 1.11
# Fixed the timer to only be started once
# v1.0 -> 1.1
# Implemted a baseRapeWarning attribute on players to count safe base kills
# Implemted allowed amount of safe base kills (3)
# up to this amount player only loses kill points + 1 score pr baseRapeWarning
# over this amount player is allso killed
# Implemtes a timer for removing 1 baseRapeWarning every 2 minutes
#
# Description:
# Server side only admin script
#
# This script will punish players who kill enemy within the area of a safe base
#
# Requirements:
# None.
#
# Installation as Admin script:
# 1: Save this script as 'AntiBaseRape.py' in your <bf2>/admin/standard_admin directory.
# 2: Add the lines 'import AntiBaseRape' and 'AntiBaseRape.init()' to the file
# '<bf2>/admin/standard_admin/__init__.py'.
#
# TODO:
# Since not all maps are alike, the requirements for base rape protiction
# should be able to be altered individualy for each control point.
#
# Thanks to:
# Battlefield.no for inspiration from their pingkick.py script
#
# ------------------------------------------------------------------------

import host
import bf2
import math
import mm_utils
from bf2.stats.constants import *
from bf2 import g_debug

# Set the version of your module here
__version__ = 1.11

# Set the required module versions here
__required_modules__ = {
'modmanager': 1.0
}

# Does this module support reload ( are all its reference closed on shutdown? )
__supports_reload__ = True

# Set the description of your module here
__description__ = "AntiBaseRape v%s" % __version__

# ------------------------------------------------------------------------
# Constants
# ------------------------------------------------------------------------

DEFAULT_SAFEBASE_RADIUS = 50 # Default safe area radius (normal commandpoint radius = 10)
ALLOWED_SAFEBASEKILLS = 2
SAFEBASEKILL_TIMER_INTERVAL = 300 # Intervals between removing a point from players.baseRapeWarning

# ------------------------------------------------------------------------
# Variables
# ------------------------------------------------------------------------

WarnReduceTimer = None # Timer that reduces the warnings at intervals

# ------------------------------------------------------------------------
# Init
# ------------------------------------------------------------------------

class BaseRape( object ) :

def __init__( self, modManager ):
# ModManager reference
self.mm = modManager

# Internal shutdown state
self.__state = 0

def init( self ):
if g_debug: print "AntiBaseRape init"
if 0 == self.__state:
host.registerHandler('PlayerConnect', self.onPlayerConnect, 1)
host.registerHandler('PlayerKilled', self.onPlayerKilled)

# Update to the running state
self.__state = 1

# Start the timer that reduces warnings on the SAFEBASEKILL_TIMER_INTERVAL
WarnReduceTimer = bf2.Timer(self.onSafeBaseKillTimer, SAFEBASEKILL_TIMER_INTERVAL, 1)
WarnReduceTimer.setRecurring(SAFEBASEKILL_TIMER_INTERVAL)

# Connect already connected players if reinitializing
for p in bf2.playerManager.getPlayers():
self.onPlayerConnect(p)
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# onPlayerConnect
# ------------------------------------------------------------------------
def onPlayerConnect(self, player):
self.resetPlayer(player)
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# onPlayerKilled
# ------------------------------------------------------------------------
def onPlayerKilled(self, victim, attacker, weapon, assists, object):
# killed by self
#vehicle = attacker.getVehicle()
#vicvehicle = victim.getVehicle()
#rootVehicle = getRootParent(vehicle)
#vicrootVehicle = getRootParent(vicvehicle)
#attackerVehicle = bf2.objectManager.getRootParent(weapon)
if attacker == victim:
pass
elif attacker != None and attacker.getTeam() != victim.getTeam():

self.checkForSafeBase(attacker, victim, weapon)
# killed by enemy
#elif (attacker != None) and (attacker.getTeam() != victim.getTeam()) and (getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER) and (getVehicleType(vicrootVehicle.templateName) != VEHICLE_TYPE_AIRDEFENSE) and (getVehicleType(vicrootVehicle.templateName) != VEHICLE_TYPE_GRNDDEFENSE):
#attackerVehicle = bf2.objectManager.getRootParent(weapon)
#if attackerVehicle.isPlayerControlObject and attackerVehicle.getIsRemoteControlled():
# pass
#else:

# ------------------------------------------------------------------------


def shutdown( self ):
"""Shutdown and stop processing."""

# Unregister game handlers and do any other
# other actions to ensure your module no longer affects
# the game in anyway
if WarnReduceTimer:
WarnReduceTimer = None
WarnReduceTimer.destroy()

# Flag as shutdown as there is currently way to:
# host.unregisterHandler
self.__state = 2

# ------------------------------------------------------------------------
# Reset the number of warnings
# ------------------------------------------------------------------------
def resetPlayer(self, player):
player.baseRapeWarning = 0
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# Check if victim was killed within safebase area
# ------------------------------------------------------------------------
def checkForSafeBase(self, attacker, victim, weapon):
currentmap = bf2.gameLogic.getMapName()
if currentmap == "dalian_plant" and victim.getTeam() == 1:
DEFAULT_SAFEBASE_RADIUS = 320
if currentmap == "dalian_plant" and victim.getTeam() == 2:
DEFAULT_SAFEBASE_RADIUS = 100
if currentmap == "daqing_oilfields" and victim.getTeam() == 1:
DEFAULT_SAFEBASE_RADIUS = 275
if currentmap == "daqing_oilfields" and victim.getTeam() == 2:
DEFAULT_SAFEBASE_RADIUS = 180
if currentmap == "dragon_valley":
DEFAULT_SAFEBASE_RADIUS = 94
if currentmap == "fushe_pass" and victim.getTeam() == 1:
DEFAULT_SAFEBASE_RADIUS = 75
if currentmap == "fushe_pass" and victim.getTeam() == 2:
DEFAULT_SAFEBASE_RADIUS = 54
if currentmap == "gulf_of_oman" and victim.getTeam() == 1:
DEFAULT_SAFEBASE_RADIUS = 80
if currentmap == "gulf_of_oman" and victim.getTeam() == 2:
DEFAULT_SAFEBASE_RADIUS = 95
if currentmap == "kubra_dam":
DEFAULT_SAFEBASE_RADIUS = 83
if currentmap == "operation_blue_pearl":
DEFAULT_SAFEBASE_RADIUS = 200
if currentmap == "operation_clean_sweep":
DEFAULT_SAFEBASE_RADIUS = 39
if currentmap == "road_to_jalalabad":
DEFAULT_SAFEBASE_RADIUS = 50
if currentmap == "sharqi_peninsula":
DEFAULT_SAFEBASE_RADIUS = 24
if currentmap == "strike_at_karkand":
DEFAULT_SAFEBASE_RADIUS = 54
if currentmap == "wake_island_2007":
DEFAULT_SAFEBASE_RADIUS = 150
if currentmap == "zatar_wetlands" and victim.getTeam() == 1:
DEFAULT_SAFEBASE_RADIUS = 90
if currentmap == "zatar_wetlands" and victim.getTeam() == 2:
DEFAULT_SAFEBASE_RADIUS = 68
if currentmap == "mass_destruction":
DEFAULT_SAFEBASE_RADIUS = 23
if currentmap == "warlord":
DEFAULT_SAFEBASE_RADIUS = 55
if currentmap == "highway_tampa":
DEFAULT_SAFEBASE_RADIUS = 130
if currentmap == "greatwall":
DEFAULT_SAFEBASE_RADIUS = 55
if currentmap == "insurgency_on_alcatraz_island":
DEFAULT_SAFEBASE_RADIUS = 20
if currentmap == "iron_gator":
DEFAULT_SAFEBASE_RADIUS = 55
if currentmap == "midnight_sun":
DEFAULT_SAFEBASE_RADIUS = 108
if currentmap == "atom":
DEFAULT_SAFEBASE_RADIUS = 130
if currentmap == "leviathan":
DEFAULT_SAFEBASE_RADIUS = 55
if currentmap == "night_flight":
DEFAULT_SAFEBASE_RADIUS = 30
if currentmap == "operationharvest":
DEFAULT_SAFEBASE_RADIUS = 100
if currentmap == "operationroadrage":
DEFAULT_SAFEBASE_RADIUS = 100
if currentmap == "operationsmokescreen":
DEFAULT_SAFEBASE_RADIUS = 100
if currentmap == "taraba_quarry":
DEFAULT_SAFEBASE_RADIUS = 130

victimVehicle = victim.getVehicle()
controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
for cp in controlPoints:
if cp.cp_getParam('unableToChangeTeam') != 0 and cp.cp_getParam('team') != attacker.getTeam():
distanceTo = self.getVectorDistance(victimVehicle.getPosition(), cp.getPosition())
if DEFAULT_SAFEBASE_RADIUS > float(distanceTo):
self.justify(attacker, victim, cp, distanceTo)
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# Punish attacker, give victim life back and inform all
# ------------------------------------------------------------------------
def justify(self, attacker, victim, controlPoint, distanceTo):

victim.score.deaths += -1
attacker.score.kills += -2
attacker.score.score += -4 - attacker.baseRapeWarning
attacker.baseRapeWarning += 1
self.sendWarning(attacker, controlPoint, distanceTo)
vehicle = attacker.getVehicle()
rootVehicle = getRootParent(vehicle)
if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
attacker.baseRapeWarning += 2
self.sendWarning(attacker, controlPoint, distanceTo)
if getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER:
attacker.baseRapeWarning += 2
self.sendWarning(attacker, controlPoint, distanceTo)
if attacker.baseRapeWarning > ALLOWED_SAFEBASEKILLS:
attacker.baseRapeWarning += 1
attacker.score.TKs += 1
victim.score.deaths += -2
attacker.score.kills += -4
attacker.score.score += -6 - attacker.baseRapeWarning
self.sendWarning(attacker, controlPoint, distanceTo)
if attacker.isAlive():
if getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER:
rootVehicle.setDamage(0.01)
# a vehicle will likely explode within 1 sec killing entire crew,
# not so sure about base defenses though
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# Send Warning
# ------------------------------------------------------------------------
def sendWarning(self, player, controlPoint, distanceTo):
mapName = bf2.gameLogic.getMapName()
if player.baseRapeWarning > ALLOWED_SAFEBASEKILLS:
mm_utils.msg_server("§3" + player.getName() + " - BASERAPER smile.gif §C1001(FIX BASE ATTACK)§C1001")
else:
mm_utils.msg_server("§C1001" + player.getName() + "§C1001 - FIX BASE ATTACK! Warnings: §C1001" + str(player.baseRapeWarning) + "§C1001/" + str(ALLOWED_SAFEBASEKILLS))
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# remove baseRapeWarnings over time
# ------------------------------------------------------------------------
def onSafeBaseKillTimer(self, data):
for p in bf2.playerManager.getPlayers():
if p.baseRapeWarning <= 0:
p.baseRapeWarning = 0
else:
p.baseRapeWarning += -1
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# get distance between two positions
# ------------------------------------------------------------------------
def getVectorDistance(self, pos1, pos2):
diffVec = [0.0, 0.0, 0.0]
diffVec[0] = math.fabs(pos1[0] - pos2[0])
diffVec[1] = math.fabs(pos1[1] - pos2[1])
diffVec[2] = math.fabs(pos1[2] - pos2[2])

return math.sqrt(diffVec[0] * diffVec[0] + diffVec[1] * diffVec[1] + diffVec[2] * diffVec[2])
# ------------------------------------------------------------------------


# ------------------------------------------------------------------------
# ModManager Init
# ------------------------------------------------------------------------
def mm_load( modManager ):
"""Creates and returns your object."""
return BaseRape( modManager )
Перейти в начало страницы
Вставить ник
+Цитировать сообщение
сообщение 9.9.2012, 16:21
Сообщение #26





Группа:
Сообщений: 0
Регистрация: --
Пользователь №:



cant edit sorry about triple post >.<..
here i want to ask about map 1.5 patch safe base radius..
is it okay with radius for 64 players map?
how to calculate the radius?

Раскрывающийся текст
if currentmap == "operation_blue_pearl":
DEFAULT_SAFEBASE_RADIUS = 200
if currentmap == "highway_tampa":
DEFAULT_SAFEBASE_RADIUS = 250
if currentmap == "greatwall":
DEFAULT_SAFEBASE_RADIUS = 85
if currentmap == "midnight_sun":
DEFAULT_SAFEBASE_RADIUS = 200
if currentmap == "operationharvest":
DEFAULT_SAFEBASE_RADIUS = 150
if currentmap == "operationroadrage":
DEFAULT_SAFEBASE_RADIUS = 275
if currentmap == "operationsmokescreen":
DEFAULT_SAFEBASE_RADIUS = 230
if currentmap == "taraba_quarry":
DEFAULT_SAFEBASE_RADIUS = 200


Сообщение отредактировал seanman - 9.9.2012, 16:22
Перейти в начало страницы
Вставить ник
+Цитировать сообщение
сообщение 9.9.2012, 22:36
Сообщение #27





Группа:
Сообщений: 0
Регистрация: --
Пользователь №:



You should be Squad Leader on the server running necessary map and then just place "Move" marker on the uncaptureable flag
For best measurements you must place it on exact point for flag pole/holder.
Then game will show you allowed distance in meters, which accepted by this script (distance tools may be disabled by Alt button in game)
How you may be noticed from geometry course, it means spherical space for safe base
All distances used in your script works on any map layer 16/32/64

Сообщение отредактировал Tema567 - 9.9.2012, 22:38
Перейти в начало страницы
Вставить ник
+Цитировать сообщение
сообщение 10.9.2012, 19:02
Сообщение #28





Группа:
Сообщений: 0
Регистрация: --
Пользователь №:



Thx tema567 smile.gif.. btw i've another made a baserape script with more points it works for infant and vehicle

Раскрывающийся текст
# Module: AntiBaseRape 2 for Battlefield 2 Server bf2.wildpark.net(closed server only for WildPark users).
# Author: orion.
# Tester: Skuuka (thx)
# Author :watdezig aka seanman
# Version 1.5
#
# Description:
# Server side only admin script.
#
# This script will punish players who kill enemy within the area of a safe base.
# credit to:shander as the 1st maker.
#Lotus Developer Team, Kaskus, Orion. as maker
#tester 1.5 : arie "capulet[2]nd"
# Requirements:
# modmanager
#infant and vehcle works biggrin.gif.
# ATTENTION!!!
# You must add string
# def getnoVehicles(self): return host.ss_getParam('noVehicles')
# in file /python/bf2/GameLogic.py for class ServerSettings.
#
#
# Have fun
#

import bf2
import host
import mm_utils
from bf2.stats.constants import *
from bf2 import g_debug
import math
import time


# Set the version of your module here
__version__ = 1.5

# Set the required module versions here
__required_modules__ = {
'modmanager': 1.0
}

# Does this module support reload ( are all its reference closed on shutdown? )
__supports_reload__ = False

# Set the description of your module here
__description__ = "AntiBaseRape 2 v%s" % __version__


class fStt(object):
def __init__(self, player):
self.timedeath = 0
self.warning = 0
self.enterVeh = 0

class new_baserape_maps(object):
def __init__(self, map, num_cp, army):
if map == "daqing_oilfields":
if army == 1:
self.tch_x = [ {'x':-246, 'y':380.5, 'z':165, 'h':25, 'r':85}, {'x':-110, 'y':533, 'z':155, 'h':18, 'r':90} ] # PLA(NB, VPP)
else:
self.tch_x = [ {'x':346, 'y':-578, 'z':120, 'h':38, 'r':150} ] # USA(NB)
if map == "dalian_plant":
if army == 1:
self.tch_x = [ {'x':-707, 'y':-367, 'z':180, 'h':25, 'r':115}, {'x':-796, 'y':-125.5, 'z':180, 'h':25, 'r':30} ] # PLA(NB, VPP)
else:
self.tch_x = [ {'x':763, 'y':-13, 'z':155, 'h':35, 'r':50} ] # USA(NB)
if map == "gulf_of_oman":
if army == 1:
self.tch_x = [ {'x':310, 'y':240, 'z':24, 'h':25, 'r':50}, {'x':127.5, 'y':250, 'z':23, 'h':25, 'r':40} ] # MEC(NB, heli)
else:
self.tch_x = [ {'x':-677, 'y':-490, 'z':38, 'h':35, 'r':60} ] # USA(NB)
if map == "operation_clean_sweep":
if army == 1:
self.tch_x = [ {'x':-121, 'y':-555, 'z':31, 'h':8, 'r':16, 'point':'smallairstrip', 'owner':1, 'c':13}, {'x':703.5, 'y':83, 'z':29, 'h':15, 'r':25, 'point':'mecairfield', 'owner':1, 'c':13}, {'x':256.3, 'y':-397.8, 'z':37, 'h':15, 'r':9, 'point':'communicationcentral', 'owner':1, 'c':13} ] # MEC(VPP, VPP(base), heli)
else:
self.tch_x = [ {'x':-552, 'y':544, 'z':29, 'h':15, 'r':50}, {'x':-428, 'y':667.5, 'z':36, 'h':20, 'r':48}, {'x':-328, 'y':682, 'z':36, 'h':25, 'r':50} ] # USA(NB, VPP, VPP)
if map == "kubra_dam":
if army == 1:
self.tch_x = [ {'x':-496.5, 'y':-730, 'z':66, 'h':10, 'r':40, 'point':'intake', 'owner':1, 'c':13}, {'x':-458.5, 'y':-584, 'z':65, 'h':25, 'r':25, 'point':'intake', 'owner':1, 'c':13} ] # MEC(VPP, heli)
else:
self.tch_x = [ {'x':158.5, 'y':125.5, 'z':60, 'h':20, 'r':65}, {'x':519, 'y':332.5, 'z':75, 'h':30, 'r':85} ] # USA(NB, VPP)
if map == "wake_island_2007":
if army == 1:
self.tch_x = [ {'x':408, 'y':-374, 'z':100, 'h':10, 'r':15, 'point':'airfield', 'owner':1, 'c':9}, {'x':373, 'y':-350, 'z':100, 'h':15, 'r':15, 'point':'airfield', 'owner':1, 'c':9} ] # PLA(VPP, heli)
else:
self.tch_x = [ {'x':-745.5, 'y':633.5, 'z':98, 'h':30, 'r':55} ] # USA(NB)
if map == "zatar_wetlands":
if army == 1:
self.tch_x = [ {'x':727, 'y':-401, 'z':60, 'h':17, 'r':75}, {'x':795, 'y':-510, 'z':60, 'h':25, 'r':45} ] # MEC(NB, VPP)
else:
if num_cp == 7:
self.tch_x = [ {'x':-772, 'y':102, 'z':41, 'h':20, 'r':80}, {'x':-849, 'y':153.5, 'z':38, 'h':25, 'r':40} ] # USA(NB, NB(VPP))
else:
self.tch_x = [ {'x':-386, 'y':921, 'z':48, 'h':25, 'r':60}, {'x':-565, 'y':482, 'z':30, 'h':15, 'r':85} ] # USA(NB(VPP), NB)
if map == "fushe_pass":
if army == 1:
if num_cp == 6:
self.tch_x = [ {'x':-531.5, 'y':231.7, 'z':90, 'h':30, 'r':70} ] # PLA(NB)
else:
self.tch_x = [ {'x':-668, 'y':-493.8, 'z':115, 'h':40, 'r':130} ] # PLA(NB)
else:
if num_cp == 6:
self.tch_x = [ {'x':302, 'y':-203, 'z':80, 'h':30, 'r':60} ] # USA(NB)
else:
self.tch_x = [ {'x':608.5, 'y':576.8, 'z':85, 'h':25, 'r':80}, {'x':734.5, 'y':712, 'z':87, 'h':35, 'r':65} ] # USA(NB, VPP)
if map == "dragon_valley":
if army == 1:
if num_cp == 6:
self.tch_x = [ {'x':92.5, 'y':-679, 'z':100, 'h':25, 'r':30, 'point':'refinery', 'owner':1, 'c':13} ] # PLA(Heli)
else:
self.tch_x = [ {'x':92.5, 'y':-679, 'z':100, 'h':25, 'r':30, 'point':'refinery', 'owner':1, 'c':13}, {'x':185.5, 'y':-647, 'z':100, 'h':20, 'r':35, 'point':'refinery', 'owner':1, 'c':13} ] # PLA(Heli, VPP)
else:
if num_cp == 6:
self.tch_x = [ {'x':116, 'y':314, 'z':51, 'h':25, 'r':40} ] # USA(NB)
else:
self.tch_x = [ {'x':338.5, 'y':846, 'z':67, 'h':30, 'r':55} ] # USA(NB)
if map == "highway_tampa":
if army == 1:
self.tch_x = [ {'x':-493, 'y':636.5, 'z':25, 'h':25, 'r':105} ] # MEC(NB)
else:
self.tch_x = [ {'x':608, 'y':-526, 'z':25, 'h':15, 'r':50},{'x':706, 'y':-466.5, 'z':26, 'h':25, 'r':50} ] # USA(NB, VPP)
if map == "taraba_quarry":
if army == 1:
if num_cp == 5:
self.tch_x = [ {'x':18.5, 'y':186.4, 'z':120, 'h':25, 'r':35} ] # MEC(NB)
else:
self.tch_x = [ {'x':-489, 'y':-553, 'z':155, 'h':25, 'r':70}, {'x':-645.5, 'y':-525, 'z':160, 'h':20, 'r':50} ] # MEC(NB, VPP)
else:
if num_cp == 7:
self.tch_x = [ {'x':427, 'y':-461.5, 'z':155, 'h':20, 'r':60}, {'x':575.5, 'y':-420, 'z':160, 'h':20, 'r':45} ] # EURO(NB, VPP)
if map == "operationsmokescreen":
if army == 1:
self.tch_x = [ {'x':72.5, 'y':-522, 'z':96, 'h':15, 'r':60}, {'x':108, 'y':-629, 'z':87, 'h':30, 'r':70} ] # MEC(NB, VPP)
else:
self.tch_x = [ {'x':7, 'y':430.5, 'z':96, 'h':15, 'r':55}, {'x':87, 'y':528.5, 'z':97, 'h':30, 'r':80} ] # EURO(NB, VPP)
if map == "road_to_jalalabad":
if army == 2:
self.tch_x = [ {'x':-205.4, 'y':7.7, 'z':40, 'h':15, 'r':45} ] # USA(NB)
if map == "sharqi_peninsula":
if army == 1:
if num_cp == 4:
self.tch_x = [ {'x':-316.3, 'y':-226.2, 'z':78, 'h':6, 'r':25} ] # MEC(NB)
else:
self.tch_x = [ {'x':-647, 'y':205, 'z':90, 'h':15, 'r':27}, {'x':-605, 'y':-201, 'z':90, 'h':15, 'r':35}, {'x':-288.5, 'y':-597, 'z':70, 'h':15, 'r':25}, {'x':-247.5, 'y':-585, 'z':75, 'h':20, 'r':18} ] # MEC(NB, NB, NB, Heli)
else:
if num_cp > 4:
self.tch_x = [ {'x':-98.25, 'y':-144.25, 'z':128, 'h':15, 'r':15, 'point':'tvstation', 'owner':2, 'c':13} ] # USA(Heli)
if map == "strike_at_karkand":
if army == 2:
self.tch_x = [ {'x':-160, 'y':-282, 'z':159, 'h':10, 'r':40} ] # USA(NB)
if map == "operation_blue_pearl":
if num_cp > 4:
if army == 2:
self.tch_x = [ {'x':282, 'y':-123, 'z':15, 'h':20, 'r':58} ] # USA(island)
if map == "midnight_sun":
if num_cp > 4:
if army == 2:
self.tch_x = [ {'x':533, 'y':-40, 'z':110, 'h':25, 'r':65}, {'x':607, 'y':61, 'z':110, 'h':25, 'r':75} ] # USA()
else:
self.tch_x = [ {'x':-735, 'y':-382, 'z':96, 'h':20, 'r':75}, {'x':-664, 'y':-346, 'z':103, 'h':20, 'r':82} ] # PLA()
if map == "operationharvest":
if army == 2:
if num_cp == 5:
self.tch_x = [ {'x':471.7, 'y':436, 'z':30, 'h':20, 'r':59} ] # USA(NB)
if num_cp == 8:
self.tch_x = [ {'x':-405, 'y':-561, 'z':32, 'h':25, 'r':47}, {'x':-455, 'y':-495, 'z':28, 'h':25, 'r':51} ] # USA(NB, heli)
if num_cp == 9:
self.tch_x = [ {'x':-405, 'y':-561, 'z':32, 'h':25, 'r':47}, {'x':-442, 'y':-483, 'z':28, 'h':25, 'r':42}, {'x':340, 'y':-486, 'z':48, 'h':25, 'r':31} ] # USA(NB, heli)
else:
if num_cp == 8:
self.tch_x = [ {'x':245, 'y':678, 'z':35, 'h':25, 'r':42}, {'x':215, 'y':560, 'z':28, 'h':25, 'r':48} ] # MEC(heli,NB)
if num_cp == 9:
self.tch_x = [ {'x':245, 'y':678, 'z':35, 'h':25, 'r':42} ] # MEC(heli)
if map == "operationroadrage":
if army == 2:
if num_cp == 5:
self.tch_x = [ {'x':329, 'y':127.5, 'z':50, 'h':15, 'r':57} ] # USA()
if num_cp == 7:
self.tch_x = [ {'x':-130, 'y':818, 'z':50, 'h':20, 'r':47}, {'x':45, 'y':808, 'z':45, 'h':20, 'r':35} ] # USA()
else:
if num_cp == 5:
self.tch_x = [ {'x':-169, 'y':-188, 'z':40, 'h':20, 'r':62} ] # MEC()
if num_cp == 7:
self.tch_x = [ {'x':32, 'y':-738, 'z':45, 'h':20, 'r':67}, {'x':-148.5, 'y':-738, 'z':45, 'h':20, 'r':43} ] # MEC(heli,NB)

class old_baserape_maps(object):
def __init__(self, map, army):
self.r = 0
if map == "greatwall" and army==1:
self.r = 50
if map == "greatwall" and army==2:
self.r = 30
if map == "jibbel_city" and army==2:
self.r = 30
if map == "bocage_2005" and army==1:
self.r = 65
if map == "bocage_2005" and army==2:
self.r = 40
if map == "strike_at_karkand_2" and army==2:
self.r = 40
if map == "berlin" and army==2:
self.r = 18
if map == "heliwar" and army==2:
self.r = 125
if map == "heliwar" and army==1:
self.r = 115
if map == "rising_city" and army==2:
self.r = 30
if map == "vulcan_island" and army==2:
self.r = 35


check_new_maps = { "daqing_oilfields":[7,9], "gulf_of_oman":[7,9], "dalian_plant":[6,8], "operation_clean_sweep":[4,6,8], "kubra_dam":[8,9],
"wake_island_2007":[6],"zatar_wetlands":[7,9],"dragon_valley":[6,11],"fushe_pass":[6,10],"highway_tampa":[6,8],"taraba_quarry":[5,7],
"operationsmokescreen":[7],"road_to_jalalabad":[7,8],"sharqi_peninsula":[4,8,9], "strike_at_karkand":[7,9],"operation_blue_pearl":[7,8],
"midnight_sun":[6,8],"operationharvest":[5,8,9],"operationroadrage":[5,7]
}

check_old_maps = ["greatwall","jibbel_city","stream","bocage_2005","strike_at_karkand_2","berlin","cp_abadan","vulcan_island","rising_city", "heliwar"]

check_noVeh_maps = ["greatwall","sharqi_peninsula","road_to_jalalabad","jibbel_city","berlin"]

mapName = ""
noVehicles = 0
num_cp = 0


class new_baserape2( object ):
def __init__( self, modManager ):
self.mm = modManager
self.__state = 0

def onEnterVehicle( self, player, vehicle, freeSoldier):
plVehicle = player.getVehicle()
pl_Vehicle = bf2.objectManager.getRootParent(plVehicle)
if ((getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_HELICOPTER) or (getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_AVIATOR)):
player.faa.enterVeh = int(time.time())


def onExitVehicle(self, player, vehicle):
if not player.isAlive():
player.faa.enterVeh = 0
return

if player.faa.enterVeh > 0:
plVehicle = player.getVehicle()
pl_Vehicle = bf2.objectManager.getRootParent(plVehicle)
if (getVehicleType(pl_Vehicle.templateName) == VEHICLE_TYPE_SOLDIER):
player.faa.enterVeh = 0


def onPlayerKilled(self, victim, attacker, weapon, assists, object):
if (attacker == None) or (attacker.getTeam() == victim.getTeam()) or (victim == None) or (weapon == None):
return

if int(noVehicles) == 1:
if mapName not in check_noVeh_maps:
return

if (mapName == "sharqi_peninsula") and (victim.getTeam() == 2):
return
else:
if(victim.faa.enterVeh>0):
delta = int(time.time()) - victim.faa.enterVeh
if int(delta) > 20:
return

#victimVehicle = victim.getVehicle()
#vic_Vehicle = bf2.objectManager.getRootParent(victimVehicle)
#attackerVehicle = attacker.getVehicle()
#att_Vehicle = bf2.objectManager.getRootParent(attackerVehicle)

#attackerVehicle = bf2.objectManager.getRootParent(weapon)
#if attacker == (attackerVehicle.isPlayerControlObject and attackerVehicle.getIsRemoteControlled()):
#pass
#else:
#if (getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_SOLDIER) or (getVehicleType(vic_Vehicle.templateName) == VEHICLE_TYPE_AIRDEFENSE):
#return

if attacker == victim:
pass
elif attacker != None and attacker.getTeam() != victim.getTeam():
self.checkForSafeBase(victim, attacker, mapName, num_cp)

if check_new_maps.has_key(mapName) and num_cp in check_new_maps[mapName]:
self.checkForSafeBase(victim, attacker, mapName, num_cp)

if mapName in check_old_maps:
tx = old_baserape_maps(mapName, victim.getTeam())
if tx.r > 0:
victimVehicle = victim.getVehicle()
controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
for cp in controlPoints:
if cp.cp_getParam('unableToChangeTeam') != 0 and cp.cp_getParam('team') != attacker.getTeam():
distanceTo = self.getVectorDistance(victimVehicle.getPosition(), cp.getPosition())
if float(distanceTo) < tx.r:
mm_utils.msg_server (" §3" + attacker.getName() + " - §C1001 Jangan Pantek Cok §C1001")
self.mm.info("BASERAPE! att=" + str(attacker.getName()) + " vic=" + str(victim.getName()) +" Radius=" + str(tx.r) + " Distance=" + str(distanceTo) )
self.justify(attacker, victim)


def checkForSafeBase(self, victim, attacker, mapName, num_cp):
victimVehicle = victim.getVehicle()
coor_X = victimVehicle.getPosition()[0]
coor_Y = victimVehicle.getPosition()[2]
coor_Z = victimVehicle.getPosition()[1]

tx = new_baserape_maps(mapName, num_cp, victim.getTeam())
for cp in tx.tch_x:
if (float(coor_Z) > cp['z']) and (float(coor_Z) < (cp['z'] + cp['h'])):
dist = math.sqrt( (float(coor_X) - float(cp['x']))**2 + (float(coor_Y) - float(cp['y']))**2 )
if float(dist) < cp['r']:
if cp.has_key('point'):
attackerVehicle = attacker.getVehicle()
att_Vehicle = bf2.objectManager.getRootParent(attackerVehicle)
if ((getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_ARMOR) or (getVehicleType(att_Vehicle.templateName) == VEHICLE_TYPE_TRANSPORT)):
return

for obj in bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint'):
namepoint = obj.templateName.lower()[cp['c']:]
if (namepoint == cp['point']):
ownerteam = int(obj.cp_getParam('team'))
if (ownerteam != cp['owner']):
return

mm_utils.msg_server(" §3" + attacker.getName() + " - §C1001 Jangan Pantek Cok §C1001")
self.mm.info("BASERAPE! att=" + str(attacker.getName()) + " vic=" + str(victim.getName()) +" Radius=" + str(cp['r']) + " Distance=" + str(dist) )
self.justify(attacker, victim)


def justify(self, attacker, victim):
vehicle = attacker.getVehicle()
rootVehicle = getRootParent(vehicle)

victim.timedeath = int(time.time())
victim.score.deaths += -1
attacker.score.kills += -2
attacker.score.score += -2 - attacker.faa.warning
attacker.score.TKs += 1
attacker.faa.warning += 1
#if getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER:
# attacker.faa.warning +=1
#if attacker.faa.warning > 3:
#victim.score.deaths += -1
#attacker.score.kills += -2
#attacker.score.score += -4 - attacker.faa.warning
# attacker.score.TKs += 1
#vehicle = aattacker.getVehicle()
#rootVehicle = getRootParent(vehicle)
#if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
#attacker.faa.warning += 1
#if getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER:
#attacker.faa.warning += 1
if attacker.isAlive():
#vehicle = attacker.getVehicle()
#rootVehicle = getRootParent(vehicle)
#if getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER:
# attacker.faa.warning += 1
if getVehicleType(rootVehicle.templateName) != VEHICLE_TYPE_SOLDIER:
#attacker.faa.warning += 1
rootVehicle.setDamage(0.01)
#else:
#attacker.faa.warning += 1
#rootVehicle.setDamage(1)
if attacker.isCommander():
team = attacker.getTeam()
enemyteam = 3 - team
attacker.setTeam(enemyteam)
attacker.setTeam(team)
if attacker.faa.warning > 4:
#victim.score.deaths += -1
#attacker.score.kills += -2
#attacker.score.score += -4
#attacker.score.TKs += 1
#attacker.faa.warning += 1
mm_utils.msg_server (" - §3 §C1001 Nah Kan Batoe Seh Loe §C1001")
host.rcon_invoke('game.sayall "Player %s kicked for violating of the no kill rules within safe base area"' % (attacker.getName() ) )
host.rcon_invoke('admin.kickplayer "%s" %i "You kicked for violating of the no kill rules within safe base area"' % (attacker.getName(), 15) )


def getVectorDistance(self, pos1, pos2):
diffVec = [0.0, 0.0, 0.0]
diffVec[0] = math.fabs(pos1[0] - pos2[0])
diffVec[1] = math.fabs(pos1[1] - pos2[1])
diffVec[2] = math.fabs(pos1[2] - pos2[2])

return math.sqrt(diffVec[0] * diffVec[0] + diffVec[1] * diffVec[1] + diffVec[2] * diffVec[2])


def onGameStatusChanged( self, status ):
if status == bf2.GameStatus.Playing:
global num_cp, mapName, noVehicles
controlPoints = bf2.objectManager.getObjectsOfType('dice.hfe.world.ObjectTemplate.ControlPoint')
num_cp = len(controlPoints)
mapName = bf2.gameLogic.getMapName()
noVehicles = int(bf2.serverSettings.getnoVehicles())
for player in bf2.playerManager.getPlayers():
player.faa.timedeath = 0
player.faa.warning = 0
player.faa.enterVeh = 0


def onPlayerRevived(self, attacker, victim):
if int(attacker.timedeath) > 0:
timex = int(time.time()) - int(attacker.timedeath)
if int(timex) < 16:
attacker.score.deaths += 1
attacker.timedeath = 0


def onPlayerConnect(self, player):
player.faa = fStt(player)


def init( self ):
host.registerGameStatusHandler( self.onGameStatusChanged )

if 0 == self.__state:
host.registerHandler('PlayerConnect', self.onPlayerConnect, 1 )
host.registerHandler('PlayerKilled', self.onPlayerKilled )
host.registerHandler('PlayerRevived', self.onPlayerRevived )
host.registerHandler('EnterVehicle', self.onEnterVehicle )
host.registerHandler('ExitVehicle', self.onExitVehicle )

self.__state = 1


def mm_load( modManager ):
"""Creates and returns your object."""
return new_baserape2( modManager )


and this one antispawnrape for modmanager

Раскрывающийся текст

# -*- coding: cp1252 -*-
# This script has been modifed by Titch2349, of the BF2s Forums.
# Website: http://www.mattlunn.me.uk
# Contact: matt@mattlunn.me.uk
# -*- coding: cp1252 -*-
#thx matlunn i made it for modmanager by watdezig aka seanman from kaskus.co.id
# This script is based on the AntiBaseRape.py, created by SANders.

import host
import bf2
import math
import mm_utils
from bf2.stats.constants import *
from bf2 import g_debug

# ------ DON'T EDIT ABOVE THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING! ----------
__version__ = 1.2

__required_modules__ = {
'modmanager': 1.0
}

__supports_reload__ = True

__description__ = "AntiSpawnRape 2 v%s" % __version__

ALLOWED_SPAWNRAPEKILLS = 5 # This is the amount of spawn kills allowed before getting kicked
SPAWNRAPE_TIME = 4 # The amount of time after a player spawns (in seconds), after which a kill is no longer deemed as spawnrape.
SPAWNRAPE_DEDUCTION_INTERVAL = 120 # Intervals between removing a point from players.spawnRapeWarning

# ------ DON'T EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING! ----------

WarnReduceTimer = None # Timer that reduces the warnings at intervals

class SpawnRape( object ) :

def __init__( self, modManager ):
# ModManager reference
self.mm = modManager

# Internal shutdown state
self.__state = 0

def init(self):
if g_debug: print "AntiSpawnRape init"
if 0 == self.__state:
host.registerHandler('PlayerConnect', self.onPlayerConnect, 1)
host.registerHandler('PlayerKilled', self.onPlayerKilled)
host.registerHandler('PlayerSpawn', self.onPlayerSpawn)

self.__state=1

WarnReduceTimer = bf2.Timer(self.onSafeBaseKillTimer, SPAWNRAPE_DEDUCTION_INTERVAL, 1)
WarnReduceTimer.setRecurring(SPAWNRAPE_DEDUCTION_INTERVAL)
for p in bf2.playerManager.getPlayers():
self.onPlayerConnect(p)





def onPlayerConnect(self, player):
self.resetPlayer(player)

def onPlayerSpawn(self, player,soldier):
bf2.Timer(self.cancelPlayerSpawn, SPAWNRAPE_TIME, 1, player)
player.hasJustSpawned = 1

def cancelPlayerSpawn(self, player):
player.hasJustSpawned = 0

def onPlayerKilled(self, victim, attacker, weapon, assists, object):
if attacker == victim:
pass
elif attacker != None and attacker.getTeam() != victim.getTeam():
self.checkForJustSpawned(attacker, victim)
def shutdown( self ):
"""Shutdown and stop processing."""

# Unregister game handlers and do any other
# other actions to ensure your module no longer affects
# the game in anyway
if WarnReduceTimer:
WarnReduceTimer = None
WarnReduceTimer.destroy()

# Flag as shutdown as there is currently way to:
# host.unregisterHandler
self.__state = 2

def resetPlayer(self, player):
player.spawnRapeWarning = 0
def checkForJustSpawned(self, attacker, victim):
victimVehicle = victim.getVehicle()
if victim.hasJustSpawned == 1:
self.justify(attacker, victim)




def justify(self, attacker, victim):
victim.score.deaths += -1
attacker.score.kills += -1
attacker.score.score += -2 - attacker.spawnRapeWarning
attacker.spawnRapeWarning += 1
self.sendWarning(attacker)
#vehicle = attacker.getVehicle()
#rootVehicle = getRootParent(vehicle)
#if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
# attacker.spawnRapewWarning +=1
# sendWarning(attacker)
#if getVehicleType(rootVehicle.templateName) == VEHICLE_TYPE_SOLDIER:
# attacker.spawnRapewWarning +=1
# sendWarning(attacker)
if attacker.spawnRapeWarning > ALLOWED_SPAWNRAPEKILLS:
# victim.score.deaths += -1
# attacker.score.kills += -1
# attacker.score.score += -2 - attacker.spawnRapeWarning
# attacker.spawnRapeWarning += 1
# sendWarning(attacker)
host.rcon_invoke("admin.kickPlayer " + str(attacker.index))

def sendWarning(self, player):
if player.spawnRapeWarning > ALLOWED_SPAWNRAPEKILLS:
mm_utils.msg_server(" §3 §C1001 duh g ngrti lg dch w ma u" + player.getName())
else:
mm_utils.msg_server(" §3 " + player.getName() + ",§3 §C1001 Nah Yaaaa!!! (" + str(player.spawnRapeWarning) + ")")

def onSafeBaseKillTimer(self, data):
for p in bf2.playerManager.getPlayers():
if p.spawnRapeWarning <= 0:
p.spawnRapeWarning = 0
else:
p.spawnRapeWarning += -1

def sendMsgAll(self, msg):
host.rcon_invoke("game.sayAll \"" + str(msg) + "\"")


def mm_load( modManager ):
"""Creates and returns your object."""
return SpawnRape( modManager )


enjoy and thx for this forum smile.gif.

Сообщение отредактировал seanman - 10.9.2012, 19:07
Перейти в начало страницы
Вставить ник
+Цитировать сообщение
сообщение 11.9.2012, 18:23
Сообщение #29





Группа:
Сообщений: 0
Регистрация: --
Пользователь №:



Цитата(seanman @ Понедельник, 10 Сентября 2012, 21:02:29) [snapback]1749056[/snapback]

Thx tema567 smile.gif.. btw i've another made a baserape script with more points it works for infant and vehicle
enjoy and thx for this forum smile.gif.

Thanks for your scripts, man it will be useful, already stored in my collection.

Also i've written some scripts and doing new functions on our servers. maybe you have ideas what's should be implemented as bonus in addition to these great scripts.
Перейти в начало страницы
Вставить ник
+Цитировать сообщение
сообщение 13.9.2012, 6:03
Сообщение #30





Группа:
Сообщений: 0
Регистрация: --
Пользователь №:



rolleyes.gif errr.. ahahaha i dont have it for now but later yes i will share it to you and this forum smile.gif

and so thanks to sh@rk biggrin.gif too.

Сообщение отредактировал seanman - 13.9.2012, 6:12
Перейти в начало страницы
Вставить ник
+Цитировать сообщение

2 страниц V  < 1 2
Ответить в данную темуНачать новую тему
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 



Текстовая версия Сейчас: 27.9.2024, 10:22
Консультации адвоката по уголовным делам. Бесплатно. По всей России