Destroying an Object Multiple Times

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
Psyringe
Recruit Womprat Killer
Posts: 9
Joined: Sat Apr 22, 2017 4:58 am
Projects :: SWBFII- ARC ACTS- CTF CTG TMK PPD TFK
Games I'm Playing :: SWBFII ACTS WTFZF ++
xbox live or psn: N/A
Location: United States
Contact:

Destroying an Object Multiple Times

Post by Psyringe »

Caught up in a design workflow fork, the route I'm considering involves multiple destruction's. Done some searching and know a bit about structure; but knowing if the following works with a link or example would be awesome:

Is it possible via LUA (or otherwise) to Transform an Object into a Different Object, with health, on destruction with an animated effect.

The idea is a Prop or Building is partially destroyed but has health remaining to be destroyed more. This is a popular effect; glass cups to fortifying barriers.

Figure it's possible. Not sure. No rush.

Thanks in advance!
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: Destroying an Object Multiple Times

Post by Marth8880 »

You might be able to do this via Lua scripting with the OnObjectDamage event handler. It'd look something like this:

Code: Select all

propDamage = OnObjectDamageName(
    function(object, damager)
        if GetObjectHealth(object) < 100 then
            SetProperty(object, "GeometryName", "new_msh_file_name")
        end
    end,
"object_class_name"
)
Parts of this might be wrong, but otherwise that's the basis of what would the code block might look like.

Refer to Battlefront2_scripting_system.doc for more information.
Psyringe
Recruit Womprat Killer
Posts: 9
Joined: Sat Apr 22, 2017 4:58 am
Projects :: SWBFII- ARC ACTS- CTF CTG TMK PPD TFK
Games I'm Playing :: SWBFII ACTS WTFZF ++
xbox live or psn: N/A
Location: United States
Contact:

Re: Destroying an Object Multiple Times

Post by Psyringe »

Awesome. Thanks. Stuck on binary; was looking for "destroy" or "dest".
ForceMaster
Lieutenant General
Lieutenant General
Posts: 737
Joined: Fri Aug 08, 2008 11:27 pm
Projects :: Tron The Grid
Games I'm Playing :: The best..SWBFII
xbox live or psn: No gamertag set
Location: C:\Program Files\ForceMaster\Bin\ForceMaster.exe

Re: Destroying an Object Multiple Times

Post by ForceMaster »

I agree with Marth :) but maybe the code needs to extend a bit.

IMPORTANT: your object needs to be

Code: Select all

ClassLabel = "destructablebuilding"
instead of "prop". Props can't be destroyed ingame or via LUA.

Try this:

Code: Select all


objectName = "my_object_name" -- You need specify what object 

OnObjectDamage(
   function(object, damager) --

      if GetObjectHealth(objectName) < 1000 then -- Set a number near the max health. First destruction.

            SetProperty(objectName, "GeometryName", "new_msh_file_name") -- First change of geometry
            KillObject(objectName) --Object dissapears...
            RespawnObject(objectName) -- ...and respawn in les than eye closes!  :D 
            SetProperty(objectName, "MaxHealth", 999)
            SetProperty(objectName, "CurHealth", 999)

      elseif  GetObjectHealth(objectName) < 700 then -- Set a number near the second max health. second destruction.

            SetProperty(objectName, "GeometryName", "second_msh_file_name") -- second change of geometry
            KillObject(objectName) --Object dissapears...
            RespawnObject(objectName) -- ...and respawn in les than eye closes!  :D 
            SetProperty(objectName, "MaxHealth", 699)
            SetProperty(objectName, "CurHealth", 699)

      elseif  GetObjectHealth(objectName) < 500 then -- Set a number near the third max health. Third destruction.

            SetProperty(objectName, "GeometryName", "second_msh_file_name") -- Third change of geometry
            KillObject(objectName) --Object dissapears...
            RespawnObject(objectName) -- ...and respawn in les than eye closes!  :D 
            SetProperty(objectName, "MaxHealth", 499)
            SetProperty(objectName, "CurHealth", 499)

--         If you need more destructions copy from "elseif" to the line above and set new values
       
       end
)
Finally your destructable building needs a destroyed geometry and chunks, that add more realism. Hope help you.
Psyringe
Recruit Womprat Killer
Posts: 9
Joined: Sat Apr 22, 2017 4:58 am
Projects :: SWBFII- ARC ACTS- CTF CTG TMK PPD TFK
Games I'm Playing :: SWBFII ACTS WTFZF ++
xbox live or psn: N/A
Location: United States
Contact:

Re: Destroying an Object Multiple Times

Post by Psyringe »

As soon as I test it; BOOM video example/confirmation. I'll let you know.

Was asking early on because I can do the multi-part destruction when doing the binary destruction; saves time (a lot, actually, and looks better). Thanks so much for that. :D
Post Reply