Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: new Direct Control Script idea...  (Read 5873 times)

0 Members and 1 Guest are viewing this topic.

Igorrr

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 130
  • Ugh...Ughugh!!!!!!
    • View Profile
    • Struggle For Life And Honour
new Direct Control Script idea...
« on: July 27, 2004, 07:29:07 AM »

I have an idea to improve the Direct Control Script, but I need some help...

The problem with the current script most of all is that the waypoints are considered when the actor is walking using the direct control.
But I want the actor to ignore the waypoints when using the direct control.

Instead of having the actor "walking" by using the GoTo function you can have the actor walk ignoring the waypoints by using the PlayAnim function instead.
Problems of course are that because of the looping the actor won't stop moving and at the same time also ignores the unwalkable areas.
So in some way while he is "walking" you have to make sure that he stops short before reaching a unwalkable area and also find a way to interrupt the movement anyhow.

I've tried this out and it works more or less:
Code: [Select]
if(Keyboard.KeyCode==VK_F1)
  {
    while(Scene.IsWalkableAt(actor.X,actor.Y-15)==true)
    {
     if (actor.Ready==true) actor.PlayAnimAsync("actors/knight/up/move_up.sprite");
     Sleep(20);
    }
   actor.Reset();
  }
 if(Keyboard.KeyCode==VK_F2)
  {
    while(Scene.IsWalkableAt(actor.X,actor.Y+15)==true)
    {
     if (actor.Ready==true) actor.PlayAnimAsync("actors/knight/down/move_down.sprite");
     Sleep(20);
    }
   actor.Reset();
  } 

The problem here is if I want to walk down while he is walking up he will first finish walking up before walking down.
Also I don't believe the loop will end if I interrupt with any other key. First when the actor reaches a not walkable area. (right??)


Does anyone have any idea how to solve this?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: new Direct Control Script idea...
« Reply #1 on: July 27, 2004, 07:59:04 AM »

Ok, how about this?

(warning: quick&dirty code ahead)
[code]
#include "scripts\base.inc"
#include "scripts\keys.inc"

var TargetX, TargetY;

var LastDir = -1;
var CurrentDir = -1;

while(true)
{
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Igorrr

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 130
  • Ugh...Ughugh!!!!!!
    • View Profile
    • Struggle For Life And Honour
Re: new Direct Control Script idea...
« Reply #2 on: July 27, 2004, 08:24:55 PM »

Mnemonic YOU'RE A MACHINE!!!

It works really sweet!!! Much better than the old script.
I added a Game.Interactive query to have the actor only perform the action if the game is interactive.
The problem is the script alone sometimes makes other scripts stop abruptly.
I handled that problem by detaching the script everytime I set the game to NOT interactive.
It works flawlessly now, but I wonder if my solution was elegant...
Logged

tinchopunk

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 90
    • View Profile
    • martinarregui.tumblr.com
Re: new Direct Control Script idea...
« Reply #3 on: December 08, 2004, 04:24:14 AM »

how can improve this to 3dcharacter???
move with the keys...
thanks
 MArtin
Logged

SOLO

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 23
    • View Profile
Re: new Direct Control Script idea...
« Reply #4 on: August 15, 2012, 11:19:56 PM »

Hi,
     I am using your Direct Control Script Mnemonic and it works great but I want it only to work when Game.Interactive =true;
I have it at the moment attached in Project Manager should I have it attached to the ACTOR script?

It works to a degree but stops other scripts running properly how can this be overcome, I see from a historic topic the IGORR did this but I cannot figure it out.........

Any help would be great!

As always........ Thanks



Its OK I have sorted this myself with the detach and attach script commands that IGORR mentioned.

« Last Edit: August 21, 2012, 11:56:39 AM by SOLO »
Logged
Best Regards
SOLO
 

Page created in 0.02 seconds with 24 queries.