Getting a character to spawn at a specific cp
Moderator: Moderators
- Tourny
- Command Sergeant Major

- Posts: 289
- Joined: Sat Sep 27, 2008 5:58 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Crifton
- Contact:
Getting a character to spawn at a specific cp
Hi.
How do I use "SpawnCharacter()"? I think that might help.
How do I use "SpawnCharacter()"? I think that might help.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Getting a character to spawn at a specific cp
characterId - The id of the character you want to spawn. In SP, the human player has an id of 0. Some event callbacks, such as OnCharacterSpawn(), give you the character id of the spawning player.SpawnCharacter( characterId, matrix )
matrix - The location where you want the new unit to spawn. This is any place you can teleport to. If you want it to be at a certain spawn node, use GetPathPoint(pathName, nodeNumber)
If the character has selected a unit class which is full, the game will attempt to spawn the human as the first unit class on that team. If it is a bot, then I don't think it gets spawned. If the first unit class is full, then the character just won't spawn at all. If this is happening, you will see it in the debug log.
- Tourny
- Command Sergeant Major

- Posts: 289
- Joined: Sat Sep 27, 2008 5:58 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Crifton
- Contact:
Re: Getting a character to spawn at a specific cp
How do I get it to find the character ID of the player in a function?
EDIT: Sorry about the duplicate topic, I honestly had no idea it had posted...
EDIT: Sorry about the duplicate topic, I honestly had no idea it had posted...
- bobfinkl
- Rebel Colonel

- Posts: 593
- Joined: Sun Jul 13, 2008 9:01 am
- Projects :: Lots of unreleased stuff
- xbox live or psn: No gamertag set
- Location: The quaint little city gametoast.
Re: Getting a character to spawn at a specific cp
You can use the OnCharacterSpawn function, if you need it written out for you tell me and I'll write it. Although there is one flaw with this method, you have to kill the person you want spawning at the specific cp.
- Tourny
- Command Sergeant Major

- Posts: 289
- Joined: Sat Sep 27, 2008 5:58 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Crifton
- Contact:
Re: Getting a character to spawn at a specific cp
Well, I used Zerted's Table from the duplicate topic, but having the function to spawn it at the CP would be appreciated.
- bobfinkl
- Rebel Colonel

- Posts: 593
- Joined: Sun Jul 13, 2008 9:01 am
- Projects :: Lots of unreleased stuff
- xbox live or psn: No gamertag set
- Location: The quaint little city gametoast.
Re: Getting a character to spawn at a specific cp
I don't know how the SpawnCharacter works so I'll leave that blank for now:
That's the structure of the coding, but I'm not sure what KillObject should be or if it's correct, and the matrix you have to put in yourself since I don't know the cp you want.
Code: Select all
onspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then -- Makes sure the character is human
KillObject(character) -- not sure if this should be a different function
SpawnCharacter(character, matrix)
ReleaseCharacterSpawn(onspawn)
onfirstspawn = nil
end
end
)- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Getting a character to spawn at a specific cp
What player are you trying to get? There are a few ways to do it...
- Tourny
- Command Sergeant Major

- Posts: 289
- Joined: Sat Sep 27, 2008 5:58 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Crifton
- Contact:
Re: Getting a character to spawn at a specific cp
Well, I'm essentially aiming for any character that has been killed by the CIS.
Is there a way I can not spawn the character and instead use the data in the table for SpawnCharacter? Or does the unit have to spawn first? I know some form of this can be done because Repsharpshooter did it in Battle Arena 2.0. When you kill someone outside the arena in clan mode, it spawns you in prison.
EDIT: I decided to make a region that engulfs the entire map, and then have it teleport them when they spawn. It didn't work. Then I added MoveEntityToNode(blah blah blah) After the set properties in the functions Zerted wrote and put the Teleport code at the bottom of the script. They still won't teleport. They switch to team 3, though.
Is there a way I can not spawn the character and instead use the data in the table for SpawnCharacter? Or does the unit have to spawn first? I know some form of this can be done because Repsharpshooter did it in Battle Arena 2.0. When you kill someone outside the arena in clan mode, it spawns you in prison.
EDIT: I decided to make a region that engulfs the entire map, and then have it teleport them when they spawn. It didn't work. Then I added MoveEntityToNode(blah blah blah) After the set properties in the functions Zerted wrote and put the Teleport code at the bottom of the script. They still won't teleport. They switch to team 3, though.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Getting a character to spawn at a specific cp
Then post your lua and the debug log.
- Tourny
- Command Sergeant Major

- Posts: 289
- Joined: Sat Sep 27, 2008 5:58 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Crifton
- Contact:
Re: Getting a character to spawn at a specific cp
LUA:
Debug Log:
I know it has a severity 3 error at the end, but I'm not sure what to do about it. Should I create a seperate function to hold the MoveEntityToNode?
Hidden/Spoiler:
Debug Log:
Hidden/Spoiler:
I know it has a severity 3 error at the end, but I'm not sure what to do about it. Should I create a seperate function to hold the MoveEntityToNode?
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: Getting a character to spawn at a specific cp
Change that line to MoveEntityToNode(player, "Team3Spawn", 0). It seems that functions wants the character not the unit. "Team3Spawn" is the name of the path you want the players teleporting to correct.
Also, add SetMemoryPoolSize("SoldierAnimation", 500) with your other memory pool lines. There are other memory pools you can fill too. Filling the pools makes your map more stable and shortens the debug log.
Also, add SetMemoryPoolSize("SoldierAnimation", 500) with your other memory pool lines. There are other memory pools you can fill too. Filling the pools makes your map more stable and shortens the debug log.
- Tourny
- Command Sergeant Major

- Posts: 289
- Joined: Sat Sep 27, 2008 5:58 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Crifton
- Contact:
Re: Getting a character to spawn at a specific cp
Ok, I did what Zerted said and seemed to get better results. All of the SoldierAnimation problems went away, but the only real change in the Debug Log was this:
I've decided to try removing the "0" at the end and just using player, Team3Spawn. I have a question, though. If this works (which I try not to count on) will it send them to any node on the path or only the 0th node?
EDIT: But first, after noticing that all my other teleports (which work) have the pathname in quotes, I'll try putting it in quotes.
EDIT EDIT: The player teleports now! =D. But I need to make it use all of the cells, so I'm going to use my previous plan and have it teleport you to a different one by class. I'm going to look up the function for it and try it now.
EDIT EDIT EDIT: The AI and humans again refuse to teleport, but this time the Debug log says nothing.
LUA:
Those are only the functions that I made. The rest is normal Death Star.
Code: Select all
Warning!: Path not specified for Entity 0 moveEDIT: But first, after noticing that all my other teleports (which work) have the pathname in quotes, I'll try putting it in quotes.
EDIT EDIT: The player teleports now! =D. But I need to make it use all of the cells, so I'm going to use my previous plan and have it teleport you to a different one by class. I'm going to look up the function for it and try it now.
EDIT EDIT EDIT: The AI and humans again refuse to teleport, but this time the Debug log says nothing.
LUA:
Hidden/Spoiler:
Those are only the functions that I made. The rest is normal Death Star.
