Is there a(n) AC Emitter UID?

Started by Nicant, February 24, 2016, 08:16:47 PM

Previous topic - Next topic

Vanguard

I used "showtrace" instead of "showtracelog", as I noted per the "edit" part. It was a clear mistake on my side ( fast typing code from memory ) and not a case of case-sensitivity. Otherwise you are AbSoLuTeLy cOrReCt.  :-*

Nicant

#16
Quote from: Vanguard on March 16, 2016, 05:16:59 AM
Quote from: Nicant on March 12, 2016, 03:19:19 PM
Ok, the problem about this is how would i make it be able to only find an AC-Emitter in a certain range? I am using this for the Creeper Nullifier. Sorry for long Delay. Tried the script, doesn't seem to pick up AC-Emitters as Emitters. I am just going to make my own AC-Emitter.
1)

45 35 41 33 ->minX ->maxX ->minY ->maxY
# Now use the values for the Loop in the code above to loop through the terrain instead of mapwidth. Easy enough.

2) What exactly do you get from the codesnippet? Simply stating "it does not pikc up AC emitters" is, in my opinion, nonsense since technically there are only "EMITTERS", some of which put a positive value of creep on the map, some of which do put a negative amount of creep on the map.

So, if the script does not pick up an "EMITTER", there has to be the mistake.

Put two emitters on the map, one positive, one negative. Attach the measurement scrtipt to a CRPL core and activate the trace. Run the script every thirty frames and see if the problem is simply that at map start the emitters were not initialized yet, or something as simple as that.

You really don´t need to reinvent the wheel here. Just go through the usual debug.


#untested code idea, not at home, can´t test.
#loop through entire map and get the unit ID. if it is an emitter, we continue getting the production amount.
once
45 35 41 33 ->minX ->maxX ->minY ->maxY
showTraceLog
endonce

<-maxX <-minX do
<-maxY <-minY do
J I GetUnitAt ->UnitID
<-UnitID GetUnitType "Emitter" if
    Trace("Script found an emitter with unitID: " <-unitID concat)
    # Getting the Production amount to test
    <-UnitID 0 "productionAmt" getScriptVar ->productionamt
    Trace("Productionamount detected: " <-productionamt concat)
    # Test if it's negative and store it properly
endif
loop
loop
trace("Loop finished, sleeping 30")
30 delay


This should give you a fairly accurate idea of where you are with your code. As always: Untested code.

edited: Replaced "showtrace" with Builder17´s correction in script

Dosen't work. Moved the AC-Emitter and Normal Emitter everywhere on the map and nothing. The map size was 50X50.
CW4 hype!!

Builder17

#17
Should "EMITTER" in Getunittype be in all caps?

Vanguard

#18
Like I said, untested code. If the code doesn´t even pick up a regular type emitter, then yes, obviously there is something broken very badly.

Try "EMITTER" and see if that changes anything. I´ve been too busy dividing(punpunpun) my time between games lately to test it myself. Also for testing, the <-mapwidth code is better, simply becase you don´t need to care about positioning.

Also, try this: put an emitter on your map and note the coordinates. Try the top left corner. For example put it at X 3 Y 3 and note the coordinates.

Then run this code:


once
showTraceLog


3 3  GetUnitAt ->UnitID
trace (<-UnitID)
# Or EMITTER or EmItTeR or whatever works Check the CRPL reference.
<-UnitID GetUnitType "Emitter" if
trace(<-UnitID " This unitID is an emitter" concat)
else
trace (<-UnitID " This unit was not taken for an emitter" concat)
endif

0 ->productionamt
<-UnitID 0 "productionAmt" getScriptVar ->productionamt

<-productionamt 0 eq if
trace ("No productionamount was retrieved from the object")
endif
<-productionamt 0 gt if
trace ("The production amount of: " <-productionamt " was positive" concat concat)
endif
<-productionamt 0 lt if
trace ("The production amount of: " <-productionamt " was negative" concat concat)
endif

endonce


