making the nuke weapon purchasable

I need some help toggling a condition on when the nuke is fired

Information and discussion for custom maps and mods.
Post Reply
Yoghurt
Posts: 24
Joined: Wed Apr 07, 2021 11:49 am

making the nuke weapon purchasable

Post by Yoghurt »

Hello everyone,

I've successfully found a way to make it so that you have to pay for each use of both the airstrike and ion cannon support powers, however I can't get it to work for the nukepower trait.

In my mod the communications center builds an invisible actor. this actor has the SupportPower trait and kills itself when the camera actor from the SupportPower trait appears.

Since the NukePower trait doesn't have a camera actor I cannot implement the same logic here. I tried but failed using the ToggleConditionOnOrder trait.

I've familiarised myself with yaml but not with lua script yet. I'm not sure if maybe lua would be the answer..?


Please could someone point me in the right direction. Thanks in advance

abcdefg30
Posts: 644
Joined: Mon Aug 18, 2014 6:00 pm

Re: making the nuke weapon purchasable

Post by abcdefg30 »

Hi, one option could be using an ion cannon power with a dummy actor that is purchasable as you already implemented and then target the dummy actor's location by using "ActivateNukePower" via Lua: https://docs.openra.net/en/release/lua/#support-powers

It is possible but will need some fiddling around.

Yoghurt
Posts: 24
Joined: Wed Apr 07, 2021 11:49 am

Re: making the nuke weapon purchasable

Post by Yoghurt »

Awesome!!! Yesss!!! Thank you :D

Matt
Posts: 1144
Joined: Tue May 01, 2012 12:21 pm
Location: Germany

Re: making the nuke weapon purchasable

Post by Matt »


Yoghurt
Posts: 24
Joined: Wed Apr 07, 2021 11:49 am

Re: making the nuke weapon purchasable

Post by Yoghurt »

Could someone please help me with what's missing in this bit of Lua code.
I called the actor that the nuke would spawn from "CAMERA.nuke". It's supposed to trigger a nuke once it comes into existence. This is what I have so far, but it doesn't work:

Trigger.OnAddedToWorld(CAMERA_nuke, function()
ActivateNukePower()
end)

abcdefg30
Posts: 644
Joined: Mon Aug 18, 2014 6:00 pm

Re: making the nuke weapon purchasable

Post by abcdefg30 »

OnAddedToWorld takes a reference to an already existing actor. The easiest option would probably to check in the Tick function if Map.ActorsInWorld has any actor with type "CAMERA.nuke". (But can lead to worse performance, you'll have to try it.) Alternatively you'd need to define a cell trigger over the entire map to notice when such a camera actor is spawned (a lot of work). How do you currently spawn the "CAMERA.nuke" actor? Depending on that the best alternative could be detecting when the dummy that spawns the camera dies, i.e. add a Trigger.OnAnyProduction and detect when a dummy is built, then add a Trigger.OnKilled to the dummy and then you can call another Lua function from there.

Post Reply