Scripts / Spawning in wave and hud for kill counter Help please

Author
Message
AstrobloodKnight
8
Years of Service
User Offline
Joined: 3rd Aug 2015
Location:
Posted: 7th Aug 2015 12:18
ok i am new to lua and based on my past coding knowlodge which is out of date i am having some issuses

what i am trying to do is have things in this case AI spawn in waves based on the amount a player has killed i also would love to right a HUD to show kills so if u know how please let me know here the code so far

-------------------------------------------------------------------------------------------------------------------------------------------
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Enters Win Zone
function zombiespawn_init(e)
Killed = 0
wavecurrentWave = 1
wavemaxLevels = 3
waveinactive = true
Kills = 5
Difficulty = 5
end
function zombiespawn_main(e)
if g_Entity[e]['plrinzone']==1 then
PlaySound(e,0)
if waveinactive == true then
if wavecurrentWave == 1 then --Level 1
Prompt("Kill more zombie " .. Kills - Killed .. "/" .. Kills .. " Remain")
Spawn(3)
Spawn(4)
Spawn(5)
Spawn(6)
Spawn(7)
if wavecurrentWave == 2 then --Level 2
if Killed == Kills then
wavecurrentWave = 2
elseif Kills > Killed then
Prompt("Kill more zombie " .. Kills - Killed .. "/" .. Kills .. " Remain")
end
Prompt("Kill more zombie " .. Kills - Killed .. "/" .. Kills .. " Remain")
Spawn(8)
Spawn(9)
Spawn(10)
Spawn(11)
Spawn(12)
Spawn(13)
Spawn(14)
Kills = Difficulty + Kills
if wavecurrentWave == 3 then --level 3
if Killed == Kills then
wavecurrentWave = 2
elseif Kills > Killed then
Prompt("Kill more zombie " .. Kills - Killed .. "/" .. Kills .. " Remain")
end
Prompt("Kill more zombie " .. Kills - Killed .. "/" .. Kills .. " Remain")
Spawn(15)
Spawn(16)
Spawn(17)
Spawn(18)
Spawn(19)
Spawn(20)
if Killed == Kills then
wavecurrentWave = 1
elseif Kills > Killed then
Prompt("Kill more zombie " .. Kills - Killed .. "/" .. Kills .. " Remain")
end
Kills = Difficulty + Kills
Destroy(e)
end
end
end
end
end
end
PM
AstrobloodKnight
8
Years of Service
User Offline
Joined: 3rd Aug 2015
Location:
Posted: 7th Aug 2015 12:30
btw my questions are one how do i get it from spawning the same set of npcs and get it to go to the next way it keeps spawning the first wave over and over again
PM
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 7th Aug 2015 14:39
Infinite spawning of characters is not functional yet. So this may be rather difficult at the moment.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit

AstrobloodKnight
8
Years of Service
User Offline
Joined: 3rd Aug 2015
Location:
Posted: 7th Aug 2015 14:56
i dont want Infinite spawning of characters i just want waves of them my code only spawns the first set of spawns but will not take the amount of kills into the program and test for the var to see if its true or not.

ex.

if Kills = 5 then spawn next set
if kills = 10 spawn next set

everytime i spawn in first set it loops and loops the first set instead of going to next wave or set any ideas how to check for this and make it work
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 7th Aug 2015 18:49 Edited at: 7th Aug 2015 18:50
your if says if wave == 1 then
and all the rest is run inside that (which is obviously not the intention as wave2 is not wave1)

you want to 'elseif wave == 2 then' and 'elseif wave == 3 then'
also the checks are in the wrong place - they should be below the 'if kills == killed' check (as this is needed to check the round has finished)

for respawning characters you should give them lots of hp to start with (as a kinda buffer hp, say 5000+normal hp) then check they go below the added value - so starting with 5100, anything below 5001 is "dead".
then you can reset the characters to the new phase (as any character that actually reaches 0 hp is removed from the game play automatically)

this will also allow you to check when a character dies as when it reaches the buffer hp it can then increase the kill count (this should be done in the ai script and not in your spawning script)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
AstrobloodKnight
8
Years of Service
User Offline
Joined: 3rd Aug 2015
Location:
Posted: 7th Aug 2015 19:55
thanks for the help
PM
AstrobloodKnight
8
Years of Service
User Offline
Joined: 3rd Aug 2015
Location:
Posted: 7th Aug 2015 20:11
idk if this looks right but am i at least headed the right way

