Scripts / Hurt Zone

Author
Message
thatandplay
5
Years of Service
User Offline
Joined: 11th Oct 2019
Location:
Posted: 29th Jan 2021 19:33
For some reason, my character is only getting hurt when they are in the center of the hurtzone. I dragged the stars to make it a larger area but it's not working. It works when they are only in the center.

Thanks!

Here is the script

-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Detonate proximity mine

function hurt2_init(e)
StartTimer(e)
end

function hurt2_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 70 then
if g_PlayerPosY < g_Entity[e]['y']+38.5 then
if GetTimer(e) > 100 then
HurtPlayer(-1,5)
StartTimer(e)
end
end
end
end
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 29th Jan 2021 19:40
You need g_Entity[e].plrinzone == 1 instead of the player distance checks.
Been there, done that, got all the T-Shirts!
PM
thatandplay
5
Years of Service
User Offline
Joined: 11th Oct 2019
Location:
Posted: 29th Jan 2021 19:48
I'm still lost.

function hurt2_init(e)
StartTimer(e)
end

function hurt2_main(e)
--PlayerDist = GetPlayerDistance(e)
--if PlayerDist < 70 then
--if g_PlayerPosY < g_Entity[e]['y']+38.5 then
if g_Entity[e]['plrinzone']==1 then
if GetTimer(e) > 100 then
HurtPlayer(-1,5)
StartTimer(e)
end
end
end
end
PM
thatandplay
5
Years of Service
User Offline
Joined: 11th Oct 2019
Location:
Posted: 29th Jan 2021 19:59
Ok, this works.

-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Detonate proximity mine

function hurt2_init(e)
StartTimer(e)
end
function hurt2_main(e)
if g_Entity[e]['plrinzone']==1 then
if GetTimer(e) > 100 then
HurtPlayer(-1,5)
StartTimer(e)
end
end
end
PM
thatandplay
5
Years of Service
User Offline
Joined: 11th Oct 2019
Location:
Posted: 5th Mar 2021 17:03
Why is it I have a hurt zone in the water below a bridge and when the player cross the bridge the player gets hurt? ugggggg. The hurt zone is 100% below the bridge.

What I'm looking for is if you are in the water you get damage.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 5th Mar 2021 17:27
Add a height check, i.e. only hurt if player height - zone height is less than a certain amnount.
Been there, done that, got all the T-Shirts!
PM
thatandplay
5
Years of Service
User Offline
Joined: 11th Oct 2019
Location:
Posted: 5th Mar 2021 18:20
height check... interesting. I'll search for that. Thank you!

Also, my terrain is not level and the yellow stars are all at different heights when I position them from the top-down view. Will pressing "Return" fix this? So far no luck. Can I disable anything so it does not automatically adjust?
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 5th Mar 2021 18:36
Height is the Y location. g_Entity[ e ].y gives you the zone height, g_PlayerPosY is the player height.

Looking back up this thread a bit I notice you commented out the height check!

i.e. this bit: if g_PlayerPosY < g_Entity[e]['y']+38.5 then

So what you probably want is:
if g_Entity[e].plrinzone ==1 and g_PlayerPosY < g_Entity[e].y + 38.5 then
Been there, done that, got all the T-Shirts!
PM
thatandplay
5
Years of Service
User Offline
Joined: 11th Oct 2019
Location:
Posted: 5th Mar 2021 19:53
Thanks, AmenMoses! I'll try that.
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 6th Mar 2021 11:44
Quote: "Also, my terrain is not level and the yellow stars are all at different heights when I position them from the top-down view. Will pressing "Return" fix this? So far no luck. Can I disable anything so it does not automatically adjust?
"

it doesn't matter about the points around the edge, they are only to show the area of the zone and their height won't matter, the height will be calculated from the center circle of the zone.
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: 6th Mar 2021 12:50
You can even work with the heigh of the terrain itself.
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

Login to post a reply

Server time is: 2024-12-22 02:21:56
Your offset time is: 2024-12-22 02:21:56