Welcome, Guest. Please login or register.

What openbor you prefer: Double dragon,battletoads or final fight !? by lirexpatrio
[December 07, 2012, 07:15:27 pm]


what are your favorite games OpenBOR?! by lirexpatrio
[December 07, 2012, 07:09:46 pm]


Post Some Awesome Videos by maxman
[December 07, 2012, 05:51:39 pm]


Can @cmd playmusic "aaaa" 1 also increse music sound ? by BeasTie
[December 07, 2012, 05:24:38 pm]


Streets of Rage: Silent Storm by mtrain
[December 07, 2012, 03:45:05 pm]


Site will be down for maintenance on 12/8/2012 thru 12/10/2012 by Damon Caskey
[December 07, 2012, 07:42:42 am]


Cancelled SOR 3d Remake by riccochet
[December 07, 2012, 03:58:33 am]


Dungeon Fighter: B.O.R. by msmalik681
[December 07, 2012, 03:24:27 am]


[TUTORIAL] How to create 4 Games of OpenBOR in 1 CD (650 MB) by magggas
[December 06, 2012, 09:46:25 pm]


custknife by Bloodbane
[December 06, 2012, 09:34:09 pm]


blockfx help by B.Kardi
[December 06, 2012, 04:09:14 pm]


street of age 4 hd by corradlo
[December 06, 2012, 01:41:36 pm]


ClaFan - Classic Fantasy ver 1.17 by soniczxblade
[December 06, 2012, 05:01:20 am]


Bug Archive by Bloodbane
[December 06, 2012, 02:00:44 am]


"Bio-Doom" and "Gears of Doom" by BulletBob
[December 05, 2012, 10:07:21 pm]


Contra Locked 'N' Loaded v2 by Bloodbane
[December 05, 2012, 09:39:43 pm]


Downloadable OpenBoR Manual by BeasTie
[December 05, 2012, 08:31:24 pm]


Having trouble testing changes by B.Kardi
[December 05, 2012, 03:05:53 pm]


DragonBall Absalon by msmalik681
[December 05, 2012, 02:52:13 pm]


[Hi-Res] Swamp by Vibrant
[December 05, 2012, 10:47:14 am]


  • Dot Guests: 203
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.



Author Topic: Script Request: Using a2-a4 for single-button and long inputs.  (Read 4246 times)

0 Members and 1 Guest are viewing this topic.

Offline the7k

  • Hero Member
  • *****
  • Posts: 749
  • PSN: the_7k
Script Request: Using a2-a4 for single-button and long inputs.
« on: October 03, 2009, 04:17:35 am »
Well, I guess I'll have to make a script request for this issue.

I want to use 'a2' as a single-button press. Press a2, and freespecial happens.

I always want to use 'a2' within longer inputs. Press D,F,a2 and freespecial2 happens.

The problem is, freespecial always happens. Never freespecial2. I can't use a2 to activate other freespecials if I already have it set to activate a freespecial with the button press alone.

So, who has figured out a way around this issue through script?

Offline BonusJZ

  • Hero Member
  • *****
  • Posts: 1091
  • Banned
    • YouTube Chanel
Re: Script Request: Using a2-a4 for single-button and long inputs.
« Reply #1 on: October 03, 2009, 06:00:40 am »
Quote
I want to use 'a2' as a single-button press. Press a2, and freespecial happens.
Just use for example :
com a2 freespecial3
com a4 freespecial12
Quote
always want to use 'a2' within longer inputs. Press D,F,a2 and freespecial2 happens.
com d f a2 freespecial3
com d f a4 freespecial12

Offline the7k

  • Hero Member
  • *****
  • Posts: 749
  • PSN: the_7k
Re: Script Request: Using a2-a4 for single-button and long inputs.
« Reply #2 on: October 03, 2009, 03:16:00 pm »
Yes, that's how I have it set up. And everytime I press d f a2, it just recognizes a2.
a2 is my kick button. So, lets say I have d u a2 for a flash kick. I press down, then up, then a2. No flash kick. Just a kick. It's been like that for ages.

Here's my freespecial deal:
Quote
com a2   freespecial10

