Help with Scripting

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
Lagomorphia
Major
Major
Posts: 502
Joined: Sun Dec 13, 2009 10:02 am

Help with Scripting

Post by Lagomorphia »

I'm trying to modify archer01's unit spawning AI script to spawn three units, rep_inf_scorch, rep_inf_fixer and rep_inf_sev when rep_inf_boss spawns. These three units would spawn at the same command post as rep_inf_boss and follow him, but would not spawn if they already are on the battlefield.
For example: rep_inf_boss spawns and the other three spawn around him. rep_inf_boss moves into the battlefield followed by the other three units, but he and rep_inf_fixer are killed by a grenade. rep_inf_boss respawns at another command post, but as rep_inf_scorch and rep_inf_sev already are on the battlefield only rep_inf_fixer spawns with him. rep_inf_scorch and rep_inf sev make their way back to rep_inf_boss, but rep_inf_scorch is killed on the way. rep_inf_boss is soon killed again and this time when he spawns only rep_inf_scorch spawns with him. rep_inf_sev and rep_inf_fixer make their way back to rep_inf_boss.

My script so far (not much good)
Hidden/Spoiler:
---[[ DeltaSquad
ReadDataFile("dc:SIDE\\rc1.lvl",
"rep_inf_scorch",
"rep_inf_fixer",
"rep_inf_sev",
SetTeamName(3, "deltasquad")
AddUnitClass(3, "rep_inf_scorch",1,1)
AddUnitClass(3, "rep_inf_fixer",1,1)
AddUnitClass(3, "rep_inf_sev",1,1)
SetUnitCount(3, 3)
SetTeamAsEnemy(3, ATT)
SetTeamAsFriend(3, DEF)
SetTeamAsEnemy(ATT, 3)
SetTeamAsFriend(DEF, 3)
AddAIGoal(3,"Deathmatch",100)


OnCharacterSpawn(rep_inf_boss)
function(character,controlled)
if GetEntityClass(controlled) == GetEntityClassPtr(TroopSpawnerWeapon) then
local SupportTeam = 3 --Team the new spawned character is in (change this)
local teamSize = GetTeamSize(SupportTeam)
for i = 0, teamSize-1 do
local characterIndex = GetTeamMember(SupportTeam, i)
local charUnit = GetCharacterUnit(characterIndex)
if not charUnit then
local destination = GetEntityMatrix(GetCharacterUnit(character))
SpawnCharacter(characterIndex,destination)
end
end
end
end,
REP --User team (change this)
)
--]]
The original script:
http://www.gametoast.com/forums/viewtop ... 47#p126047
Lagomorphia wrote:The archer01 script spawns units when a certain weapon is used. What I'm trying to do is replace the weapon use with spawning, which is quite simple. However, as I'm not sure how to get the original working the ability to switch between triggers is useless.

First I need to know how to work the archer01 script, then I'll swap the triggers and, if it doesn't happen anyway, need to prevent duplicates from spawning.

Sorry if that wasn't clear.
Last edited by Lagomorphia on Wed Sep 08, 2010 12:14 pm, edited 1 time in total.
MrCrayon
Jedi Knight
Jedi Knight
Posts: 554
Joined: Sat Apr 17, 2010 8:15 pm
Projects :: Coruscant map Want to help PM me
Games I'm Playing :: Battlefront 3
Location: Buried in homework, but getting better

Re: Help with Scripting

Post by MrCrayon »

I am still learning when it comes to the advanced scripting, but what I would suggest is to look inside the assets campaign scripts. I am pretty sure when i was browsing through them I saw something that denies the a.i. the privilege to spawn at certain command posts.

Another idea is you could activate the 'disallow a.i. spawn' fake console code thing and just turn it off when you reach a command post check point. That way, when a guy dies, he stays dead untill Boss shows up at a command post check point!
User avatar
Lagomorphia
Major
Major
Posts: 502
Joined: Sun Dec 13, 2009 10:02 am

Re: Help with Scripting

Post by Lagomorphia »

The archer01 script spawns units when a certain weapon is used. What I'm trying to do is replace the weapon use with spawning, which is quite simple. However, as I'm not sure how to get the original working the ability to switch between triggers is useless.

First I need to know how to work the archer01 script, then I'll swap the triggers and, if it doesn't happen anyway, need to prevent duplicates from spawning.

Sorry if that wasn't clear.
Post Reply