Page 1 of 1
Pawns attacking pawns
Posted: Fri Oct 17, 2008 8:35 pm
by GMer
Ok, here it goes:
I am trying to make a battlefield where team A finds the nearest Team B player, and will attack them, but if they are attacked they attack the one who is attacking them (And the same with team B), I know it has to do with the distance finding function (the name escapes me) and making it go to an order if it is true... could someone tell me the functions that would be used to create this?
If it takes a while it's ok, I still need to make the models for the game!
Re: Pawns attacking pawns
Posted: Fri Oct 17, 2008 9:36 pm
by metal_head
I asked the same question and Juutis helped me out,I couldn't find the topic,but I think it's name was "Here's A Hard One" look for it,not very much time passed since I asked it.
Re: Pawns attacking pawns
Posted: Fri Oct 17, 2008 10:09 pm
by GMer
So this is the topic here?
http://www.realityfactory.info/forum/vi ... A+Hard+One
With the perfectai.s? (quite a long script
I feel sorry for the person who wrote it
) So I would just change HostileDifferent to true, or is it more complicated (if it isn't, yay!
)
Re: Pawns attacking pawns
Posted: Fri Oct 17, 2008 11:03 pm
by metal_head
It's more complicated,I think it's already done,I've changed HostileDifferent to true,and there was no effect,it's too late and I can't think now
maybe in the morning I'll be able to help..
,sorry it's just..my mind is gone aay I'm so sleepy right now.
Try reading the topic,I think that all will get clear to you,Juutis explains really well how the scripts work,I've learned a lot from him so far!
Re: Pawns attacking pawns
Posted: Sat Oct 18, 2008 1:42 am
by GMer
Ok, time to crawl over that impossibly long script!
Re: Pawns attacking pawns
Posted: Thu Oct 30, 2008 1:15 pm
by Masta_J
So basically, you are trying to create a pawn that switches to attacking different pawns and the player. I have a similar system in my game which I used for my scripted player as an auto targeting function. The way I did it however is a very long and sloppy, and I'm sure there is an easier way, but here it is anyways:
Firstly, you need to set your pawns field of view. Do this in your setup or spawn order by adding this command SetFOV(90); the brackets must contain the ammount in degrees that you want your pawn's visible to be.
Add this command to the pawn most frequently executed order eg. the run or idle orders:
Code: Select all
if(self.enemy_vis=false)
{
newtarget();
}
Then add this order to your script:
Code: Select all
newtarget[ ()
{
if(IsEntityVsible("enemy1"))
{
SetTarget("enemy1");
}
if(IsEntityVsible("enemy2"))
{
SetTarget("enemy2");
}
if(self.enemy_vis = false)
{
SetTarget("");
}
}]
You will need to give the pawns you want to be attacked the entitynames: enemy1, enemy2, enemy3 (however many you want), just make sure that none of the pawns share the same entityname. Once you've done that, then you just add the IsEntityVsible command along with the SetTarget command to the newtarget order (as above) and bobs your uncle. Basically what the newtarget order does is check to see if your pawn can see the the entity with the specified entityname and if it returns true, set that entity to be the current target. What makes this process long is the fact that you have to define every single entity that you want to be a possible target into the newtarget order.
I don't know what your script looks like, but bear in mind that this was run from low level orders in my script. Hope this helps...
Re: Pawns attacking pawns
Posted: Thu Oct 30, 2008 1:20 pm
by Masta_J
Sorry, I almost forgot! If you want to target the player, simply change in the SetTarget("enemy#") command in the newtarget order to SetTarget("Player").
Re: Pawns attacking pawns
Posted: Thu Oct 30, 2008 3:03 pm
by Juutis
Masta_J wrote:Sorry, I almost forgot! If you want to target the player, simply change in the SetTarget("enemy#") command in the newtarget order to SetTarget("Player").
TargetPlayer();
Dunno if it's always the case but for me SetTarget("Player") wouldn't work.
Re: Pawns attacking pawns
Posted: Thu Oct 30, 2008 4:26 pm
by metal_head
Yeah, TargetPlayer(); is the one which works.
Re: Pawns attacking pawns
Posted: Thu Oct 30, 2008 10:09 pm
by GMer
Thank you very much... I don't really fret over long scripts, they don't take up too much space (like the GML coding, that has every single function planned out and everything... no fun at all, and I like fun! At least I hope so
)
Re: Pawns attacking pawns
Posted: Tue Jan 27, 2009 5:59 pm
by GMer
Isn't there a funtion to find a pawn with a certain variable? I remember something about finding a target wit "enemy_health" or something in the maual or Making 3D games with Reality Factory.