Main Menu

Enemy AI

Started by Builder17, May 05, 2016, 01:21:51 AM

Previous topic - Next topic

Builder17

I give up with this one , it's meant to rebuild enemy unit under it if it has digitalis and powerzone under it

GoodMorning

Your form seems to be:

once
  @MakeInvisible
  @GetEnemy
endonce

@EnemyBroken if
  @GetPZ #Check for a PZ, if so get the UID and record success.
  <-PZ_Found if
    @PulseCreeper
    @EnoughDigi if
      @Rebuild
      @DestroyPZ
    endif
  endif
endif


I notice a number of inconsistencies, firstly in the number of parameters provided to GetInRange -type functions, and the "do" loops.
If you wish, I shall build this, but for Emitters only.

You seem not to have accounted for the fact that an Emitter will have dropped a PZ when destroyed, so it will rebuild indefinitely. The Digi criterion will not help, as Emitters, I believe, constantly regenerate the Digi, so it won't have time to be killed. Also, there may be a 1-frame gap where a unit might be ordered to come here.

Good idea, but it needs a bit more to execute. Want me to take a look when time allows?
A narrative is a lightly-marked path to another reality.

Builder17

#2
I am having map what I used to test this , do you want to see it before you take a look into this better?  :-\

I want that it gets enemy type and makes at least default version of it after there is digitalis and PZ under it , can that be done using something like:
<-EnemyType "EMITTER" eq if
   "EMITTER" CurrentCoords CreateUnit
endif
<-EnemyType "SPORETOWER" eq if
   "SPORETOWER" CurrentCoords CreateUnit
endif
etc. I am not sure about this.  :'(

GoodMorning

It shouldn't be a problem. I'm likely to not have much time for a while, but when I do, this shouldn't take too long.

The only thing I am unsure of is: Do you wish the PZ created by, say, a Spore Tower being destroyed to count, or must it be pre-existing?

It can be done. Indeed, that's how it will be done. It's the optimisation and conditions that take time.
A narrative is a lightly-marked path to another reality.

Builder17

When you nullify normal enemy it gives PZ . Rebuilder.crpl gets that PZ UID , if enemy is destroyed.

You need any other information?

GoodMorning

I thought you meant something else. Never mind. I infer you mean only to eat the PZ dropped.
A narrative is a lightly-marked path to another reality.

GoodMorning

Here you go. It's untested, but the most suspect parts are the GetUnitType return, and the 0 range on the GetAllUnitsInRange call.
Note that this will not work well with multiple PZs/Emitters stacked. I'm not sure if the Digi term should be only "full health", but that's your decision.


#Rebuilder, as requested by Builder17

#To allow attachment to other cores,
#we do not change visibility/PZ attributes

$Rebuild_Delay:30
$Require_Digi:1

once
  CurrentCoords 0 0 GetAllUnitsInRange 0 do
    ->UID
<-UID GetUnitType ->Type
<-Type "EMITTER" eq if
  <-UID ->EmitterID
  <-UID 0 "PRODUCTIONINTERVAL" GetScriptVar ->Int
  <-UID 0 "PRODUCTIONAMT" GetScriptVar ->Amt
endif
  loop
 
  0 ->BreakPulseDone
endonce

CurrentCoords 0 0 GetAllUnitsInRange 0 do
    ->UID
<-UID GetUnitType ->Type
<-Type "POWERZONE" eq if
 
  <-BreakPulseDone not if
    1 ->BreakPulseDone
CurrentCoords 2000 SetCreeperNoLower
  endif
 
  <-Rebuild_Delay Delay
 
  CurrentCoords GetDigitalis 0 gt <-Require_Digi not or if
    <-UID 0 Destroy
 
    "EMITTER" CurrentCoords CreateUnit ->UID
    <-UID 0 "PRODUCTIONINTERVAL" <-Int SetScriptVar
    <-UID 0 "PRODUCTIONAMT" <-Amt SetScriptVar

0 ->BreakPulseDone
  endif
endif
loop
A narrative is a lightly-marked path to another reality.