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 / [x9] Variables - read and write

Author
Message
mnemonic
17
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden
Posted: 29th Mar 2012 00:23
I have a level where I want 20 enemies, but I want to spawn 10 at the time (to ease the suffering of the gpu/cpu)
When the first 10 are killed (nomatter the order) Each and every one of them shall increase a variable when they are killed, and when the variable reaches 10, the rest will spawn. The solution I've come up with is that I have the destroy script for the enemies increase a variable which I set in another script which also checks if the variable equals 10 it will activate the other enemies.

How do I code this?

I'm using an unmodded version of FPSCx9 (1.18)

Best!

www.memblockgames.com
mnemonic
17
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden
Posted: 29th Mar 2012 00:51
Ok, I managed to solve this by myself. For testing I put 4 enemies in a level. 2 spawns at start, the other 2 does not spawn at start, a triggerpoint sets and checks the variable.



The triggerpoint script looks like the above

and the destroy scripts for the first 2 enemies looks like this:



the thing is that the enemies activated by the trigger point becomes transparent even thou the transparancy property is set to 0.
Anyone has an idea of why this happens?

www.memblockgames.com
007
13
Years of Service
User Offline
Joined: 22nd Aug 2011
Location:
Posted: 29th Mar 2012 01:38
Hello my friend,

Well, i will try to help, because in programming there are a lot of ways on doing the same thing.

First of all, i already do this on my game (and there is no need to use variables, except the state and activated), but just with little differences.

Think this way:

1) Place 10 enemies in your map, then place a "trigger" entity, can be anything, try a box (i.e) and name it as "triggerbox", place it on a non visible area of your map. Set on it properties always active and set it`s "strenght" to 0.

2) On this trigger box you assign this main script:

:activated=1:incstate=1,activated=0
:state=10:activateifused=1

3) On the field ifused of each one of the first 10 enemies, you put the name "triggerbox", and you select for the destroy script of those first 10 enemies the script "destroyandactivate.fpi", or simply put this final statement on the destroy script of those first 10 enemies:

activateifused=1

4) So each enemy of those first 10 that you kill, will "activate" the trigger box, and each time the triggerbox is activated, it will increase one number in the state variable, and return the activate variable to zero (reset) to be able to be set to 1 again, and again (10 times).

So when the state variable of the triggerbox reaches 10, it means that the first 10 enemies were killed.

5) And simply on the ifused field of the triggerbox, you put the name of the next 10 enemies. So you must name them all the same name, like "secondary_enemy", and on their properties you just set "spawn at start = NO" and "spawn after delay = YES". Voila!

It will work perfectly, like you want.

Go have a

Goldenye 007 N64
mnemonic
17
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden
Posted: 29th Mar 2012 23:39
Thanks mate! I'll try your method out when I've got the time. I can see instanly that it works aswell as mine. I just hope that your method fixes the transparency problem I described.

www.memblockgames.com
Meows
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location: Totally over the Rainbow
Posted: 31st Mar 2012 07:07
Note,
In version 1.19.009
The 10 secondary_enemy's spawn after you kill 2 of the first target enemy's

How would you prevent them from spawning until all 10 of the first targets were killed

Life is a short trip to another world
mnemonic
17
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden
Posted: 31st Mar 2012 12:37
I have not yet tried out 007's method of using the state variable instead. I have been trying to do a "mix-up" of mine, and his method, by keeping my variable, but instead of letting the first entities destroy script just inc the variable I each of them activate the trigger zone and that trigger zone increases the variable as well as setting it.

The code for the trigger is:



I think it should work, I see no errors in it. Ofcource I may have missed something, anyone else might see something that I don't. That's what we're here for, helping each other I don't know,,, but I acctually think that activated=0 does not deactivate the triggerpoint (as It seems) In the script the variable should only be increased if the entity is activated. But the other enemies spawns even when only one of the first entities is killed. Well,, but the problem still remains,,, the entities that are to spawn still appears transparent. But all FPSC scriptors must think about that we script an engine that TGC has made, and they have programmed the engine to interpret the scripts in a way which most of us don't really know. ,,, um,,, THAT we know but I mean not how the engine source code interprets the scripts.

www.memblockgames.com
Meows
13
Years of Service
User Offline
Joined: 12th Oct 2011
Location: Totally over the Rainbow
Posted: 1st Apr 2012 01:27
Well. I must admit I am NOT a scripter of worth yet.
I could not get things to work right. So I use my standby,

I can have a never ending supply of NPC's with this.
easy and fast. You can chain 20 if you want to.
OR use 20 NPC to spawn 20 X 20 X 20 X 20 more.
Put in destroy script, in ifused put a name.
in the inused NPC use same destroy script and put new name in IFUSED field.

I use it to populate the next section the player will visit and use it to populate areas that the player has to travel back to.

Very good for death to repopulate the area the player spawns at if they die. Trigger for this. Activated deactivated at start and Activated if the player passes a set Trigger.

Life is a short trip to another world
mnemonic
17
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden
Posted: 4th Apr 2012 01:03
Now I tried 007 script and it worked, and the transparancy problem is wiped away also, but since my first variable script also works without the transparancy problem it's thanks to the latest version I just upgraded to (1.19) Thank you TGC, thank you 007 and all other cool people here that deserves a thank you

www.memblockgames.com
007
13
Years of Service
User Offline
Joined: 22nd Aug 2011
Location:
Posted: 4th Apr 2012 17:58
I`m glad my method worked for you (my method is based from some tutorials of the Official Community Guide).

I am yes very happy for sharing knowledge with people here, and in life, sharing good things with people always make us live a happier life and learn new things, and most important, knowledge only grows when sharing it with people.

007.

Goldenye 007 N64
mnemonic
17
Years of Service
User Offline
Joined: 14th Jan 2007
Location: Sweden
Posted: 5th Apr 2012 01:42
Quote: "

I am yes very happy for sharing knowledge with people here, and in life, sharing good things with people always make us live a happier life and learn new things, and most important, knowledge only grows when sharing it with people.
"


well said!

I think that your method is better than mine, using the state and activated variables is better for these things, I did not know that these could be used in this way. But anyway it keeps custom variables free for other things. A good way of using custom varables could for example be if you're making a game where you find, and pick up coins, you could use a variable to keep track of how many the player has.

www.memblockgames.com
007
13
Years of Service
User Offline
Joined: 22nd Aug 2011
Location:
Posted: 5th Apr 2012 17:20
Yes bro, this is the thing!

I only use dimvars when want to track custom "objectives", pickups and the such.

If you want a good conseilling, buy Model Pack 54 (The Scary Thinker), you won`t imagine how this will be able to improve your scripting skills!

You don`t need to use the model pack itself, but you can do like i did, study it, see how the achievements system work and then adapt to your needs. I converted this model pack in a very complex mission objectives system with levels of dificulty and also, the harder the difficulty is, the player will have more objectives to accomplish.

Give it a try, you won`t regret.

Cheers,

007.

Goldenye 007 N64

Login to post a reply

Server time is: 2024-11-27 17:26:45
Your offset time is: 2024-11-27 17:26:45