Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Spawn Enemies Based on Player's Kill Count

Author
Message
Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 20th Jan 2011 10:03
Hi,

I'm not sure if this is useful to anyone or not, but I've written a script to spawn enemy types based on the player's kill count:



I've simplified the script here from the one I'm using in my project as I use different variables and enemies, but this example (hopefully) gives you an idea of what is going on.

In order for this script to work you'll need to place 3 enemies in your level and name them EnemyHard, EnemyMed and EnemyEasy. Then alter their stats so that EnemyHard is tougher than EnemyMed is tougher than EnemyEasy. This can be done by giving the enemies better weapons or simply increasing their health.

The script itself needs to be added into the main *.fpi of a dynamic entity such as a blood-splat (or something similar) so that it runs and spawns the enemies as expected.

What (should) happen is:
- EnemyHard is spawned if the player has killed over 100,
- EnemyMed is spawned if the player has killed between 50 and 99,
- EnemyEasy is spawn if the player has killed less than 50.

[url="http://raptr.com/No_Turn_Right?src=em_forum"][/url]
The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 20th Jan 2011 23:27
Won't that spawn hard and medium at the same time since medium will spawn as long as it's over 49 kills. I would change the line to this



Srry about my english im from sweeden
Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 21st Jan 2011 06:41
Not sure. I thought setting state=1 at the end meant that the next line would not be true?

Anyway the suggesion is solid - thanks.

[url="http://raptr.com/No_Turn_Right?src=em_forum"][/url]
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 21st Jan 2011 07:28
Changing the state to 1 without a state 1 will prevent the script from working anymore, since there are no state=1 condition lines.


The one and only,


Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 21st Jan 2011 09:08
So technically both

:state=0,vargreater=49,varless=100:settargetname=EnemyMed,activatetarget=1

(i.e. no need for state=1) and

:state=0,vargreater=99:settargetname=EnemyHard,activatetarget=1,state=1
:state=0,vargreater=49:settargetname=EnemyMed,activatetarget=1,state=1

would work.

[url="http://raptr.com/No_Turn_Right?src=em_forum"][/url]
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 21st Jan 2011 19:15
My suggestions would be to step through the different spawns via states. Here's some pseudo-code to show what I mean:

ALWAYS - globalvar=1

state=0 - spawn easy enemies and go to state 1

state=1 - If var is greater than 50, spawn medium enemies and go to state 2

state=2 - if var is greater than 100, spawn hard enemies and go to state 3


Hope that helps.


The one and only,


Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 21st Jan 2011 20:47
Cheers, but that's not quote the effect I was after.

My script was intending to only spawn the enemy of the desired toughness and keep the lesser enemy hidden, hence the state=1 at the end of each line.

[url="http://raptr.com/No_Turn_Right?src=em_forum"][/url]
The Zoq2
15
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 22nd Jan 2011 00:06
Like ply said State 1 at the end of the line will make the script fail.

This is because when the players killcount is less than 50 it will do all the comads on that line. That means it will spawn the easy enemies onece then go to state 1. The "state" condition checks if the current state of the scipt = the specified number, if it is it will return true, if it isn't it will return false. Since conditions in the line has to be true for the action to be used nothing will hapen when the script goes to state 1

Srry about my english im from sweeden
Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 22nd Jan 2011 17:13
Just an update I tested the following scipt:



And it worked. Only the Hard enemy spawned when my Kill Count (globalvar=1) was greater than 99.

[url="http://raptr.com/No_Turn_Right?src=em_forum"][/url]
Seth Black
FPSC Reloaded TGC Backer
19
Years of Service
User Offline
Joined: 22nd Feb 2005
Location: Pittsburgh, PA
Posted: 22nd Jan 2011 18:16 Edited at: 22nd Jan 2011 18:17
...yes, because that line of code was read first.

Did only the Medium Enemy spawn when the Kill Count reached 50, before it,
in the same instance?

Did only the Easy Enemy spawn when the Kill Count was less than 50 before
that, in the same instance?

Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 22nd Jan 2011 19:18
I validated it by running the script 4 times and changing the setvar part each time:

:state=0:setvar=100 (only hard enemy appeared)

:state=0:setvar=99 (only medium enemy appeared)

:state=0:setvar=50 (only medium enemy appeared)

:state=0:setvar=49 (only easy enemy appeared)

[url="http://raptr.com/No_Turn_Right?src=em_forum"][/url]
Seth Black
FPSC Reloaded TGC Backer
19
Years of Service
User Offline
Joined: 22nd Feb 2005
Location: Pittsburgh, PA
Posted: 22nd Jan 2011 19:29 Edited at: 22nd Jan 2011 19:29
...scripting it as such merely creates a single use instant spawn event, that
excludes the other two enemies.

Were you not attempting to have it recognize the global variable count on the fly,
and adjust to the correct enemy?

Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 22nd Jan 2011 20:04
I should have put my script in context. I'm planning to integrate this code into a larger scrip that manages the spawning of enemies in waves. If the player's kill count moves up a level during a wave, the next wave will have the tougher enemies. I'm also planning on re-playing levels as the player progresses, and to reduce boredom i wanted the levels to get harder each re-play.

[url="http://raptr.com/No_Turn_Right?src=em_forum"][/url]
Seth Black
FPSC Reloaded TGC Backer
19
Years of Service
User Offline
Joined: 22nd Feb 2005
Location: Pittsburgh, PA
Posted: 22nd Jan 2011 20:10
...if it delivers what you're after, that's all that really matters.

As a single component, it doesn't appear to be a viable stand alone script.

