Forum

> > CS2D > Scripts > How to detect spawn points?
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to detect spawn points?

20 replies
Page
To the start Previous 1 2 Next To the start

old How to detect spawn points?

BcY
Reviewer Off Offline

Quote
Hello guys!
I have a problem;
How to detect all of the spawn points that exists in the map?
I see there is a spawn point for T out of the map and i couldnt find it because when somebody spawns there the server is crashing.

old Re: How to detect spawn points?

GeoB99
Moderator Off Offline

Quote
You would normally check the entity spawn positions through Editor without necessarily to check them via script. If you want it otherwise then let it be.

As these folks above explained (though not completely), you'd just iterate all the Info_T entities of the map with this Lua function.
1
2
3
for _, e in pairs( entitylist(0) ) do
	print('Info_T entity coordinations @ ' .. e.x .. ' as X path and ' .. e.y .. ' as Y path.')
end
To explain briefly the logic of the code: the
for
loop will iterate all over the entities with value ID as 0 (hence Info_T) and will print onto the console their coordination. This as to not iterate to the whole entities since we're focusing on the T spawn paths.

old Re: How to detect spawn points?

BcY
Reviewer Off Offline

Quote
Thank you all guys.
@user GeoB99: just found it;
Info_T entity coordinations @ 168624128 as X path and 1634951539 as Y path.

I'm like WTF. Seems like a bug,am i wrong?

old Re: How to detect spawn points?

_oops
User Off Offline

Quote
As I remember, that's kind of map glitch when the map file is corrupted.

same thing happened me before and couldn't find solution. ( yes, I just recreated whole map. )
Try use cs2d cmd triggerposition ? not sure it will fix the problem.

old Re: How to detect spawn points?

BcY
Reviewer Off Offline

Quote
@user _oops: it's really awkward,im still in shock. I also figured it out; when a t spawns there,it crashes the server. I dont know what causes to this problem but it's really annoying.

Btw thanks for helping,@user _oops i will try that.

old Re: How to detect spawn points?

GeoB99
Moderator Off Offline

Quote
@user BcY: Huh? The hell did these numbers come from? Fairly sure whether there's something wrong in the Editor or the map file format is corrupted like user _oops cited which is quite odd. Normally a corrupted file shouldn't open as it would rather trigger an error in the first place.

old Re: How to detect spawn points?

_oops
User Off Offline

Quote
Lucky that I still have corrupted map file.

IMG:https://puu.sh/pHS9I/8ed46aabb2.png


Ye! same thing happened for me. I just put script that makes impossible to join terrorist force to prevent crashing.

EDIT: ye, cs2d cmd triggerposition was the solution.
1
2
3
4
5
6
7
8
9
10
11
function GLITCH_SPAWN_REMOVE()
	for _,e in pairs(entitylist()) do
		if (entity(e.x,e.y,"typename") == "Info_T" ) then
			if ( e.x > map("xsize") or e.y > map("ysize") ) then
			parse("triggerposition "..e.x.." "..e.y)
			print("\169255255255Found glitched spawn point - "..e.x.."|"..e.y)
			end
		end
	end
end
GLITCH_SPAWN_REMOVE()
edited 1×, last 27.06.16 05:26:16 pm

old Re: How to detect spawn points?

DC
Admin Off Offline

Quote
I would love to know why and how the map files break in some cases. Weird and bad stuff. It shouldn't happen...

The real solution to this issue should be to get rid of the "broken" entities instead of writing scripts to ignore them. If your map does not contain too many entities you can use the shortcut shift+ctrl+del to remove ALL entities. You will obviously have to place all healthy entities again afterwards but you'll at least keep the map tiles.

I'll add a todo to the backlog to add a editor window showing a list of all entities so you can easily jump to specific ones or remove them.

old Re: How to detect spawn points?

BcY
Reviewer Off Offline

Quote
user DC has written
I would love to know why and how the map files break in some cases. Weird and bad stuff. It shouldn't happen...

The real solution to this issue should be to get rid of the "broken" entities instead of writing scripts to ignore them. If your map does not contain too many entities you can use the shortcut shift+ctrl+del to remove ALL entities. You will obviously have to place all healthy entities again afterwards but you'll at least keep the map tiles.

I'll add a todo to the backlog to add a editor window showing a list of all entities so you can easily jump to specific ones or remove them.


Unfortunately there are too many entities in my map.Is there an entity limit,i just wonder? Maybe it causes the problem? Btw thanks for helping.
_
@user Mami Tomoe: it's not that easy man,as i know.Or maybe i know it wrong,can you tell me detailed?

old Re: How to detect spawn points?

DC
Admin Off Offline

Quote
No, there is no (realistically reachable) limit for the entity count.

The map file can in fact be altered with a HEX editor. It would be easier to fix the position though. You can just do a search for a signed 32 bit integer to find the x/y position and change it.

Removing the whole entity is a bit more complicated because you can't easily see which bytes belong to the entity and you would also have to decrease the total entity count (also saved as a signed 32 bit integer) by 1.

old Re: How to detect spawn points?

Dousea
User Off Offline

Quote
Recreating the whole map is moderately easy as I recall. Look at the map format. You can save the bytes that don't belong to 'entity category', then only rearrange the bytes for the entities, removing the 'glitched' spawn entities. Use Lua. I will give you details if you need them.

old Re: How to detect spawn points?

_oops
User Off Offline

Quote
I do remember this thing happened when I copy-pasted Lua script into cs2d entity trigger_if without breaking lines.
Not only lua script. Including copy paste sentences into any kind of entities. I'm not sure this way still corrupt map file.

old Re: How to detect spawn points?

VADemon
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
local mapSizeX, mapSizeY = map("xsize"), map("ysize")
local brokenCount = 0

print("OutOfBoundaries Entity check started!\n")
print("Map: ".. map("name"))
print("Map size in tiles: ".. mapSizeX .." | ".. mapSizeY)

local list = entitylist()
for k, ent in pairs( list ) do
	if ent.x > mapSizeX or ent.x < 0 or ent.y > mapSizeY or ent.y < 0 then
		brokenCount = brokenCount + 1
		print("Entity with ID ".. entity(ent.x, ent.y, "type") ..", ".. entity(ent.x, ent.y, "typename") .." called '".. entity(ent.x, ent.y, "name") .."' @ ".. ent.x .."|".. ent.y)
	end
end

print("OutOfBoundaries Entity check finished!\n")
msg("Check of broken entities finished, ".. brokenCount .." invalid entities found")

This code will show you all entities that are outside the playable map boundaries (aka beyond map size). If cs2d entity info_t spawn entities are broken then there must be more than just that. Just drop that piece of code into /autorun/ and launch the map, the results will be shown in console.

@user BcY: would be nice of you to upload the broken map so we can take a look at and study it. If it's a bug like user _oops suggested then it may be feasible to fix by deleting several invalid lines.

old Re: How to detect spawn points?

_oops
User Off Offline

Quote
I tried to create corrupted map file however result was different.
console output this sentence.
1
UPDATE MAP: Found unknown entity type: 102 @ 195273387 , 544108393

I wondered will the script can tell what kind of entity is it
1
msg("Entity : "..entity(e.x,e.y,"typename").." @ "..e.x.."|"..e.y)
after load the script, my game just crashed.


Strange thing was an entity(cs2d entity Trigger_Start) that triggered cs2d entity Trigger_If that causing glitch was erased itself when I opened the map file again.
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview