Scripts / Request: Random Spawn

Author
Message
teereex
7
Years of Service
User Offline
Joined: 23rd Jul 2016
Location:
Posted: 11th Feb 2020 10:35
Hi im in need of a script that spawns you randomly on the map, so every time you die you spawn some where else, if possible make it so it can be attached to like a zone so i can place the spawn points manually...

Thank you in advance
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 11th Feb 2020 11:41
You should elaborate a bit.
Quote: "script that spawns you randomly on the map, so every time you die you spawn some where else"

Let's see if I've got your point:

1- You has a bunch of soldiers on your map, unspawned many of them.
2- When player kill someone automatically/randomly spawn another one, in a different spot.

Let me know if I'm right, before do nothing.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
teereex
7
Years of Service
User Offline
Joined: 23rd Jul 2016
Location:
Posted: 11th Feb 2020 11:51
i mean that you as the player will spawn at some random location then the default "player start" or by a "checkpoint" when you get killed,
well it should be more or less random but as i said, i want a script to be attached to like the "trigger zone" and the player will spawn at a random one that has that script, so then lets say there is 20 zones with the script, the script randomly picks one of those...
... and also would it be possible to remove every pick up like weapons keys etc so only the default start weapon is attached.
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 11th Feb 2020 15:26
As I did:
Using 3 barrels as destination point, and attach each one the script below.



Use triggerzone as well and place player marker over the triggerzone.
Attach to triggerzone the script below.



It works for me.
You will get player starting in random spot every time you try your level.

Notice I'm using 3 entities (barrels) as destination points, anyway you can place as much as you want to.
Untested as standalone game.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
teereex
7
Years of Service
User Offline
Joined: 23rd Jul 2016
Location:
Posted: 11th Feb 2020 16:04
what do i need to call the scripts ?.
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 11th Feb 2020 21:48
Quote: "what do i need to call the scripts ?."

Read my preview post, it say I've using a barrels plus 1 triguer zone. You can use what you want, anyway they need to be dynamic (green color when hovering over entity). Static entities don't run scripts.

Quote: "... and also would it be possible to remove every pick up like weapons keys etc so only the default start weapon is attached"

You mean between levels in standalone?
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
teereex
7
Years of Service
User Offline
Joined: 23rd Jul 2016
Location:
Posted: 12th Feb 2020 03:24
it should be on death so when you die the picked up stuff should be removed from the "inventory" in the same level
PM
teereex
7
Years of Service
User Offline
Joined: 23rd Jul 2016
Location:
Posted: 12th Feb 2020 06:12 Edited at: 12th Feb 2020 06:15
i cant get the script to work, video shows what im doing
https://streamable.com/dxtc1
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 12th Feb 2020 08:44
If you edit a script using notepad / notepad ++ you will see the word "function rndpos_spawn_init (e)" in this case save the file as "rndpos_spawn.lua" in the scriptbank folder.
Do the same with the script called "plr_randomspawn"

If you want to change the name of the file you will have to change the name of the function too, in your case it would be:

"function spawn_init (e)"
"function spawn_main (e)"
so the file would be called "spawn.lua"

First let's try as is.
Do not change the name of the scripts, in fact do not change anything at all.
Create a new map and follow the steps in the video.



On the first attempt the player spawn near the barrel rusted.
On the second attempt the player spawn near the barrel clean.
In other words, the player spawn in a random place every time you test the map; which I understand is the first objective.
Now that you have verified on your computer that the scripts work, you can now make the changes you want to adapt it to your needs.

As for the second objective.
I personally do not use standalone except when I have to try to reproduce an error that a user experiences and to try to help.

But from what I've read, you pretend just the opposite of what many people claim: GG does not keep objects between levels. If this is true, you have the problem solved.
However, if I have some free time, I will try to create a standalone with several levels and check it personally.

Through LUA you can get, but you have to modify some lua files to get it, files that would be modified as soon as you check files via steam, or an update of GG.

Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
teereex
7
Years of Service
User Offline
Joined: 23rd Jul 2016
Location:
Posted: 12th Feb 2020 09:54 Edited at: 12th Feb 2020 09:54
i would like the random spawn to be also when player dies. so every time you die the spawn gets picked randomly again
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 12th Feb 2020 17:41
Replace script called "rndpos_spawn" with this one below:



Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
PCS
7
Years of Service
User Offline
Joined: 7th Jul 2016
Playing:
Posted: 12th Feb 2020 19:33
you can also try this. https://forum.game-guru.com/thread/218767#msg2587707
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11

Login to post a reply

Server time is: 2024-03-29 09:21:50
Your offset time is: 2024-03-29 09:21:50