Stone Posted October 15, 2021 Posted October 15, 2021 So this is a scripting question, of which I am just beginning to learn. I want to be able to damage a static object (building) and capture when remaining life is below a certain percentage so I can then explode and destroy the object. Any help greatly appreciated. Thanks. Intel i7 9700K 4.6GHz · NVIDIA GeForce GTX2080 · AORUS Z390 PRO WIFI-CF · ASUS ROG Swift PG348Q 34" Curved· SK hynix Gold P31 1TB PCIe NVMe Gen3 M.2 2280 Internal SSD · 32Gb 1600MHz DDR4 · Windows 10 Pro · Saitek Cessna Pro Pedals · Thrustmaster Warthog HOTAS · HP Reverb G2
Chump Posted October 15, 2021 Posted October 15, 2021 local unit = <some unit> if unit:getLife() < 1 then unit:destroy() end This will destroy any unit that is destroyed (a bit redundant). If you could be more concise, the answer would probably be more like what you are asking for.
Stone Posted October 16, 2021 Author Posted October 16, 2021 Thanks for the quick reply. So, I put the following into a REPETITIVE ACTION - DO SCRIPT, where 'Static' is the actual name of the static object I'm trying to destroy: local unit = StaticObject.getByName('Static') if unit:getLife() < 100 then unit:destroy() end ...but I can shoot at the Static object until I'm out of ammo and nothing ever happens. I'm either doing something wrong or the static object never seems to register any damage. Any further help welcomed. Thanks. Intel i7 9700K 4.6GHz · NVIDIA GeForce GTX2080 · AORUS Z390 PRO WIFI-CF · ASUS ROG Swift PG348Q 34" Curved· SK hynix Gold P31 1TB PCIe NVMe Gen3 M.2 2280 Internal SSD · 32Gb 1600MHz DDR4 · Windows 10 Pro · Saitek Cessna Pro Pedals · Thrustmaster Warthog HOTAS · HP Reverb G2
Grimes Posted October 16, 2021 Posted October 16, 2021 That will error once the actual object is destroyed because it would basically be nil:getLife(). Anyway, I added a test message that will display the life value as a message. Bomb the target to get an idea of how much damage whichever weapon you are using does to the target. Also Object.destroy() just removes it from the world. If you wanted to explode it you'd need something like: trigger.action.explosion(unit:getPoint(), 3000) local unit = StaticObject.getByName('Static') trigger.action.outText(unit:getLife(), 20, true) --- just added this so you can see what the value is. Just delete whenever. if unit and unit:getLife() < 100 then unit:destroy() end The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Stone Posted October 16, 2021 Author Posted October 16, 2021 Thanks!! - I can make that work. Regards Intel i7 9700K 4.6GHz · NVIDIA GeForce GTX2080 · AORUS Z390 PRO WIFI-CF · ASUS ROG Swift PG348Q 34" Curved· SK hynix Gold P31 1TB PCIe NVMe Gen3 M.2 2280 Internal SSD · 32Gb 1600MHz DDR4 · Windows 10 Pro · Saitek Cessna Pro Pedals · Thrustmaster Warthog HOTAS · HP Reverb G2
Recommended Posts