Scripts / How do I make a script to break a plank of wood model?

Author
Message
RoadKill
3
Years of Service
User Offline
Joined: 5th Dec 2021
Location:
Posted: 3rd Feb 2023 22:50
I've been trying to figure out a way to break or destroy the planks in the death valley pack and if I hit the plank with a hammer it registers the collision or hit but does nothing else, I've tried checking the health of the entity with a "if g_Entity[e]['health'] = 0 then Destroy( e ) end" in the _main section of my script.

I've also tried graphix_explosion.lua script but still does nothing, am I trying to destroy something that can't break or destroy?
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 4th Feb 2023 13:42
Firstly that Lua snippet won't work as it would need to be == 0. Also say <= 0 as the health could drop below 0. (there used to be a bug such that when the health was 0 or below the script no longer gets called btw, not sure if that was ever fixed)

Secondly if you want entities to be breakable then they need to be made that way in the first place. i.e. they need to have some sort of animation frames built in and a script that drives the animation to mimic the breaking action. None of the stock objects are made this way.

Destroy( e ) should remove the entity from the map but you can also use Hide(e) to simply make it invisible (that way you can re-used that entity elsewhere on the map with appropriate scripting) and CollisionOff(e) to remove it's physical body.
Been there, done that, got all the T-Shirts!
PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 5th Feb 2023 13:43
As Amen pointed out the mesh should be ready to be breaking in GG or GGMax.
https://www.youtube.com/watch?v=DPkOQ4kqgP4
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 5th Feb 2023 17:02 Edited at: 5th Feb 2023 17:02
@ RoadKill
This stuff is too old I did it ages ago, but it might help as a starting point.
It works fine, I just tested it minutes ago in GG.

https://youtu.be/plM-zHibbkY
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

Attachments

Login to view attachments
PM

Login to post a reply

Server time is: 2024-12-21 16:05:00
Your offset time is: 2024-12-21 16:05:00