function zombiespawn_init(e)
Wave = 0
WaveStart = 0
Killed = 0
Kills = 0
end
function zombiespawn_main(e)
if WaveStart == 1 then
if g_Entity[e]['plrinzone']==1 then
Prompt("Round 1 Start")
PlaySound(e,0)
Spawn(3)
Spawn(4)
Spawn(5)
Spawn(6)
Spawn(7)
Wave = 1
Kills = 5
elseif Kills < Killed then
Prompt("Kill more zombie " .. Kills - Killed .. "/" .. Kills .. " Remain")
if Kills == Killed then
Prompt("Round 2 Start")
Spawn(8)
Spawn(9)
Spawn(10)
Spawn(11)
Spawn(12)
Spawn(13)
Spawn(14)
Kills = 7
Wave = 2
elseif Kills < Killed then
Prompt("Kill more zombie " .. Kills - Killed .. "/" .. Kills .. " Remain")
if Kills == Killed then
Prompt("Round 2 Start")
Spawn(15)
Spawn(16)
Spawn(17)
Spawn(18)
Spawn(19)
Spawn(20)
Kills = 6
Wave = 3
elseif Kills < Killed then
Prompt("Kill more zombie " .. Kills - Killed .. "/" .. Kills .. " Remain")
end
end
end
end
PM
AstrobloodKnight
8
Years of Service
User Offline
Joined: 3rd Aug 2015
Location:
Posted: 7th Aug 2015 20:48
or maybe like this

function zombiespawn_init(e)
Wave = 0
WaveStart = 1
Killed = 0
Kills = 0
end
function zombiespawn_main(e)
if WaveStart == 1 then
if g_Entity[e]['plrinzone']==1 then
Prompt("Round 1 Start")
PlaySound(e,0)
Spawn(3)
Spawn(4)
Spawn(5)
Spawn(6)
Spawn(7)
Prompt("Kill more zombie " .. Killed .." Remain")
if Killed == 5 then
Killed = 0
Prompt("Round 2 Start")
Spawn(8)
Spawn(9)
Spawn(10)
Spawn(11)
Spawn(12)
Spawn(13)
Spawn(14)
Prompt("Kill more zombie " .. Killed .." Remain")
if Killed == 7 then
Killed = 0
Prompt("Round 2 Start")
Spawn(15)
Spawn(16)
Spawn(17)
Spawn(18)
Spawn(19)
Spawn(20)
Prompt("Kill more zombie " .. Killed .." Remain")
if Killed == 6 then
Prompt("Waves complete")
Destory(e)
end
end
end
end
end
end
PM
AstrobloodKnight
8
Years of Service
User Offline
Joined: 3rd Aug 2015
Location:
Posted: 7th Aug 2015 21:05
idk why but i am so confused
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Aug 2015 00:26 Edited at: 8th Aug 2015 00:28
indeed, you've now removed the wave check which is important
it should look more like this (there are other ways of course but this follows your original code)

