Home   Help Search Login Register  

Author Topic: Making characters Jump - Help Required !  (Read 1911 times)

0 Members and 1 Guest are viewing this topic.

Offline Roni

  • Members
  • *
  • Play the Game !
Making characters Jump - Help Required !
« on: 02 Oct 2003, 01:06:01 »
Hello All

I live in Australia and have had OFP since before it was released in the USA (I bought my copy in August 2001 !), but have only just got around to teaching myself how to script.  Now I've started I'm hooked !  This is my first post and my first query for the group so please excuse this query if it is stupid/redundant/has been done before/isn't possible.

I am trying to make a script that makes a character jump a set height.  It doesn't seem too hard but there are two items that elude me.

Essentially, I want to allow the player to be able to hit a certain key to run the script ("jump.sqs").  I know that I can use an addaction but I am thinking that if you re trying to hurdle an obect the combination of fingers and keystrokes required may be a bit much.  A one key function would be far preferable.

Here's what I have so far -

In player character's init field -
<some command that allows you to hit a key to run a script> [key,"jump.sqs"]



The script - "jump.sqs"

; if character is in the air already then he can't jump
? getpos select 2 > 0: exit

; character raises arms
this switchmove "FXStandSurUniv" ; is this correct syntax ?

;pause
~0.2

; character stands in place for an instant
this switchmove "effectstandstill"

;pause
~0.1

; character jumps to set height.  I want to set this so that it is realistic yet useful for jumping fences, small objects etc.  any suggestions ?
this setpos [getpos this select 0, getpos this select 1, (getpos this select 2)+1]

; character crouches in the air
this switchmove "effectcrouch" ; is this correct syntax ?

;pause
~0.1

; character falling back to earth
this switchmove "effectstandstill"

;pause
~0.1

; character hits the ground (if timed right !)
this switchmove "effectcrouch" ; is this correct syntax ?

exit



So on to the questions -

Question 1 - Is there a function in the scripting language that allows you to assign a script to a key stroke ?  Example - onkey ["j","jump.sqs"]


Question 2 - Does anyone have a list of all of the switchmoves that you can assign to a character.  As a corollory, how can you add new switchmoves ?

Any help would be greatly appreciated

Unnamed

  • Guest
Re:Making characters Jump - Help Required !
« Reply #1 on: 02 Oct 2003, 01:58:06 »
Quote
Question 1 - Is there a function in the scripting language that allows you to assign a script to a key stroke ?  Example - onkey ["j","jump.sqs"]

Not via a script, perhaps if you made an entire mod and edited resource.bin or something?

Quote
Question 2 - Does anyone have a list of all of the switchmoves that you can assign to a character.

http://www.ofpec.com/editors/resource_view.php?id=471

Quote
As a corollory, how can you add new switchmoves ?

