Page 1 of 1

[Solved] Fake console commands in mission script/ Hero health questions

Posted: Sun Sep 06, 2020 11:09 pm
by JustSomeGuy
I know you can set an AI hero's health but I would like to know if you can set a player hero's health value in a mission script so that the hero has different health on different missions. Additionally, I want to know if fake console commands can be preset in the script. More specifically, I want to change the fov on certain missions, and eliminate fall damage from others without creating entirely new versions of the characters, or manually using the fake console commands every time one of those missions are played. Thanks in advance.

Re: Fake console commands in mission script/ Hero health questions

Posted: Mon Sep 07, 2020 7:54 am
by Sporadia
The answer to your first question is a definitive yes. You can use the mission lua to change any unit's health. Just put some code like this in the ScriptPostLoad() function:

Code: Select all

SetClassProperty("all_hero_leia", "MaxHealth", 400) -- set leia's max health to 400
SetClassProperty("all_hero_leia", "CurHealth", 400) -- set leia's current health to 400
SetClassProperty() changes a class' traits at the spawn screen. If you wanted to get more complicated and start changing the health of units that are already spawned, then you will have to use SetProperty() instead. I wrote something on how to do that in the past (read the spoiler):
http://www.gametoast.com/viewtopic.php? ... 95#p537695

Or there's a simpler thread on the sticky if you want to start there:
http://www.gametoast.com/viewtopic.php?f=27&t=13946

Fake Console commands aren't lua, but there is a lua solution to removing fall damage. It's SetClassProperty() again.

Code: Select all

SetClassProperty("all_inf_rifleman", "CollisionScale", "0.0 0.0 0.0")
You can use SetProperty() and SetClassProperty() to change any line that appears in an odf. That's what they're for. CollisionScale = "0.0 0.0 0.0" is taken from the jettrooper odf so I hope it's the right line.

I haven't looked into changing fov so can't help you there. There is probably a way of modding fov without using the fake console though.

Edit: Had to fix the links

Re: Fake console commands in mission script/ Hero health questions

Posted: Mon Sep 07, 2020 5:20 pm
by JustSomeGuy
Wow, I had no idea mission scripting was that powerful or versatile when it came to editing units. This was very helpful, thank you. I'll leave the thread open for a few more days just in case anyone knows an answer to the fov problem, though.

Edit: Never mind, I figured it out