Product Chat / How to make an entitiy give you health when you collect it?

Author
Message
Duchenkuke
GameGuru VBOTB Developer
8
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 29th Jan 2017 12:54
Hey guys,

Following scenario:

In the world, there is a banana. I want it to increase the health by 5 points when you "collect" it.
Yesterday, I searched around for some time and couldn't find anything that fits...

Then I searched for command lines that I thought would do this and added them to the script. I think it was addplayerhealth +5 or something like that. Cant tell for sure. Bottom line is, it did not work..

Can you guys tell me the line I need to write in order to get this to work?

I also checked the global.lua too but didn't find anything matching... I really tried!

Any help would be much apreciated !

Kind Regards, Duchenkuke

Windows 10 64bit - Intel Core i7-2600 CPU @ 3.40GHz, 8,0 GB Ram, AMD Radeon R9 270X

Youtube:
The German Music Dude: https://www.youtube.com/user/DeutscherVolker
DK Productions: https://www.youtube.com/channel/UCIqwvScXnJL_zNYqSsfTCqA
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 29th Jan 2017 13:57
Erm.. how about the default health script, health.lua it uses AddPlayerHealth(e) and you set the value in the entities properties

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
Duchenkuke
GameGuru VBOTB Developer
8
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 29th Jan 2017 14:37
oh I didnt know that the value in the properties sets the amount of health given. Thanks!

Will check that out. I want to use the AddPlayerHealth line with another script wich reduces the hunger of the player. The food's purpose is not to increase the health only. Thats why I asked. Should have mentioned that in the first post.
Windows 10 64bit - Intel Core i7-2600 CPU @ 3.40GHz, 8,0 GB Ram, AMD Radeon R9 270X

Youtube:
The German Music Dude: https://www.youtube.com/user/DeutscherVolker
DK Productions: https://www.youtube.com/channel/UCIqwvScXnJL_zNYqSsfTCqA
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 29th Jan 2017 14:41
Yup, it's AddPlayerHealth(e) and one of the settings in the entities properties will control how much, I can't remember which it is.

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
Duchenkuke
GameGuru VBOTB Developer
8
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 29th Jan 2017 14:43
Thank you very much for your help!
Windows 10 64bit - Intel Core i7-2600 CPU @ 3.40GHz, 8,0 GB Ram, AMD Radeon R9 270X

Youtube:
The German Music Dude: https://www.youtube.com/user/DeutscherVolker
DK Productions: https://www.youtube.com/channel/UCIqwvScXnJL_zNYqSsfTCqA
Freakon
GameGuru TGC Backer
15
Years of Service
User Offline
Joined: 24th Feb 2009
Location: UK
Posted: 29th Jan 2017 14:44 Edited at: 29th Jan 2017 14:45
Does this mean Banana got the job?

Duchenkuke
GameGuru VBOTB Developer
8
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 29th Jan 2017 14:54 Edited at: 29th Jan 2017 14:55
LOL

but mine hasn't got the job yet xD

I added AddPlayerHealth(e) to the script. (under function)

Not sure what line in the properties is the right one. Tried with strength first, didn't work.

When I take the banana, I get -1 health xD

I will figure this out
Windows 10 64bit - Intel Core i7-2600 CPU @ 3.40GHz, 8,0 GB Ram, AMD Radeon R9 270X

Youtube:
The German Music Dude: https://www.youtube.com/user/DeutscherVolker
DK Productions: https://www.youtube.com/channel/UCIqwvScXnJL_zNYqSsfTCqA
Duchenkuke
GameGuru VBOTB Developer
8
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 29th Jan 2017 15:05 Edited at: 29th Jan 2017 15:05
It works with chips ! They give +10 health and they use the same script.

but the banana gives -1 ..... WTF they have the exact same properties settings
Windows 10 64bit - Intel Core i7-2600 CPU @ 3.40GHz, 8,0 GB Ram, AMD Radeon R9 270X

Youtube:
The German Music Dude: https://www.youtube.com/user/DeutscherVolker
DK Productions: https://www.youtube.com/channel/UCIqwvScXnJL_zNYqSsfTCqA
Freakon
GameGuru TGC Backer
15
Years of Service
User Offline
Joined: 24th Feb 2009
Location: UK
Posted: 29th Jan 2017 15:05
Quote: "Not sure what line in the properties is the right one. Tried with strength first, didn't work."


Yeah, strength is the 'health' of the item, like how much damage it will take before destroyed.

I'm sure I have a script somewhere for this exact thing and you input the health you want to add to 'entity name'. I'll have a quick dig around and see if I can find it for you.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 29th Jan 2017 15:09
You need to edit the fpe and change quantity to the value you want to increase HP by if you want the stock health script.to work. Unfortunately the original method of adding health is a bit awkward.
The better way is to create a script with
SetPlayerHealth(g_PlayerHealth+5)
Change the 5 to the value to give.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Duchenkuke
GameGuru VBOTB Developer
8
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 29th Jan 2017 15:09
Thanks, I feel so dumb with this... I really try to learn more about scripts and gg in general, but sometimes I feel like a complete newbie.
Windows 10 64bit - Intel Core i7-2600 CPU @ 3.40GHz, 8,0 GB Ram, AMD Radeon R9 270X

Youtube:
The German Music Dude: https://www.youtube.com/user/DeutscherVolker
DK Productions: https://www.youtube.com/channel/UCIqwvScXnJL_zNYqSsfTCqA
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 29th Jan 2017 15:29
Sorry my bad, when I said properties I meant the properties in the fpe.

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 29th Jan 2017 15:29 Edited at: 29th Jan 2017 15:31
No worries, as I say, the original method used for the default health items isn't very user friendly so its not you
If you do use the better method of creating a new script remember to toggle or destroy the script so that you won't add health forever.
You could simply replace the line
AddPlayerHealth(e)
With
SetPlayerHealth(g_PlayerHealth+5)
In the stock health script and it should work fine.
If you want to be more flexible about it you can adjust it to
SetPlayerHealth(g_PlayerHealth+g_Entity[e]['health'])
That way you can adjust the strength of the entity in the editor to change the amount of health it'll give.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Duchenkuke
GameGuru VBOTB Developer
8
Years of Service
User Offline
Joined: 7th Jun 2016
Location: Germany
Posted: 29th Jan 2017 15:34
Thanks guys. Finally^^

And it works perfectly.
Windows 10 64bit - Intel Core i7-2600 CPU @ 3.40GHz, 8,0 GB Ram, AMD Radeon R9 270X

Youtube:
The German Music Dude: https://www.youtube.com/user/DeutscherVolker
DK Productions: https://www.youtube.com/channel/UCIqwvScXnJL_zNYqSsfTCqA

Login to post a reply

Server time is: 2024-11-24 18:00:28
Your offset time is: 2024-11-24 18:00:28