If you wanted to use the ones you just mentioned you could do it with an addon (don't think there is an easier way?), using the CfgMove class:

Code: [Select]
class CfgMovesMC
{

   class Default {};
   class CombatBase: Default {};
   class StandBase: Default {};
   class States
   {      
   class FOBinoc: CombatBase
      {
         actions = BinocActions;
         file=sdalekstat.rtm; // TODO: ai variants
         speed=-2;
         looped=true;
         disableWeapons=false;
         showItemInHand = true;
         soundEnabled=false;
         enableBinocular = true;
         head=headNo;
         connectFrom[] = {CombatToBinoc,1};
         interpolateTo[]={CombatDying,0.1,CombatDyingVer2,0.1,CombatDyingVer3,0.1};
         
      };


   class FOBinocLying: CombatBase
      {
         actions = BinocLyingActions;
         file=plazenidalekstat.rtm; // TODO: ai variants
         speed=-2;
         looped=true;
         disableWeapons=false;
         showItemInHand = true;
         soundEnabled=false;
         enableBinocular = true;
         onLandBeg=true;
         onLandEnd=true;
         duty = RestDuty;
         connectFrom[] = {LyingToBinocLying,1};
         interpolateTo[]={LyingDying,0.1};
      };

   class FOBinocStand: CombatBase
      {
         actions = BinocStandActions;
         file=bezdalekstat.rtm; // TODO: ai variants
         speed=1;
         looped=true;
         disableWeapons=false;
         showItemInHand = true;
         soundEnabled=false;
         enableBinocular = true;
         connectFrom[]={StandToBinocStand,0.1};
         interpolateTo[]={StandDying,0.1,StandDyingVer2,0.1};
      };

   class FOBinocCrouch: CombatBase
      {
         actions = BinocCrouchActions;
         file=klekdalekstat.rtm; // TODO: ai variants
         speed=2;
         looped=true;
         disableWeapons=false;
         showItemInHand = true;
         soundEnabled=false;
         enableBinocular = true;
         connectFrom[]={CrouchToBinocCrouch,1};
         interpolateTo[]={CrouchDying,0.1};
      };

   class FOCrouch: CombatBase
      {
         preload = true;
         actions=CrouchActions;
         file=klek.rtm;
         speed=2;
         variantsPlayer[]={};
         variantsAI[]={};
         visibleSize = 0.6;
         aimPrecision = 0.5;
         recoilSuffix = "halffixed";
         connectFrom[]={CombatToCrouch,1};
         interpolateTo[]={CrouchDying,0.1};
      };
   };

};

These where just existing binocular move anims I modified and renamed, so they do not loop. The bits you would want would be.

connectfrom
connectto

I think you should be able to connect all those move into one playmove command.

This was the original source for my CfgMoves, I've only scratched the surface:

http://www.ofpec.com/yabbse/index.php?board=13;action=display;threadid=9578

You can create new anims using an ofp animation editor available here somewhere.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Making characters Jump - Help Required !
« Reply #2 on: 02 Oct 2003, 02:26:57 »
Welcome to the forums!

Not a silly question at all, in fact one I don't recall seeing before and I've read a lot of questions.

Unnamed has pretty much covered most of it.   The only other thing I can think of is the setVelocity command, which you may want to use.   It sounds like you already have the command reference.

You have the correct switchmove syntax though it might sometimes be easier to use the name of the unit.   So if  you had name the unit loon1 it would be

loon1 switchmove "whatever"

The problem with your whole system is that there is no forward movement - it's all very well jumping in the air but it won't get you over the obstacle if you don't move forward as well.

Plenty of reviewed ArmA missions for you to play

Offline Roni

  • Members
  • *
  • Play the Game !
Re:Making characters Jump - Help Required !
« Reply #3 on: 02 Oct 2003, 02:43:29 »
Thanks for the tips, much appreciated !

I was going to add a lateral offset (forward movement) using some form of getdir and a bit of trigonometry  :o but figured that if the player was moving then his momentum should carry him through.  Besides, there may be some instances when all you wanted to do was peep over a wall   ;)

So in summary, it looks like the script should work (I'm drawing it up now - I'll post it when I've got it running), but there is no way to assign it to a key.  Are you sure that there is no way around this ?  There are so many other things that work via keystrokes (radio calls, set formation etc) it seems like strange oversight by the wonderful mob at Bohemia NOT to have that ability.

Oh well, maybe it's not that important - I'll let you know how easy it is to run and jump in a few hours . . .



Roni

deaddog

  • Guest
Re:Making characters Jump - Help Required !
« Reply #4 on: 02 Oct 2003, 04:42:44 »
Quote
There are so many other things that work via keystrokes (radio calls, set formation etc) it seems like strange oversight by the wonderful mob at Bohemia NOT to have that ability.
That is true, but none of these things work with a single keystroke.  You can use a radio trigger to execute scripts, so the key sequence would be 0-0-X, where X is 0-9.

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Making characters Jump - Help Required !
« Reply #5 on: 02 Oct 2003, 04:51:47 »
Roni,

Firist, let me say, "what a GREAT IDEA!"

You may not be able to assign the script to a key, but you can assign your action menu key to a key that is near to your movement keys.  Then if you use addACtion with the script it should become the top action menu item.  Since it is the highest menu item a quick double tap of the  action key should activate the script.  Also, a mouse with a middle button defaults as the action key, and that should allow for very well coordinated jumps.  You could even make a trigger associated with "jumpable" objects so that the "jump" action is added to the action menu as soon as the player is within proximity of the fence or whatever.

I would definitly recommend you use the setVelocity function to make for smoother motion.  You could then have the soldier accelerate uppward until his feet leave the ground, then decelerate  as he approaches his max elevation, then accelerate downward (all consistent with earths 9.8 m/s2 gravity, of course  ;)).  Anyway, the coding would be complex, but it would make for really nice aniamtion.

