Page 1 of 1

I want get all entities of class actor touching the trigger

Posted: Tue Dec 23, 2008 2:21 pm
by Aprop
Ahhh another my topic... so, i want get as local every allied soldier, with variable .var == 1, who touch the trigger... they have diffrent targetnames, so i cant use simply for... i think about parm.other, but i dont know what is exacly parm. or other, maybe ill try it but first i wait for reply - no time for miss tests.

Btw can entity have 2 targetnames? Or add every allied soldier to level.allies, then use "for" for level.allies ?

Posted: Tue Dec 23, 2008 3:59 pm
by $oldier Of Ra
Normal triggers are only for players (depending on the definition). You must use special spawnflag triggers for bots. Luckily for you that's what I'm best at :D so I know you need to use spawnflags 12 to accomplish that.

Code: Select all

local.t = spawn trigger_use "spawnflags" "12"
Then use this in your setthread:

Code: Select all

local.ent = parm.other
You can also use a normal trigger without spawnflags and then use this in the setthread:

Code: Select all

while(1)
{
self waittill trigger
local.ent = self.other
//your script
}
end
In either case, local.ent is the bot who triggered the trigger. If you only want the Actors with a certain variable activating the trigger then set an if statement right after the local.ent definition.

2 targetnames? Nope, but 2 or more entities can have the same targetname.

Posted: Tue Dec 23, 2008 4:50 pm
by Aprop

Code: Select all

self.other


...? You mean parm.other ? Bots can trigger trigger USE with spawnflags??
Or normal trigger (multiple?) without spawnflags? I should set flag MONSTERS, because normal trigger (use) is only for players?? Btw how can i test is actor american?


And about targetnames... i its possible to add x entities with different targetnames to level.soldiers, then use for local.i;level.soldiers.size'local.i++ and get each of them? How it looks like?

Posted: Tue Dec 23, 2008 4:59 pm
by $oldier Of Ra
No, if you don't use spawnflags 12, parm.other will identify players then self.other will define other entities. With spawnflags 12, parm.other will be actors because it's impossible for a player to activate that kind of trigger because spawnflags 12 equals these 2 flags: NOT_PLAYERS & MONSTERS and 8 + 4 = 12 ;)

I recommend you use the spawnflag method, I use the self.other method for triggers set in .bot files with bdbodger's botmapper and jv's botscripts. I was just showing that there are more than 2 possibilities for bots to trigger triggers.

Yes they can trigger almost any kind of trigger with spawnflags 12.

As for the targetnames; yes but you'll have to do it all manually :?

level.soldiers[1] = $actor_siegfried
level.soldiers[2] = $actor_johnson
level.soldiers[3] = $badguy_connor

etc...

You should've used a targetname array... Name all allied AI $goodguy and all axis AI $badguy or something and then use a for statement.

Posted: Tue Dec 23, 2008 5:26 pm
by Aprop
$oldier Of Ra wrote: You should've used a targetname array... Name all allied AI $goodguy and all axis AI $badguy or something and then use a for statement.
Alright... i actually have some diffrent targetnames, cappy, startingsoldier etc, but ill change theyre targetnames to $allied... btw will it work?

Code: Select all

level.cappy = $cappy
$cappy.targetname = allied
?

Posted: Tue Dec 23, 2008 6:02 pm
by $oldier Of Ra
Those were examples :P

Code: Select all

level.cappy = $cappy
Well this won't be an array unless there are more than 1 entities with the targetname $cappy.

Code: Select all

$cappy.targetname = allied 
I don't think that will work. That entity already has a targetname $cappy, you cannot change it again or add a new one.

Posted: Tue Dec 23, 2008 6:26 pm
by Aprop
Really? ...! I know.
$oldier Of Ra wrote:

Code: Select all

$cappy.targetname = allied 
I don't think that will work. That entity already has a targetname $cappy, you cannot change it again or add a new one.
It works, i just tested it.

Posted: Tue Dec 23, 2008 6:45 pm
by $oldier Of Ra
Then the engine is less logical than I thought.
But why would you want to do that anyways? You're making it very hard on yourself when it can be done so easily, just targetname every allied AI with the same name and every axis AI with the same name. Then just use a for statement. By using all these loopholes and tricks just to get a for statement working is going to make your script so complicated, you won't even understand it in the end. :?

If you're doing this because you're scripts are working with individual AI, then I still suggest you give them the same targetname and give those AI also a tag.