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 / Randomly spawn an entity

Author
Message
fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 1st Aug 2007 14:07
Is there a script or a way to randomly generate entities? id like to have a way to alter how my level will look by randomly generating entities, the script or computer would decide where to generate entities, it may generate an entity in a place or it may not and that part of the map would be empty or would have an entity.
xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 1st Aug 2007 16:11
There probably is way (to an extent) to do what you want. It may be easier to base the spawns on the player movement though, spawning different enemies depending on what path the player takes.

Best.

I'm sorry, my answers are limited. You must ask the right question.

fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 1st Aug 2007 18:40
Its not enemies I want, Im using entities as walls and will spawn then randomly, I know we use segments for walls but its for a specific game concept, so it doesn't matter that Im using entities.
I just need to be able to randomly generate a tiny maze over and over again.
xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 1st Aug 2007 18:50
Yeah, sorry I read that wrong, but the same applies to entities. It just seems that the random spawning of walls in a maze would be wicked hard and spawning walls depending on which path the player took would be easier, though limiting.

Best.

I'm sorry, my answers are limited. You must ask the right question.

fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 2nd Aug 2007 01:05
The maze has 4 exits, when they get to an exit it teleports them to the opposite side and re spawns the maze, so yes, it is done though where the player is.

So yes that is one part of it.
The player runs about in the maze, gets to an exit, the maze is destroyed the player is teleported to the opposite side exit and a new maze is made.

This could also be done by having all the walls under the floor then having something that chooses which walls to use and then a mover bringing them up. So say if the game space is 10x10, have each square with a wall on an elevator platform, the computer randomly decides which platforms will rise to make the maze, so that's another way of doing it, just need a way for the computer to decide which of the platforms to have move up when a maze is being made, once the player gets to an exit, all those platforms move down and it makes a new maze by deciding which platforms to raise up from under the floor hidden from view, the walls would not have to be able to clip with the floor, otherwise they would not come up though the floor, so they would have to clip players but not segments.

So 2 ways to do this then, but as Im no scripter im not sure how to make this.
fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 2nd Aug 2007 13:20 Edited at: 2nd Aug 2007 14:59
What it needs is a random number generator, one is randomly generating an outcome so a random number generator would help things.

I hear that scripting follows stringing together a lot of pre set commands, is there a list of these commands some place that we put together to make a script. If there is it needs putting on a sticky.

I see there is FPI Maker 0.5, Im sur4e I have seen something that checks scripts for errors or checks it works without having to test it in game, not sure if this is it
xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 2nd Aug 2007 16:24
For a list of conditions and action (commands) go here.

There is a ramdom generator.
RANDOM=X is true when a random value between 0 and X is equal to one

Good luck with this.

I'm sorry, my answers are limited. You must ask the right question.

fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 2nd Aug 2007 19:16 Edited at: 2nd Aug 2007 19:17
Quote: "There is a random generator.
RANDOM=X is true when a random value between 0 and X is equal to one"


so if one puts RANDOM=10

it will do a random generator and give the command true if it comes up as 1, so if I put RANDOM=10
then its a 10% chance, if I want it 50% then I put RANDOM=2

Is thats it, if so one cant have less than 50% chance of true, if one wanted 25% chance one would have to do the outcome not as true but false RANDOM=4 is false, would give it 25% chance of being a true outcome.

Have I got this right, how exactly does the random command work?
xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 2nd Aug 2007 19:41 Edited at: 2nd Aug 2007 19:44
Yep. Exactly.

random=4 means that the engine will pick a number between 1 and 4, giving it a 1-in-4 chance of being 1(true), or 25 percent.

Best.

I'm sorry, my answers are limited. You must ask the right question.

fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 2nd Aug 2007 19:54 Edited at: 2nd Aug 2007 19:54
If the statement is always true then odds are like below (some are missing but you get the point)
1-2 = 50%
1-3 = 33%
1-4 = 25%
1-5 = 20%
1-10 = 10%
1-50 = 2%
1-100 = 1%

the best odds we can get are 50% that it is true, so how do we have something be 80% chance it will be true or anything above 50% as 1-2 is the highest odds we can make.
xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 2nd Aug 2007 20:00
You could repeat the condition.