if wave == 1 then
Spawn(#)
number_of_enemies = 2
--repeat til all enemies are in play
elseif wave == 2 then
Spawn(#)
number_of_enemies = 3
--etc til all waves are done
end
if killed == number_of_enemies then
wave = wave + 1
killed = 0
end
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
AstrobloodKnight
8
Years of Service
User Offline
Joined: 3rd Aug 2015
Location:
Posted: 8th Aug 2015 06:34
function zombiespawn_init(e)
wave = 1
Killed = 0
number_of_enemies = 0
end
function zombiespawn_main(e)
if g_Entity[e]['plrinzone']==1 then
Prompt("Loading Round")
PlaySound(e,0)
if wave == 1 then
Prompt("Round 1 Start")
Spawn(3)
Spawn(4)
Spawn(5)
Spawn(6)
Spawn(7)
number_of_enemies = 5
elseif wave == 2 then
Prompt("Round 2 Start")
Spawn(8)
Spawn(9)
Spawn(10)
Spawn(11)
Spawn(12)
Spawn(13)
Spawn(14)
number_of_enemies = 7
elseif wave == 3 then
Prompt("Round 3 Start")
Spawn(15)
Spawn(16)
Spawn(17)
Spawn(18)
Spawn(19)
Spawn(20)
number_of_enemies = 10
end
if killed == number_of_enemies then
wave = wave + 1
killed = 0
end
end
end


it wont move on to around 2 my guess is because its not counting kills or the tigger is always set to round one if i destory it after the first around i dont think it will continue doing rounds. well if i put this in gobal theres no need for a tigger is there?
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Aug 2015 10:51
Yep you need to count the kills of course but that's easy, just add
killed = killed + 1
To the end (inside the exit(e) part) of any AI script the enemies are using.

Also your version requires the player to stay inside the zone entire time which is likely not going to happen so you should add a trigger variable like

If GetPlayerInZone(e) == 1 then
Started =1
End

Then instead of your zone check in your script you check for started being 1
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
AstrobloodKnight
8
Years of Service
User Offline
Joined: 3rd Aug 2015
Location:
Posted: 8th Aug 2015 11:19
thanks so much
PM
AstrobloodKnight
8
Years of Service
User Offline
Joined: 3rd Aug 2015
Location:
Posted: 8th Aug 2015 12:03
thanks so much but i think i am going insane maybe i jsut need to stop trying and give up on this idea and go learn some lua first

reason i am having issuse is when ur player steps in the zone they spawn but if you stay in the zone they just keep spawning as you kill them and they dont die ever and then on top of this the next round wont start because unless ur in the zone it wont count kills but if ur in the zone you can't kill them i think i am going mad

function zombiespawn_init(e)
wave = 1
Killed = 0
number_of_enemies = 0
Started = 0
end

function zombiespawn_main(e)
Prompt("Loading Round")
if GetPlayerInZone(e) == 1 then
Started =1
end
if Started == 1 then
if wave == 1 then
Prompt("Round 1 Start")
Spawn(3)
Spawn(4)
Spawn(5)
Spawn(6)
Spawn(7)
number_of_enemies = 5
Started = 0
end
if wave == 2 then
Prompt("Round 2 Start")
Spawn(8)
Spawn(9)
Spawn(10)
Spawn(11)
Spawn(12)
Spawn(13)
Spawn(14)
number_of_enemies = 7
Started = 0
end
if wave == 3 then
Prompt("Round 3 Start")
Spawn(15)
Spawn(16)
Spawn(17)
Spawn(18)
Spawn(19)
Spawn(20)
number_of_enemies = 10
Started = 0
end
if killed == number_of_enemies then
Started = 1
wave = wave + 1
killed = 0
end
if Started == 0 then
Prompt ("Round Hasn't Started Yet")
end
end
end
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Aug 2015 16:31 Edited at: 8th Aug 2015 16:53
really? so you can "spawn" dead characters? i didn't know this, if that's true then that's a nice find

the main issue is this part needs to be moved outside of the Started == 1 check

if killed == number_of_enemies then
Started = 1
wave = wave + 1
killed = 0
end

but with the way you have set it up you will also need to check wave is greater than 0 or change the init number_of_enemies so that it wont mess up as with the current init setup killed and number_of_enemies both equal 0 - thus the condition is true.


(untested but should work)

edit, just tried it and you can indeed bring dead characters back to life using Spawn(#), this would make you need much less characters.
just store the location of the desired starting point for them when they reset and then
*replace the #'s with the entity number of the character to use*


then instead of needing 22 enemies you only need 10 (using the numbers in your script)

i made a quick sample video of a script respawning the same enemy each time he dies in a random location near the player using a version of the above technique
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
AstrobloodKnight
8
Years of Service
User Offline
Joined: 3rd Aug 2015
Location:
Posted: 8th Aug 2015 16:57
dude thats amazing really thats so kool
PM
AstrobloodKnight
8
Years of Service
User Offline
Joined: 3rd Aug 2015
Location:
Posted: 8th Aug 2015 17:10 Edited at: 8th Aug 2015 17:11
i am having an issues with the respawning it tells me its not index did i place it in the wrong place

PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Aug 2015 18:30 Edited at: 8th Aug 2015 18:31
i think it might be because the characters are set to spawn at start = no?
try using that method for wave 2 onwards and keep the original Spawn(#) for wave 1
(it's kinda telling them to move before the engine is really registering they exist)

also you are using the default enemies right? or entities set up as characters (ischaracter = 1 in the fpe file)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
AstrobloodKnight
8
Years of Service
User Offline
Joined: 3rd Aug 2015
Location:
Posted: 8th Aug 2015 19:27
i am use default enemies and i fix the waves issues you forgot to Cap the K in killed

also
CollisionOff(#)
SetPosition(#,x,y,z)
AIEntityGoToPosition(g_Entity[#]['obj'],g_PlayerPosX,g_PlayerPosZ)
CollisionOn(#)
Spawn(#)

the third line doesnt seem to work it tells me it it doesnt index
PM

Login to post a reply

Server time is: 2024-05-06 21:39:11
Your offset time is: 2024-05-06 21:39:11