Page 1 of 1

Linking Destructable Objects

Posted: Sun Mar 04, 2007 4:06 pm
by trainmaster611
If you have several destructable objects, how would you make it so that if one is destroyed, so are all the rest. I'm guessing this will involve some intensive scripting since I plan on linking chunks, turrets, and cps together :?

Posted: Sun Mar 04, 2007 5:18 pm
by RC-1290
why don't you just check one of the shipped spacemaps....
It uses the script ScriptCB_DoFile("LinkedDestroyables")
this is about the linked destroyables in SPA2c_c

Code: Select all

function SetupLinkedObjects()
    SetupShields()
    SetupDestroyables()
--    SetupTurrets()  
end

function SetupShields()
    -- CIS Shielded objects    
    linkedShieldObjectsCIS = { "cis_fly_fedcruiser5", "cis_fly_fedcruiser1", "cis_fly_fedcruiser8", "cis_fly_fedcruiser9", 
                                "cisbridge01", "cis_prop_shipturret3", "cis_prop_shipturret1", "ciseng02", "ciseng01", "comms_cis"}
    shieldStuffCIS = LinkedShields:New{objs = linkedShieldObjectsCIS, maxShield = 70000, addShield = 2000, controllerObject = "shield_cis"}
    shieldStuffCIS:Init()
    
    function shieldStuffCIS:OnAllShieldsDown() 
        ShowMessageText("level.spa.hangar.shields.atk.down", REP)
        ShowMessageText("level.spa.hangar.shields.def.down", CIS)
        EnableLockOn({"cisbridge01", "ciseng02", "ciseng01", "comms_cis"}, true)
    end
end

function SetupDestroyables()
    --CIS destroyables
    engineLinkageCIS = LinkedDestroyables:New{ objectSets = {{"ciseng01", "ciseng02"}, {"engine_cis"}} }
    engineLinkageCIS:Init()
    
end

Posted: Mon Mar 05, 2007 6:56 pm
by trainmaster611
I've never noticed that before. Where did you get it? :)

Ok so looking at this briefly, what I'm afraid I may stumble upon is what do the Setup lines do and what am I putting there and to make the objects linked, all I have to do is list the names of the objects (chunks), the turrets, etc. with "ObjectNameHere", right? :D


-[EDIT]-

Oh and where exactly in the LUA does this go? :?

Posted: Tue Mar 06, 2007 2:59 pm
by RC-1290
Study some space lua's. I haven't done any work with linked objects yet but I did start to learn about mission objectives by combining the things said in the ' how where etc ambush topic' ( don't know the exact topic name), the scripting documentation, my current knowledge in PHP and C++ and by looking at the scripts in the assets.
---
Remeber things like " SetupDestroyables()" are functions; block of codes. those can have any name you give em. Those " setup" lines are just ways to keep the code managable and compact. Sorry I'm bad at explaining things but I suggest checking a tutorial about functions in for example the programming language C++ or something. You'll find that lua files have much similarities with some very well known programming languages.
---
I think I just confused you and made everything sound harder than it is. Don't worry, I'm sure there is someone here that can explain stuff... like I said, I can't :P.
Good luck

RC-1290'Dreadnought'

Posted: Tue Mar 06, 2007 4:17 pm
by MercuryNoodles
This is for the destructible capital ship idea, right? You should mention details like that, so we don't waste time guessing. Chunks shouldn't be a worry, since chunks would be dealt with in an odf. You only need to list ZE-given object names for the LinkedDestroyables, but I think more advanced scripting will be needed to destroy the CPs as well. That next step I can't explain, since I haven't dealt with it yet.


Here's an example from my lua, with some details highlighted:
frigateLinkageIMP = LinkedDestroyables:New{ objectSets = {{"imp_bldg_frigateturret", "imp_bldg_frigateturret1", "imp_bldg_frigateturret2", "imp_bldg_frigateturret3", "imp_bldg_frigateturret4", "imp_bldg_frigateturret5"}, {"imp-frigate"}} }
frigateLinkageIMP:Init()
Basically, just remember to list the objects you don't want causing everything to blow first. In this case, they are individual turrets (red), with the frigate itself in the second (blue) set. Oh, and the new script name's in yellow so you know it goes in two places.

Btw, they go between this line:

function SetupDestroyables()

and "end".

Posted: Tue Mar 06, 2007 6:23 pm
by trainmaster611
I found something about linked turrets in the LUA but not anything about SetupDestroyables(). Would that mean I would have to start my own section? And what exactly is frigateLinkageIMP? Is it a command for the Munger to read or is it an odf or what? :|

Btw, this is already starting to make sense. :P Thanks for the help so far :)