Best of luck to you, in your future endeavours.

Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 23rd Jan 2011 00:51
If the script is only to be executed once per level, then it will do the job just fine, as you said. I was under the impression that you wanted the harder enemies to spawn as soon as the player killed a certain number of enemies.

Hope it works out for you


The one and only,


Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 23rd Jan 2011 11:04 Edited at: 23rd Jan 2011 13:02
Here is the next development of the script, but I am now in need of some help:


The script prevents all enemies from spawning until the player steps into the trigger zone.

Then it spawns an Easy enemy in zone 1. After killing this enemy, another Easy enemy is spawned in zone 2, but after killing this enemy is killed another Easy enemy is meant to spawn back in zone 1, but this does not happen. Can anyone help?

I've attached a pdf of how I tested the feature.

[url="http://raptr.com/No_Turn_Right?src=em_forum"][/url]

Attachments

Login to view attachments
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 24th Jan 2011 02:38
Are your enemy spawn points set as "Always Active"? It could be that the player has ventured too far from zone 1's spawn point and it's no longer executing.


The one and only,


Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 24th Jan 2011 06:38
I tried changing the enemesto "Always Active" but I ot the same result. I am wondering if once an entity has been destroyed it cannot be re-spawned.

[url="http://raptr.com/No_Turn_Right?src=em_forum"][/url]
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 25th Jan 2011 01:17
As long as the spawner's "max spawn" hasn't been reached it should continue to churn out enemies.

What sort of settings do you have applied to your spawner?


The one and only,


Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 25th Jan 2011 06:39
If you mean the entity controlling the spawning (i.e. the blood splat) then the max spawn is zero.

The enemy's max spawn was set to 1.

I did some testing of different vales and I concluded that the DESTROY script was not executed until the enemy had spawned the maximum number of times.

For example. If I set the maximum spawn of EasyEnemy01 to 3 the enemy would re-appear 3 times consecutively (re-appearing as soon as i had killed them) before the EasyEnemy02 would appear in the other room. So it seems to me, any spawning control needs to be placed in the MAIN script of the enemy and not the DESTROY script.

I'm trying to figure out a way using "spawnon" and "spawnoff" based on the globalvar defining the players location. I'll report back when I've finished testing.

[url="http://raptr.com/No_Turn_Right?src=em_forum"][/url]
Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 25th Jan 2011 09:05
Did a little bit more testing on the train this morning and I now believe that the DESTROY script is ran, but that a re-spawn is triggered each time until the maximum spawn value is reached.

I've tried using "spawnoff" within the MAIN script, but the enemy still re-spawns. Any ideas why?

[url="http://raptr.com/No_Turn_Right?src=em_forum"][/url]
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 26th Jan 2011 01:51
If you're using PB, you can turn off the spawning from another entity via activating the spawner with a value of -1.

Example:



I've used this technique before with PB to spawn crates one at a time from a spawn point. Note that int he example I've given here, you'll need to put the spawner entity's name in the ifused field of the entity using that script.

Hope that helps. Not even sure if you're using PB.


The one and only,


Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 26th Jan 2011 09:03
I'm not using PB, but I did do another test specifically looking at the "spawnoff" action and I'm concluding it is a bug within FPSC.

I created a simple, one room level with 1 enemy set up with:
Maximum at any time: 1
Maximum Spawn: 5
Spawn after Destroy: No

I also placed the "spawnoff" actions in every state of the APPEAR, MAIN and DESTROY scripts.

When I run the level, the Enemy still spawns 5 times after it is killed. I am going to raise a Bud thread unless anyone can point out where I am going wrong.

[url="http://raptr.com/No_Turn_Right?src=em_forum"][/url]
Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 26th Jan 2011 19:56
Ok I think I've figured it out. After much testing and looking through the source code I have made the following conclusions:

1. With Stock FPSC the re-spawning occurs automatically unless some spawn after delay settings are used.

2. There is no way to control the re-spawning of an entity by scripts after an entity has been destroyed.

3. The "spawnoff" and "spawnon" actions only affect the entity's Spawn At Start parameter and, in my opinion, are useless.

I can either wait for a mod, make my own mod or figure out how to do what I want another way.

[url="http://raptr.com/No_Turn_Right?src=em_forum"][/url]
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 27th Jan 2011 01:09
PB can help with the spawning, as I've illustrated above. But, if you're only looking to have that one feature, it may be less of a hassle (and cheaper) to make your own mod to do that.


The one and only,


Only those who sow the seeds of their desires will reap their benefits later.
However, I have seeds of my own to tend to. I don't have time to be someone else's watering can.
kaixboi
14
Years of Service
User Offline
Joined: 9th Aug 2010
Location: UK
Posted: 1st Feb 2011 00:44
Going slightly off the point at hand, but where would i put this sript to make it work?


Thanks,

Nazi Zombies = RULES!
Ched80
14
Years of Service
User Offline
Joined: 18th Sep 2010
Location: Peterborough, UK
Posted: 1st Feb 2011 09:53
Erm...it doesn't work.

but if you want to try, put the script in a dynamic entity such as a blood splat.

[url="http://raptr.com/No_Turn_Right?src=em_forum"][/url]
kaixboi
14
Years of Service
User Offline
Joined: 9th Aug 2010
Location: UK
Posted: 1st Feb 2011 21:32
I was referring to the one you posted before, the one you said does work


and thank you.

Nazi Zombies = RULES!

Login to post a reply

Server time is: 2024-11-24 12:28:19
Your offset time is: 2024-11-24 12:28:19