|
Post by [BMG]Neutro on Dec 6, 2017 21:45:20 GMT 1
Hi do you have some special XML or PAK files in your BK folder? because the map crash if i try to load it in the EDITOR. that means some "dependencies" are missing
|
|
|
Post by Quintaxel on Dec 6, 2017 21:53:22 GMT 1
I use Panzerkrieg as default so that's probably the reason of the crash. I suggest you make a new map. Put the buildings with ScripId's 500,510 and 520 on the map and some units of your choice so you can hit the buildings. Then link the script to the map.
You can put as many buidlings on the map as you want with any ScriptID as long as you enter the ScriptID's of the buildings in the table. This is the whole idea of the script. Let me know if it works.
|
|
|
Post by [BMG]Neutro on Dec 7, 2017 19:09:09 GMT 1
NEW SCRIPT FROM YOUR ZIP FILE
Well lol the FORUM remove the following symbols please check the picture.... as soon as you post it will kill the symbols ... so i had to type everything twice omg....
ORIGINAL POST IN FORUM with the missing symbols
function InitBuildingsHP() local i = 1; while Building ~= nil do DisplayTrace ("Building = %g", Building); MaxHP = GetObjectHPs(Building); DisplayTrace("Max HPs %g", MaxHP); DamageObject(Building, (MaxHP/2)); -- here the building is destroyed to 50% health i = i + 1; end; RunScript( "KeepHealth", 2000); -- Running the script Keephealth every 2 seconds Suicide(); --Script runs only once end;
Hello well first of all now your script work! i notice that the script in the LUA file is different from your post in this Forum: example above i marked some of the differences. maybe thats why i did not work from the beginning?
OK well this is really cool but there must be one more logic problem.
YOUR advice I have tested the script with 3 buildings but it should work with more buildings. The script will damage each building in the table Building {} to 50 %. This will cause a lot of smoke on the map. You could set each building to 50 % in the map editor and leave out the script line;
DamageObject(Building, (MaxHP/2)); -- here the building is destroyed to 50% health
from the function;
function InitBuildingsHP()
if i do this i dont have the smoke problem and stuff but if the building gets completely destroyed it will not be repaired to 50% it will have less then 50% HP and something strange happen then: every second it goes completely down (100% destroyed) and repairs itself to maybe 20%? HP and go down again and repair and go down again and repair..... i think the script need a information for every building what his initial HP are? looks like the script dont work correct if the building is not at 100% HP at map start. and the DamageObject line is removed....
|
|
|
Post by Scyooff on Dec 7, 2017 19:34:05 GMT 1
NEW SCRIPT FROM YOUR ZIP FILE
Well lol the FORUM remove the following symbols please check the picture.... as soon as you post it will kill the symbols ... so i had to type everything twice omg....
Hi Neutro normally you can add script by clicking on the "insert code" icon on the right of the "insert user link" icon
|
|
|
Post by Quintaxel on Dec 7, 2017 20:22:46 GMT 1
Strange that some characters disappear after posting. Didn't know this. I will use the code window in the future. The script will work with more buildings, no problem.
I was not correct. We need to change more code if the buildings start with 50 % health on the map. I'll check the code and get back to you later.
|
|
|
Post by Quintaxel on Dec 9, 2017 12:14:59 GMT 1
Changed the script a bit it meets your needs (I hope it does).
The script keeps the health points of builidings at their initial value, the value at the start of the game. Unlike the previous version this script is not limited to keeping buildings at 50%. You could also keep buildings at 100 % HP. You need to put all ScriptID's in the table Building {}. Each building needs is own unique ScripID
The script is quite basic. You could add more complexity so that each building could be kept at a set value of HP, only valid for that particular building. eg: Keep building with Script ID 500 at 50 % HP, building with ScriptID 510 at 25% HP and so on.
Also a function could be added so that buidlings restore to their maximum HP value at the start of the game, out of sight of the player, but cannot be destroyed more then there initial value.
Building = {500,510,520,530,540,550,560}; -- Table contains ScriptID of buildings
MaxHP = {};
function KeepBuildingHP()
local i = 1;
while Building[i] ~= nil do
HP = GetObjectHPs(Building[i]);
if HP < (MaxHP[i])then
DamageObject(Building[i], - ((MaxHP[i]) - HP));
end;
i = i + 1;
end;
end;
function InitBuildingsHP()
local i = 1;
while Building[i] ~= nil do
MaxHP[i] = GetObjectHPs(Building[i]);
i = i + 1;
end;
RunScript( "KeepBuildingHP", 2000); -- Running the script Keephealth every 2 seconds
Suicide(); --Script runs only once
end;
function Init()
DisplayTrace ("Init Running");
RunScript ("InitBuildingsHP",1000);
end;
|
|
|
Post by [BMG]Neutro on Dec 9, 2017 13:33:50 GMT 1
This is awesome! perfect! if you dont mind i would like to put you and keepitsimple in the credits and i would send you the finished map (hopefully in 2 weeks) so you can see what i have done with it.
many thanks
|
|
|
Post by Quintaxel on Dec 9, 2017 15:36:50 GMT 1
No problem, glad I could help. Have fun mapping.
|
|