pawn attack
- creekmonkey
- Posts: 116
- Joined: Tue Oct 23, 2007 2:55 pm
pawn attack
Is there a way of getting a pawn to attack actor correctly if actor is higher or lower than pawn?
I have a pawn which is a shark. It swims ok and its depth can vary when following script points. But I need the shark to change its pitch and attack in that direction if the actor's y position is higher or lower than the pawn. I have serched the forum for quite a long time and cant seem to find any reference to this. Is it even posible?
Thanks in advance for any help.
I have a pawn which is a shark. It swims ok and its depth can vary when following script points. But I need the shark to change its pitch and attack in that direction if the actor's y position is higher or lower than the pawn. I have serched the forum for quite a long time and cant seem to find any reference to this. Is it even posible?
Thanks in advance for any help.
- darksmaster923
- Posts: 1857
- Joined: Wed Jan 03, 2007 10:32 pm
- Location: Huntington Beach, California, USA
The manual:
... so basically it is very easy to make the a pawn change its pitch:
self.enemy_pitch
A read-only variable that contains the pitch angle, in radians, the Pawn must face to be pointing at the target.
self.ideal_pitch
A variable that must contain the pitch angle, in radians, that you wish to have the Pawn rotate to. Used by the rotation functions when rotating the Pawn.
ChangePitch();
Rotate the Pawn's actor from its current pitch angle towards the pitch angle specified by self.ideal_pitch at a speed of self.pitch_speed degrees per second. When the Pawn's pitch angle reaches the desired angle, rotation will cease.
... so basically it is very easy to make the a pawn change its pitch:
Code: Select all
self.ideal_pitch = self.enemy_pitch;
ChangePitch();Pain is only psychological.
- creekmonkey
- Posts: 116
- Joined: Tue Oct 23, 2007 2:55 pm
I am not able to get the shark pawn to change pitch, I have placed the code in the lowlevel attack routine
"monster_run_start" but that doesnt work. Is this the correct routine to place the code in?
monster_run_start[ ()
{
Animate(RUN); //RUN // play run animation
self.ThinkTime = 0; // start thinking on next frame
self.think = "monster_run"; // go to run attack routine
self.ideal_yaw = self.enemy_yaw;
attack_state = AS_NONE; // not attacking yet
self.yaw_speed = YAWSPEED; // set rotation speed
self.ideal_pitch = self.enemy_pitch; //set pitch to actor's y position
ChangePitch(); // change pitch
melee_time = time;
back_up = false; // setup obsticle avoidance
} ]
"monster_run_start" but that doesnt work. Is this the correct routine to place the code in?
monster_run_start[ ()
{
Animate(RUN); //RUN // play run animation
self.ThinkTime = 0; // start thinking on next frame
self.think = "monster_run"; // go to run attack routine
self.ideal_yaw = self.enemy_yaw;
attack_state = AS_NONE; // not attacking yet
self.yaw_speed = YAWSPEED; // set rotation speed
self.ideal_pitch = self.enemy_pitch; //set pitch to actor's y position
ChangePitch(); // change pitch
melee_time = time;
back_up = false; // setup obsticle avoidance
} ]
- creekmonkey
- Posts: 116
- Joined: Tue Oct 23, 2007 2:55 pm
I was able to get the pawn to change pitch by placing
self.ideal_pitch in the monster_run_start routine
and placing in the ai_face routine
self.ideal_yaw = enemy_yaw;
ChangeYaw(); // rotate to face enemy
self.ideal_pitch = enemy_pitch;
ChangePitch();
The Pawn does change pitch now and attacks, but will not attack in the direction of the pitch.
What am I doing wrong here?
By the way I am using a modifed genericmelee script.
I tried using the flock.s script but when the pawn gets close during attack he turns away and goes back to script points.
self.ideal_pitch in the monster_run_start routine
and placing in the ai_face routine
self.ideal_yaw = enemy_yaw;
ChangeYaw(); // rotate to face enemy
self.ideal_pitch = enemy_pitch;
ChangePitch();
The Pawn does change pitch now and attacks, but will not attack in the direction of the pitch.
What am I doing wrong here?
By the way I am using a modifed genericmelee script.
I tried using the flock.s script but when the pawn gets close during attack he turns away and goes back to script points.
In the "walk_movetogoal" routine you need to change "if(walkmove(self.current_yaw, dist) = true)" to
"if(flymove(self.current_pitch, self.current_yaw, dist) = true)"
and change
"walkmove((self.current_yaw-(180*0.0174532925199433)), dist);"
to "flymove((self.current_pitch-(180*0.0174532925199433)),(self.current_yaw-(180*0.0174532925199433)), dist);"
That should make it work.
"if(flymove(self.current_pitch, self.current_yaw, dist) = true)"
and change
"walkmove((self.current_yaw-(180*0.0174532925199433)), dist);"
to "flymove((self.current_pitch-(180*0.0174532925199433)),(self.current_yaw-(180*0.0174532925199433)), dist);"
That should make it work.
- creekmonkey
- Posts: 116
- Joined: Tue Oct 23, 2007 2:55 pm
- creekmonkey
- Posts: 116
- Joined: Tue Oct 23, 2007 2:55 pm
I have tried that Bernie
Currently I have an if statement in the walkmove routine
if(self.current_Y >-144)
{
return 0;
}
If I put anything there
return 0;
return ;
exct
the shark stops, but I can not get it to leave the attack routine.
I tried puting NewOrder("LostTarget") Idle, or patrol but still nothing happens till the player moves out of sight distance
Currently I have an if statement in the walkmove routine
if(self.current_Y >-144)
{
return 0;
}
If I put anything there
return 0;
return ;
exct
the shark stops, but I can not get it to leave the attack routine.
I tried puting NewOrder("LostTarget") Idle, or patrol but still nothing happens till the player moves out of sight distance
- creekmonkey
- Posts: 116
- Joined: Tue Oct 23, 2007 2:55 pm
- creekmonkey
- Posts: 116
- Joined: Tue Oct 23, 2007 2:55 pm