Created
September 5, 2025 13:10
-
-
Save bukowa/b5816b1b38326a66fc364dfc69c785ec to your computer and use it in GitHub Desktop.
script2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Clear the console output for a clean view | |
| consul.console.clear() | |
| -- Shortcut function to write messages into the Consul console | |
| function wr(x) | |
| consul.console.write(x) | |
| end | |
| -- Get the first army from the first alliance | |
| local army1 = bm:alliances():item(1):armies():item(1) | |
| -- Get the first army from the second alliance | |
| local army2 = bm:alliances():item(2):armies():item(1) | |
| -- Create unit controllers for each army | |
| -- Unit controllers are used to issue commands to units in the army | |
| local uc1 = army1:create_unit_controller() | |
| local uc2 = army2:create_unit_controller() | |
| -- Add all units of army1 to its unit controller | |
| for i = 1, army1:units():count() do | |
| uc1:add_units(army1:units():item(i)) | |
| end | |
| -- Add all units of army2 to its unit controller | |
| for i = 1, army2:units():count() do | |
| uc2:add_units(army2:units():item(i)) | |
| end | |
| -- Take control of units | |
| uc1:take_control() | |
| uc2:take_control() | |
| -- Disable fire at will | |
| uc1:fire_at_will(false) | |
| uc2:fire_at_will(false) | |
| -- Teleport units | |
| uc1:teleport_to_location(battle_vector:new(100,0,500), 0, 100) | |
| uc2:teleport_to_location(battle_vector:new(100,0,800), 180, 100) | |
| -- Create new unit controls for both armies, of general and Ger Youth | |
| ucg1 = army1:create_unit_controller() | |
| ucg1:add_units(army1:units():item(1)) | |
| ucg1:add_units(army1:units():item(10)) | |
| ucg2 = army2:create_unit_controller() | |
| ucg2:add_units(army2:units():item(1)) | |
| ucg2:add_units(army2:units():item(14)) | |
| -- Take control of units | |
| ucg1:take_control() | |
| ucg2:take_control() | |
| -- Teleport units | |
| ucg1:teleport_to_location(battle_vector:new(100,0,600), 0, 100) | |
| ucg2:teleport_to_location(battle_vector:new(100,0,700), 180, 100) | |
| -- Start taunt | |
| ucg1:start_taunting() | |
| ucg2:start_taunting() | |
| -- Create unit control for enemy youths | |
| ucg2y = army2:create_unit_controller() | |
| ucg2y:add_units(army2:units():item(14)) | |
| -- Make them step forward | |
| ucg2y:step_forward() | |
| -- Make them attack general | |
| ucg2y:change_move_speed(true) | |
| ucg2y:attack_unit(army1:units():item(1), true) | |
| -- Remove any previous callback watchers | |
| clbname = "unique_callback" | |
| bm:remove_process(clbname) | |
| -- Create a callback that will check for ammunition of unit | |
| -- Once it goes to 0, order another attack move | |
| bm:repeat_callback(function() | |
| consul.console.clear() | |
| local unit = army2:units():item(14) | |
| local ammo_left = unit:ammo_left() | |
| consul.console.write("ammo left: " .. ammo_left) | |
| if ammo_left == 0 then | |
| -- Ammo is gone, attack again | |
| consul.console.write("attack melee!") | |
| ucg2y:attack_unit(army1:units():item(1), true) | |
| -- Stop the ammo check callback | |
| bm:remove_process(clbname) | |
| -- Call a new callback to check if the unit is routing | |
| bm:repeat_callback(function() | |
| if unit:is_routing() then | |
| consul.console.write("unit is routing, kill our general") | |
| army1:units():item(1):kill_number_of_men(300) | |
| bm:remove_process("routing_check") -- Use a new process name | |
| end | |
| end, 1000, "routing_check") | |
| else | |
| -- Just keep attacking in case there's no more range! | |
| ucg2y:attack_unit(army1:units():item(1), true) | |
| end | |
| end, 1000, clbname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment