Scripts / How to make an entity unkillable/invulnerable

Author
Message
Bolt Action Gaming
GameGuru Tool Maker
10
Years of Service
User Offline
Joined: 24th Oct 2013
Location: Harrisburg, PA (USA)
Posted: 30th Oct 2014 18:19
I know this is probably really simple but is there a way to make a character in ai_neutral not take any damage/die?

Could probably figure it out on my own but I'm trying to keep my brain running on a diff train- don't want to go chasing some squirrel that blows out my last bit of creativity.

Thanks

Please check out my reviews blog

http://fpscreloadedreview.blogspot.com
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 30th Oct 2014 19:25
no if you shoot a character afaik they will always bleed but you can use SetEntityHealth(e,v) to always keep their HP high enough so they wont die

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Bolt Action Gaming
GameGuru Tool Maker
10
Years of Service
User Offline
Joined: 24th Oct 2013
Location: Harrisburg, PA (USA)
Posted: 30th Oct 2014 19:48
I'll have to see how it does. Some of what I'm doing involves chars with 1-5 HP so it might not be viable.

Please check out my reviews blog

http://fpscreloadedreview.blogspot.com
Bolt Action Gaming
GameGuru Tool Maker
10
Years of Service
User Offline
Joined: 24th Oct 2013
Location: Harrisburg, PA (USA)
Posted: 1st Nov 2014 20:10
Unfortunately no go on this one. Low HP guys die. Can't figure out how to make em respawn either, which would work.

Please check out my reviews blog

http://fpscreloadedreview.blogspot.com
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 1st Nov 2014 22:35
why do you need them to be both low HP and also not die? seems a bit confusing? are you trying to create a "lives" type situation or some sort of low HP rage?
you can't currently respawn the same entity afaik (i.e. the entity number will still be for the dead guy) but you can set a hidden entity into it's place (i.e. a new entity number) which depending on how many times you need to do this could be quite possible (i have used a similar technique below - skip to 0:32)


life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
tomjscott
User Banned
Posted: 1st Nov 2014 23:01
I don't quite understand the issue. If you want it to be invincible then why are you setting it's health so low? Why does it need low health AND invincibility? Aren't these mutually exclusive?

System Specs: OS - Windows 7 Home Premium 64-bit SP1, CPU - AMD Phenom II X4 945, 3.0Ghz, RAM - 8Gb DDR3, GFX Card - 2048MB NVIDIA GeForce GT 640, FPSC-R Version - Beta 1.0085
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 2nd Nov 2014 02:25
@smallg - a shrink ray gun! Awesome.

Bolt Action Gaming
GameGuru Tool Maker
10
Years of Service
User Offline
Joined: 24th Oct 2013
Location: Harrisburg, PA (USA)
Posted: 3rd Nov 2014 17:54
I'll explain since I changed my mind and will be releasing it for free now.



I made a custom NPC AI with string system. The problem was, I wanted one piece of code and a series of global strings which could be called via an array.



So basically you put something like:



nsarray[1]="Hey dude, what's up?"



into the global.lua file. ALL of this code works. The question was how to feed it a differentiating 'flag' since there's no flag per-se which can be set on the character settings like in acknex or a thousand other game engines. I tried using the name of the NPC, but couldn't make that work. You can see where this is going, right?



So basically it feeds the health value as the array value, thus pulling said string. This way each NPC can be set by simply choosing "AI_NPC.LUA" and then setting his health to whatever value you wanted (1-whatever).



It works like a champ.



The problem is the guys can die, which kind of sucks for NPCs.



That's it in a nutshell. I suppose I could use bigger HP values, but I was hoping for an easy fix.

Please check out my reviews blog

http://fpscreloadedreview.blogspot.com
tomjscott
User Banned
Posted: 3rd Nov 2014 18:13
Good idea. I actually had the same idea. I used health value in Rescue the Princess for an enum value in a couple of cases and was looking to do something similar for custom AI characters as well. So, I fully understand the scenario now. The simple solution then is to simply make your enum values much larger such as 100001, 100002, etc. You can then just take the portion of the value you want for your array (1, 2, 3, etc.) and they'll also have a health so high they can't be killed.

System Specs: OS - Windows 7 Home Premium 64-bit SP1, CPU - AMD Phenom II X4 945, 3.0Ghz, RAM - 8Gb DDR3, GFX Card - 2048MB NVIDIA GeForce GT 640, FPSC-R Version - Beta 1.0085
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 3rd Nov 2014 18:23 Edited at: 3rd Nov 2014 18:25
i'm not 100% sure i understand completely but it seems like you want a linked field from the right-click properties into a script? but wont that mean that if you do accidentally shoot them it'll change what they do?

i expect what you are asking for will be included once they expand on the IfUsed field (or do actually give us a link to the name as you originally said)

for now i think health is the only way though yeah.



or possibly if you dont want them to move (or can create your own movement without the AI character controls) then you could maybe not set them as characters at all and use strength instead of health

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Bolt Action Gaming
GameGuru Tool Maker
10
Years of Service
User Offline
Joined: 24th Oct 2013
Location: Harrisburg, PA (USA)
Posted: 3rd Nov 2014 19:40
Nice fix tom. Didn't know what the maximum values were for the HP. If you can go to 10k, then it's probably like 65335 or something.



My concern there though would be if they get shot, wouldn't it affect the string used?

Ex: If he has 10030 HP, gets shot for 25 dmg, he'd be at 10005 dmg and use the wrong string.



I mean I guess it's better than dying, but still.



Also you're right smallg - I could use it in that manner. I might still do that, just to see how it turns out.

Please check out my reviews blog