If true, it continues on to whatever you wanted to happen.

else, repeat the condition random=2.

Now I'm not sure what that does to the odds exactly. It seems like that would increase them to 75 percent, but sometimes I can't figure those thing out in my head.

Best.

I'm sorry, my answers are limited. You must ask the right question.

fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 2nd Aug 2007 21:15
repeating it make the odds less, if we want 90%, so a cert.
you say do it twice, then we need to win the first odds 50% then do some more odds, that makes the odds worse, not more like a cert.
to get more than 50% odds if they cant be changed one would have to do the calculation not on it being true but false, 1-10 + false
that makes it 90% it will be true.
But I'm not sure we can have a false statement, id like to know how these things are worked out as it seems hit and miss for working out random numbers, like any odds we want.
Any ideas anyone?
xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 2nd Aug 2007 21:27
No, you don't need to win the first odds to do it again. Only do it again if the result is false.

state=1:random=2,state=4 (test for true)
state=1:random=2,state=4 (test for true again)
state=1:state=8 (both times false)

:state=4:...true code

:state=8:...false code

It passes through the test twice. If true the first time, it goes on to state 4. If not, It tries again. That's got to give you better odds. The more you test it, the better the odds one of them will be true. If both or more fail, it goes on to false code.

Best.

I'm sorry, my answers are limited. You must ask the right question.

fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 3rd Aug 2007 01:57 Edited at: 3rd Aug 2007 04:12
I think one can do this by having entities beneath the floor of the player, when the script is activated the entities raise up through the floor, is it possible to have entities raise up through the floor ? There is no hole in the floor, they just come though it, if they cant then its properties need to be changed, like its clip (detection of something)needs changing, so the floor doesn't clip it, (block) but it has clip (blocks) for players, is this possible?

one could activate this by being in a zone and the trigger sets the script off, but I only want it to do it once, as if the player stood in the zone then he would have the script running over and over again, so it must only do it once, so it has to active once, not keep doing it because the player is still in the trigger zone.

Also is this the same scripting language used in the Gamecreators other products, because if it is, if one got used to the scripting here, then one may be able to use their other products.
fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 3rd Aug 2007 11:32 Edited at: 4th Aug 2007 17:18
Just trying to work scripting out, what will happen in this simple script is, player goes to zone, this sets off the script for the entity, entity script does a test, it has a 50% of being true, if it is the entity moves up 100 units.

so at the start of the level its not activated

:state=0:state=1

a trigger zone will make the script run

PLRWITHINZONE

I find it off that a command for the zone or trigger isnt here.
how does it know which zone.

to test if the platform will go up or not

:state=1:random=2

:state=1

MOVEUP=100

so the entity moves up 100 units

something along these lines
fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 4th Aug 2007 17:08
Im sure the script to make an entity move up 100 units bu with a random element, activated by a zone is just this script below, Does this look correct?

---------------------------------
;Random Lift

;Header

desc = Random Lift (Up) (activate may activate an entity to move up)

;Triggers

:state=1:random=2
:state=1:moveup=100

;End of Script
---------------------------------

So the script is saying descriptrion in the first bit.

;Triggers
This means its activated by a trigger, not sure if thats suppose to be there or not.

:state=1:random=2
This means state 1 is a random check, it gives 50% odds of being true.

:state=1:moveup=100
Means move up 100 units if the random call is made and is true.

thats it end of script, is it correct?
xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 4th Aug 2007 18:01 Edited at: 4th Aug 2007 18:05
;Triggers

:state=0:state=1
:state=1,random=2:state=2 ;if true, lift. state=1 and random=2 are both conditions.
:state=1:state=3 ;if not, do nothing
:state=2:moveup=100

;End of Script

I'm sorry, my answers are limited. You must ask the right question.

fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 4th Aug 2007 20:59
This is quite interesting, I see how that works out, I find it interesting that to do nothing we give it state (a condition) and thats state 3, but as there isnt a state 3 telling it to do something, it does nothing, rather than saying state 3 is a command to do nothing, perhaps if you did that it may do that completly and really do nothing including running the game, Im not sure, just find it interesting that to make it do nothing we give it a state with no command/instruction in it.

