Scripts / How to Spawn a Flock of NPC’s

Author
Message
ozziedave
18
Years of Service
User Offline
Joined: 20th Apr 2006
Location: Australia
Posted: 21st Jun 2015 10:18
As you all know, if you can Spawn NPC’s as you need them, it saves the processing of them until
required, and might give you a few extra frames per second in speed.

This little piece of code allows you to set a ‘TRIGGER ZONE’ that Spawns as many NPC’s as you
want at the one time, as the Player steps onto the Trigger Zone.
-------------------------------------------------------------------------------------------------------------------------------------------
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Enters Win Zone
function spawn_npcs_1_init(e)
end

function spawn_npcs_1_main(e)
if g_Entity[e]['plrinzone']==1 then
PlaySound(e,0)

Spawn(136) -- ID Number of NPC - Found by placing mouse pointer
over NPC, and reading first Number in Bottom Editor Bar.

Spawn(58) -- Next NPC ID Number
Spawn(123) -- Next NPC ID Number
Spawn(119) -- Next NPC ID Number
Spawn(13) -- Next NPC ID Number
Spawn(94) -- Next NPC ID Number
Spawn(124) -- Next NPC ID Number
Spawn(66) -- Next NPC ID Number
Spawn(11) -- Next NPC ID Number
Spawn(148) -- Next NPC ID Number
Spawn(98) -- Next NPC ID Number

Destroy(e)
end
end

PLACE IN 'MAIN' IN TRIGGER ZONE

Attachments

Login to view attachments
PM
ozziedave
18
Years of Service
User Offline
Joined: 20th Apr 2006
Location: Australia
Posted: 21st Jun 2015 11:12 Edited at: 21st Jun 2015 11:17
Fixed lua file edited original post.

Attachments

Login to view attachments
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 21st Jun 2015 18:10
you can already do it with the 'ifused' field and the entity names, dont need to open the script then
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11

Login to post a reply

Server time is: 2024-05-03 11:28:42
Your offset time is: 2024-05-03 11:28:42