Home   Help Search Login Register  

Author Topic: Help destroy a building  (Read 1214 times)

0 Members and 1 Guest are viewing this topic.

Offline Wheelz456

  • Members
  • *
  • I'm a llama!
Help destroy a building
« on: 18 Jan 2012, 16:23:40 »
Have checked the forums, not the right answers. :scratch:

This is my problem, I wanna destroy a building.  ???
First I'm using Nearestbuilding command: _Building = NearestBuilding Player (To find the building id code)
This returns: Null object :weeping:

Used _Building = NearestObject [Player, "B1"] (where B1 is the name of the addon building, I know this should be type and it also do not give results)  :dunno:
Returns: Null Object  :weeping:

my idea is to make my own Cti mission and need this. Ai destroy my building, the workers check that it's dammaged and repair it or if destroyed delete the building after a while.

This is part of my test script:

Hint "Script Started"
~1
;_Building = NearestObject [Player, "B1"]
~1
_Building = NearestBuilding Player
;~1
titletext[format["The nearest building is: %1",_Building],"PLAIN DOWN"]
~1
_Building setdammage 3

Nothing happens to my building, also tried 30 satchel charges no dammage, used 3 X abrams fired all ammo to no avail the building doesn't even get a scratch on it even dropped three nuclear missiles on it.
Are the buildings undestructable or what am I doing wrong?
It's only me and the building on the map.
« Last Edit: 18 Jan 2012, 16:27:08 by Wheelz456 »

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: Help destroy a building
« Reply #1 on: 18 Jan 2012, 16:32:53 »
The code below should help you find the ID of your building:

Code: [Select]
_building = NearestBuilding player

hint format ["%1", typeof _building]

Ok, so your other problem is that you cannot dammage the building?

Well, it is possible that the building was configured to be almost indestructable. You just change the amount of armour or HP in the config file (I know that radio towers would often take about 7 satchels to destroy them)

It looks like the main reason why the building wouldn't destruct with 'setdammage' is because _building wasn't defined properly.

You could try something along the lines of:

Code: [Select]
?(getdammage _building > 0): _building setdammage 0.5
That will make the building partially dammaged.

Hope this helps

Gruntage


"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline Wheelz456

  • Members
  • *
  • I'm a llama!
Re: Help destroy a building
« Reply #2 on: 18 Jan 2012, 17:31:01 »
Thanx for the reply

I have tried many options and found that some of the addon buildings where not configured correctly.
I unfortunately haven't played around with the config files, newb there.

I use the Typeof command to identify any and all objects, i just name the object and it replies the object type. My favorite. To use it my way:
Create a trigger for radio alpha and in the init field put - 

hint format ["The object name is:%1", typeof 'Name of object']
name the object you want do identify, usefull in finding that cool tank in the addon list.

Tested the code on different map and I also include a teleportation command to jump to the selected building(Player setpos getpos _Building), and every thing works fine. Got a civil building and destroyd it with my code and the correct results where displayed on the screen just like I want it. Tried with different buildings from the same addon group (@WGL).
The building I used was the Control Centre and it seems to be indistructable, replace it with the airport and my script works like a dream.

My conclusion is that the addon wasn't configured correctly. Need to avoid those buildings by testing them before I use them.

Again thanx for the reply, got my brain going again after some time of not scripting.