http://fpscreloadedreview.blogspot.com
tomjscott
User Banned
Posted: 3rd Nov 2014 20:46
I was thinking that you'd probably save off the index value on initialization and then the health value wouldn't be needed any more even if it changed.

System Specs: OS - Windows 7 Home Premium 64-bit SP1, CPU - AMD Phenom II X4 945, 3.0Ghz, RAM - 8Gb DDR3, GFX Card - 2048MB NVIDIA GeForce GT 640, FPSC-R Version - Beta 1.0085
Bolt Action Gaming
GameGuru Tool Maker
10
Years of Service
User Offline
Joined: 24th Oct 2013
Location: Harrisburg, PA (USA)
Posted: 3rd Nov 2014 21:24
Not a bad idea; at least puts me in the ballpark.
The only problem is the script currently runs using some local variables within the _main function. If I use it in the init portion, I can't just use a variable since that will be global and shared among all the objects running the script. I'd have to use an Array and here again you run into the problem of how to index it.

Please check out my reviews blog

http://fpscreloadedreview.blogspot.com
tomjscott
User Banned
Posted: 3rd Nov 2014 22:36 Edited at: 3rd Nov 2014 22:37
I'm probably not understanding completely what you are going for. Your example of the following:



nsarray[1]="Hey dude, what's up?"



Is only a single line of text. Are you saying that you'd have different NPCs and each one would just have a single line of text to say? And that text would be indexed via the array value? If so, I'm thinking this is extremely limiting. Wouldn't you want the NPCs to be able to say multiple lines of text?



Anyway, if this is the case and you are simply trying to access a single element of an array for that particular NPC then I don't see a problem. You simply make a global array that uses the e value of the entity and then store the particular index that you extract from the large health value. Essentially, this:



1. Extract index from large health value in init script (e.g. index = 1)

2. Set global array by entity's e value and assign the index to it. (e.g. npcindex[e] = index)

3. Get NPC dialog text from global array (e.g. Prompt(nsarray[npcindex[e]]))



You see?

System Specs: OS - Windows 7 Home Premium 64-bit SP1, CPU - AMD Phenom II X4 945, 3.0Ghz, RAM - 8Gb DDR3, GFX Card - 2048MB NVIDIA GeForce GT 640, FPSC-R Version - Beta 1.0085
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 3rd Nov 2014 22:37
well then you can use a combination of the 2 - i.e. store the initial HP then in the main function check if HP has changed and put it back (to counter any accidental shooting) and if you need to change the value for any reason you just also change the inital value along with it

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Bolt Action Gaming
GameGuru Tool Maker
10
Years of Service
User Offline
Joined: 24th Oct 2013
Location: Harrisburg, PA (USA)
Posted: 4th Nov 2014 02:13 Edited at: 4th Nov 2014 02:17
This is the current code

global.lua:





AI_NPC.lua





video example forthcoming ...

Please check out my reviews blog

http://fpscreloadedreview.blogspot.com
Bolt Action Gaming
GameGuru Tool Maker
10
Years of Service
User Offline
Joined: 24th Oct 2013
Location: Harrisburg, PA (USA)
Posted: 4th Nov 2014 02:38


Please check out my reviews blog

http://fpscreloadedreview.blogspot.com
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 7th Nov 2014 04:18 Edited at: 7th Nov 2014 04:22
Popped in for a moment, think this might help.







That should cut down on the amount of code required. Just a single local var is all you should need here. I believe this satisfies your requirements of "not dying" as well as not changing the displayed text when the entity receives damage.



IIRC, local vars declared outside of functions in LUA will act like global variables, except they're only visible to the file they were declared in. In all honesty, i haven't tried the above code yet (hardware issues right now)... but it should work and at least the idea is there. I used the idea mentioned above of using 10001, etc health values, so make sure you apply the proper amount of health to your NPCs.





~Plystire

I'm sure there's already a thread about it somewhere, if a link could be provided, I will post there.
MK83
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 10th Jun 2006
Location: Greeneville, TN USA
Posted: 7th Nov 2014 11:15 Edited at: 7th Nov 2014 11:26
@Bolt Action Gaming,did you try this?

AMD 9850 black, 6 gigs ram, GTX 260 Win 8.1 x64

[URL=http://s1288.photobucket.com/user/mk83456/media/e5i8_zpsb276ee1a.png.html][IMG]http://i1288.photobucket.com/albums/b482/mk83456/
PM
MK83
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 10th Jun 2006
Location: Greeneville, TN USA
Posted: 7th Nov 2014 11:20 Edited at: 7th Nov 2014 11:26
that worked in fpsc classic, I believe.

AMD 9850 black, 6 gigs ram, GTX 260 Win 8.1 x64



PM
Bolt Action Gaming
GameGuru Tool Maker
10
Years of Service
User Offline
Joined: 24th Oct 2013
Location: Harrisburg, PA (USA)
Posted: 7th Nov 2014 14:33 Edited at: 7th Nov 2014 14:33
Sorry, haven't been able to really do much, catching up on some housework.



I had a lot of 'test pieces' in my code which were done because of a bad saved level that gave my script fits. I left them in place in case I had to modify it again. I appreciate the perspective on cleaned up code though. Looks like yours is missing the code to display the out of range default text as well, but that's easy enough to add in.



Here again we run into the same issue of the health being modifiable.



The last breakthrough I had was finding this video:





I contacted the creator and he pointed me to his code which apparently he posted to the forums here a few months ago. I'm going to try playing with it via object ID and see if I can use that instead of health as a passable flag.

Please check out my reviews blog

http://fpscreloadedreview.blogspot.com

Login to post a reply

Server time is: 2024-04-19 01:24:21
Your offset time is: 2024-04-19 01:24:21