MoveTo / MoveToward problem

The best and quickest support by a group of top-notch editing specialists, guaranteed!

Moderator: Forum Guards

MoveTo / MoveToward problem

Postby Cozmo » Wed Sep 12, 12 11:29 pm

For a mod I'm doing, I have a scripted melee attack in state code, where it plays the animation, then delays, then checks if the player is within range and does the damage.

This works great, but the NPCs stop to attack, so unless you fight them in a small enclosed space, they're useless. So, seeing as this is within state code, I added a MoveToward function just before the delay so they would run after their target while attacking. Problem is, they don't seem to be able to execute any code under the MoveToward line until they get to their destination. And if you stand still, they never get to their destination, and just run around you until they give up and finish the attack.

Code: Select all
   if(RandInt <= 2) //NORMAL ATTACK
   {
      PlayAnimPivot('Attack',,0.1);
      MoveToward(Enemy, GroundSpeed); //Nothing after this line gets called until finished!
      Sleep(0.4); //Wait for the animation

      if(VSize(Location-Enemy.Location) < 130)
      {
         Enemy.TakeDamage(6+RandInt, Self, Enemy.Location, vect(0,0,0), 'Shot');
         DeusExPlayer(Enemy).ShakeView(0.8, 15.0, 30.0);
      }

      PlayRunning();
   }


I tried MoveTo(Enemy.Location) as well, which is a little better than standing still, but has the same problem if the player stands still.

Basically, I need a way to leave the MoveToward() as soon as the Sleep() is finished. If anyone can help, I'd appreciate it, plus the mod would be significantly better. :P
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK

Postby Allan » Thu Sep 13, 12 2:51 am

Hm... Perhaps try placing the vSize check before the MoveTo[ward] call, so if it's within range, it'll attack instead of trying to move? :p
User avatar
Allan
Alpha
 
Posts: 4545
Joined: Wed Dec 21, 05 1:41 pm
Location: Northamptonshire, England.

Postby Poor » Thu Sep 13, 12 5:29 am

MoveTo and MoveToward are latent functions. The next line won't execute until the pawn reaches the destination. You can use Tick() to perform other functions while the latent function is running, but I'm not sure if you can prematurely stop the latent function.

Why not just use a melee weapon?
Poor
Poster
 
Posts: 190
Joined: Tue Jan 04, 11 7:42 pm

Postby Cozmo » Thu Sep 13, 12 6:49 pm

Thanks for the replies!

Allan wrote:Hm... Perhaps try placing the vSize check before the MoveTo[ward] call, so if it's within range, it'll attack instead of trying to move? :p


I thought about this, but then the attack would happen as the animation starts, so it'd be either standing still or without a delay. :( I'd like to give the players a slight chance to run away if they see it coming (NPC runs slightly slower than player).

Poor wrote:Why not just use a melee weapon?


I was originally going to use a weapon, but to be honest I'm a noob of a coder, especially when it comes to fixing replication problems with NPCs. They have several custom attacks too, I find it easier to control how they're used this way.

Poor wrote:MoveTo and MoveToward are latent functions. The next line won't execute until the pawn reaches the destination. You can use Tick() to perform other functions while the latent function is running, but I'm not sure if you can prematurely stop the latent function.


Ah, thanks for the tip. :) I think I'll remove sleep and do the attack timing/coding in a function called through Tick(). I'll play around and report any progress.
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK


Return to Editing issues

Who is online

Users browsing this forum: No registered users and 13 guests
cron