Is there a(n) AC Emitter UID?

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

Previous topic - Next topic

Nicant

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!)
CW4 hype!!

GameGibu

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
Bringing you Custom maps since 2971!
☆CRPL Master☆

Karsten75

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.

Nicant

#3
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! :)
CW4 hype!!

Vanguard

#4
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.

Builder17

Basic enemy units are 0 as script name.

J

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

Vanguard

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?

J

Read carefully, it's already on the wiki: 'Script: 0'

Karsten75

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.

Vanguard

Ah, allright. Well, that actually makes it abundantly clear. Thanks.

Nicant

#11
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.
CW4 hype!!

Vanguard

#12
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

Builder17

It is ShowTraceLog , but looks like nice code.

GoodMorning

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.
A narrative is a lightly-marked path to another reality.