By the way is this how the Gamecreators Playbasic languge works or Dark Basic, or is this a special language created just for fpsc.
xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 4th Aug 2007 21:17 Edited at: 4th Aug 2007 21:17
We give it the state=3 to take it out of the loop, making the script run once only. Alternatively, we could add a state 3 line...

:state=3:none

If it were a script that needed to constantly generate a random, we could have used...

:state=3:state=1

If we wanted it to run only while the player was within a certain distance, we could change the first state...

:state=0,plrdistwithin=50:state=1

The language is very simple and limited, but there are a lot of options.


As for the other programs, I don't know.

Best.

I'm sorry, my answers are limited. You must ask the right question.

fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 4th Aug 2007 23:33 Edited at: 4th Aug 2007 23:34
Im wondering to make the moving entity move back down, what happens is that I want it to re set and do it again and again, I could do this either by triggers, so have a trigger to decide what entities move up like we have outlined above, then just have another trigger to make the entities move back down.

Or perhaps have a counter on the screen, not sure if we can draw new items on the HUD and have them change and have what is drawn on the screen affect something in the game, like if we had level one written at the top of the screen, we activate the entities to move, then have a script that says every time you are asked to draw a new number on the screen, i.e. it changes to level 2, that all entities return to the start position, If you can it means we can have a level number effect what happens in a game, so that entities have there behavior effected by what level it is.

So Im a bit lost on how I can make entities that have moved go back to there starting positions so the function of moving new random entities up can be done again and again.
xplosys
18
Years of Service
User Offline
Joined: 5th Jan 2006
Playing: FPSC Multiplayer Games
Posted: 4th Aug 2007 23:51
Moving the entities back down is as simple as moveup=-100. As for how you intend to orchestrate this operation, I'm as interested as you are to see how you do it.

best.

I'm sorry, my answers are limited. You must ask the right question.

fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 5th Aug 2007 11:11 Edited at: 5th Aug 2007 11:13
but it would have to know which ones to move down, how would it know which entities need to go back down.
I know its all the entities that have been moved up, or all entities on that level of map height, but Im not sure how to make the script know. Ill have a look thorugh the commands and see if something comes to mind.
fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 5th Aug 2007 21:09
Can one make a zone and say all entities in this zone do such and such, so we can call something to happen to entities if they are in a certain zone of the level, Is that possible?
Marine10 beta corp
17
Years of Service
User Offline
Joined: 14th Jan 2007
Location: First Man Studios
Posted: 6th Aug 2007 04:44
yes... the Random=X script command can be used... but to make a maze that is different each time requires some intense scripting... if its possible at all

-Marine 10 beta corp

FIRST MAN STUDIOS
fallen one
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: My imagination!
Posted: 6th Aug 2007 12:20
Ill be testing this out, yes a true maze would need some heavy scripting, that's if it was possible, this wont be a maze more a set of obstacles really.
protoborg
17
Years of Service
User Offline
Joined: 2nd Jul 2007
Location: Somewhere in this reality
Posted: 12th Aug 2007 07:37
Okay, what no one seems to be thinking about is the fact that RANDOM=x is designed to use numbers between 0 and x. Therefore, the probabilities would work like this:

x | probability
1 | 50%
2 | 33.3%
3 | 25%
4 | 20%
5 | 17%
6 | 14%
7 | 12.5%, etc.

In order to increase the odds above 50%, you would have to use an equation that equals 1 more than half the time. As far as the clipping issue goes, you would not have a floor as the lifts would BE the floor. You DO NOT need a floor. Once the lifts have reached the top, they can be walked on! That is the whole point of the lift.

I suspect the simplest way to do this would with the create-destroy script. I do not remember the thread that discusses this script, but you can search for it. The script "creates" the object as you approach it and "destroys" it as you move away. You could use this on the entity walls.

You know your code sucks when it does what you want before you know what you want.

Login to post a reply

Server time is: 2024-11-23 20:59:54
Your offset time is: 2024-11-23 20:59:54