I was trying to make a custom unit, but i just found a problem. I am trying to find a way how to detect stored energy or AC, but I dont know the command. Could someone help me?
Self CONST_AMMO GetUnitAttribute This gets current ammo of CRPLCORE script is in
Self CONST_AMMOAC GetUnitAttribute This gets current AC of CRPLCORE script is in
If you want get some other unit ammo/AC change Self to UID of unit
Also it would be nice to see that script you are making, just curious
Thank you, but then how do i reduce the stored ammount of AC/ammo?
Code:
Self CONST_AMMOAC GetUnitAttribute
if
CurrentCoords -10 AddCreeper
Delay 15
endif
To modify attributes, all you need to do is getunitattribute to setunitattribute and put a value in.
Here are some examples...
Self CONST_AMMO 10 SetUnitAttribute
Self CONST_AMMOAC 5 SetUnitAttribute
The 10 and 5 are where you place your value to change the attribute. This link may be helpful to you... http://knucklecracker.com/wiki/doku.php?id=crpl:crplreference (http://knucklecracker.com/wiki/doku.php?id=crpl:crplreference)
It shows every command you can use in CRPL and tells you how to use it too!
What should this custom unit do?
Knowing it could help us
There should be comparator before if
Self CONST_AMMOAC GetUnitAttribute 10 gte
if
I was thinking about a unit, that you put in AC, and it makes AC around, just for a test.
And acually, can i make a unit, that will work like a Energy to AC Converter, or a different type of a reactor?
Yes, that's possible!
And how can I make that unit?
Heres the code for that unit! It will take in ammo and produce AC! I had nothing to do so i made it for you! You can even use this for your other units as a template
# EnergyToAC.crpl
# Created on: 6/11/2017 5:24:08 PM
# ------------------------------------------
once
Self CONST_MAXAMMO 25 SetUnitAttribute #Sets maximum ammo
Self CONST_AMMO 0 SetUnitAttribute #Sets ammo to 0
Self CONST_CONNECTABLE True SetUnitAttribute #Makes sure unit can connect to collectors
Self CONST_CANREQUESTAMMO True SetUnitAttribute #Makes sure unit can request ammo packets
Self CONST_SHOWAMMOBAR True SetUnitAttribute #Shows the ammo bar for the unit
0 SetTimer0 #Sets timer0 to 0 Timers are more useful than delays because they do not "freeze" the core
endonce
GetTimer0 eq0 if #Wait till the timer is at 0
Self CONST_AMMO GetUnitAttribute ->Ammo #Check how much ammo it has
<-Ammo 1 gte if #Check and see if there is atleast 1 ammo in it's ammo store
<-Ammo 1 sub ->Ammo #Subtract the total ammo supply by 1
CurrentCoords -10 AddCreeper #Makes anti creeper positive numbers for creeper, negative numbers for anti-creeper.
Self CONST_AMMO <-Ammo SetUnitAttribute #Sets the ammo to the amount of ammo that it has from the subtractor
30 SetTimer0 #Sets the timer to wait for 1 second. 30 frames = 1 second
endif
endif
Thank you all for the code, it is all working as it should.
But wait, can i make a different type of a reactor?
Producing energy is difficult. Spawning standard Reactors or running the power through Siphons is the only really workable means, and both have inherent flaws.
Welll, could you check out the other topic for the chimera cannons?
Well, can i make a custom "AC Bertha", that the AC Bertha will have Auto Target for creeper, and when the AC bullet lands,it will make AC arround it.
Is it possible?
And can i make a Creeper Bertha, what will work the same as the AC Bertha, too?
It's possible, but the effect can vary.
An AC Bertha would likely operate by flattening Creeper in the area, much as a normal Bertha, and then placing AC where it was. There's also the "titanic AC payload" option.
You can also have it operate as a conversion.
And, could someone give me the two parts (the body and the barrel) of the sprayer?
GoodMorning, could you give me the code for the first idea of the AC Bertha? (the first idea is the flattering and then putting down AC)
Well, I don't have scripts on hand, but it is possible.
I think you should talk to Nicant, who has built a Sleeper Bertha. The following commands may prove helpful:
http://knucklecracker.com/wiki/doku.php?id=crpl:docs:damagecreeper
http://knucklecracker.com/wiki/doku.php?id=crpl:docs:shortestangle
http://knucklecracker.com/wiki/doku.php?id=crpl:docs:addcreeper
http://knucklecracker.com/wiki/doku.php?id=crpl:docs:getdeepestcreepercell
If you want images for units, then you can get most of them here: http://knucklecracker.com/wiki/doku.php?id=crpl:custom_image_repository (http://knucklecracker.com/wiki/doku.php?id=crpl:custom_image_repository)
Or here: http://knucklecracker.com/wiki/doku.php?id=cw3:units:concepts (http://knucklecracker.com/wiki/doku.php?id=cw3:units:concepts)
Now making a working enemy Bertha is a bit difficult, but once one is made, you could reuse the code and make other turret-like units. Along with the Bertha you would also need a script for the projectile. I will make a rough script later that will help you form together a Bertha.
I must say that the idea to be on the forum wasnt a bad idea... Anyways, thank you!
Well, i just put out the "Bertha" idea, but i found a custom image (the Scout image) and instead of targetin the Creeper/Units, it will find the Higest ammount of Creeper (GetDeepestCreeperCell), then it will do a blast (DamageCreeper) and then it will deploy AC/Creeper (AddCreeper). But I didnt found a solution for the unit to come back to the units and reload. Maby I could locate the Units and Queue the movement..?
Wait, how do I make a code, that it makes CRPLCores with a different code?
The approximate procedure is to write each script, and attach them to different Cores.
You ca also attach the same script to multiple Cores. Or multiple scripts to the same Core.
Wait, I did finally manage to make it! I will upload the image and the code! (Put the Bertha.crpl to the CRPLCore, and dont attact the Bullet.crpl to anyting, just leave it there, put on the CRPLCore any image you want... :D
# Bertha.crpl
# Created on: 6/12/2017 2:42:36 PM
# ------------------------------------------
once
Self CONST_MAXAMMO 250 SetUnitAttribute #Sets maximum ammo
Self CONST_AMMO 0 SetUnitAttribute #Sets ammo to 0
Self CONST_CONNECTABLE True SetUnitAttribute #Makes sure unit can connect to collectors
Self CONST_SHOWAMMOBAR True SetUnitAttribute #Shows the ammo bar for the unit
0 SetTimer0 #Sets timer0 to 0 Timers are more useful than delays because they do not "freeze" the core
endonce
GetTimer0 eq0 if #Wait till the timer is at 0
Self CONST_AMMO GetUnitAttribute ->Ammo #Check how much ammo it has
<-Ammo 250 gte if #Check and see if there is atleast 100 ammo in it's ammo store
<-Ammo 250 sub ->Ammo #Subtract the total ammo supply by 100
CreateUnit("CRPLCore" CurrentCoords) ->Bullet
AddScriptToUnit(<-Bullet "Bullet.crpl")
Self CONST_AMMO <-Ammo SetUnitAttribute #Sets the ammo to the amount of ammo that it has from the subtractor
endif
endif
# Bullet.crpl
# Created on: 6/12/2017 3:10:38 PM
# ------------------------------------------
GetDeepestCreeperCell SetCurrentCoords
CurrentCoords -2500 AddCreeper
Destroy(self 3)
And, I just found a small problem. The problem is that when the bullet explodes, it leaves a Power Zone. Is there a command to turn off the Power Zone after destruction?
Self CONST_CREATEPZ FALSE SetUnitAttribute
In Bullet.crpl there is one zero too much in creeper amount -2500?
Dont matter about the number... I just made it SUUUUUUUUUUUUUUUUUUUUUUUUUUUUPER OP....
And, is it possible to locate a CRPLCore?
Yes, you can use GetCoresWithVar
And, is it possible to make a code that when you hold down the right buttonon the mouse, the CRPLCore will be right on the location of the mouse, and, when I will stop holding the right button on the mouse, the CRPLCore will stop moving?
1 GetMouseButton if #Right mouse button is down
GetMousePosition ->MousePX ->MousePY
Self CONST_PIXELCOORDX <-MousePX SetUnitAttribute
Self CONST_PIXELCOORDY <-MousePY SetUnitAttribute
endif
This should work.
And, can I set the CurrentCoords of a CRPLCore to a different CRPLCore?
Yes, provided you have the UID of the other Core.
Self CONST_PIXELCOORDX <-Other CONST_PIXELCOORDX GetUnitAttribute SetUnitAttribute
...and similarly for Y.
Sorry, but the unit what will move is just going to the Down Left corner...