Offline Roni

  • Members
  • *
  • Play the Game !
Re:Making characters Jump - Help Required !
« Reply #6 on: 02 Oct 2003, 05:33:57 »
Hi All

Thanks again for the input.  I've made a simple mockup of the script and it seems to work okay, with one or two quirks.

First - I agree - no need to assign a key since a "double tap" addaction works just fine.  Just the right amount of concentration and dexterity required to get the timing right.

Second - no need for setVelocity - I've tried various forms and levels of jump (from minijump to superjump and found that a jump of 2m works really well, even if it is a bit unrealistic to expect anyone to jump that high in full kit.  It does mean though that a move towards a low building and a well timed jump can get you up high enough to crawl onto the roof.  Haven't tried leaping barbed wire yet though . . .  :P

Finally - the animations that I chose really do suck.  I'm experimenting with every combination of switchmove and playmove option from macguba's handy reference (hey - now I know where I know that name - thanks for the nput macguba !) but no luck so far.  I may have to find a friendly modeller make up some new ones  :)

However, to make the script complete I reckon it would need two additional things - an associated sound and a health factor hit.

Unless I am mistaken adding a sound effect would be reasonably simple - simply sample a grunt and a puff, convert it from wav to ogg with the appropriate utility then call it from within the script.  Am I missing anything ?  Okay, so I've checked the command ref and it looks like it may take a description.ext mod - so maybe not so easy . . .

The health hit would just be a simple command to fatigue the character a bit for his efforts.  Would stop bunnyhoppers (please - let this game never become Counterstrike !) and would make a sprint and hurdle over a wire entaglement a real chore !

I'm back to my references to try and find the relevant bits.

Cheers !

 

« Last Edit: 02 Oct 2003, 05:41:04 by Roni »

Offline rhysduk

  • Former Staff
  • ****
Re:Making characters Jump - Help Required !
« Reply #7 on: 02 Oct 2003, 23:55:34 »
[size=5.5]WELCOME TO THE FORUMS MATE [/size]

Pleased to have you around...

Watch out for LCD .. he is a bit of a big head  :-X i said nothing ok ?

Rhys ;D Have fun mate
Reviewed Missions Board: Please Read the User's Guide before posting!

Pride and Joy 1 (HW100-T)

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Making characters Jump - Help Required !
« Reply #8 on: 03 Oct 2003, 01:32:24 »
You're right, adding a sound would be simple.     There's a good tute, I think it's by bloodmixer.   The first ogg converter I tried didn't work, but the second one was fine.  The description.ext bit is easy, just copy and paste from somewhere and edit as required.

As for the health, you could try something like

setDammage (getDammage loon1) + 0.1

in the script.   Might also be worth putting a getdammage condition at the start so that you can't jump tall buildings if your dammage is greater than say 0.8.
Plenty of reviewed ArmA missions for you to play

Offline Roni

  • Members
  • *
  • Play the Game !
Re:Making characters Jump - Help Required !
« Reply #9 on: 03 Oct 2003, 07:05:17 »
Thanks all.

Well, I got the script working but now I'm having troubles with the animation when I am moving forward.  When you are in 3rd person view the engine sets the camera a fixed position behind and above you and for some reason this does not change automatically.  As a result, multiple anim changes as my man jumps all tend to jerk and stutter.  I'm sure that there is an answer involving camera functions . . .

