I was trying to make a custom unit...

Started by Ondrejoda, June 11, 2017, 10:48:24 AM

Previous topic - Next topic

Ondrejoda

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?

Builder17

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

Ondrejoda

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

Nicant

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
It shows every command you can use in CRPL and tells you how to use it too!
CW4 hype!!

Builder17

What should this custom unit do?
Knowing it could help us

There should be comparator before if

Self CONST_AMMOAC GetUnitAttribute 10 gte
if
   

Ondrejoda

#5
I was thinking about a unit, that you put in AC, and it makes AC around, just for a test.

Ondrejoda

And acually, can i make a unit, that will work like a Energy to AC Converter, or a different type of a reactor?

Nicant

CW4 hype!!

Ondrejoda


Nicant

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

Ondrejoda

Thank you all for the code, it is all working as it should.

Ondrejoda

But wait, can i make a different type of a reactor?

GoodMorning

Producing energy is difficult. Spawning standard Reactors or running the power through Siphons is the only really workable means, and both have inherent flaws.
A narrative is a lightly-marked path to another reality.

Ondrejoda

Welll, could you check out the other topic for the chimera cannons?

Ondrejoda

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?