com d f a2 freespecial4

com f d f a2 freespecial5

com d f a freespecial6

Notice freespecial4 and freespecial5? They may as well not be there. freespecial10 overrides them.
« Last Edit: October 03, 2009, 03:27:51 pm by the7k »

Offline Bloodbane

  • Hero Member
  • *****
  • Posts: 7113
  • Dark Dragon
Re: Script Request: Using a2-a4 for single-button and long inputs.
« Reply #3 on: October 05, 2009, 01:20:36 am »
 I think key.c would be the best place to make scripts for this. Hmmm... we need to detect time intervals between each key press though so D,F,A2 can't be performed like this D+F+A2.
OpenBoR Manual

Basic OpenBoR Tutorials

OpenBoR Tricks & Tutorials

"The more often enemies attack, the more open they are to counter attacks"

Offline the7k

  • Hero Member
  • *****
  • Posts: 749
  • PSN: the_7k
Re: Script Request: Using a2-a4 for single-button and long inputs.
« Reply #4 on: October 05, 2009, 01:42:51 am »
Would it be better for me to eliminate the single-button input through com settings, and do that through script, or would I instead have to code the entire long-motion input? Or would I have to code both of them?

Because, to be perfectly honest, I can only take some much code before my head explodes.

Offline Bloodbane

  • Hero Member
  • *****
  • Posts: 7113
  • Dark Dragon
Re: Script Request: Using a2-a4 for single-button and long inputs.
« Reply #5 on: October 05, 2009, 01:51:04 am »
Quote
Would it be better for me to eliminate the single-button input through com settings, and do that through script, or would I instead have to code the entire long-motion input? Or would I have to code both of them?

 Oh yes, I forgot to tell you that it's best to remove the 'com' for that attack and do that through script to avoid conflict. The script would check if motion input has been successfully inputted or not when say A2 is pressed. If it's right, perform the freespecial with long input but if it's not, just perform the single input one.
OpenBoR Manual

Basic OpenBoR Tutorials

OpenBoR Tricks & Tutorials

"The more often enemies attack, the more open they are to counter attacks"

Offline the7k

  • Hero Member
  • *****
  • Posts: 749
  • PSN: the_7k
Re: Script Request: Using a2-a4 for single-button and long inputs.
« Reply #6 on: October 05, 2009, 01:53:19 am »
So, which should I remove from Com again? The Single-button one (com a2), or the direction based ones (com d u a2)?

Offline the7k

  • Hero Member
  • *****
  • Posts: 749
  • PSN: the_7k
Re: Script Request: Using a2-a4 for single-button and long inputs.
« Reply #7 on: April 01, 2010, 11:57:46 pm »
Alright, rather than make yet another thread on the same topic, I'll just bring back the old blood.

I think I'd be able to do this if I could just get this to work. The top is just the foundation DC laid down, so I don't think I should clutter the place up with it.
Code: [Select]
   if (vName == "Morrigan"){ //Morrigan
      
       if (iAniID == 0 || iAniID == 1){ //Idle,Walk
if (iAttack2){ //New Attack2
changeentityproperty(vSelf, "animation", openborconstant("ANI_FREESPECIAL10")); //Kick
}//endattack2
}//endanicheck
     }//endmorrigan
Well, this didn't crash the system, so that's a start. However, when I press Attack2, it only activates Freespecial10 for a millisecond before going back into the Idle stance.

Edit: Well, crap. Now I've fixed the problem with AIFlag + TakeAction (I remembered the Flags before, but forgot about TakeAction)... but now it's back to Freespecial10 overriding the longer inputs.

I guess I just flat-out can't have it both ways. In fact, I keep moving if I press Attack2 while walk, while if I just use com settings, it keeps me still. I may as well have not even bothered with the script.

