questions about usermodes, "walk to"

Started by hawanja, Sat 29/05/2004 22:12:29

Previous topic - Next topic

hawanja

Hey guys, I have a WORKING simple combat system that where you click on the enemy and the hero throws a punch. I have the code under "any click on character," however it doesn't work when the cursor is in Walk mode. How do I change it so that it does?

I'd like to have it so that when you click on the zombie the hero throws a punch, even in Walk mode. As it is it only works in the other modes, which means you have to cycle through to the walk mode to move and then back to any other mode to fight, which works okay, it's just akward (plus the zombie gets many free hits while you're fiddleing with the mouse trying to cycle back to hit him.) I suppose I could put it under a key press, I'd just much rather not involve the keyboard if possible.


Here's my code, if anyone's interested. Once I figure out how to arm weapons I'll post the whole thing so that other noobie people like myself can use it.

   

// script for character3: Any click on character


if (character[BIFFY].x > character[ZOMBIE].x){
    SetGlobalInt(15,1);//hero's attack variable
    AnimateCharacter (2,5,3,0);//hero throws punch
    PlaySound (7);} 

if (character[BIFFY].x < character[ZOMBIE].x){
    SetGlobalInt(15,1);//same as above but the punch is in the other direction
    AnimateCharacter (2,4,3,0);
    PlaySound (7);}


Scorpiorus

Yeah, by default AGS won't run anyclick interaction while in walk mode. To change that behavior open the general settings pane and put a tick next to the "Don't automatically move character in walk mode" option. But with that option enabled that player won't be able to move around, therefore to correct it you have to adjust the on_mouse_click function in the global script by putting an explicit code that handles moving:

function on_mouse_click(int button) {
   // called when a mouse button is clicked. button is either LEFT or RIGHT
   if (IsGamePaused() == 1) {
   // Game is paused, so do nothing (ie. don't allow mouse click)
   }
   else if (button==LEFT) {
      if (GetCursorMode() == MODE_WALK) MoveCharacter(GetPlayerCharacter(), GetViewportX()+mouse.x, GetViewportY()+mouse.y);
      ProcessClick(mouse.x, mouse.y, GetCursorMode());
   }
   else {Ã,  Ã, // right-click, so cycle cursor
      SetNextCursorMode();
Ã,  }
}

hawanja

fabulous, works like a charm. Thanks very much.

Now I have to make weapons, and figure out a way to "arm" them. I suppose you'd do this through global variables and setting views. I'll post the whole thing once it's finished so you may all share my combat system.

SMF spam blocked by CleanTalk