Scripts / Script not working sometimes

Author
Message
TazMan
GameGuru TGC Backer
13
Years of Service
User Offline
Joined: 20th Jan 2011
Location: Worldwide Web
Posted: 1st Mar 2016 15:34
Hello everyone. I have a script that starts a dart trap but sometimes it is not hurting the player even though he is within the hurt zone. Could anyone give me any ideas.

My Script:

HP Pavilion Laptop, AMD A8-4555M APU with Radeon(tm) Graphics HD Graphics 1.6GHz, 8GB Memory, 64 Bit Operating System (Windows 10), 1 TB Hard Drive.

I've got something to say - It's better to burn out than fade away.
Nathan38
13
Years of Service
User Offline
Joined: 13th Feb 2011
Location:
Posted: 1st Mar 2016 20:11 Edited at: 1st Mar 2016 20:29
Documentation says this:

HurtPlayer(e,v)
Cause V damage to player

so I guess you'd use HurtPlayer(e,5), I'm not an expert in scripting though.

Also I dont think' defining "damage" as a variable is necessary, you could use g_PlayerHealth, since it is a global
TazMan
GameGuru TGC Backer
13
Years of Service
User Offline
Joined: 20th Jan 2011
Location: Worldwide Web
Posted: 2nd Mar 2016 10:31
Thanks Nathan38, I know this is not a problem since I have already tried hard coding the amount of health to take off and I still get the same problem, the script still does not work sometimes.
HP Pavilion Laptop, AMD A8-4555M APU with Radeon(tm) Graphics HD Graphics 1.6GHz, 8GB Memory, 64 Bit Operating System (Windows 10), 1 TB Hard Drive.

I've got something to say - It's better to burn out than fade away.
Corno_1
GameGuru Tool Maker
14
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 2nd Mar 2016 11:50
Ok, why you do a array with the damage? A local var would do the same, after you not have any code for different traps. But this is not the problem.

For your problem:
1) Check where the middle of your object is! If you modeled the 0,0,0 axis at a corner of the model, there is the startpoint for the distance calculation.
2) Your code is strange:

You should die immediatly if you enter the 60 distance, because the is no timer.

This are the two things I see in my short time without testing. Maybe it fix it.
My dream is to develope games, which makes fun when I create it and fun when other people play it.
PM
TazMan
GameGuru TGC Backer
13
Years of Service
User Offline
Joined: 20th Jan 2011
Location: Worldwide Web
Posted: 2nd Mar 2016 14:24
I am using an array for the damage variable so that people can have more than one dart trap and possibly have different amounts of damage for each.

1. The 0,0,0 axis is at the centre of the object so that can't be the problem.

2. The reason I do not have a timer and the player does not die straight away is because it is a dart trap where darts shoot from one wall to another, the idea of this is that the player can get through it with a lot of damage or they can find a switch that turns them off (this is not in the script yet). The timer functionality here is not applicable the damage is based on how many darts hit you and this is based on the variable damage and whether you are standing in the area at the time.

Thanks Corno_1 for having a look and trying to help though.
HP Pavilion Laptop, AMD A8-4555M APU with Radeon(tm) Graphics HD Graphics 1.6GHz, 8GB Memory, 64 Bit Operating System (Windows 10), 1 TB Hard Drive.

I've got something to say - It's better to burn out than fade away.
Corno_1
GameGuru Tool Maker
14
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 2nd Mar 2016 16:13
Do you see also the line I added? I not mentioned it, but there is a new line in the code:
--Do not forget to set the animating thing back to 0, otherwise he will never start the animation again.
g_Entity[e]['animating'] == 0

did you test this?
My dream is to develope games, which makes fun when I create it and fun when other people play it.
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd Mar 2016 17:00
@corno its not needed as the engine can already tell when something is not animating (and would cause an error with the double equals)

@taz i dont think there's any issue with your script but maybe it's just because of the natural delay in the engine from when you (re)spawn, you are temporarily immune to damage, i would also consider increasing the range to 65, just to check.
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
TazMan
GameGuru TGC Backer
13
Years of Service
User Offline
Joined: 20th Jan 2011
Location: Worldwide Web
Posted: 2nd Mar 2016 17:18
Thanks for that smallg, I tried increasing the distance to 80 but that didn't make a difference. Do you think that it is because my machine is too slow (I do work on quite a slow laptop 37fps max) and if not do you think it is something that I should tell TGC about as a possible fix.
HP Pavilion Laptop, AMD A8-4555M APU with Radeon(tm) Graphics HD Graphics 1.6GHz, 8GB Memory, 64 Bit Operating System (Windows 10), 1 TB Hard Drive.

I've got something to say - It's better to burn out than fade away.
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 2nd Mar 2016 18:24
You might consider spreading poison darts, so the player would have a limit to take the antidote, otherwise he die.
Meantime (being reliable to change texture at fly), the physical aspect of the player change, as time passes.

I worked for some time with these darts, inspired by Tomb Ryder game, there I remember that they were poisoned darts.

3com
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

PM
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 2nd Mar 2016 20:05
if you try a Prompt(GetPlayerDistance(e)) within your main section when you are testing what do you see? Does it dip below 60 and if so does it hurt player as you expect then? Or does the distance fluctuate as the animation runs? I'm curious why this doesn't work . Wondering if it's one of those 'out of bounds' animation quirks, but haven't seen it before.

Cheers.
TazMan
GameGuru TGC Backer
13
Years of Service
User Offline
Joined: 20th Jan 2011
Location: Worldwide Web
Posted: 3rd Mar 2016 10:36
@3com I had not thought of that, I will try and do that with these, after all it will give me an object to find and pickup so that the player can get a health boost.

@cybernescence Unfortunatley I have tried showing the distance as I go towards the darts and it does show below 60 but the damage does not occur when the player has just re - spawned, if I stand and wait a few seconds everything works perfectly so I think smallg is correct.

Thanks for the help anyway.
HP Pavilion Laptop, AMD A8-4555M APU with Radeon(tm) Graphics HD Graphics 1.6GHz, 8GB Memory, 64 Bit Operating System (Windows 10), 1 TB Hard Drive.

I've got something to say - It's better to burn out than fade away.
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 3rd Mar 2016 13:33
Quote: "I had not thought of that, I will try and do that with these, after all it will give me an object to find and pickup so that the player can get a health boost"

That's the attitude, turn a problem into a new opportunity.

You know what people say, if life gives you lemons, find someone who will give you vodka.

3com
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

PM

Login to post a reply

Server time is: 2024-12-22 13:51:07
Your offset time is: 2024-12-22 13:51:07