Hi, first of all, I know that you do not support online cheating but let me explain. I'd like to decrease re-spawn timer for multiplayer (15 second one). I know this is possible because there is a server already that has it(its called cemetry or something like that).
This wouldn't be cheating because you can obviously only use this in your own dedicated server and it gives no advantage. It's more like re-balancing the gameplay a bit.
I'm not sure if anyone ever stumbled on this yet so I'm just asking for suggestions in which .lvl file would this information be stored(I'm thinking ingame.lvl but not too sure)?Thanks as always
No prob. You actually helped me indirectly didnt you xD
topic may be closed
Re: Spawn timer?
Posted: Thu Jan 31, 2013 4:41 am
by [RDH]Zerted
You can setup a repeating timer to respawn all dead units every ## seconds. Another way would be to add an death event listener and respawn a unit as soon as it dies. The problems for human players is that they might not have enough time to switch units and they won't be able to control where they respawn. I always called this "force spawn". I'm sure the code is hiding somewhere in these forums.
If you want this on a server, you'll need to create a custom user script so that your code gets loaded on the maps you want. If you run the code when not the host, your game will respawn you but the server won't respawn you. Your unit gets 'disconnected' and can't do anything because it doesn't actually exist.
Re: Spawn timer?
Posted: Thu Jan 31, 2013 7:26 am
by nobody3
that sounds good because forcing players to spawn is what i was looking for, the thing is, would the script also work on ps2 dedicated server? I think it would but not sure
Re: Spawn timer?
Posted: Fri Feb 01, 2013 2:38 pm
by [RDH]Zerted
I've never tested it on a PS2, but I would expect it to work.
Re: Spawn timer?
Posted: Fri Feb 01, 2013 3:40 pm
by nobody3
im not sure how to do it though, what would I need to do? does the"force spawn" code have to be ran through fake console? because there is none on ps2, oh well there is but I dont know how to turn it on but its possible because another person has done it before
Re: Spawn timer?
Posted: Fri Feb 01, 2013 6:07 pm
by [RDH]Zerted
Long way using a timer (adapted from the spawn as locals script). This is a custom user script requiring v1.3 and following v1.3's tutorials on munging custom user scripts. Untested code:
Hidden/Spoiler:
[code]print("always_respawn_script: Entered")
--attempt to take control of (or listen to the calls of) the ScriptPostLoad function
if ScriptPostLoad then
print("always_respawn_script: Taking control of ScriptPostLoad()...")
--check for possible loading errors
if always_respawn_script_ScriptPostLoad then
print("always_respawn_script: Warning: Someone else is using our always_respawn_script_ScriptPostLoad variable!")
print("always_respawn_script: Exited")
return
end
--backup the current ScriptPostLoad function
always_respawn_script_ScriptPostLoad = ScriptPostLoad
--this is our new ScriptPostLoad function
ScriptPostLoad = function()
print("always_respawn_script: ScriptPostLoad(): Entered")
--Checking Map name and Mode name to see which map we're on
if __thisMapsMode__ == "end1_conquest" then
print("user_script_1: Map is Endor")
--Team1SpawnUnit = "ewk_inf_trooper"
--Team2SpawnUnit = "ewk_inf_trooper"
Team1SpawnPath = "CP10SpawnPath"
Team2SpawnPath = "Path6"
elseif __thisMapsMode__ == "tat2_con" then
print("user_script_1: Map is Mos Eisley")
Team1SpawnPath = "CP1_SpawnPath"
Team2SpawnPath = "CP3_SpawnPath"
elseif __thisMapsMode__ == "tat3_con" then
print("user_script_1: Map is Jabba's Palace")
Team1SpawnPath = "CP1SPAWN"
Team2SpawnPath = "CP4Spawn"
else
print("always_respawn_script: Disabling this script on unknown map: ", __thisMapsMode__)
print("always_respawn_script: Exiting after always_respawn_script_ScriptPostLoad()")
return always_respawn_script_ScriptPostLoad() --make sure to forward the method call to the real ScriptPostLoad, so the game can function normally
end
--------------------------------------------------
-- Functions to help process the ingame players --
--kills the player with the given index
function KillPlayer( index )
--if the player is already dead, do nothing
local unit = GetCharacterUnit(index)
if not unit then return end
--make sure this kill doesn't count towards ending the map
local team = GetCharacterTeam(index)
AddReinforcements(team, 1)
--kill the player
KillObject(unit)
end
--respawns the player with the given index
function ReSpawnUnit( index )
--TODO may have to kill the player twice to make sure the camera locks in on the new unit
KillPlayer(index)
--team 1 players
if GetCharacterTeam(index) == 1 then
--attempt to select which unit type to spawn as
if Team1SpawnUnit != nil then
SelectCharacterClass(index, Team1SpawnUnit)
end
--attempt the actual unit spawning
SpawnCharacter(index, GetPathPoint(Team1SpawnPath, 0))
--team 2 players
elseif GetCharacterTeam(index) == 2 and Team2SpawnPath != nil then
--attempt to select which unit type to spawn as
if Team2SpawnUnit != nil then
SelectCharacterClass(index, Team2SpawnUnit)
end
--attempt the actual unit spawning
SpawnCharacter(index, GetPathPoint(Team2SpawnPath, 0))
end
end
--called when we generated the ingame player list
function OnSpawnFunctions(players)
--if no v1.3 patch r117+, then can't do anything
if not uf_processPlayers then
print("always_respawn_script: WARNING: The uf_processPlayers function is missing. Please update your game to the latest UnOfficial v1.3 patch")
return
end
--if no players table, then can't do anything
if not players then
print("always_respawn_script: WARNING: The players table is missing")
end
--for each ingame player,
local n
local i
for i=1,table.getn(players) do
--if the player is dead respawn him/her
if not GetCharacterUnit(players.indexstr) then
ReSpawnUnit(players.indexstr)
end
end --ends 'for i=1'
end --ends 'OnSpawnFunctions'
--------------------------------------------------
------------------------------------------------------
-- every 15 seconds, process all the ingame players --
if SpawnUnit ~= nil then
local waitTime = 15
local charSpawnTimerDone = function(timer)
uf_processPlayers( OnSpawnFunctions )
SetTimerValue("CharacterSpawn_timer", waitTime)
StartTimer("CharacterSpawn_timer")
end
--configure the timer
CreateTimer("CharacterSpawn_timer")
SetTimerValue("CharacterSpawn_timer", waitTime)
OnTimerElapse(charSpawnTimerDone,"CharacterSpawn_timer")
StartTimer("CharacterSpawn_timer")
end
------------------------------------------------------
print("always_respawn_script: ScriptPostLoad(): Exiting after always_respawn_script_ScriptPostLoad()")
return always_respawn_script_ScriptPostLoad() --make sure to forward the method call to the real ScriptPostLoad, so the game can function normally
end
print("always_respawn_script: Have control of ScriptPostLoad()")
else
print("always_respawn_script: Warning: No ScriptPostLoad() to take over")
print("always_respawn_script: Exited")
return
end
print("always respawn script: Exited")[/code]
The shorter way would be to use OnCharacterDeath (or whatever it is). Inside that use SelectCharacterClass() and SpawnCharacter(). Ambushing does a similar thing so look at the ambush code for another example. You'll still need to make a custom user script to get your code injected into the server. The documentation include with v1.3 has the steps to do that. I don't rmember if it's safe to install v1.3 ontop of the PS2 dedicated server software. Run the v1.3 r129 installer normally but be sure to select the proper path for the server software instead of the actual PC game.
If you go the OnCharacterDeath route, I recommend creating a basic map and trying your code on that. Then convert your working script changes into a custom user script.