Scripts / Spawn a dead enemy

Author
Message
GoodnessCookie
10
Years of Service
User Offline
Joined: 27th May 2014
Location:
Posted: 27th May 2014 18:27 Edited at: 28th May 2014 12:28
Hello everyone!



I want to make a horror game demo, with lot of jumpscares. I have two ideas to do this:

1. Spawn a dead enemy, than clear it away

2. Show a big scary picture for approx. 0.5 sec and than hide it.



My problem is, i'm new to lua scripting and i don't know how to do any of them.

Any ideas?
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 28th May 2014 00:05
i did try changing the animation frame but it didn't seem to work how i was expecting (maybe because im using the stock character which has hard coded scripts though)



here is a script to place the stock character on his back (currently) for 5 seconds and then he disappears





life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
GoodnessCookie
10
Years of Service
User Offline
Joined: 27th May 2014
Location:
Posted: 28th May 2014 14:55
Thank you, it's working. Noew I have another question.

How do I spawn an entity from a trigger zone? I tried the way wich was working in FPS Creator Classic (right click on entity, spawn after delay) but it doesn't work. I tried to write a script:



if g_Entity[e]['plrinzone']==1 then

PlaySound(e,0);

Spawn(e);

SwitchScript(e,"jumpscare.lua");

Destroy(e);

end

end



I know what's the problem. The "e" variable is not right for me, but i am not perfect in lua. Any ideas?
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 28th May 2014 17:35 Edited at: 28th May 2014 18:12
i would base it on distance to the entity so the code will be like this





life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Dralel
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location: UK
Posted: 1st Jun 2014 21:00
I'm having a bit of trouble spawning a non-spawned enemy via the Spawn(e) LUA command.

GPU: GTX 660, CPU: i7 3770 Intel 3.40ghz x4, PSU: 650 Watt, RAM: 8GB DDR3, OS: Win7 Ultimate 64-bit
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 1st Jun 2014 23:10
Quote: "I'm having a bit of trouble spawning a non-spawned enemy via the Spawn(e) LUA command. "




will spawn the entity as soon as you get near it's location

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Dralel
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location: UK
Posted: 2nd Jun 2014 00:52
Thanks alot, it worked! Is there a way to spawn an entity if a player steps into a storyzone now?

GPU: GTX 660, CPU: i7 3770 Intel 3.40ghz x4, PSU: 650 Watt, RAM: 8GB DDR3, OS: Win7 Ultimate 64-bit
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd Jun 2014 01:35
spawnzone.lua


life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Dralel
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location: UK
Posted: 2nd Jun 2014 01:58
Hmm that doesn't appear to be working, how do I find the local entity's number?

GPU: GTX 660, CPU: i7 3770 Intel 3.40ghz x4, PSU: 650 Watt, RAM: 8GB DDR3, OS: Win7 Ultimate 64-bit
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd Jun 2014 03:32 Edited at: 2nd Jun 2014 03:33
http://fpscrforum.thegamecreators.com/?m=forum_view&t=207801&b=2&msg=2488873#m2488873

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Dralel
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location: UK
Posted: 2nd Jun 2014 03:48
Thanks, the prompte script was working and the entity number was 74. But I still can't get the entity to spawn when I enter the story zone, it simply does not appear no matter what I do.

GPU: GTX 660, CPU: i7 3770 Intel 3.40ghz x4, PSU: 650 Watt, RAM: 8GB DDR3, OS: Win7 Ultimate 64-bit
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd Jun 2014 12:20
did you set my script to the storyzone main?

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Dralel
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location: UK
Posted: 2nd Jun 2014 14:46
I'm not sure what you mean, I added your script to plrinzone.lua, and then tried it using its own file, none of them work still.

GPU: GTX 660, CPU: i7 3770 Intel 3.40ghz x4, PSU: 650 Watt, RAM: 8GB DDR3, OS: Win7 Ultimate 64-bit
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd Jun 2014 15:10
works fine for me, you may need to remove the entity and try setting the "spawn at start" to no before you apply the script - it does seem a little buggy sometimes.

once you have set the entity number of the object you want to spawn, set the object to "spawn at start = no" then apply the spawnzone.lua to the zone marker (to the script field inside the right click menu)
picture for layout


video


p.s. any1 else noticed that the code snippets stopped opening?

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Dralel
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location: UK
Posted: 2nd Jun 2014 15:21
Thanks, but it still doesn't work at all... I followed your instructions and did the following:
1. placed new entity, set spawn at start = 0, checked its number with prompte.lua (it is 74)
2. placed trigger zone a bit further away and inserted the script that should spawn the entity

But when I enter the zone he doesn't spawn, the weird thing is spawning the entity from player distance away works fine.

GPU: GTX 660, CPU: i7 3770 Intel 3.40ghz x4, PSU: 650 Watt, RAM: 8GB DDR3, OS: Win7 Ultimate 64-bit
PM
AuShadow
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 2nd Dec 2013
Location: Australia
Posted: 2nd Jun 2014 15:33
Yes on the codecsnippets but add lang=lua before the ] on the first code block thing and it works. So wit () instead of [] it is (code lang=lua) and (/code)

PC Specs: Windows 7 home 64-bit, Amd 7900 3gb DDR5 graphics, 8gb DDR3 Ram, Intel i7 3.4ghz

Feel free to visit and edit the public FPSCR resource wiki page: http://fpscrresource.wikispaces.com/home
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd Jun 2014 16:35
so i need to change all my snippets? think i'll wait a while and see if it gets updated again

