Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 6b666b6

Browse files
authored
csdm_spawn_manager: better spawns placement for Z coord (#53)
* Add ducking detection * Fix: index of bounds error * ADD_Z_POSITION to 2.0
1 parent fa4e860 commit 6b666b6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

cstrike/addons/amxmodx/scripting/CSDM_ReAPI/csdm_spawn_manager.sma

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const Float:MIN_SPAWN_RADIUS = 450.0 // beta
1515

1616
// spawn editor options
1717
const MAX_SEARCH_DISTANCE = 2500
18-
const Float:ADD_Z_POSITION = 15.0
18+
const Float:ADD_Z_POSITION = 2.0
1919

2020
new const Float:g_flGravityValues[] = {1.0, 0.5, 0.25, 0.15, 0.05}
2121

@@ -175,7 +175,7 @@ RandomSpawn(const pPlayer)
175175
if(!g_iTotalPoints || g_bFirstSpawn[pPlayer])
176176
return false
177177

178-
new iRand = random(g_iTotalPoints), iAttempts, iLast = g_iLastSpawnIndex[pPlayer]
178+
new iRand = random(g_iTotalPoints - 1), iAttempts, iLast = g_iLastSpawnIndex[pPlayer]
179179
do
180180
{
181181
iAttempts++
@@ -188,8 +188,8 @@ RandomSpawn(const pPlayer)
188188
return true
189189
}
190190

191-
if(iRand++ > g_iTotalPoints) {
192-
iRand = random(g_iTotalPoints)
191+
if(iRand++ >= g_iTotalPoints) {
192+
iRand = random(g_iTotalPoints - 1)
193193
}
194194

195195
} while(iAttempts <= g_iTotalPoints)
@@ -575,6 +575,9 @@ GetPosition(const pEntity, Float:vecOrigin[coord_e], Float:vecAngles[coord_e], F
575575
get_entvar(pEntity, var_origin, vecOrigin)
576576
get_entvar(pEntity, var_angles, vecAngles)
577577
get_entvar(pEntity, var_v_angle, vecVAngles)
578+
579+
if(get_entvar(pEntity, var_flags) & FL_DUCKING)
580+
vecOrigin[2] += 18.0
578581
}
579582

580583
bool:SetAimedEntity(const pPlayer, pEntity = NULLENT, bool:bPrint = true)

0 commit comments

Comments
 (0)