Problems with Squad Command

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
KnightsFan
Second Lance Corporal
Second Lance Corporal
Posts: 108
Joined: Fri Mar 06, 2009 9:34 pm

Problems with Squad Command

Post by KnightsFan »

I have two questions.

1. Is it possible to make an autoturret be fired in a straight line, instead of simply dropped in front of you?

2. I'm trying to execute LUA codes when autoturrets are dropped, but my if/else statements don't work.

Code: Select all

	OnCharacterDispenseControllable(
	    function(player, controllable)
		if GetEntityClassName(controllable) == ame_weap_inf_formup_ord then
		    ClearAIGoals(GIS)
		    KillObject(controllable)
		    AddAIGoal(GIS, "Follow", 100, 0)
		elseif GetEntityClassName(controllable) == ame_weap_inf_defend_ord then
		    ClearAIGoals(GIS)
		    AddAIGoal(GIS, "Defend", 100, controllable)
		end
	    end
	)
It always executes the first code, making the AI follow me. If I switch the order, it will still always do the first and make them defend the autoturret.

Any help is appreciated.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Problems with Squad Command

Post by Maveritchell »

Your if statements aren't comparing an input and a string, they're comparing an input and a (nonexistent) variable.

E.g.

Code: Select all

ame_weap_inf_formup_ord
should be
"ame_weap_inf_formup_ord"
User avatar
KnightsFan
Second Lance Corporal
Second Lance Corporal
Posts: 108
Joined: Fri Mar 06, 2009 9:34 pm

Re: Problems with Squad Command

Post by KnightsFan »

I added quotes around them but now neither works at all. I'm not getting any errors pertaining to either besides that they aren't localized.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Problems with Squad Command

Post by Maveritchell »

KnightsFan wrote:I added quotes around them but now neither works at all. I'm not getting any errors pertaining to either besides that they aren't localized.
That probably means that there's an error with the name(s) you're referencing.
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: Problems with Squad Command

Post by Fiodis »

Maveritchell wrote:it just doesn't have a string output. You need to match up a GetEntityClass to a FindEntityClass, a la:

Code: Select all

GetEntityClass(etc) == FindEntityClass("ex_type_entity")
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Problems with Squad Command

Post by Maveritchell »

Fiodis wrote:
Maveritchell wrote:it just doesn't have a string output. You need to match up a GetEntityClass to a FindEntityClass, a la:

Code: Select all

GetEntityClass(etc) == FindEntityClass("ex_type_entity")
Not the same code. From the scripting_system.doc:
CharacterDispenseControllable: function (player, controllable)
This event occurs whenever a character drops a controllable item (such as a remote droid or a mini-turret). If you want to check exactly what kind of controllable was dropped, use GetEntityClassName(controllable).
User avatar
KnightsFan
Second Lance Corporal
Second Lance Corporal
Posts: 108
Joined: Fri Mar 06, 2009 9:34 pm

Re: Problems with Squad Command

Post by KnightsFan »

Thanks! They are both working like a charm now.
But I still want to know how to fire an autoturret straight out instead of drop it in front of myself, if that's possible.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Problems with Squad Command

Post by Maveritchell »

KnightsFan wrote:But I still want to know how to fire an autoturret straight out instead of drop it in front of myself, if that's possible.
Objects are always deployed in an arc. You can adjust the elevation of the toss (ShotElevate, in the dispenser .odf) and the strength/velocity of the object (Max/MinStrength; dispenser .odf, Velocity; deployable .odf).
Post Reply