Edit2: The Edit Strikes Back.
Alright, I think I got something that works... even if it feels a bit laggy.
Code: [Select]
     if (vName == "Morrigan"){ //Morrigan
       
       if (iAttack2R){
if (iAniID == 0 || iAniID == 1){ //Idle,Walk
      changeentityproperty(vSelf, "aiflag", "idling", 0);
changeentityproperty(vSelf, "aiflag", "attacking", 1);
changeentityproperty(vSelf, "takeaction", "common_attack_proc");
changeentityproperty(vSelf, "animation", openborconstant("ANI_FREESPECIAL10")); //Kick
}//endanicheck
}//endattack2r
     }//endmorrigan
Now instead of activating on key press, it activates on key release. Not ideal, but at least now I can use com settings for special attacks involving the kick button - the script won't interrupt because by the time you've released the kick button, you'll be in the middle of a move, rather than the idle or walk animation.

Still need to figure out how to make the character not 'slide' when you hit Attack2 while walking.
« Last Edit: April 02, 2010, 12:42:23 am by the7k »

Offline Bloodbane

  • Hero Member
  • *****
  • Posts: 7113
  • Dark Dragon
Re: Script Request: Using a2-a4 for single-button and long inputs.
« Reply #8 on: April 02, 2010, 05:17:04 am »
Quote
if (iAttack2R){

 No wonder. Try using iAttack2.

Quote
Still need to figure out how to make the character not 'slide' when you hit Attack2 while walking.

 Just add script to stop character's movement in freespecial10.
OpenBoR Manual

Basic OpenBoR Tutorials

OpenBoR Tricks & Tutorials

"The more often enemies attack, the more open they are to counter attacks"

Offline Orochi_X

  • Hero Member
  • *****
  • Posts: 3301
  • Now! Count up your crimes.
Re: Script Request: Using a2-a4 for single-button and long inputs.
« Reply #9 on: April 02, 2010, 07:49:35 am »
O.K. Not to sound big headed or anything but my 4 attack button script is off the hook!  :laughing:

I'll explain a few things and then attach the file when I get back home.

Firstly , when referencing the animation , I always use the name rather than the ID number. When new animations get added , the ID numbers sometimes change , causing scripts to break. It shouldn't really effect low end ID's , like walk or idle , but it's better to stick to the safer method.
 
The sliding effect can easily be countered by adding changeentityproperty(vSelf, "velocity", 0, 0, 0); at the same place where you change the aiflags. This will stop all movement.

For the issue of having the script override other freespecials , you will need an indexed var for each player. Make sure you have script.txt in the data folder. This is an example I pulled up of what it should contain from the forums. Make sure that there are enough vars allocated for what you need to do.

Code: [Select]
#maxscriptvars {int}
#define a variable list in each script that can be accessed by index
#use getscriptvar(index) and setscriptvar(index, value) to use those variables
maxscriptvars   5

#maxentityvars {int}
#define a variable list in each entity that can be accessed by index
#use getentityvar(entity, index) and setentityvar(entity, index, value) to use those variables
maxentityvars   150

#maxindexedvars {int}
#define a global variable list that can be accessed by index
#use getindexedvar(index) and setindexedvar(index, value) to use those variables
maxindexedvars  100

#maxglobalvars {int}
#define a global variable list that can be accessed by name
#see getglobalvar setglobalvar getlocalvar setlocalvar for details
#the default value is 2048
#If there's no script in the game, just set it to 0, or don't change it unless you know how big it should be
maxglobalvars  2048

Now , what I do is save the current time to the indexed var when I press a direction. Then , when I press a button , I compare the current time to the time that was saved in the indexed var. If the difference is relatively small , the player must have been performing a freespecial and so the script stops. Otherwise , we go on and perform the scripted attack.

I'll insert example code and attach the script when I get back home.


* Orochi_X says : " Sore ga doushita? " :looney:

Offline Damon Caskey

  • Hero Member
  • *****
  • Posts: 5335
    • The Gorge
Re: Script Request: Using a2-a4 for single-button and long inputs.
« Reply #10 on: April 02, 2010, 08:19:30 am »
The top is just the foundation DC laid down, so I don't think I should clutter the place up with it.
Code: [Select]
   if (vName == "Morrigan"){ //Morrigan
      
       if (iAniID == 0 || iAniID == 1){ //Idle,Walk
if (iAttack2){ //New Attack2
changeentityproperty(vSelf, "animation", openborconstant("ANI_FREESPECIAL10")); //Kick
}//endattack2
}//endanicheck
     }//endmorrigan

Is that really mine? I don't remember ever hard coding animation ID's... that's a big no no. Replace iAniID == X with iAniID = openborconstant("ANI_WHATEVER"). The reason is explained by OX above; the engine's ID's for animations might change, and if they do hard coded references to them will break.

Also, like OX says, just adding changeentityproperty(vSelf, "velocity", 0,0,0); to stop movement will end the sliding problems. This is because the changing animations in of itself doesn't instruct the engine to change current velocity. That's actually a good thing; it gives you greater control so long as you account for it.

DC




OpenBOR Wiki.

Coming Soon:
Spoiler
Fatal Fury Chronicals


Offline the7k

  • Hero Member
  • *****
  • Posts: 749
  • PSN: the_7k
Re: Script Request: Using a2-a4 for single-button and long inputs.
« Reply #11 on: April 02, 2010, 02:50:43 pm »
Quote
if (iAttack2R){

 No wonder. Try using iAttack2.
That's what I was using before. If I do that, then any move I try that uses Attack2 at the end of it (like d u a2) will just become Attack2. Wanna do a kick? It'll be a kick. Wanna do a flash kick? It'll be just a kick. Wanna do a Hurricane Kick? It'll ALSO be just a kick. The same problem I've always had.

I had to do it on key release because it checks to see if you're in idle or walk. If you've done d u a2, then you will be in the middle of a freespecial - not idle or walk.

Anyway, thanks for the velocity deal and all that. If I can get OX's incoming file to work, I'll use that - otherwise, I'll just stick to what I have. It's usable, at least. I've gotta go to work soon anyway, so I can't devote a lot of time to trail and error right now.

Offline Damon Caskey

  • Hero Member
  • *****
  • Posts: 5335
    • The Gorge
Re: Script Request: Using a2-a4 for single-button and long inputs.
« Reply #12 on: April 02, 2010, 03:06:09 pm »
Wait a second.. I just reread your first post, and unless I'm missing something, you don't need script for this. At one time you would have, but not any more.

Not too long ago, single press support for the other buttons was added. So if you want a kick on A2, just set up a freespecial as your kick, add com A2 to the model header, and there you go. This should solve all of your issues. You can use cancel for the combo system, longer commands will override the single presses, and you can save script for something more exotic.

Don't forget to adjust the number of available freespecials though; each use of com or cancel counts as one.

DC

« Last Edit: April 02, 2010, 03:08:52 pm by Damon Caskey »
OpenBOR Wiki.

Coming Soon:
Spoiler
Fatal Fury Chronicals


Offline Orochi_X

  • Hero Member
  • *****
  • Posts: 3301
  • Now! Count up your crimes.
Re: Script Request: Using a2-a4 for single-button and long inputs.
« Reply #13 on: April 02, 2010, 05:26:33 pm »
Freespecials with a single button press take priority over those with longer inputs but end with the same button.

com a2 freespecial
com d f a2 freespecial2

Freespecial will always be performed. It's been like that since utunnels improved the freespecial code. I might take a look and try to figure something out.

EDIT: Yeah , the freespecial stuff is set out so that the single button freespecial is checked and played out before any of the other checks are even performed. As such , they will always have the highest priority.

I'll post my script up in a few minutes. I need food!
« Last Edit: April 02, 2010, 05:43:37 pm by Orochi_X »


* Orochi_X says : " Sore ga doushita? " :looney:

Offline Damon Caskey

  • Hero Member
  • *****
  • Posts: 5335
    • The Gorge
Re: Script Request: Using a2-a4 for single-button and long inputs.
« Reply #14 on: April 02, 2010, 06:44:48 pm »
Just tried it, you're right. Wow, that was a very bad change and needs reverting like yesterday. Naturally doing so will probably cause about 1001 new bugs.  :bored:

DC
OpenBOR Wiki.

Coming Soon:
Spoiler
Fatal Fury Chronicals


 



 0%




mighty
SimplePortal 2.3.3 © 2008-2010, SimplePortal