ó
L”RYc           @   sx   d  Z  d Z d Z d Z d Z d d l Z d d l Z d d l Z d d l Z d d l	 m
 Z
 d e f d	 „  ƒ  YZ d S(
   s  
There is a small delay after the script has sent the spawnCommand to the engine and the object has actually been instantiated.
To solve this problem the script starts looking for the object after a short time.
This constant is in seconds and should be as low as possible.
gš™™™™™¹?g     ˆÃ@g      $@g      @iÿÿÿÿN(   t   outputt	   BF2Objectc           B   sà   e  Z d  Z e d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   i
   c         C   sñ   | |  _  t |  _ t |  _ | |  _ d  |  _ d  |  _ d  |  _ | |  _	 g  |  _
 t |  _ g  |  _ t j |  _ t j d k rŠ d t _ n t j d 7_ t |  j d t t |  j d f |  _ | |  _ |  j ƒ  t j |  j t d d ƒ d  S(   Nic   i
   i   (   t   tempateNamet   Falset   isControlPointt   isPlayerControlObjectt   hasArmort   Nonet   tokent   _actualObjectt   _idt	   _templatet	   _cmdStackt   _validt	   _handlersR   t
   _currentIdt   _spawnIdt   OBJECT_SPAWN_SPACINGt   OBJECT_SPAWN_HEIGHTt   _expectedSpawnPost	   _hasArmort   _spawnObjectt   bf2t   Timert
   findObjectt   FIND_OBJECT_DELAY(   t   selft   templateR   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyt   __init__I   s*    												
c   
      B   s—  |  j  r d  S|  j |  j ƒ } xqe j j |  j ƒ D]Z} e | d ƒ rP q5 n  | j ƒ  sb q5 n  |  j | j	 ƒ  |  j
 ƒ e k  r5 d  } x‰ | D] } e j d | ƒ e j d ƒ j d ƒ } e | d ƒ e | d ƒ e | d ƒ f } |  j | |  j
 ƒ e k  r | } Pq q We |  _ | |  _  | |  _ | j |  _ | j |  _ | | _ x |  j D] } | d  Uq[Wx |  j D] }	 |	 |  ƒ qwWd  Sq5 Wd  S(   Nt   ids   Object.active ids   Object.absolutePositiont   /i    i   i   (   R	   t   _getIdsR   R   t   objectManagert   getObjectsOfTemplatet   hasattrt   isValidt   getVectorDistancet   getPositionR   t   OBJECT_SPAWN_POSITION_TRESHOLDR   t   hostt   rcon_invoket   splitt   floatt   TrueR   R
   R   R   R   R   R   (
   R   t   dummyt   objIdst   objt   objIdR   t   rawpost   post   cmdt   handler(    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyR   z   s8    	!-				c         C   s"   t  j d | ƒ t  j d ƒ d  S(   Ns   Object.active ids   Object.delete(   R'   R(   (   R   R   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyt	   _deleteId¶   s    c         C   s{   t  j d | ƒ } | j d ƒ } g  } xL | D]D } t | ƒ d k rM q/ n  | j d ƒ } | d } | j | ƒ q/ W| S(   Ns   Object.listObjectsofTemplate s   
i    t    i   (   R'   R(   R)   t   lent   append(   R   R   t   rawIdst	   objectIdst   rawIdR   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyR   ½   s    
c         C   s}   d |  j  } d | d | d d d |  j  g } d | d |  j d	 d
 d g } | | } x | D] } t j | ƒ qb Wd  S(   Nt   bf2obj_s$   ObjectTemplate.create ObjectSpawner s(   ObjectTemplate.activeSafe ObjectSpawner s   ObjectTemplate.isNotSaveable 1s!   ObjectTemplate.hasMobilePhysics 0s#   ObjectTemplate.setObjectTemplate 1 s   Object.create s    Object.absolutePosition %s/%s/%ss   Object.rotation 0.0/0.0/0.0s   Object.team 1s   Object.delete(   R   R   R'   R(   (   R   t   spawnerNamet   spawnerCmdst
   createCmdst   cmdsR2   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyR   Ð   s    
	
c         C   sE   t  j | d | d d | d | d d | d | d d ƒ S(   Ni    i   i   (   t   matht   sqrt(   R   t   at   b(    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyR$   î   s    c         C   s   |  j  S(   N(   R
   (   R   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyt   getIdø   s    c         C   s)   |  j  r% t |  _  |  j |  j ƒ n  d  S(   N(   R   R   R4   R
   (   R   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyt   deleteý   s    		c         C   s&   | |  j  k r" |  j  j | ƒ n  d  S(   N(   R   R7   (   R   R3   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyt   registerCreateHandler  s    c         C   s!   |  j  r |  j  j ƒ  S|  j Sd  S(   N(   R	   R#   R   (   R   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyR#     s    	c         C   s4   |  j  r |  j j | ƒ n |  j j d | ƒ d  S(   Ns   self.setPosition((%s,%s,%s))(   R   R	   t   setPositionR   R7   (   R   R1   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyRG     s    	c         C   s   |  j  r |  j j ƒ  Sd Sd  S(   Ng        (   g        g        g        (   R   R	   R%   (   R   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyR%     s    	c         C   s4   |  j  r |  j j | ƒ n |  j j d | ƒ d  S(   Ns   self.setRotation((%s,%s,%s))(   R   R	   t   setRotationR   R7   (   R   t   rot(    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyRH     s    	c         C   s!   |  j  r |  j j ƒ  n d Sd  S(   Ng        (   g        g        g        (   R   R	   t   getRotation(   R   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyRJ   $  s    	c         C   s   |  j  r |  j j ƒ  Sd  Sd  S(   N(   R   R	   t	   getParentR   (   R   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyRK   *  s    	c         C   s   |  j  r |  j j ƒ  Sd Sd  S(   N(    (   R   R	   t   getChildren(   R   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyRL   0  s    	c         C   s!   |  j  r |  j j | ƒ Sd  Sd  S(   N(   R   R	   t   getTemplatePropertyR   (   R   t   property(    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyRM   6  s    	c         C   s   |  j  S(   N(   R   (   R   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyR   =  s    c         C   s   |  j  r |  j j ƒ  Sd Sd  S(   Ng        (   R   R	   t	   getDamage(   R   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyRO   A  s    	c         C   s4   |  j  r |  j j | ƒ n |  j j d | ƒ d  S(   Ns   self.setDamage(%s)(   R   R	   t	   setDamageR   R7   (   R   t   damage(    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyRP   H  s    	c         C   s   |  j  r |  j j ƒ  St Sd  S(   N(   R   R	   t
   getIsWreckR   (   R   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyRR   N  s    	c         C   s   |  j  r |  j j ƒ  Sd Sd  S(   N(    (   R   R	   t   getOccupyingPlayers(   R   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyRS   T  s    	c         C   s   |  j  r |  j j ƒ  St Sd  S(   N(   R   R	   t   getIsRemoteControlledR   (   R   (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyRT   Z  s    	(   t   __name__t
   __module__R   R   R   R   R4   R   R   R$   RD   RE   RF   R#   RG   R%   RH   RJ   RK   RL   RM   R   RO   RP   RR   RS   RT   (    (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyR   E   s0   1	<				
																	(   t   __doc__R   R   R   R&   R@   R'   R   t	   bf2.Timert   logR    t   objectR   (    (    (    s_   D:\Program files(unsetuped)\Battlefield 2\mods\NModvb\python\game\gamemodes\aiArty\BF2Object.pyt   <module>    s   	