I decided against the setVelocity function for two reasons - 1) it didn't work and 2) - the command ref says that it is for vehicles only.   :P

The main change that I made was to change the one big jump into lots of little jumps, each separated by 0.1 of a second.  Basically, rise 0.5m, pause, rise 0.4m, pause etc, then fall 0.1m, pause, fall 0.2m, pause etc back to earth.  Unless of course you did it while running over the cliff, then it's pause, OOPS ! . . .  :o

If you notice my jump is now 1.5m (0.5 +0.4+ . . . 0.1 = 1.5m up, then down).  I tried 2m and it looks like that must be some breakpoint for taking damage - after about 5-10 hops my guy ended up with a broken leg !

I will take on board the custom anims, the sound and the health suggestions - thanks all.  Just one thing - is there a difference in the game between health and damage ?  I mean - when you sprint you get tired and when you rest you recover.  When you take a bullet you get damaged but as far as I can tell without a medic or LOTS of time you are stuffed.  I want jumping to tire you, not slowly kill you.


Final note - I've read a million FAQs and references and I'm sure that  I missed this but what is the protocol with posting scripts to this forum ?  Do I have to include a mission to show it off as well ?  If so maybe I'll set up a hurdles track somewhere as an sqm ('The La Trinite Games' ?).

Roni
« Last Edit: 03 Oct 2003, 07:06:15 by Roni »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Making characters Jump - Help Required !
« Reply #10 on: 03 Oct 2003, 11:50:55 »
Health and damage as you define them are different in the game.   I have no idea how to affect/increase the getting tired thing (like when you run) which is why I suggested the damage thing.  

I think you can use setvelocity on your loons if you want a laugh.

As for posting scripts ... well you don't need to have an example mission if you're posting a script on the forum, though obviously it helps.    If you submit it to the Ed Depot - and for something as cool as this you definitely should - then an example mission, while not technically a formal requirement, is very desirable.
Plenty of reviewed ArmA missions for you to play

max_killer_payne

  • Guest
Re:Making characters Jump - Help Required !
« Reply #11 on: 03 Oct 2003, 15:02:56 »
try using the setvelocity command, thats solved quite a few of my problems, including a mutant script that gives you force powers!!

Offline Blanco

  • Former Staff
  • ****
Re:Making characters Jump - Help Required !
« Reply #12 on: 03 Oct 2003, 20:57:29 »
...about the keystroke issue, ...
Vektorboson made an artilleryscript (something completely different, I know) ...where you can type the distance with one digit on the keyboard.

dl the script here :
http://home.arcor.de/vektorboson/downloads/fast_arty.zip

I don't know much about scripting or how he did it, but I thought it could be usefull...

Welcome 2 the forums

Search or search or search before you ask.

Offline Roni

  • Members
  • *
  • Play the Game !
Re:Making characters Jump - Help Required !
« Reply #13 on: 04 Oct 2003, 08:23:12 »
Once again - thanx all !  I've been on forums before (or is that 'fora' before ?) a year or so back but I still get stunned by the help of strangers.  :)

I will try again with the setVelocity command - this whole jump thing came about as an aside while I was working on an Iraqi scenario (Fedayeen vs Iraqi police and US regulars) and it sort of took over.  The idea was to make some way for the bad guys to get onto the roof tops to snipe at passing convoys   :gunman:

I'll trawl through the command reference to see if there is anything that simulates fatigue - I'm leaning towards a terminal animation of Lying - doesn't fatigue you but sure makes bunnyhopping impossible if you have to stand up after each jump.

BTW - this is probably not news to the group but I discovered that animations aren't necessarily static, if you know what I mean.  The combat sprint animation for example actually moves the character forward, so having it in the mddle of a jump (pumping legs etc) actually changes the characters location.  Looks like I'm going to have to have one set of animations for standing, running and sprinting jumps  :-\

Watch this space for the beta version !