Scripts / Making objects killable

Author
Message
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 27th Mar 2019 10:35
I've been trying to make my own script to be able to kill an entity and making it animate, but i'm not getting anywhere.

I've tried to use 3Coms explodable script, but it doesn't work in the way i need it to, i need the entity to take damage and the script to activate the animation when that entities health reaches 0 because i need it to work with third person melee, and 3Coms script doesn't use entity health to trigger the animation, it looks like it uses some sort of player looking/visible system that detects mouse click and plays animation, which means third person melee doesn't work because player visible doesn't work with third person due to the position of the camera.

What i have so far is rudimentary, but i thought it would work, but nothing at all happens when i shoot the entity.



Anyone able to help?

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Pirate Myke
Forum Support
14
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 27th Mar 2019 13:52
You are asking for an exact match. Maybe try
if g_Entity[e]['health'] <= 10 then

The math in GG for this function is kind of different as it sometimes takes a percentage of an amount of damage points.
RIP
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

New:
Intel(R) Core(TM) i5-8400 CPU @ 2.81GHz, 12GB RAM, Nvidia gtx1050ti 4gb, Windows 10 Home 64bit, Screen resolution 1920 x 1080. System Passmark 3774




smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 27th Mar 2019 15:18
It's difficult to tell without seeing any more info, my guess would be you have the model set to always active = yes? If so then you will need to check the model is not animating otherwise it's actually looping the first frame of the animation endlessly... If it's not always active then it should be disappearing instantly? If that is the case you need to use preexit and exit to manage your animation.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 27th Mar 2019 18:02
I have no idea what you said just then smallg lol.

All i want it to do is you shoot or stab an entity, it plays the animation and stops on the last frame with collision off so you can walk through it.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 27th Mar 2019 19:04 Edited at: 27th Mar 2019 19:04
something like this should work (always active = yes)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 27th Mar 2019 19:41 Edited at: 27th Mar 2019 19:43
Thanks smallg, unfortunately it doesn't work, nothing happens when you shoot the wall i'm using, i've tried it on stock doors too and nothing.

Anyway, i've given up with the killing bit, and i'm just going to do a press E to shove the wall script instead, i've adapted your script above, which works perfectly, however if i put a second object in the level with that script the second one shows the prompt, and turns the collision off when you hit E, but doesn't animate.



Any ideas?

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 27th Mar 2019 19:43
For the sake of performance and readability could we all please use:

local Ent = g_Entity[ e ]

...

if Ent.animating == 0 then
if Ent.activated == 97 then
etc.

Been there, done that, got all the T-Shirts!
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 27th Mar 2019 19:45 Edited at: 27th Mar 2019 19:48
How would that look? and would it fix my issue?

Basically i have a wall that can animate to collapse, i want to walk up to it, and it prompts me to knock it over by pressing E, when i press E the animation plays and stops on the last frame, an collision is off, and i want to be able to use it on more than one object.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 27th Mar 2019 19:53
Something like this:

Been there, done that, got all the T-Shirts!
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 27th Mar 2019 20:00
Ahh, taking a look at some of my own scripts you may have to check that the frame has reached the last animation frame and set Ent.animating to 0.

Been there, done that, got all the T-Shirts!
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 27th Mar 2019 20:07 Edited at: 27th Mar 2019 20:08
Nope, that doesn't even play the animation.

However, changing:

SetAnimation( e, 0 )

to

SetAnimation( 0 )

makes it work perfectly, thanks guys.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 27th Mar 2019 20:41
Here it is in action:


Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Pirate Myke
Forum Support
14
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 27th Mar 2019 22:04
Very nice.
RIP
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

New:
Intel(R) Core(TM) i5-8400 CPU @ 2.81GHz, 12GB RAM, Nvidia gtx1050ti 4gb, Windows 10 Home 64bit, Screen resolution 1920 x 1080. System Passmark 3774




3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 27th Mar 2019 23:35 Edited at: 27th Mar 2019 23:42
Too late, sorry.
If you want to go via health take into account strength via fpe, or item properties. Also min and max:
if g_Entity[e]['health'] >= 1 and g_Entity[e]['health'] < 50 then....
Nice one Belidos.
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
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 27th Mar 2019 23:47
Nice Belidos! Glad to see that it works. Great idea.
You created the wall?

We getting closer to Fortnite every day! LOL

BTW you know that there's no prob now
going back to your weapon smashing- right?
But you would want to eliminate the distance factor,
instead give it a health bar?! With peanuts, pistachios or almonds?
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 28th Mar 2019 15:36
Thanks bod much appreciated. I'll check it out as soon as i get home, but i haveca feeling it wont work, a have a script that is an adapted door script to shoot oit open, which works on the stock doors, but not on my wall. I've checked the fpe but it's almost identical so i don't think its script or fpe, i think its something to do with the model, maybe that its made of multiple objects with their own origins and that might be confusing the hit box or something. Not sure what to do anout that.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 28th Mar 2019 17:56
Yeah i know what you mean, but its mot the door partnim talking about, the entity health just doesn't go down on my model when you shoot it, i think its the multiple object origins confusing the code, i might have to make it again as a single mesh with bones so theres only the one origin point.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 28th Mar 2019 20:51 Edited at: 28th Mar 2019 21:12
Yup, i got it to work now, i had to redo the model as a single mesh with bones instead, looks like if it's made up of multiple mesh objects with their own origins it confuses gameguru and doesn't register a hit. Your script works perfectly on it now Bod, i'd like to thank you from the bottom of my heart for that.

Edit: Ok, found a flaw in your script Bod, it works perfectly with one door, but if you put two doors on the same level with the same script then the second one animates the moment the level loads without shooting it lol, however now that i have entity health working, i can adapt the script amen helped with so all's good.

Thanks a lot for all your help guys, i try not to ask until i'm pulling my hair out because i like to do things myself, so any help you give me is very appreciated.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 28th Mar 2019 22:47
Quote: "Glad you got it working, "


Thanks!

Quote: "I am completely bald after trying to make a driveable articulated lorry, it's now in the much more capable hands of AmenMoses and I'm off to buy some hair restorer."


Don't i know that feeling! If it wasn't for smallg and amen moses i'd be a mess right now lol

I've seen those truck you are talking about, they look awesome, really good work there as always.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 28th Mar 2019 22:54
With regards to the model issue.

Originally (and a common way of animating) i had created each block as a separate object within the mesh, so each had their own origin point, which was used for key frame animation. When you export you select all the objects to export.

Gameguru uses the last object selected as the overall model origin point, but what i think was happening was that although gameguru is using the last origin point for the insertion point, it gets confused when assigning things like hits to the object because it doesn't know which origin point to work with.

So instead i joined all the individual objects into one single mesh, then animated by adding bones for each part i want to move, that way it only has one object origin point, and boom it worked perfectly!

As a bonus, my animated entities can now be click selected without having to drag select them, so i think it's the same issue that was causing that problem too.

Primary Desktop:
i7 7700,k NV1070 8GB, 16GB 3200mhz memory, 1x 2TB Hybrid, Win10.

Secondary Desktop:
i5 4760k, NV960 2GB, 16GB 2333mhz memory, 1x 2TB Hybrid, Win10.

Laptop:
i3, Intel 4000 series graphics, 6GB memory, 1x 500gb HDD, Win8.1.

Login to post a reply

Server time is: 2024-12-22 14:10:43
Your offset time is: 2024-12-22 14:10:43