@Dralel as you can see in the video it works fine, you have missed something (it'll work even if the entity isnt inside the zone - makes no difference)

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Dralel
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location: UK
Posted: 2nd Jun 2014 16:49
Then there must be a bug in the game engine, I've done every step precisely and fiddled around with the script, entities and trigger zones to make this work and it just won't no matter what I do.

GPU: GTX 660, CPU: i7 3770 Intel 3.40ghz x4, PSU: 650 Watt, RAM: 8GB DDR3, OS: Win7 Ultimate 64-bit
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd Jun 2014 17:56
what does happen when you run it?
the entity stays "hidden"?

did you try on a new map just to test as well?

was the entity that did spawn from the distance check the same entity that you are using for this zone script?

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Dralel
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location: UK
Posted: 2nd Jun 2014 18:11 Edited at: 2nd Jun 2014 19:13
EDIT: Silly, silly silly me! I got it working. In my code, I had to change "Spawn(e)" to "Spawn(entity)", and it works!



I'm still a little baffled that I can spawn an entity via distance using Spawn(e), though.

GPU: GTX 660, CPU: i7 3770 Intel 3.40ghz x4, PSU: 650 Watt, RAM: 8GB DDR3, OS: Win7 Ultimate 64-bit
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 2nd Jun 2014 19:34
(e) relates to the entity number that the script is being run on (in this case it would have been the zonemarker itself where as before it would have been the actual entity you wanted to spawn)

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
BarZaTTacKS
10
Years of Service
User Offline
Joined: 3rd Feb 2014
Location:
Posted: 4th Jun 2014 16:11 Edited at: 4th Jun 2014 16:12
So with this script we would need a new script for each entity correct? Because if I duplicate the script for a duplicated character they all show and disappear at the same time no matter the distance.
PM
Dralel
GameGuru TGC Backer
11
Years of Service
User Offline
Joined: 4th Nov 2013
Location: UK
Posted: 4th Jun 2014 16:50
At the moment yeah, one script per entity. Hopefully there's some built-in option in the game engine that refers to a global script per entity.

GPU: GTX 660, CPU: i7 3770 Intel 3.40ghz x4, PSU: 650 Watt, RAM: 8GB DDR3, OS: Win7 Ultimate 64-bit
PM
Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 4th Jun 2014 17:49
Don't want to advertise myself, but instead of hardcoding entity's E, you could find entity you want to spawn that is nearest to the player and use it's E, because in most cases you'd want to work with nearest entity. Check out this: http://fpscrforum.thegamecreators.com/?m=forum_view&t=208181&b=2&msg=2489072#m2489072

Volga
10
Years of Service
User Offline
Joined: 31st May 2014
Location: Turkey
Posted: 12th Jun 2014 22:29
I'm trying to use your codes, smallg. But I'm having some problems because I'm brand new to codes. I just opened a notepad in scriptbank. Copied your codes into it. Then I named the notepad file with the same name with code's function. After I added .lua. In FPSCR, I dragged a character. Set "spawn after delay=yes" and "spawn at start=no". Then I dragged a trigger. Change "main=with your code's name" and "If used=character's name". But when I start it gives an LUA ERROR. Please help me. Could you write what should I do step by step? Thanks in advance.

Vertigo
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 12th Jun 2014 22:56
if you let me know what you are trying to do then i can help you more, these scripts probably wont work with the new version of reloaded and stock characters cant be hidden unless you remove the standard AI script.

save the following as spawn.lua and then place a start marker and an enemy character a bit infront, set the enemy to "spawn at start = no" and set the "main" script field to this spawn.lua and run - the enemy should only appear once u reach his location (note he will not do anything once he appears).


life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 12th Jun 2014 23:13
I think you can combine this with SwitchScript function to make it fight once spawned.

So, it would look like this:



smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 13th Jun 2014 12:40
Avram wrote: "I think you can combine this with SwitchScript function to make it fight once spawned."


good thinking

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Volga
10
Years of Service
User Offline
Joined: 31st May 2014
Location: Turkey
Posted: 13th Jun 2014 14:49
Thanks for your replies. When tried both of them it said "No function called ai_cover_main".

Vertigo
Volga
10
Years of Service
User Offline
Joined: 31st May 2014
Location: Turkey
Posted: 13th Jun 2014 15:18
I just opened a forum message for what I need. If you have time to look, I'll be so happy.

http://fpscrforum.thegamecreators.com/?m=forum_view&t=208988&b=2

Vertigo
Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 13th Jun 2014 15:48
Check if you have ai_cover.lua file in folder Files\scriptbank\? You can use any ai_*.lua script. I don't have Reloaded installed here so I don't know the exact names, and I can't test it, but it should work. Use some ai_ script that is already assigned to another enemy character.

Volga
10
Years of Service
User Offline
Joined: 31st May 2014
Location: Turkey
Posted: 13th Jun 2014 19:47
I have ai_cover.lua in Files\scriptbank. :/

Vertigo
Avram
GameGuru TGC Backer
18
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 13th Jun 2014 22:28
Is ai_cover.lua assigned to another entity? If not, try something like this:



Note that this thread includes file extension for "Include" function and not for "SwitchScript" function. I'm not sure if it's correct so you can play a bit (try to remove .lua extension in "include" or try to add it to "SwitchScript" function call)

Login to post a reply

Server time is: 2024-12-22 05:09:49
Your offset time is: 2024-12-22 05:09:49