Jump to content
Sign in to follow this  
monkeyboy27

Invincible building

Recommended Posts

I need to make a building invincible for one of my missions. I've filled it full of troops and one of the objectives is to clear the building, the only problem is it always takes too much damage during the process, and gets destroyed. There must be some way of making it invincible, or raising it's hitpoints. I did a search, but couldn't find anything.

Share this post


Link to post
Share on other sites

you could run a simple loop on it that constantly repairs it.

something like:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

while {true} do {this setdamage 0; sleep 0.5};

not tested but i think that *should* work...

just though about it a little more; you say building.. that means you first gotta "get" the building via getnearestbuilding id...

create a gamelogic near the building and put this in the init field:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">while {true} do {((getpos this) nearestObject <id of building>) setdamage 0; sleep 0.5}

Share this post


Link to post
Share on other sites

Since the loop is limited only to 10000 cycles, this solution will work only for 80 minutes, which could cause problems if is it used in some long COOP.

Better solution could be Event Hadlers:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addeventhandler ["dammaged",{_this select 0 setdamage 0}]; this addeventhandler ["killed",{_this select 0 setdamage 0}]

Share this post


Link to post
Share on other sites
Since the loop is limited only to 10000 cycles, this solution will work only for 80 minutes, which could cause problems if is it used in some long COOP.

Better solution could be Event Hadlers:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addeventhandler ["dammaged",{_this select 0 setdamage 0}]; this addeventhandler ["killed",{_this select 0 setdamage 0}]

i thought that limitation was lifted? but your solution is better anyway wink_o.gif no constant checking necessary...

Share this post


Link to post
Share on other sites

Cheers guys. I've not used event handlers before though. I'm still working through all the tutorials on ofpec, and haven't reached that section yet wink_o.gif How to I associate it with the building? Specifically its the hotel in Chantico, Id 64642.

I tried lethals method as well, and I couldn't get that to work either. It kept giving errors. I put the building ID in, and it brings a "do:type string expected code" window up, and says "error invalid number in expression" at the top. Is there a mistake in the code? I'm pretty new to these things, so can't really spot them myself smile_o.gif

Share this post


Link to post
Share on other sites

Cheers guys. I've not used event handlers before though. I'm still working through all the tutorials on ofpec, and haven't reached that section yet wink_o.gif How to I associate it with the building? Specifically its the hotel in Chantico, Id 64642.

I tried lethals method as well, and I couldn't get that to work either. It kept giving errors. I put the building ID in, and it brings a "do:type string expected code" window up, and says "error invalid number in expression" at the top. Is there a mistake in the code? I'm pretty new to these things, so can't really spot them myself smile_o.gif

Share this post


Link to post
Share on other sites

Don't event handlers break under certain conditions though? I seem to recall that there where issues with them if you're using them in MP. I also seem to recall that certain things would stop working if you saved and reloaded mid mission.

Share this post


Link to post
Share on other sites
Cheers guys. I've not used event handlers before though. I'm still working through all the tutorials on ofpec, and haven't reached that section yet wink_o.gif How to I associate it with the building? Specifically its the hotel in Chantico, Id 64642.

I tried lethals method as well, and I couldn't get that to work either. It kept giving errors. I put the building ID in, and it brings a "do:type string expected code" window up, and says "error invalid number in expression" at the top. Is there a mistake in the code? I'm pretty new to these things, so can't really spot them myself smile_o.gif

let me fire up arma real quick and i take a look for ya smile_o.gif

Share this post


Link to post
Share on other sites

mhh.. something strange is going on...

