Pawns attacking pawns

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
GMer
Posts: 329
Joined: Thu Oct 25, 2007 4:49 pm
Location: On the rock in the 3rd solar orbit.

Pawns attacking pawns

Post by GMer » Fri Oct 17, 2008 8:35 pm

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! :lol:
Over 3 years (has it been that long?) and just now I noticed the day and month of my birthday were switched. Whoops!

Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Pawns attacking pawns

Post by metal_head » Fri Oct 17, 2008 9:36 pm

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.

User avatar
GMer
Posts: 329
Joined: Thu Oct 25, 2007 4:49 pm
Location: On the rock in the 3rd solar orbit.

Re: Pawns attacking pawns

Post by GMer » Fri Oct 17, 2008 10:09 pm

So this is the topic here?

http://www.realityfactory.info/forum/vi ... A+Hard+One

With the perfectai.s? (quite a long script :shock: I feel sorry for the person who wrote it :D ) So I would just change HostileDifferent to true, or is it more complicated (if it isn't, yay! :D )
Over 3 years (has it been that long?) and just now I noticed the day and month of my birthday were switched. Whoops!

Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Pawns attacking pawns

Post by metal_head » Fri Oct 17, 2008 11:03 pm

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 :D maybe in the morning I'll be able to help.. :D,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!

User avatar
GMer
Posts: 329
Joined: Thu Oct 25, 2007 4:49 pm
Location: On the rock in the 3rd solar orbit.

Re: Pawns attacking pawns

Post by GMer » Sat Oct 18, 2008 1:42 am

Ok, time to crawl over that impossibly long script! :lol:
Over 3 years (has it been that long?) and just now I noticed the day and month of my birthday were switched. Whoops!

Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56

Masta_J
Posts: 37
Joined: Tue Apr 17, 2007 1:35 pm
Location: Johannesburg South Africa

Re: Pawns attacking pawns

Post by Masta_J » Thu Oct 30, 2008 1:15 pm

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...
A good warrior knows his limits, but a great warrior finds his way around them.

Masta_J
Posts: 37
Joined: Tue Apr 17, 2007 1:35 pm
Location: Johannesburg South Africa

Re: Pawns attacking pawns

Post by Masta_J » Thu Oct 30, 2008 1:20 pm

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").
A good warrior knows his limits, but a great warrior finds his way around them.

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Pawns attacking pawns

Post by Juutis » Thu Oct 30, 2008 3:03 pm

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.
Pain is only psychological.

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Pawns attacking pawns

Post by metal_head » Thu Oct 30, 2008 4:26 pm

Yeah, TargetPlayer(); is the one which works.

User avatar
GMer
Posts: 329
Joined: Thu Oct 25, 2007 4:49 pm
Location: On the rock in the 3rd solar orbit.

Re: Pawns attacking pawns

Post by GMer » Thu Oct 30, 2008 10:09 pm

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 :lol: )
Over 3 years (has it been that long?) and just now I noticed the day and month of my birthday were switched. Whoops!

Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56

User avatar
GMer
Posts: 329
Joined: Thu Oct 25, 2007 4:49 pm
Location: On the rock in the 3rd solar orbit.

Re: Pawns attacking pawns

Post by GMer » Tue Jan 27, 2009 5:59 pm

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.
Over 3 years (has it been that long?) and just now I noticed the day and month of my birthday were switched. Whoops!

Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56

Post Reply