Spawned entity does not attack [Solved]

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
Noobasaurus
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2006
Joined: Tue Aug 17, 2010 5:56 pm

Spawned entity does not attack [Solved]

Post by Noobasaurus »

I spawned in an entity and set its team to an enemy team but it does not attack.

Code: Select all

		CreateEntity("cis_hero_darthmaul", destination, "maul")
		SetProperty("maul", "Team", 2)
It just spawns and sits there. Is there another way I should be spawning it or am I doing something wrong?
Last edited by Noobasaurus on Wed Jul 09, 2014 5:46 pm, edited 1 time in total.
razac920
2nd Lieutenant
2nd Lieutenant
Posts: 365
Joined: Sun Jan 16, 2011 12:42 am

Re: Spawned entity does not attack

Post by razac920 »

Uhh, i've never tried to spawn a unit like that. Why not instead do:
character = GetTeamMember(teamnum,index) -- say you make a team 3 and don't allow them to spawn
SelectCharacterClass(character,"cis_hero_darthmaul")
SpawnCharacter(character, destination)
SetObjectTeam(GetCharacterUnit(character),2)

Also you will want to add earlier on:
AddAIGoal(teamnum,"Deathmatch",100)
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: Spawned entity does not attack

Post by Marth8880 »

If you're spawning the unit onto a path node, a better way of spawning it (than how you're currently doing it) would be to use the Ambush() function. To use it, call the Ambush script with ScriptCB_DoFile() and use this to spawn the unit:

Code: Select all

Ambush(pathName, numDudes, fromTeam, aiDamageThreshold)
pathName is obviously the name of the path, numDudes is the number of units to spawn, fromTeam is the team from which the units will spawn (I'd recommend setting up a local team and using that), and aiDamageThreshold is optional and I believe it sets essentially the health "floor" for how much damage AI can deal to the spawned units, for example, if it's set to 0.3 (the value can range from 0.0-1.0), other AI cannot bring the spawned units' health past 30%.
Noobasaurus
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2006
Joined: Tue Aug 17, 2010 5:56 pm

Re: Spawned entity does not attack

Post by Noobasaurus »

Oh, whoops. Yeah, I'll do that. I also have the deathmatch line as well.

Thanks. It works great now.

And to Marth: I'll use that. Looks much easier than what I'm currently doing. But how can I set the class of the unit(s) being spawned?
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: Spawned entity does not attack

Post by Marth8880 »

Noobasaurus wrote:But how can I set the class of the unit(s) being spawned?
You can't. :( You'd have to set up multiple teams if you wanted to be exact on which unit classes spawn where.
Post Reply