You really should familiarize yourself with the basic concepts of debugging, Nicant, whereas you need to catch EVERY possible outcome of your script and trying to break complex problems down to very simple problems. This will help you to see where the programs takes it decisions. The IF/ELSE construct is quintessential. Even seeing yourself that the script simply does not grab the emitter as intended will tell you, were the problem is. So negative/bad information is useful information.

This is in no way meant to be critique, I fully intend to be helpful and I hope my answer got you closer to the solution of your problem.  8)

Nicant

#19
Quote from: Vanguard on March 18, 2016, 08:25:57 AM
Like I said, untested code. If the code doesn´t even pick up a regular type emitter, then yes, obviously there is something broken very badly.

Try "EMITTER" and see if that changes anything. I´ve been too busy dividing(punpunpun) my time between games lately to test it myself. Also for testing, the <-mapwidth code is better, simply becase you don´t need to care about positioning.

Also, try this: put an emitter on your map and note the coordinates. Try the top left corner. For example put it at X 3 Y 3 and note the coordinates.

Then run this code:


once
showTraceLog


3 3  GetUnitAt ->UnitID
trace (<-UnitID)
# Or EMITTER or EmItTeR or whatever works Check the CRPL reference.
<-UnitID GetUnitType "Emitter" if
trace(<-UnitID " This unitID is an emitter" concat)
else
trace (<-UnitID " This unit was not taken for an emitter" concat)
endif

0 ->productionamt
<-UnitID 0 "productionAmt" getScriptVar ->productionamt

<-productionamt 0 eq if
trace ("No productionamount was retrieved from the object")
endif
<-productionamt 0 gt if
trace ("The production amount of: " <-productionamt " was positive" concat concat)
endif
<-productionamt 0 lt if
trace ("The production amount of: " <-productionamt " was negative" concat concat)
endif

endonce


You really should familiarize yourself with the basic concepts of debugging, Nicant, whereas you need to catch EVERY possible outcome of your script and trying to break complex problems down to very simple problems. This will help you to see where the programs takes it decisions. The IF/ELSE construct is quintessential. Even seeing yourself that the script simply does not grab the emitter as intended will tell you, were the problem is. So negative/bad information is useful information.

This is in no way meant to be critique, I fully intend to be helpful and I hope my answer got you closer to the solution of your problem.  8)

Well, i have done many, many tests and i got lots of answers. First, there is a problem with your code, luckily it was a very small one. You forgot to put an "eq" between "Emitter" and "if" at the top of the code. Now, because there is an "eq" now, you would now have to put "Emitter" in all caps now because the "getunitat" outputs "EMITTER" and the "eq" needs it in all caps to be excepted as an emitter! Second, the script does not say that the AC-Emitter is a regular emitter. Which proves that AC-Emitters are not emitters, but something different. I'll have to keep testing though, hopefully i find something that will make it target AC-Emitters! :)

EDIT: I found the AC-Emitter UID!!! The UID for the AC-Emitter is ANTIEMITTER! All i need to do now is have it search for AC-EMITTERS in a specified range. I am also going to see if i can put this on the wiki! Thanks vanguard (and everyone else for helping!), do you want to be credited for helping me with the CNullifier?

EDIT2: Added on the wiki. All i did was add it on the getunittype page. I don't know if there are more pages this should be added to though. :)
CW4 hype!!

J

QuoteEDIT: I found the AC-Emitter UID!!! The UID for the AC-Emitter is ANTIEMITTER! All i need to do now is have it search for AC-EMITTERS in a specified range. I am also going to see if i can put this on the wiki! Thanks vanguard (and everyone else for helping!), do you want to be credited for helping me with the CNullifier?
UID stands for 'unique identifier' and is a number (or any other sequence) the game automatically assigns to units. If the are two AC emitters they have different UIDs. ANTIEMITTER is just a name or an 'identifier', at least it's not unique.

You don't have to credit me, but if you really want to, only in the script is enough.

Builder17

I think GetAllUnitsInRange gets also antiemitters if you use GetUnitType "ANTIEMITTER" eq with it...  :-\

Vanguard

Really really really glad your figured it out Nicant! Way to go.  ;D

Looking forward to your map, mate.  8)

kwinse

If I remember correctly, antiemitters get converted to regular emitters with appropriate negative productionAmt when loading, so watch out for that.