Placed turrets ignoring enemies

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
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Placed turrets ignoring enemies

Post by Fiodis »

I dispensed two different autoturrets with beam weapons and used LUA to set them to teams 3 and 4, as well as setting 3 and 4 against each other and friendly with everyone else:
Hidden/Spoiler:
[code] beamswitch_a = OnCharacterDispenseControllable(
function(character, controllable)
if GetEntityClass(controllable) == FindEntityClass("rep_bldg_inf_trapstart_a") then
SetObjectTeam(controllable, 3)
SetTeamAsFriend(ATT,3)
SetTeamAsFriend(3,ATT)
SetTeamAsFriend(DEF,3)
SetTeamAsFriend(3,DEF)

SetTeamAsEnemy(3,4)
end
end
)

beamswitch_b = OnCharacterDispenseControllable(
function(character, controllable)
if GetEntityClass(controllable) == FindEntityClass("rep_bldg_inf_trapstart_b") then
SetObjectTeam(controllable, 4)
SetTeamAsFriend(ATT,4)
SetTeamAsFriend(4,ATT)
SetTeamAsFriend(DEF,4)
SetTeamAsFriend(4,DEF)

SetTeamAsEnemy(4,3)
end
end
)

sidetest = OnCharacterDispenseControllable(
function(character, controllable)
if GetEntityClass(controllable) == FindEntityClass("rep_bldg_inf_sidetest") then
SetObjectTeam(GetCharacterUnit(character), 3)
end
end
)[/code][/size]
That's all in ScriptPostLoad. I've also tried putting the SetTeamAsEnemy and SetTeamAsFriend code where the local side tutorial says to put it, in ScriptInit.

The problem is that the turrets ignore everything around them, including each other. I want them to shoot each other up, but instead they just try to stare each other down. When I used the sidetest weapon to switch myself to team 3, just to check if the team switching was working, the team 4 turret became my enemy, like it should. It had a red health bar and everything, but I paraded in front of it in all manner of ways without it batting an eyelash, much less slicing me with an energy beam.

Here's also the beam weapon odf. Both turrets use the same weapon.
Hidden/Spoiler:
[code][WeaponClass]
ClassParent = "com_weap_veh_beam"

[Properties]
OrdnanceName = "rep_weap_inf_trapbeam_a_ord"

//FireSound = "imp_weap_hover_fightertank_beam_fire"
//FireLoopSound = "imp_weap_hover_fightertank_beam_loop"


RoundsPerClip = "0"
ShotDelay = "1.0"
ReloadTime = "0.0"

LockOnRange = "0.0"

TriggerSingle = "0"

MinRange = "0"
OptimalRange = "50"
MaxRange = "150"

TargetEnemy = "1"
TargetNeutral = "0"
TargetFriendly = "0"

TargetPerson = "1"
TargetAnimal = "1"
TargetDroid = "1"
TargetVehicle = "1"
TargetBuilding = "1"

AITargetPerson = "1"
AITargetAnimal = "1"
AITargetDroid = "1"
AITargetVehicle = "1"
AITargetBuilding = "1"


[/code][/size]
It does look like I got the targeting parameters right, but maybe there's something I missed. Any ideas? If you need any other files, just let me know.
User avatar
Dakota
Field Commander
Field Commander
Posts: 991
Joined: Mon Dec 06, 2010 8:21 pm
Projects :: making random weapon assets
Games I'm Playing :: SWBF2 and more
xbox live or psn: PS3 beats xbox
Location: at a computer desk floating around in space

Re: Placed turrets ignoring enemies

Post by Dakota »

i made an auto turret with a beam weapon once and it wouldn't fire.

are you sure that the weapon itself works? try making the turret pilotable to check.

(maybe its just that its a beam and ai hate beams.)
AQT
Gametoast Staff
Gametoast Staff
Posts: 4910
Joined: Sat Nov 03, 2007 4:55 pm
Location: SoCal, USA

Re: Placed turrets ignoring enemies

Post by AQT »

Dakota wrote:(maybe its just that its a beam and ai hate beams.)
The AI use beam weapons all the time in the shipped game. The AI auto turrets in Sky's Dark Space/Last Days mod use their beam weapons without a problem.
User avatar
Dakota
Field Commander
Field Commander
Posts: 991
Joined: Mon Dec 06, 2010 8:21 pm
Projects :: making random weapon assets
Games I'm Playing :: SWBF2 and more
xbox live or psn: PS3 beats xbox
Location: at a computer desk floating around in space

Re: Placed turrets ignoring enemies

Post by Dakota »

AQT wrote:
Dakota wrote:(maybe its just that its a beam and ai hate beams.)
The AI use beam weapons all the time in the shipped game. The AI auto turrets in Sky's Dark Space/Last Days mod use their beam weapons without a problem.

well the thing about beams sometimes i think is just that in the stock game they don't use them well sometimes.

the spider walker has that problem. and i had the problem with a turret like that. anyway checking if the turret gun works by piloting the turret would help see if the weapon is the problem or not anyway.
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Placed turrets ignoring enemies

Post by Fiodis »

Dakota wrote:well the thing about beams sometimes i think is just that in the stock game they don't use them well sometimes.

the spider walker has that problem. and i had the problem with a turret like that. anyway checking if the turret gun works by piloting the turret would help see if the weapon is the problem or not anyway.
Eh. What's "using it well"? At the end of EP2 you see beam weapons not being held steady, but being swept over the battlefield - exactly like BF2's Spider Walkers do.

Anyway, any kind of aiming problem should probably be able to be fixed to some degree via odf. My problem isn't so much that the turrets don't fire well; they don't fire at all. Their barrels don't even track me when I switch myself to an enemy team. It's like they don't notice me. And they certainly don't notice each other, despite being on opposing teams. Maybe I need to do something with AI goals? At the moment I give each turret's team a Deathmatch AI goal with a weighting of 100. Ought I use something else?
User avatar
Dakota
Field Commander
Field Commander
Posts: 991
Joined: Mon Dec 06, 2010 8:21 pm
Projects :: making random weapon assets
Games I'm Playing :: SWBF2 and more
xbox live or psn: PS3 beats xbox
Location: at a computer desk floating around in space

Re: Placed turrets ignoring enemies

Post by Dakota »

ok its just in the first message you said they just try to stare each other down. but did you test the weapon itself to see if you can fire it. sometimes the turrets just won't use a weapon if it crashes or doesn't work.
FragMe!
Gametoast Staff
Gametoast Staff
Posts: 2244
Joined: Sat May 13, 2006 12:34 am
Projects :: Not sure keep changing my mind.
Games I'm Playing :: F1 and SWBF
xbox live or psn: No gamertag set
Location: Origin name GT_FragMe
Contact:

Re: Placed turrets ignoring enemies

Post by FragMe! »

Just checking, your turret odf does have the following line yes?

Pilottype = "self"
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Placed turrets ignoring enemies

Post by [RDH]Zerted »

You forgot to change the PerceivedTeam value. Use SetProperty()

Also, put the team setup code back where it normally goes. There's no reason to re-set the teams alliances every time a turret is spawned. I know what you were thinking.
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Placed turrets ignoring enemies

Post by Fiodis »

[RDH]Zerted wrote:You forgot to change the PerceivedTeam value. Use SetProperty()

Also, put the team setup code back where it normally goes. There's no reason to re-set the teams alliances every time a turret is spawned. I know what you were thinking.
Thanks, that worked. :)
Post Reply