From 7c8b25cbbcf17a7b4f519988809366e617b69d9e Mon Sep 17 00:00:00 2001 From: surrim Date: Sun, 12 Dec 2010 22:30:12 +0000 Subject: [PATCH] AI/Carrier.ec: Reformatted AI/Repairer.ec: Code cleaned a bit git-svn-id: https://osmod.svn.sourceforge.net/svnroot/osmod@11 86818540-93ee-40cb-8eba-4b5640fd30e9 --- trunk/Scripts/Units/AI/Carrier.ec | 913 ++++++++++++------------------ trunk/Scripts/Units/Repairer.ec | 74 +-- 2 files changed, 377 insertions(+), 610 deletions(-) diff --git a/trunk/Scripts/Units/AI/Carrier.ec b/trunk/Scripts/Units/AI/Carrier.ec index 6b7d467..9cd1b69 100644 --- a/trunk/Scripts/Units/AI/Carrier.ec +++ b/trunk/Scripts/Units/AI/Carrier.ec @@ -16,587 +16,382 @@ * along with OSMod. If not, see . */ -carrier "translateScriptNameContainerTransporter" -{ - int m_nMoveToX; - int m_nMoveToY; - int m_nMoveToZ; - int m_nCurrPutGetX; - int m_nCurrPutGetY; - int m_nCurrPutGetZ; - int m_nContainerX; - int m_nContainerY; - int m_nContainerZ; - int m_nGetContainerFrom;//0 - mine, 1 - single container +carrier "translateScriptNameContainerTransporter"{ + int m_nMoveToX; + int m_nMoveToY; + int m_nMoveToZ; + int m_nCurrPutGetX; + int m_nCurrPutGetY; + int m_nCurrPutGetZ; + int m_nContainerX; + int m_nContainerY; + int m_nContainerZ; + int m_nGetContainerFrom; //0 - mine, 1 - single container - enum lights - { - "translateCommandStateLightsAUTO", - "translateCommandStateLightsON", - "translateCommandStateLightsOFF", -multi: - "translateCommandStateLightsMode" - } + enum lights{ + "translateCommandStateLightsAUTO", + "translateCommandStateLightsON", + "translateCommandStateLightsOFF", + multi: + "translateCommandStateLightsMode" + } + state Initialize; + state Nothing; + state StartMoving; + state Moving; + state MovingToContainerSource; + state MovingToContainerDestination; + state GettingContainer; + state PuttingContainer; - state Initialize; - state Nothing; - state StartMoving; - state Moving; - state MovingToContainerSource; - state MovingToContainerDestination; - state GettingContainer; - state PuttingContainer; - //------------------------------------------------------- - state Initialize - { - return Nothing; - } - //------------------------------------------------------- - state Nothing - { - return Nothing; - } - //------------------------------------------------------- - state StartMoving - { - return Moving, 20; - } - //-------------------------------------------------------------------------- - state Moving - { - if (IsMoving()) - { - return Moving; - } - else - { - NextCommand(true); - return Nothing; - } - } - //------------------------------------------------------- - state MovingToContainerSource - { - int nPosX; - int nPosY; - int nPosZ; + state Initialize{ + return Nothing; + } - if (IsMoving()) - { - return MovingToContainerSource; - } - else - { - nPosX = GetLocationX(); - nPosY = GetLocationY(); - nPosZ = GetLocationZ(); - //sprawdzic czy dojechalismy tam gdzie nalezalo - if ((nPosX == m_nCurrPutGetX) && (nPosY == m_nCurrPutGetY) && (nPosZ == m_nCurrPutGetZ)) - { - if (m_nGetContainerFrom == 0) - { - CallGetContainer(); - } - else - { - assert m_nGetContainerFrom == 1; - CallGetSingleContainer(m_nContainerX, m_nContainerY, m_nContainerZ); - } - return GettingContainer; - } - else - { - //kazac mu tam znowu jechac (!moze jakis licznik zeby nie wywolywal w kolko) - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + state Nothing{ + return Nothing; + } - return MovingToContainerSource; - } - } - } - //------------------------------------------------------- - state MovingToContainerDestination - { - int nPosX; - int nPosY; - int nPosZ; + state StartMoving{ + return Moving; + } - if (IsMoving()) - { - return MovingToContainerDestination; - } - else - { - nPosX = GetLocationX(); - nPosY = GetLocationY(); - nPosZ = GetLocationZ(); - //sprawdzic czy dojechalismy tam gdzie nalezalo - if ((nPosX == m_nCurrPutGetX) && (nPosY == m_nCurrPutGetY) && (nPosZ == m_nCurrPutGetZ)) - { - CallPutContainer(); - return PuttingContainer; - } - else - { - //kazac mu tam znowu jechac (!moze jakis licznik zeby nie wywolywal w kolko) - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + state Moving{ + if(IsMoving()){ + return Moving; + } + NextCommand(true); + return Nothing; + } - return MovingToContainerDestination; - } - } - } - //------------------------------------------------------- - state GettingContainer - { - unit uBuilding; - unit uContainer; - if (IsGettingContainer()) - { - return GettingContainer; - } - else - { - if (HaveContainer()) - { - //jesli biezemy pojedynczy kontener to teraz znalezc nastepny w poblizu - if (m_nGetContainerFrom == 1) - { - uContainer = FindSingleContainer(); - if (uContainer) - { + state MovingToContainerSource{ + int nPosX; + int nPosY; + int nPosZ; - m_nContainerX = uContainer.GetLocationX(); - m_nContainerY = uContainer.GetLocationY(); - m_nContainerZ = uContainer.GetLocationZ(); - m_nGetContainerFrom = 1; - } - else - { - //juz nie ma nastepnego w poblizu - m_nGetContainerFrom = 0; - } - } - //pojechac do budynku przeznaczenia jesli jest - if (GetDestinationBuilding() != null) - { - m_nCurrPutGetX = GetDestinationBuildingPutLocationX(); - m_nCurrPutGetY = GetDestinationBuildingPutLocationY(); - m_nCurrPutGetZ = GetDestinationBuildingPutLocationZ(); - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + if(IsMoving()){ + return MovingToContainerSource; + } + nPosX=GetLocationX(); + nPosY=GetLocationY(); + nPosZ=GetLocationZ(); + if((nPosX==m_nCurrPutGetX) && (nPosY==m_nCurrPutGetY) && (nPosZ==m_nCurrPutGetZ)){ + if(m_nGetContainerFrom==0){ + CallGetContainer(); + }else{ + assert m_nGetContainerFrom==1; + CallGetSingleContainer(m_nContainerX, m_nContainerY, m_nContainerZ); + } + return GettingContainer; + } + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + return MovingToContainerSource; + } - return MovingToContainerDestination; - } - else - { - //sprobowac znalezc ten budynek - uBuilding = FindContainerRefineryBuilding(); - if (uBuilding != null) - { - SetDestinationBuilding(uBuilding); - m_nCurrPutGetX = GetDestinationBuildingPutLocationX(); - m_nCurrPutGetY = GetDestinationBuildingPutLocationY(); - m_nCurrPutGetZ = GetDestinationBuildingPutLocationZ(); - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + state MovingToContainerDestination{ + int nPosX; + int nPosY; + int nPosZ; - return MovingToContainerDestination; - } - else - { - //!!transportBase - return Nothing; - } - } - } - else - { - //z jakiegos powodu nie wzielismy kontenera - poszukac nowej kopalni lub pojedynczego kontenera - if (m_nGetContainerFrom == 0) - { - uBuilding = GetSourceBuilding();//aby sie upewnic czy zabity (i skasowac referencje w kodzie) - if (uBuilding == null) - { - //najpierw probujemy znalezc kopalnie - uBuilding = FindContainerMineBuilding(); - } - if (uBuilding != null) - { - SetSourceBuilding(uBuilding); - m_nCurrPutGetX = GetSourceBuildingTakeLocationX(); - m_nCurrPutGetY = GetSourceBuildingTakeLocationY(); - m_nCurrPutGetZ = GetSourceBuildingTakeLocationZ(); - m_nGetContainerFrom = 0; - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + if(IsMoving()){ + return MovingToContainerDestination; + } + nPosX=GetLocationX(); + nPosY=GetLocationY(); + nPosZ=GetLocationZ(); + if((nPosX==m_nCurrPutGetX) && (nPosY==m_nCurrPutGetY) && (nPosZ==m_nCurrPutGetZ)){ + CallPutContainer(); + return PuttingContainer; + } + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + return MovingToContainerDestination; + } - return MovingToContainerSource; - } - else - { - //probujemy znalezc wolny kontener - uContainer = FindSingleContainer(); - if (uContainer) - { - m_nContainerX = uContainer.GetLocationX(); - m_nContainerY = uContainer.GetLocationY(); - m_nContainerZ = uContainer.GetLocationZ(); - m_nCurrPutGetX = GetContainerTakeLocationX(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nCurrPutGetY = GetContainerTakeLocationY(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nCurrPutGetZ = GetContainerTakeLocationZ(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nGetContainerFrom = 1; - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + state GettingContainer{ + unit uBuilding; + unit uContainer; + if(IsGettingContainer()){ + return GettingContainer; + } + if(HaveContainer()){ + if(m_nGetContainerFrom==1){ + uContainer=FindSingleContainer(); + if(uContainer){ + m_nContainerX=uContainer.GetLocationX(); + m_nContainerY=uContainer.GetLocationY(); + m_nContainerZ=uContainer.GetLocationZ(); + m_nGetContainerFrom=1; + }else{ + m_nGetContainerFrom=0; + } + } + if(GetDestinationBuilding()!=null){ + m_nCurrPutGetX=GetDestinationBuildingPutLocationX(); + m_nCurrPutGetY=GetDestinationBuildingPutLocationY(); + m_nCurrPutGetZ=GetDestinationBuildingPutLocationZ(); + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + return MovingToContainerDestination; + } + uBuilding=FindContainerRefineryBuilding(); + if(uBuilding!=null){ + SetDestinationBuilding(uBuilding); + m_nCurrPutGetX=GetDestinationBuildingPutLocationX(); + m_nCurrPutGetY=GetDestinationBuildingPutLocationY(); + m_nCurrPutGetZ=GetDestinationBuildingPutLocationZ(); + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + return MovingToContainerDestination; + } + return Nothing; + } + if(m_nGetContainerFrom==0){ + uBuilding=GetSourceBuilding();//aby sie upewnic czy zabity (i skasowac referencje w kodzie) + if(uBuilding==null){ + uBuilding=FindContainerMineBuilding(); + } + if(uBuilding!=null){ + SetSourceBuilding(uBuilding); + m_nCurrPutGetX=GetSourceBuildingTakeLocationX(); + m_nCurrPutGetY=GetSourceBuildingTakeLocationY(); + m_nCurrPutGetZ=GetSourceBuildingTakeLocationZ(); + m_nGetContainerFrom=0; + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + return MovingToContainerSource; + } + uContainer=FindSingleContainer(); + if(uContainer){ + m_nContainerX=uContainer.GetLocationX(); + m_nContainerY=uContainer.GetLocationY(); + m_nContainerZ=uContainer.GetLocationZ(); + m_nCurrPutGetX=GetContainerTakeLocationX(m_nContainerX, m_nContainerY, m_nContainerZ); + m_nCurrPutGetY=GetContainerTakeLocationY(m_nContainerX, m_nContainerY, m_nContainerZ); + m_nCurrPutGetZ=GetContainerTakeLocationZ(m_nContainerX, m_nContainerY, m_nContainerZ); + m_nGetContainerFrom=1; + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + return MovingToContainerSource; + } + return Nothing; + } + assert m_nGetContainerFrom==1; + uContainer=FindSingleContainer(); + if(uContainer){ + m_nContainerX=uContainer.GetLocationX(); + m_nContainerY=uContainer.GetLocationY(); + m_nContainerZ=uContainer.GetLocationZ(); + m_nCurrPutGetX=GetContainerTakeLocationX(m_nContainerX, m_nContainerY, m_nContainerZ); + m_nCurrPutGetY=GetContainerTakeLocationY(m_nContainerX, m_nContainerY, m_nContainerZ); + m_nCurrPutGetZ=GetContainerTakeLocationZ(m_nContainerX, m_nContainerY, m_nContainerZ); + m_nGetContainerFrom=1; + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + return MovingToContainerSource; + } + uBuilding=GetSourceBuilding(); + if(uBuilding==null){ + uBuilding=FindContainerMineBuilding(); + } + if(uBuilding!=null){ + SetSourceBuilding(uBuilding); + m_nCurrPutGetX=GetSourceBuildingTakeLocationX(); + m_nCurrPutGetY=GetSourceBuildingTakeLocationY(); + m_nCurrPutGetZ=GetSourceBuildingTakeLocationZ(); + m_nGetContainerFrom=0; + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + return MovingToContainerSource; + } + return Nothing; + } - return MovingToContainerSource; - } - else - { - return Nothing; - } - } - } - else - { - assert m_nGetContainerFrom == 1; - //najpierw probujemy znalezc nastepny wolny kontener - uContainer = FindSingleContainer(); - if (uContainer) - { - m_nContainerX = uContainer.GetLocationX(); - m_nContainerY = uContainer.GetLocationY(); - m_nContainerZ = uContainer.GetLocationZ(); - m_nCurrPutGetX = GetContainerTakeLocationX(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nCurrPutGetY = GetContainerTakeLocationY(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nCurrPutGetZ = GetContainerTakeLocationZ(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nGetContainerFrom = 1; - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + state PuttingContainer{ + unit uBuilding; + unit uContainer; + if(IsPuttingContainer()){ + return PuttingContainer; + } + if(!HaveContainer()){ + if((m_nGetContainerFrom==1) && IsContainerInPoint(m_nContainerX, m_nContainerY, m_nContainerZ)){ + m_nGetContainerFrom=1; + m_nCurrPutGetX=GetContainerTakeLocationX(m_nContainerX, m_nContainerY, m_nContainerZ); + m_nCurrPutGetY=GetContainerTakeLocationY(m_nContainerX, m_nContainerY, m_nContainerZ); + m_nCurrPutGetZ=GetContainerTakeLocationZ(m_nContainerX, m_nContainerY, m_nContainerZ); + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + return MovingToContainerSource; + } + if(GetSourceBuilding()!=null){ + m_nCurrPutGetX=GetSourceBuildingTakeLocationX(); + m_nCurrPutGetY=GetSourceBuildingTakeLocationY(); + m_nCurrPutGetZ=GetSourceBuildingTakeLocationZ(); + m_nGetContainerFrom=0; + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + return MovingToContainerSource; + } + uBuilding=FindContainerMineBuilding(); + if(uBuilding!=null){ + SetSourceBuilding(uBuilding); + m_nCurrPutGetX=GetSourceBuildingTakeLocationX(); + m_nCurrPutGetY=GetSourceBuildingTakeLocationY(); + m_nCurrPutGetZ=GetSourceBuildingTakeLocationZ(); + m_nGetContainerFrom=0; + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + return MovingToContainerSource; + } + uContainer=FindSingleContainer(); + if(uContainer){ + m_nContainerX=uContainer.GetLocationX(); + m_nContainerY=uContainer.GetLocationY(); + m_nContainerZ=uContainer.GetLocationZ(); + m_nCurrPutGetX=GetContainerTakeLocationX(m_nContainerX, m_nContainerY, m_nContainerZ); + m_nCurrPutGetY=GetContainerTakeLocationY(m_nContainerX, m_nContainerY, m_nContainerZ); + m_nCurrPutGetZ=GetContainerTakeLocationZ(m_nContainerX, m_nContainerY, m_nContainerZ); + m_nGetContainerFrom=1; + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + return MovingToContainerSource; + } + return Nothing; + } + uBuilding=GetDestinationBuilding(); + if(uBuilding==null){ + uBuilding=FindContainerRefineryBuilding(); + } + if(uBuilding!=null){ + SetDestinationBuilding(uBuilding); + m_nCurrPutGetX=GetDestinationBuildingPutLocationX(); + m_nCurrPutGetY=GetDestinationBuildingPutLocationY(); + m_nCurrPutGetZ=GetDestinationBuildingPutLocationZ(); + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + return MovingToContainerDestination; + } + return Nothing; + } - return MovingToContainerSource; - } - else - { - uBuilding = GetSourceBuilding();//aby sie upewnic czy zabity (i skasowac referencje w kodzie) - if (uBuilding == null) - { - //probujemy znalezc kopalnie - uBuilding = FindContainerMineBuilding(); - } - if (uBuilding != null) - { - SetSourceBuilding(uBuilding); - m_nCurrPutGetX = GetSourceBuildingTakeLocationX(); - m_nCurrPutGetY = GetSourceBuildingTakeLocationY(); - m_nCurrPutGetZ = GetSourceBuildingTakeLocationZ(); - m_nGetContainerFrom = 0; - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + state Froozen{ + if(IsFroozen()){ + state Froozen; + }else{ + state Nothing; + } + } - return MovingToContainerSource; - } - else - { - //probujemy znalezc wolny kontener - return Nothing; - } - } - } - } - } - } - //------------------------------------------------------- - state PuttingContainer - { - unit uBuilding; - unit uContainer; - if (IsPuttingContainer()) - { - return PuttingContainer; - } - else - { - if (!HaveContainer()) - { - //pojechac do kopalni lub po pojedynczy kontener - if ((m_nGetContainerFrom == 1) && IsContainerInPoint(m_nContainerX, m_nContainerY, m_nContainerZ)) - { - m_nGetContainerFrom = 1; - m_nCurrPutGetX = GetContainerTakeLocationX(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nCurrPutGetY = GetContainerTakeLocationY(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nCurrPutGetZ = GetContainerTakeLocationZ(m_nContainerX, m_nContainerY, m_nContainerZ); - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + event OnFreezeForSupplyOrRepair(int nFreezeTicks){ + CallFreeze(nFreezeTicks); + state Froozen; + true; + } - return MovingToContainerSource; - } - else - { - if (GetSourceBuilding() != null) - { - m_nCurrPutGetX = GetSourceBuildingTakeLocationX(); - m_nCurrPutGetY = GetSourceBuildingTakeLocationY(); - m_nCurrPutGetZ = GetSourceBuildingTakeLocationZ(); - m_nGetContainerFrom = 0; - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + command Initialize(){ + m_nGetContainerFrom=0; + SetCannonFireMode(-1, 1); + false; + } - return MovingToContainerSource; - } - else - { - //probujemy znalezc kopalnie - uBuilding = FindContainerMineBuilding(); - if (uBuilding != null) - { - SetSourceBuilding(uBuilding); - m_nCurrPutGetX = GetSourceBuildingTakeLocationX(); - m_nCurrPutGetY = GetSourceBuildingTakeLocationY(); - m_nCurrPutGetZ = GetSourceBuildingTakeLocationZ(); - m_nGetContainerFrom = 0; - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + command Uninitialize(){ + SetDestinationBuilding(null); + SetSourceBuilding(null); + false; + } - return MovingToContainerSource; - } - else - { - //!!jeszcze transportBase - //probujemy jeszcze znalezc wolny kontener - uContainer = FindSingleContainer(); - if (uContainer) - { - m_nContainerX = uContainer.GetLocationX(); - m_nContainerY = uContainer.GetLocationY(); - m_nContainerZ = uContainer.GetLocationZ(); - m_nCurrPutGetX = GetContainerTakeLocationX(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nCurrPutGetY = GetContainerTakeLocationY(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nCurrPutGetZ = GetContainerTakeLocationZ(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nGetContainerFrom = 1; - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); - return MovingToContainerSource; - } - else - { - return Nothing; - } - } - } - } - } - else - { - uBuilding = GetDestinationBuilding();//aby sie upewnic czy zabity (i skasowac referencje w kodzie) - if (uBuilding == null) - { - //z jakiegos powodu nie zdolalismy oddac kontenera - znalezc nowa rafinerie - uBuilding = FindContainerRefineryBuilding(); - } - if (uBuilding != null) - { - SetDestinationBuilding(uBuilding); - m_nCurrPutGetX = GetDestinationBuildingPutLocationX(); - m_nCurrPutGetY = GetDestinationBuildingPutLocationY(); - m_nCurrPutGetZ = GetDestinationBuildingPutLocationZ(); - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + command SetContainerSource(unit uTarget) hidden button "translateCommandSetMine"{ + SetSourceBuilding(uTarget); + m_nGetContainerFrom=0; + if(!HaveContainer()){ + m_nCurrPutGetX=GetSourceBuildingTakeLocationX(); + m_nCurrPutGetY=GetSourceBuildingTakeLocationY(); + m_nCurrPutGetZ=GetSourceBuildingTakeLocationZ(); + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + state MovingToContainerSource; + }else{ + if(GetDestinationBuilding()!=null){ + m_nCurrPutGetX=GetDestinationBuildingPutLocationX(); + m_nCurrPutGetY=GetDestinationBuildingPutLocationY(); + m_nCurrPutGetZ=GetDestinationBuildingPutLocationZ(); + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + state MovingToContainerDestination; + } + } + NextCommand(true); + true; + } - return MovingToContainerDestination; - } - else - { - //!!transportBase - return Nothing; - } - } - } - } + command GetSingleContainer(unit uTarget) hidden button "translateCommandGetContainer"{ + m_nContainerX=uTarget.GetLocationX(); + m_nContainerY=uTarget.GetLocationY(); + m_nContainerZ=uTarget.GetLocationZ(); + m_nGetContainerFrom=1; + if(!HaveContainer()){ + m_nCurrPutGetX=GetContainerTakeLocationX(m_nContainerX, m_nContainerY, m_nContainerZ); + m_nCurrPutGetY=GetContainerTakeLocationY(m_nContainerX, m_nContainerY, m_nContainerZ); + m_nCurrPutGetZ=GetContainerTakeLocationZ(m_nContainerX, m_nContainerY, m_nContainerZ); + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + state MovingToContainerSource; + }else{ + if(GetDestinationBuilding()!=null){ + m_nCurrPutGetX=GetDestinationBuildingPutLocationX(); + m_nCurrPutGetY=GetDestinationBuildingPutLocationY(); + m_nCurrPutGetZ=GetDestinationBuildingPutLocationZ(); + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + state MovingToContainerDestination; + } + } + NextCommand(true); + true; + } - //------------------------------------------------------- - state Froozen - { - if (IsFroozen()) - { - state Froozen; - } - else - { - //!!wrocic do tego co robilismy - state Nothing; - } - } - event OnFreezeForSupplyOrRepair(int nFreezeTicks) - { - CallFreeze(nFreezeTicks); - state Froozen; - true; - } - //------------------------------------------------------- + command SetContainerDestination(unit uTarget) hidden button "translateCommandSetRefinery"{ + SetDestinationBuilding(uTarget); + if(HaveContainer()){ + m_nCurrPutGetX=GetDestinationBuildingPutLocationX(); + m_nCurrPutGetY=GetDestinationBuildingPutLocationY(); + m_nCurrPutGetZ=GetDestinationBuildingPutLocationZ(); + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + state MovingToContainerDestination; + }else{ + if(GetSourceBuilding()!=null){ + m_nCurrPutGetX=GetSourceBuildingTakeLocationX(); + m_nCurrPutGetY=GetSourceBuildingTakeLocationY(); + m_nCurrPutGetZ=GetSourceBuildingTakeLocationZ(); + m_nGetContainerFrom=0; + CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + state MovingToContainerSource; + } + } + NextCommand(true); + true; + } - //------------------------------------------------------- - command Initialize() - { - m_nGetContainerFrom = 0; - //pozwolic dzialkom strzelac samym (o ile sa jakies) - SetCannonFireMode(-1, 1); - false; - } - //------------------------------------------------------- - command Uninitialize() - { - //wykasowac referencje - SetDestinationBuilding(null); - SetSourceBuilding(null); - false; - } - //------------------------------------------------------- + command Move(int nGx, int nGy, int nLz) button "translateCommandMove" description "translateCommandMoveDescription" hotkey priority 21{ + m_nMoveToX=nGx; + m_nMoveToY=nGy; + m_nMoveToZ=nLz; + CallMoveToPoint(m_nMoveToX, m_nMoveToY, m_nMoveToZ); + state StartMoving; + true; + } - /*bez nazwy - wywolywane po kliknieciu kursorem */ - command SetContainerSource(unit uTarget) hidden button "translateCommandSetMine" - { - SetSourceBuilding(uTarget); - m_nGetContainerFrom = 0; - if (!HaveContainer()) - { - m_nCurrPutGetX = GetSourceBuildingTakeLocationX(); - m_nCurrPutGetY = GetSourceBuildingTakeLocationY(); - m_nCurrPutGetZ = GetSourceBuildingTakeLocationZ(); - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + command Enter(unit uEntrance) hidden button "translateCommandEnter"{ + m_nMoveToX=GetEntranceX(uEntrance); + m_nMoveToY=GetEntranceY(uEntrance); + m_nMoveToZ=GetEntranceZ(uEntrance); + CallMoveInsideObject(uEntrance); + state StartMoving; + true; + } - state MovingToContainerSource; - } - else - { - if (GetDestinationBuilding() != null) - { - m_nCurrPutGetX = GetDestinationBuildingPutLocationX(); - m_nCurrPutGetY = GetDestinationBuildingPutLocationY(); - m_nCurrPutGetZ = GetDestinationBuildingPutLocationZ(); - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); + command Stop() button "translateCommandStop" description "translateCommandStopDescription" hotkey priority 20{ + CallStopMoving(); + state StartMoving; + true; + } - state MovingToContainerDestination; - } - } - NextCommand(true); - true; - } - //------------------------------------------------------- - command GetSingleContainer(unit uTarget) hidden button "translateCommandGetContainer" - { - m_nContainerX = uTarget.GetLocationX(); - m_nContainerY = uTarget.GetLocationY(); - m_nContainerZ = uTarget.GetLocationZ(); - m_nGetContainerFrom = 1; - if (!HaveContainer()) - { - m_nCurrPutGetX = GetContainerTakeLocationX(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nCurrPutGetY = GetContainerTakeLocationY(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nCurrPutGetZ = GetContainerTakeLocationZ(m_nContainerX, m_nContainerY, m_nContainerZ); - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); - - state MovingToContainerSource; - } - else - { - if (GetDestinationBuilding() != null) - { - m_nCurrPutGetX = GetDestinationBuildingPutLocationX(); - m_nCurrPutGetY = GetDestinationBuildingPutLocationY(); - m_nCurrPutGetZ = GetDestinationBuildingPutLocationZ(); - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); - - state MovingToContainerDestination; - } - } - NextCommand(true); - true; - } - //------------------------------------------------------- - command SetContainerDestination(unit uTarget) hidden button "translateCommandSetRefinery" - { - SetDestinationBuilding(uTarget); - if (HaveContainer()) - { - m_nCurrPutGetX = GetDestinationBuildingPutLocationX(); - m_nCurrPutGetY = GetDestinationBuildingPutLocationY(); - m_nCurrPutGetZ = GetDestinationBuildingPutLocationZ(); - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); - - state MovingToContainerDestination; - } - else - { - if (GetSourceBuilding() != null) - { - m_nCurrPutGetX = GetSourceBuildingTakeLocationX(); - m_nCurrPutGetY = GetSourceBuildingTakeLocationY(); - m_nCurrPutGetZ = GetSourceBuildingTakeLocationZ(); - m_nGetContainerFrom = 0; - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ); - - state MovingToContainerSource; - } - } - NextCommand(true); - true; - } - //------------------------------------------------------- - command Move(int nGx, int nGy, int nLz) button "translateCommandMove" description "translateCommandMoveDescription" hotkey priority 21 - { - m_nMoveToX = nGx; - m_nMoveToY = nGy; - m_nMoveToZ = nLz; - CallMoveToPoint(m_nMoveToX, m_nMoveToY, m_nMoveToZ); - state StartMoving; - true; - } - //------------------------------------------------------- - command Enter(unit uEntrance) hidden button "translateCommandEnter" - { - m_nMoveToX = GetEntranceX(uEntrance); - m_nMoveToY = GetEntranceY(uEntrance); - m_nMoveToZ = GetEntranceZ(uEntrance); - CallMoveInsideObject(uEntrance); - state StartMoving; - true; - } - //------------------------------------------------------- - command Stop() button "translateCommandStop" description "translateCommandStopDescription" hotkey priority 20 - { - CallStopMoving(); - state StartMoving; - true; - } - //------------------------------------------------------- - command SetLights(int nMode) button lights priority 204 - { - if (nMode == -1) - { - lights = (lights + 1) % 3; - } - else - { - assert(nMode == 0); - lights = nMode; - } - SetLightsMode(lights); - } - //------------------------------------------------------- - command SpecialChangeUnitsScript() button "translateCommandChangeScript" description "translateCommandChangeScriptDescription" hotkey priority 254 - { - //special command - no implementation - } - //------------------------------------------------------- - /* - command UserNoParam0() button "Find" - { - unit uContainer; - uContainer = FindSingleContainer(); - if (uContainer) - { - m_nContainerX = uContainer.GetLocationX(); - m_nContainerY = uContainer.GetLocationY(); - m_nContainerZ = uContainer.GetLocationZ(); - m_nCurrPutGetX = GetContainerTakeLocationX(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nCurrPutGetY = GetContainerTakeLocationY(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nCurrPutGetZ = GetContainerTakeLocationZ(m_nContainerX, m_nContainerY, m_nContainerZ); - m_nGetContainerFrom = 1; - CallMoveToPointForce(m_nCurrPutGetX, m_nCurrPutGetY, m_nCurrPutGetZ,); - - state MovingToContainerSource; - } - } - */ - //------------------------------------------------------- + command SetLights(int nMode) button lights priority 204{ + if(nMode==-1){ + lights=(lights+1)%3; + }else{ + assert(nMode==0); + lights=nMode; + } + SetLightsMode(lights); + } + command SpecialChangeUnitsScript() button "translateCommandChangeScript" description "translateCommandChangeScriptDescription" hotkey priority 254{ + //special command - no implementation + } } diff --git a/trunk/Scripts/Units/Repairer.ec b/trunk/Scripts/Units/Repairer.ec index cb16f8e..e9d4008 100644 --- a/trunk/Scripts/Units/Repairer.ec +++ b/trunk/Scripts/Units/Repairer.ec @@ -37,34 +37,11 @@ repairer "translateScriptNameRepairer"{ MAX_DISTANCE_FOR_AUTOMODE = 8; - findTargetWaterUnit = 1; - findTargetFlyingUnit = 2; - findTargetNormalUnit = 4; - findTargetBuildingUnit = 8; - findTargetAnyUnit = 15; - - //typ rasy (jakich IFF'ow szukamy - findEnemyUnit = 1; - findAllyUnit = 2; - findNeutralUnit = 4; - findOurUnit = 8; - - //kryterium szukania - findDisabledUnit = 8; - findDamagedUnit =16; - - //typ szukanego obiektu - findDestinationCivilUnit = 1; - findDestinationArmedUnit = 2; - findDestinationRepairerUnit = 4; - findDestinationSupplyUnit = 8; - findDestinationAnyUnit = 15; - //nOperation - operationRepair = 0; - operationCapture = 1; - operationRepaint = 2; - operationUpgrade = 3; + OPERATION_REPAIR = 0; + OPERATION_CAPTURE = 1; + OPERATION_REPAINT = 2; + OPERATION_UPGRADE = 3; } int nMoveToX; @@ -220,21 +197,21 @@ repairer "translateScriptNameRepairer"{ if(comboAutoRepairMode==AUTOREPAIR_ON){ if(FindTargetToRepair()){ - nOperation=operationRepair; + nOperation=OPERATION_REPAIR; CallMoveToPointForce(nMoveToX, nMoveToY, nMoveToZ); return MovingToTarget; } } if(comboAutoCaptureMode==AUTOCAPTURE_ON){ if(FindTargetToCapture()){ - nOperation=operationCapture; + nOperation=OPERATION_CAPTURE; CallMoveToPointForce(nMoveToX, nMoveToY, nMoveToZ); return MovingToTarget; } } if(comboAutoUpgradeMode==AUTOUPGRADE_ON){ if(FindTargetToUpgrade()){ - nOperation=operationUpgrade; + nOperation=OPERATION_UPGRADE; CallMoveToPointForce(nMoveToX, nMoveToY, nMoveToZ); return MovingToTarget; } @@ -265,10 +242,10 @@ repairer "translateScriptNameRepairer"{ if(IsMoving()){ if( !uTarget.IsFroozen() && - (nOperation==operationRepair && CanBeRepaired(uTarget)) || - (nOperation==operationCapture && CanBeConverted(uTarget)) || - (nOperation==operationRepaint && CanBeRepainted(uTarget)) || - (nOperation==operationUpgrade && CanBeUpgraded(uTarget)) + (nOperation==OPERATION_REPAIR && CanBeRepaired(uTarget)) || + (nOperation==OPERATION_CAPTURE && CanBeConverted(uTarget)) || + (nOperation==OPERATION_REPAINT && CanBeRepainted(uTarget)) || + (nOperation==OPERATION_UPGRADE && CanBeUpgraded(uTarget)) ){ if(!IsGoodPointForOperateOnTarget(uTarget, nMoveToX, nMoveToY, nMoveToZ)){ //target has moved nMoveToX=GetOperateOnTargetLocationX(uTarget); @@ -279,14 +256,14 @@ repairer "translateScriptNameRepairer"{ return MovingToTarget; } //unable to find operation point for target - nOperation=operationRepair; + nOperation=OPERATION_REPAIR; CallStopMoving(); SetTarget(null); NextCommand(true); return Nothing; } }else{ - nOperation=operationRepair; + nOperation=OPERATION_REPAIR; CallStopMoving(); SetTarget(null); NextCommand(true); @@ -294,9 +271,8 @@ repairer "translateScriptNameRepairer"{ } return MovingToTarget; } - //sprawdzic czy w punkcie w ktorym jestesmy mozemy zaczac naprawe if(IsInGoodPointForOperateOnTarget(uTarget)){ - if(nOperation==operationRepair){ + if(nOperation==OPERATION_REPAIR){ if(CanBeRepaired(uTarget)){ CallRepair(uTarget); return Repairing; @@ -305,7 +281,7 @@ repairer "translateScriptNameRepairer"{ NextCommand(true); return Nothing; } - if(nOperation==operationCapture){ + if(nOperation==OPERATION_CAPTURE){ if(CanBeConverted(uTarget)){ CallConvert(uTarget); return Converting; @@ -314,7 +290,7 @@ repairer "translateScriptNameRepairer"{ NextCommand(true); return Nothing; } - if(nOperation==operationRepaint){ + if(nOperation==OPERATION_REPAINT){ if(CanBeRepainted(uTarget)){ CallRepaint(uTarget, nRepaintSideColor); return Repainting; @@ -323,7 +299,7 @@ repairer "translateScriptNameRepairer"{ NextCommand(true); return Nothing; } - //assert nOperation==operationUpgrade; + //assert nOperation==OPERATION_UPGRADE; if(CanBeUpgraded(uTarget)){ CallUpgrade(uTarget); return Upgrading; @@ -340,7 +316,7 @@ repairer "translateScriptNameRepairer"{ return MovingToTarget; } //unable to find operation point for target - nOperation=operationRepair; + nOperation=OPERATION_REPAIR; CallStopMoving(); SetTarget(null); NextCommand(true); @@ -352,7 +328,6 @@ repairer "translateScriptNameRepairer"{ return Repairing, 5; } if(CanBeRepaired(uTarget)){ - //z jakiegos powodu jeszcze go nie naprawilismy - odjechal ? nMoveToX=GetOperateOnTargetLocationX(uTarget); nMoveToY=GetOperateOnTargetLocationY(uTarget); nMoveToZ=GetOperateOnTargetLocationZ(uTarget); @@ -369,7 +344,6 @@ repairer "translateScriptNameRepairer"{ return Converting, 5; } if(CanBeConverted(uTarget)){ - //z jakiegos powodu jeszcze go nie skonvertowaliœmy - odjechal ? nMoveToX=GetOperateOnTargetLocationX(uTarget); nMoveToY=GetOperateOnTargetLocationY(uTarget); nMoveToZ=GetOperateOnTargetLocationZ(uTarget); @@ -386,7 +360,6 @@ repairer "translateScriptNameRepairer"{ return Repainting, 5; } if(uTarget.IsLive() && (uTarget.GetSideColor()!=nRepaintSideColor)){ - //z jakiegos powodu jeszcze go nie pomalowalismy - odjechal ? nMoveToX=GetOperateOnTargetLocationX(uTarget); nMoveToY=GetOperateOnTargetLocationY(uTarget); nMoveToZ=GetOperateOnTargetLocationZ(uTarget); @@ -403,7 +376,6 @@ repairer "translateScriptNameRepairer"{ return Upgrading, 5; } if(uTarget.IsLive() && CanBeUpgraded(uTarget)){ - //z jakiegos powodu jeszcze go nie zubgradeowalismy - odjechal ? nMoveToX=GetOperateOnTargetLocationX(uTarget); nMoveToY=GetOperateOnTargetLocationY(uTarget); nMoveToZ=GetOperateOnTargetLocationZ(uTarget); @@ -441,7 +413,7 @@ repairer "translateScriptNameRepairer"{ } } if(nColor>nMaxColor){ - for(nColor=0;nColor