Is there a(n) UID for an AC Emitter? If not, how can i determine AC Emitters? Any help will be greatly appreciated and be credited in my next sleeper map! (This has something to do with the CNullifier and if you do not want to be credited say so!)
The first thing about UIDs is this: every time you start Creeper World 3, the first unit loaded/placed in whatever map you load up first (editor or not) gets UID #0 or #1, and the next unit gets #2 and so on. If you've played a bunch of maps in the same session or loaded/reloaded maps with lots of units in the same session, the number (an int) gets fairly high.
UIDs are not certain from game to game, except maybe for CRPL cores, I'd need to check, so if you cannot find an ac emitter with a command, write your own ac emitter. It's a super simple script compared to the solutions to the rest of the awesome questions you ask. You should be able to make a CRPL AC emitter, with the added benefit of you choosing all its properties. Seriously, the provided AC emitter is nothing more than a frustrating invisibly quasi-CRPL core at the base level.
Hope this helps/inspires you!
-GameGibu
Quote from: GameGibu on February 25, 2016, 01:54:29 AM
The first thing about UIDs is this: every time you start Creeper World 3, the first unit loaded/placed in whatever map you load up first (editor or not) gets UID #0 or #1, and the next unit gets #2 and so on. If you've played a bunch of maps in the same session or loaded/reloaded maps with lots of units in the same session, the number (an int) gets fairly high.
UIDs are not certain from game to game, except maybe for CRPL cores, I'd need to check, so if you cannot find an ac emitter with a command, write your own ac emitter. It's a super simple script compared to the solutions to the rest of the awesome questions you ask. You should be able to make a CRPL AC emitter, with the added benefit of you choosing all its properties. Seriously, the provided AC emitter is nothing more than a frustrating invisibly quasi-CRPL core at the base level.
Hope this helps/inspires you!
-GameGibu
UIDs are not per session. they are per map and ae allocated when the unit is created - either in the map editor or dynamically during gameplay.
Quote from: GameGibu on February 25, 2016, 01:54:29 AM
The first thing about UIDs is this: every time you start Creeper World 3, the first unit loaded/placed in whatever map you load up first (editor or not) gets UID #0 or #1, and the next unit gets #2 and so on. If you've played a bunch of maps in the same session or loaded/reloaded maps with lots of units in the same session, the number (an int) gets fairly high.
UIDs are not certain from game to game, except maybe for CRPL cores, I'd need to check, so if you cannot find an ac emitter with a command, write your own ac emitter. It's a super simple script compared to the solutions to the rest of the awesome questions you ask. You should be able to make a CRPL AC emitter, with the added benefit of you choosing all its properties. Seriously, the provided AC emitter is nothing more than a frustrating invisibly quasi-CRPL core at the base level.
Hope this helps/inspires you!
-GameGibu
Ok thanks! I'll try a CRPL AC Emitter! :)
Edit: You are already credited for something else so you will be credited! :)
Quote from: Nicant on February 24, 2016, 08:16:47 PM
Is there a(n) UID for an AC Emitter? If not, how can i determine AC Emitters? Any help will be greatly appreciated and be credited in my next sleeper map! (This has something to do with the CNullifier and if you do not want to be credited say so!)
#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.
0 <-mapwidth do
0 <-mapheight do
J I GetUnitAt ->UnitID
<-UnitID GetUnitType "Emitter" if
# Getting the Production amount to test. if it is negative, it is an AC emitter
<-UnitID "Scriptname" "PRODUCTIONAMT" getScriptVar ->productionamt
endif
loop
loop
The only thing I don´t know how to handle is the "scriptname". Unless it´s a CRPL core of which you know the scriptname, I don´t know what regular emitters´ scriptnames do look like. Try maybe "Emitter.crpl" or "Emitter" or something.
Basic enemy units are 0 as script name.
A few quickfixes, didn't test either:
#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.
<-mapwidth 0 do
<-mapheight 0 do
J I GetUnitAt ->UnitID
<-UnitID GetUnitType "Emitter" if
# Getting the Production amount to test
<-UnitID 0 "productionAmt" getScriptVar ->productionamt
# Test if it's negative and store it properly
endif
loop
loop
Thanks for the info. Didn´t know about the "0" thing for default units. Should actually be put into the wiki here: https://knucklecracker.com/wiki/doku.php?id=crpl:docs:getscriptvar
Someone got a wiki account and can at least leave a comment?
Read carefully, it's already on the wiki: 'Script: 0'
Quote from: Vanguard on March 08, 2016, 01:15:35 PM
Someone got a wiki account and can at least leave a comment?
Theory is ever forum member has a wiki account - same handle and password. Let me know if it doesn't work for you.
Ah, allright. Well, that actually makes it abundantly clear. Thanks.
Quote from: J on March 08, 2016, 12:59:33 PM
A few quickfixes, didn't test either:
#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.
<-mapwidth 0 do
<-mapheight 0 do
J I GetUnitAt ->UnitID
<-UnitID GetUnitType "Emitter" if
# Getting the Production amount to test
<-UnitID 0 "productionAmt" getScriptVar ->productionamt
# Test if it's negative and store it properly
endif
loop
loop
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.
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
It is ShowTraceLog , but looks like nice code.
I believe that there is no case sensitivity in the function names. Thus, ShowTraceLog, showtracelog, SHOWTRACELOG and SHowtrACELoG should all work. The CaseConvention used is fairly specific to CRPL. Comparing to Java, the C family, etc... will show different conventions. This one works well here, however.
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. :-*
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.
Should "EMITTER" in Getunittype be in all caps?
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)
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. :)
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.
I think GetAllUnitsInRange gets also antiemitters if you use GetUnitType "ANTIEMITTER" eq with it... :-\
Really really really glad your figured it out Nicant! Way to go. ;D
Looking forward to your map, mate. 8)
If I remember correctly, antiemitters get converted to regular emitters with appropriate negative productionAmt when loading, so watch out for that.