Scripts / Health Reward on Kill?

Author
Message
Gladkhelek
7
Years of Service
User Offline
Joined: 2nd Aug 2016
Location:
Posted: 28th Jul 2019 05:49
No one would happen to have a script lying around that makes it so that the player receives a health bonus after they've killed an enemy do they? I think it would be great shooter incentivisation for run-and-gun to have a script that functions as follows:

Player gets a kill
Is the players health 100?
If not add 15
if 15 + player's health exceeds 100 then set it to 100.

I'm sure no one has one in the detail as described but it would be nice to get some direction or again if someone has a similar one already made.

Thanks
PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 28th Jul 2019 14:08
Hi

1- Backup your ai_soldier.lua file.
2- Replace it with the ai_soldier.lua file posted below.



3- Place any dynamic entity on the map, ie: a barrel, and attach it the lifebonus.lua file posted below, as well.



hth



Basically all soldiers pass a value when they die, to the isDied var.
when this happens then player health is so happy.
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
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 28th Jul 2019 17:10
it would be better performance to only use the exit(e) part of any AI script you use though rather than looping through every entity each frame as even with a quick loop this can easily eat performance on a large map... while the exit(e) will only be called once when the entity dies

lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 29th Jul 2019 11:21 Edited at: 29th Jul 2019 11:24
Yes, you ar right.
In fact I've tried it, but for any reason "ai_soldier" does not returned nothing for me, just the global var value, it looks like when soldier died all is finished inmediatly, and code return to module_combatcore.releasecover(e)

I have to tried your code again with a different ai_soldier, since I've modified it a lot of (experiments).

What I am trying is a function that does not involve modifying any GG file, since they always change after an update and/or steam file check, this meant check entities state constantly; are they dead? some flag is needed here. Problem is the little spare time.

Maybe doing a table/array and holding there all the soldiers are on the map, if their health <= 0 meant he is dead, so active the flag, and player get their bonus. Something like this of course involve looping around and perfomance waste.
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
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 29th Jul 2019 11:35 Edited at: 29th Jul 2019 11:38
ah ok because the ai doesn't use the new preexit system by default... Lee must have missed it
edit, nope works fine for me with or without the preexit, what changes are you making to try not overwrite the stock ai?
so your ai_soldier script should look like this


i.e. we just need to create/edit the preexit(e) and an exit(e)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Attachments

Login to view attachments
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 29th Jul 2019 11:43
I've missed that "SetPreexitValue(e,2)" GG lua command.

Thanks smallg for the tip.
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
Gladkhelek
7
Years of Service
User Offline
Joined: 2nd Aug 2016
Location:
Posted: 31st Jul 2019 05:22
This is all really interesting! Thanks guys, I was looking to do this for a custom AI script so I guess I can take these and change the AI_soldier to fit my needs. Cool
PM

Login to post a reply

Server time is: 2024-05-20 05:54:23
Your offset time is: 2024-05-20 05:54:23