Page 1 of 1

making the nuke weapon purchasable

Posted: Fri Feb 16, 2024 9:23 pm
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

Re: making the nuke weapon purchasable

Posted: Wed Feb 21, 2024 12:28 pm
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.

Re: making the nuke weapon purchasable

Posted: Fri Feb 23, 2024 1:29 pm
by Yoghurt
Awesome!!! Yesss!!! Thank you :D

Re: making the nuke weapon purchasable

Posted: Fri Feb 23, 2024 7:02 pm
by Matt

Re: making the nuke weapon purchasable

Posted: Tue Feb 27, 2024 1:51 pm
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)

Re: making the nuke weapon purchasable

Posted: Wed Feb 28, 2024 12:04 am
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.