|
|
Нуб
OFFLINE
Регистрация: 07.07.2015
Возраст: 42
Сообщений: 0
Репутация: 1
|
| |
|
if u need the python code for vangaship, maybe u can fix it
import BigWorld
import Math
from Math import Vector3, Matrix
import math
from AvatarInputHandler import mathUtils
from ProjectileMover import collideDynamicAndStatic
from debug_utils import LOG_CODEPOINT_WARNING
class IAimingSystem(object):
matrix = property(lambda self: self._matrix)
def __init__(self):
self._matrix = mathUtils.createIdentityMatrix()
def destroy(self):
pass
def enable(self, targetPos):
pass
def disable(self):
pass
def getDesiredShotPoint(self):
pass
def handleMovement(self, dx, dy):
pass
def update(self, deltaTime):
pass
def getTurretJointMat(vehicleTypeDescriptor, vehicleMatrix, turretYaw = 0.0):
turretOffset = vehicleTypeDescriptor.chassis['hullPosition'] + vehicleTypeDescriptor.hull['turretPositions'][0]
turretJointMat = mathUtils.createRTMatrix(Vector3(turretYaw, 0, 0), turretOffset)
turretJointMat.postMultiply(vehicleMatrix)
return turretJointMat
def getGunJointMat(vehicleTypeDescriptor, turretMatrix, gunPitch):
gunOffset = vehicleTypeDescriptor.turret['gunPosition']
gunMat = mathUtils.createRTMatrix(Vector3(0, gunPitch, 0), gunOffset)
gunMat.postMultiply(turretMatrix)
return gunMat
def getPlayerTurretMats(turretYaw = 0.0, gunPitch = 0.0):
player = BigWorld.player()
vehicleTypeDescriptor = player.vehicleTypeDescriptor
vehicleMatrix = player.getOwnVehicleMatrix()
turretMat = getTurretJointMat(vehicleTypeDescriptor, vehicleMatrix, turretYaw)
return (turretMat, getGunJointMat(vehicleTypeDescriptor, turretMat, gunPitch))
def getPlayerGunMat(turretYaw = 0.0, gunPitch = 0.0):
return getPlayerTurretMats(turretYaw, gunPitch)[1]
def getTurretYawGunPitch(vehTypeDescr, vehicleMatrix, targetPos, compensateGravity = False):
turretOffs = vehTypeDescr.hull['turretPositions'][0] + vehTypeDescr.chassis['hullPosition']
gunOffs = vehTypeDescr.turret['gunPosition']
speed = vehTypeDescr.shot['speed']
gravity = vehTypeDescr.shot['gravity'] if not compensateGravity else 0.0
return BigWorld.wg_getShotAngles(turretOffs, gunOffs, vehicleMatrix, speed, gravity, 0.0, 0.0, targetPos, False)
def getDesiredShotPoint(start, dir, onlyOnGround = False, isStrategicMode = False):
end = start + dir.scale(10000.0)
if isStrategicMode:
point1 = __collideStaticOnly(start, end)
point2 = collideDynamicAndStatic(start, end, (BigWorld.player().playerVehicleID,), skipGun=isStrategicMode)
if point1 is None or point2 is None:
point = None
else:
dir = Math.Vector3(point2[0]) - Math.Vector3(point1[0])
point = (Math.Vector3(point1[0]) + dir.scale(0.5), None)
else:
point = collideDynamicAndStatic(start, end, (BigWorld.player().playerVehicleID,), skipGun=isStrategicMode)
if point is not None:
return point[0]
elif not onlyOnGround:
return shootInSkyPoint(start, dir)
else:
return
return
def shootInSkyPoint(startPos, dir):
dirFromCam = dir
start = startPos
dirFromCam.normalise()
vehicle = BigWorld.player().vehicle
if vehicle is not None and vehicle.inWorld and vehicle.isStarted:
shotPos = Math.Vector3(vehicle.appearance.modelsDesc['gun']['model'].position)
shotDesc = vehicle.typeDescriptor.shot
else:
type = BigWorld.player().arena.vehicles[BigWorld.player().playerVehicleID]['vehicleType']
shotPos = BigWorld.player().getOwnVehiclePosition()
shotPos += type.hull['turretPositions'][0] + type.turret['gunPosition']
shotDesc = type.shot
dirAtCam = shotPos - start
dirAtCam.normalise()
cosAngle = dirAtCam.dot(dirFromCam)
a = shotDesc['maxDistance']
b = shotPos.distTo(start)
try:
dist = b * cosAngle + math.sqrt(b * b * (cosAngle * cosAngle - 1) + a * a)
except:
dist = shotDesc['maxDistance']
LOG_CODEPOINT_WARNING()
if dist < 0.0:
dist = shotDesc['maxDistance']
finalPoint = start + dirFromCam.scale(dist)
intersecPoint = BigWorld.player().arena.collideWithSpaceBB(start, finalPoint)
if intersecPoint is not None:
finalPoint = intersecPoint
return finalPoint
def __collideStaticOnly(startPoint, endPoint):
res = None
testRes = BigWorld.wg_collideSegment(BigWorld.player().space ID, startPoint, endPoint, 128)
if testRes is not None:
res = (testRes[0], None)
return res
Добавлено через 3 минуты
sry thats the real vangaship python code, hope u can fix it
# Embedded file name: D:\Kirill\WoT\WoWs\VangaShip.py
import BigWorld, Keys
import GUI, Math
import math
from Avatar import PlayerAvatar
from Vehicle import Vehicle
import InputHandler
import PrimInstDrawer
__author__ = 'STL1te'
modActivated = True
def getForestallingPoint(target, player):
art = player.vehicle.components.artillery
ammoList = art.ammoList
shotSpeed = ammoList[art.selectedAmmoIndex].bulletSpeed * 0.1
shooterPosition = Math.Vector3(player.position)
targetPosition = Math.Vector3(target.position)
shooterVelocity = Math.Vector3(player.vehicle.velocity)
targetVelocity = Math.Vector3(target.velocity)
targetRelativePosition = targetPosition - shooterPosition
targetRelativeVelocity = targetVelocity - shooterVelocity
t = firstOrderInterceptTime(shotSpeed, targetRelativePosition, targetRelativeVelocity)
fp = targetPosition + t * targetRelativeVelocity
return fp
def firstOrderInterceptTime(shotSpeed, targetRelativePosition, targetRelativeVelocity):
velocitySquared = targetRelativeVelocity.lengthSquared
if velocitySquared < 0.001:
return 0.0
a = velocitySquared - shotSpeed * shotSpeed
if abs(a) < 0.001:
t = -targetRelativePosition.lengthSquared / (2.0 * targetRelativeVelocity.dot(targetRelativePosition) )
return max(t, 0.0)
b = 2.0 * targetRelativeVelocity.dot(targetRelativePosition)
c = targetRelativePosition.lengthSquared
determinant = b * b - 4.0 * a * c
if determinant > 0.0:
t1 = (-b + math.sqrt(determinant)) / (2.0 * a)
t2 = (-b - math.sqrt(determinant)) / (2.0 * a)
if t1 > 0.0:
if t2 > 0.0:
return min(t1, t2)
else:
return t1
else:
return max(t2, 0.0)
else:
if determinant < 0.0:
return 0.0
return max(-b / (2.0 * a), 0.0)
class ForestallingPoint(object):
def __init__(self, player, target):
if hasattr(self, '_ForestallingPoint__gui'):
self.destroy()
self.__updateCallback = None
self.__target = target
self.__player = player
self.update()
return
def __del__(self):
self.destroy()
def destroy(self):
try:
BigWorld.cancelCallback(self.__updateCallback)
except:
pass
def update(self):
global modActivated
try:
if modActivated:
if self.__target and self.__player:
if self.__target.isEnterWorld and self.__player.vehicle.isEnterWorld:
vector = getForestallingPoint(self.__target, self.__player)
pos = self.__target.position + (0, 0.5, 0)
PrimInstDrawer.drawLines([vector, pos], 4294967295L, 1, False)
PrimInstDrawer.drawStar(vector, 0.5, 4294901760L, 1)
if self.__target.health <= 0:
self.destroy()
return
self.__updateCallback = BigWorld.callback(0.01, self.update)
except:
pass
old_startVarys = Vehicle.startVarys
old_stopVarys = Vehicle.stopVarys
def new_startVarys(self):
old_startVarys(self)
if BigWorld.player().teamId == self.teamId:
return
if self.isPlayer:
return
if self.health <= 0:
return
player = BigWorld.player()
target = self
self.__FPpoint = ForestallingPoint(player, target)
def new_stopVarys(self):
old_stopVarys(self)
if BigWorld.player().teamId == self.teamId:
return
if self.isPlayer:
return
try:
self.__FPpoint.destroy()
except:
pass
Vehicle.startVarys = new_startVarys
Vehicle.stopVarys = new_stopVarys
def blabla(*args):
print 'blabla', args
def handleKeyDown(event):
global modActivated
if event.key == Keys.KEY_F8:
modActivated = not modActivated
old_handleKeyEvent = InputHandler.handleKeyEvent
def new_handleKeyEvent(event):
if event.isKeyDown():
handleKeyDown(event)
return old_handleKeyEvent(event)
InputHandler.handleKeyEvent = new_handleKeyEvent
Последний раз редактировалось tsche; 09.07.2015 в 18:10.
Причина: Добавлено сообщение
|