Posted: Wed Mar 07, 2007 11:51 am
by MercuryNoodles
This is in the xxxx_Diet Dr. Pepper.lua, not cmn.lua Look there towards the end. It defines the life support and engine linkages there.

frigateLinkageIMP is just my own script in the lua as an example for you. It could be anything, since you can name your scripts. This, I used to link turrets to an Imperial frigate, thus the name. :P

Posted: Thu Mar 08, 2007 6:47 pm
by trainmaster611
Aww I see it. Thanks :D

Posted: Sat Mar 10, 2007 1:14 am
by trainmaster611
Ok its not working :( Its acting like a prop and turrets like it did before. And I did give the chunks a max health and an add health line :?
frigateLinkageCIS = LinkedDestroyables:New{ objectSets = {{"cis_turr_74", "cis_turr_86", "cis_turr_77", "cis_turr_75", "cis_turr_85", "cis_turr_87", "cis_turr_88", "cis_turr_80", "cis_turr_79", "cis_turr_93", "cis_turr_92", "cis_turr_83", "cis_turr_84", "cis_turr_91", "cis_turr_81", "cis_turr_90", cis_turr_89", "cis_turr_82", "cis_turr_71", "cis_turr_66", "cis_turr_65", "cis_turr_68", "cis_turr_69", "cis_turr_71", "cis_turr_70", "cis_turr_72", "cis_turr_73", "cis_turr_76", "cis_prop_shipturret42", "cis_prop_shipturret43", "cis_prop_shipturret41"}, {"cis_munificent_left", "cis_munificent_right"}} } frigateLinkageCIS:Init()

Posted: Sat Mar 10, 2007 4:49 am
by MercuryNoodles
AddHealth is health regeneration, if I remember correctly, which you would use to keep things from being destroyed. See if getting rid of those lines fixes it, because I see nothing wrong with the script itself, unless you misnamed something.

Posted: Sat Mar 10, 2007 4:40 pm
by trainmaster611
Well I deleted the Addhealth line and deleted changed the part in the ODF that says "prop" to "armedbuilding". Uhhh....what's wrong with the ODF file??? Is there anything else I'm missing? :?

Btw, thanks for the turret :P

Posted: Sun Mar 11, 2007 10:33 pm
by MercuryNoodles
What's happening, now? I can't see what you see.

No problemo. heh

Posted: Mon Mar 12, 2007 5:22 pm
by trainmaster611
This is the odf file
cis_munificent_left wrote:[GameObjectClass]

ClassLabel = "armedbuilding"
GeometryName = "cis_munificent_left.msh"


[Properties]

GeometryName = "cis_munificent_left"
MaxHealth = "100000.0"
FoleyFXGroup = "metal_foley"
In game it just appears like a regular object. I did btw define the team in game :?

Posted: Tue Mar 13, 2007 3:45 am
by MercuryNoodles
Does it appear to lose health when attacked? What's happening in the game? That's what I meant.

Btw, do you have the RemoveFromMapWhenDead line in that odf as well? That may have something to do with it. I would suggest adding the Damageblahblahblah lines, but I don't know if the model has hard points to attach those effects to.

Posted: Tue Mar 13, 2007 8:43 am
by Qdin
otherwise, just look in BConstructor and apply it to a mesh. it might not be as accurate as it'll mos tlikely get attached to the pivot/local center of the mesh.

should work :wink:

Isn't AddHealth just to ADD health to that object? If I remember right there was some other line to regenerate health.

Posted: Wed Mar 14, 2007 6:28 pm
by trainmaster611
It just acts like a prop in-game. Its like I didn't even mess with the ODF :?

Posted: Fri Mar 16, 2007 9:02 pm
by trainmaster611
Ok, I figured out what I am doing wrong and now the health works in game. But despite the fact that I have the object connecty thing, they will still only be destroyed one chunk at a time :?
frigateLinkageCIS = LinkedDestroyables:New{ objectSets = {{"cis_turr_74", "cis_turr_86", "cis_turr_77", "cis_turr_75", "cis_turr_85", "cis_turr_87", "cis_turr_88", "cis_turr_80", "cis_turr_79", "cis_turr_93", "cis_turr_92", "cis_turr_83", "cis_turr_84", "cis_turr_91", "cis_turr_81", "cis_turr_90", cis_turr_89", "cis_turr_82", "cis_turr_71", "cis_turr_66", "cis_turr_65", "cis_turr_68", "cis_turr_69", "cis_turr_71", "cis_turr_70", "cis_turr_72", "cis_turr_73", "cis_turr_76", "cis_prop_shipturret42", "cis_prop_shipturret43", "cis_prop_shipturret41"}, {"cis_prop_munificent_left", "cis_prop_munificent_right"}} } frigateLinkageCIS:Init()