i've tried the eventhandler solution and while i don't get an error and the eventhandler fires off (i've put in a hint to check that) it doesn't repair the building.

also the damaged eventhandler doesn't fire off at all when i only damage the building (ie. put on one satchel which *should* damage the building...

also tried putting the repair stuff into a function via "call compile" to make sure it runs immediately and as quickly as possible but that doesn't make any difference.

gonna try the hit eventhandler next.

edit: strangely enough the hit eventhandler works smile_o.gif

even when using 3 satchels at once which normally kills the building.

here's the code:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">hotel = ((position this) nearestobject 64642); hotel addEventHandler ["hit",{call compile "hotel setdamage 0"}];

put it in the init field of a nearby unit (i used a gamelogic but should work with anything as long as it's reasonably close).

yep - works indeed. i've used 6+ satchels at once and the building still stands biggrin_o.gif

Share this post


Link to post
Share on other sites

You're right something strange is going on! Now it appears the hotel is invunerable to 1 shot kills (like 3 satchel charges, or crashing a heli into it) but still gets destroyed by cumulative damage. I destroyed it with the rockets on an mi-17, and the at-6's on a bmp. In the mission it's always bmp's that destroy it, because they're shooting their rockets at the machine guns I placed on the balcony.

Share this post


Link to post
Share on other sites

seems like the eventhandlers don't work properly (at least in this case)

i suggest you do it differently - i got it working this way:

create a file named "protecthotel.sqf" inside your mission folder.

contents are as follows (i tried putting that inside the editor but for some reson it doesn't work there...):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">hotel = (position _this) nearestobject 64642;

hotel addEventHandler ["hit",{call compile "hotel setdamage 0"}];

while {true} do {hotel setdamage 0;sleep 0.5};

now put this in the gamelogic init:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">nil = this execvm "protecthotel.sqf"

this way you're protected against those one-hit-kills and against cumulative damage. i emptied an mi-17s entire magazine into the hotel and it was left standing so i guess it works...

plus i've tested against that 100000 loop limit and the loop continued forever wink_o.gif

sounds like an intense mission btw wink_o.gif

Share this post


Link to post
Share on other sites

The hit eventhandler only fires when significant damage is caused to the object. Minor damage is ignored. You might try combining the hit EH with a killed one.

Share this post


Link to post
Share on other sites
The hit eventhandler only fires when significant damage is caused to the object. Minor damage is ignored. You might try combining the hit EH with a killed one.

I combined hit, damaged (and dammaged, too wink_o.gif ), and killed but none of them prevented the cumulative damage apparently. you could still destroy the building with rockets...

the killed and damaged events fired only when the building finally collapsed and didn't prevent that. i got the debug message i build in and still stared at a pile of rubble wink_o.gif

Share this post


Link to post
Share on other sites

Maybe this idea can help you:

First, this method is passing by all players has to run the same script, so when a player is meeting the criteria, the rest of players when the same condition, will meet it too.

With the EH "Fired" attached to players as infantry and/or attached to vehicles, you can 'start' the Event Handler, but only when 'firing' a piece of ammo, is really working.

So imagine all players starting that EH "Fired" just in his initField or if in a script, be sure EH "Fired" is launched only once by each player, only once while the player inside the server.

Better said:

As a fact, a norm, this EH in your mission can be declared once by each player, and then, fired by itself always.

If someone is declaring the EH more than once, it means that he will declare it twice... and 3 times...4 times and then it will lag till collapse ArmA, because with only one instance of EH when fired, in some cases is being fired 5 times by itself (M134 in High Rate with only one 'fire' order is launching 25 bullets, but only 5 instances of EH. Maybe it means ArmA in that case is simulating 25 bullets launching only 5.

So, please, be sure you are declaring only one time that EH "Fired".

The EH line can be something like this:

? _firsttime == 0 : _firsttime = 1 ; vehicle player addEventHandler ["fired",{_this exec "DontTouchMyHotel.sqs"}]

Declare _firsttime = 0 at the start of your mission, but never... NEVER reset the variable to 0 again. NEVEEEEEEEEEEEER!!!!!!!!!.

Why 'vehicle player'?

When the player is infantry, vehicle player = player, and when player is inside a vehicle, vehicle player = the object 'vehicle' itself. It means, EH will be fired by all players inside that vehicle (more security for your hotel)and fired too when firing normal soldier weapons.

So if you are firing AT stuff, or Hellfires stuff, EH will be launched always.

Then, when firing, they will launch the script file that is declared in the EH.

And what you need in that little script file?

- make a timer via variable (global) that is counting till zero. So, each time the same player is firing, again the script is being launched (another instance) and the timer is again reseting because its a global variable wink_o.gif .

- then, only while the timer IS NOT ZERO:

     - Hotel setDamage 0

(add a delay or it will explode the whole Internet xD maybe yes, maybe not)

- and when the timer is zero, exit the script.

No matter in how many multiple instances of "DontTouchMyHotel.sqs" is  'on air', because if you doing a 'timerloop' so short, the EH script will exit so quickly and then, not acumulating scripts on memory. Just try it, i think it will work fine. Maybe it will lag, but it only depends on your style to make that 'timerloop'.

If you putting 100 UH60MG choppers, with 200 gunners firing with High Rate leaving pressed the fire button... probably the EH will make lag to all, but i think you never will see in a server that kind of animal-synchronism. Just i hope you understanding my tarzan english.

What initial value of timer i need?

- it depends on a lot of factors. The true factor: How many time it takes an ammo-piece to reach the hotel?

From 1000 meters... a hellfire... well maybe more than 30 secs. I hope you understanding you need a 'reasonable' number of seconds. Maybe 10, 15, only 5 etc. Just try it and you will reach till your own 'magic' and reasonable number.

Yeah, you dont need to have players firing from 1000 meters... but it is possible in your mission?

Just think a little in that possibility.

setDamage 0 that hotel each time a player or vehicle is firing... and... oh!... and... if you making a loop not cumulative so during 10 secs from that fired bullet-rocket-missil etc etc you are setting his damage to 0.

I'm calling 'not cumulative loop' when you reseting a variable inside a loop in a script, so the loop is still working, instead adding new loops.

Well it means, you (as player) will start a timeout from last fired bullet-rocket-thingfireable and while the timer not reached zero... you are constantly (add a delay) setDamaging that hotel to 0.

Imagine you in a AH1Z, EH "Fired" is started, but not launched because you still not firing... and now you fired a Hellfire, then in the moment you fired, you starting a timer from x seconds to zero, so, if the timer is still NOT zero, "Hotel setDamage 0". Surely, in less than 10 seconds (only as a reference) the Hellfire crashed into building.

With that timer, you are setDamaging to zero all the time to 'minimize' and 'reset' the damage status of that hotel.

With the concept 'reset', you are taking out the idea of cumulative damage.

With the concept 'minimize' maybe it helps to reduce the probability of the building collapse. It really depends on this:

- What is doing ArmA just a few milliseconds before enabling the collapse, and if you have enough time to 'include' a setDammage to zero avoid the final collapse.

I hope you understanding my tarzan english and then, this method.

It sounds like putting that hotel into "Cheat" mode or "God mode".

So probably with this EH "fired" method, never will exist a cumulative damage, only needing to test if with 5 satchels touched off at same time can destroy that nice hotel. Not only satchels, with the AV8B GBU with 5 bombs 'well' deployed and so quickly over the roof of a building... i dont want to stay inside that hotel when it occurs to test it.

Another thing that i think that is true or at least i noticed it, is that a building can collapse in less time when is being shot in its top side (mostly of times, the roof).

Another thing that i never tested is:

I heared/maybe-did-read that there is an invisible building in ArmA objects. Maybe that invisible building can 'stop' missils, rockets etc, like an invisible barrier, or maybe you can crash into it and never seeing what is the object where you crashed.

If that building exists (i think it exists, like the Heli_H_empty, but dunno its behaviour) can be tested so you can try to shoot it and check all the time his damage, visually and via script to be shown as Hint.

So... maybe... if you putting a lot of that invisible building surrounding the perimeter of the hotel... you are adding it a natural (but tricky) barrier against rockets and more funny stuff. Probably if this last is true, that invisible building can be 'collapsed' too but in an invisible way. Not enough weird huh?

Another question from this ignorant lynx:

- Can you really and effectively "setDamage to 0" a building to quit the recent or old damage?

Resource of EH "Fired":

http://community.bistudio.com/wiki/ArmA:_Event_Handlers#Fired

One last phrase.

Probably i am explaining this easy method in a too complicated way, but this method means:

Each player that is firing a weapon (his weapon or via-vehicle) is doing "Hotel setDamage 0" from the moment just the ammo-piece fired is out of his weapon, but only during a certain time, so the player is "setDamaging to zero" before the ammo-piece hitting the hotel, while the ammo-piece hit the Hotel and after the ammo-piece hit the Hotel.

So never you will need to check the status of the building because you are 'overhealing' it each time a player is firing, and when i'm saying a player is firing... if the player is firing to heaven, he will do "Hotel setDamage 0" too.

So, all players will be the 'heroes' who saved the hotel without to know it. rofl.gif

And they used a lot of stuff to collapse it rofl.gif

I hope you understanding now why you need a 'reasonable' number of seconds in that timer.

If not understanding this whole post, try to read it again.

I really think this method can work so good.

Another kind of help is: if you want, i can get a copy of your mission, and me, adding this explained method, testing by myself a little, and when all is ok, i'll send you back your mission, and try to test it in a dedi server, because i never tried scripts in MP in dedi servers, only as a normal host in normal Internet sessions.

Share this post


Link to post
Share on other sites

Well, here i go again (sorry).

I will explain the method used with the EH "fired" with another example. Just try to imagine it while you reading it, Not think about it, just imagine it.

1.THE CARTOON

- You as the one and only player in the mission.

- You with a weapon (with ammo, of course).

- The hotel in front of you at 100 mtrs, as example.

- Each time that you are shooting the hotel, it's raining during 10 seconds over the hotel, only over the hotel.

- Well, wait a minute.

- Open fire again, what is happening? it will start to rain again over the hotel during 10 seconds.

Stop to imagine it.

Now try to declare what you've seen in that cartoon.

2. REMEMBER WHAT YOU'VE SEEN

- each time you are shooting, the rain is appearing.

- when the last piece of ammo i fired, it started to appear a rain during 10 secs.

- Once the rain is starting, it will stop past 10 seconds if no more shots.

VERY IMPORTANT:

- All the bullets i fired, hit the hotel before the rain stops.

- All the bullets i fired, hit the hotel after the rain starts.

Now, quit the concept "shoot the hotel" and again watch the cartoon.

It means "each time you shooting (no matter where you aiming) , it starts to rain over the hotel".

OK.

And the last time that you have again to watch the cartoon:

- Quit the concept "rain" and change it by "Hotel setDamage 0".

- Go again to watch the cartoon.

I think that cartoon is giving you a solve. Maybe not the best. But probably a real solution.

Now, try to imagine the cartoon again with more soldiers, and again with certain soldiers inside choppers, planes etc.

Still i'm thinking that this method can work.

Share this post


Link to post
Share on other sites

just slap a hit event handler on the known model ,find it using nearest objects add a killed if you like and for final catchment a looped setdammage 0 with a trigger set for anybody set to switch within a given catchment area and add a pause to the loop.

we used it in ofp because tonal buildings where a little weak especally if someone came in with diff version of the island. worked like a treat in mp or sp .

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×