Page 1 of 1

Spawned entity does not attack [Solved]

Posted: Wed Jul 09, 2014 5:31 pm
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?

Re: Spawned entity does not attack

Posted: Wed Jul 09, 2014 5:39 pm
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)

Re: Spawned entity does not attack

Posted: Wed Jul 09, 2014 5:43 pm
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%.

Re: Spawned entity does not attack

Posted: Wed Jul 09, 2014 5:46 pm
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?

Re: Spawned entity does not attack

Posted: Wed Jul 09, 2014 5:50 pm
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.