 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
Hyperdrmr plotscripter/musician

Joined: 25 Oct 2003 Posts: 32 Location: behind a drumset/guitar/comp
|
Posted: Mon Nov 10, 2003 10:19 pm Post subject: problem with scancode |
|
|
im trying to figure out how to make my character levitate when i press a button but it never works. i looked at the plot dictionary but that didnt help.
HERES THE SCRIPT:
script, JUMP, begin
wait for key (37)
key is pressed (37)
set hero z (0,6)
wait for hero
set hero Z (0,0)
end _________________ "i can see it in her eyes she acts just like a nurse to all the other guys"-Perfect Circle
http://gamingetc2.topcities.com/hyperdrmrpage.htm |
|
Back to top |
|
 |
LeRoy_Leo Project manager Class S Minstrel

Joined: 24 Sep 2003 Posts: 2683 Location: The dead-center of your brain!
|
Posted: Mon Nov 10, 2003 11:01 pm Post subject: |
|
|
gRAPHICS: Does he have teh shadow? Make that a sepparate Npc that pops up below him.
Plotscripting: (I am a know nothing) That looks like it should work. The wait for key command is necessary? Are the Zs supposed to be not case sensitive?
DEBUG!
-Leroy- Plot scripting amature... I tried...  _________________ Planning Project Blood Summons, an MMORPG which will incinerate all of the others with it's sheer brilliance...
---msw188 ---
"Seriously James, you keep rolling out the awesome like gingerbread men on a horror-movie assembly line. " |
|
Back to top |
|
 |
Minnek Conjurer

Joined: 03 Jun 2003 Posts: 430 Location: Somewhere
|
Posted: Mon Nov 10, 2003 11:04 pm Post subject: |
|
|
hmmmm.....let me take a shot at this.
Code: | Script,Jump,begin
if(key is pressed (37) == true),then
(
set hero Z (0,6)
)
else
(
set hero Z (0,0)
) |
that's very basic, so you'll have to add your own stuff in there. That'll make him levitate while the key is pressed, or at least it should. I have yet to test it. Let me know if it works  _________________ * SDHawk has joined #Minnek
SDHawk> AAAAAAAAAAAAAUUUUUUUUUGH
* SDHawk has left #Minnek (Leaving) |
|
Back to top |
|
 |
Hyperdrmr plotscripter/musician

Joined: 25 Oct 2003 Posts: 32 Location: behind a drumset/guitar/comp
|
Posted: Mon Nov 10, 2003 11:15 pm Post subject: |
|
|
im just trying to get the scancode numbers to where i can push a button and it does somthing. As in pitch black, you push L and the flashlight comes on. i just want to push L and somthing happens _________________ "i can see it in her eyes she acts just like a nurse to all the other guys"-Perfect Circle
http://gamingetc2.topcities.com/hyperdrmrpage.htm |
|
Back to top |
|
 |
Flamer The last guy on earth...

Joined: 04 Feb 2003 Posts: 725 Location: New Zealand (newly discovered)
|
Posted: Tue Nov 11, 2003 5:28 am Post subject: |
|
|
you do know that "set hero z" is an instant command... like "set hero position" it sets the "z" position of the hero instantly.
so your code:
Code: | script, JUMP, begin
wait for key (37)
key is pressed (37)
set hero z (0,6)
wait for hero
set hero Z (0,0)
end |
won't work, because it instantly sets hero "z" to 6 then instantly sets it back to 0, os the final result will be to keep it at 0, as if it hasn't done anything.
what you may want is something like this:
Code: | script, JUMP, begin
if(key is pressed (37)) then(
set hero z(0,1),wait(1)
set hero z(0,2),wait(1)
set hero z(0,3),wait(1)
set hero z(0,4),wait(1)
set hero z(0,5),wait(1)
set hero z(0,6), wait(2)
set hero z(0,6),wait(1)
set hero z(0,5),wait(1)
set hero z(0,4),wait(1)
set hero z(0,3),wait(1)
set hero z(0,2),wait(1)
set hero z(0,1),wait(1)
set hero z(0,0)
)
end |
this will give the hero a "jump" look to it. it would look a lot more clean with a loop instead of all that, but let's just use the basics for now.
You may also want to make the hero to jump in the direction it is facing. _________________ If we were a pack of dogs, IM would be a grand Hound, CN would be a very ficious little pitball, and Giz...well, it doesn't matter breed he is, he'd still be a bitch
(no offense to anyone that was mentioned) |
|
Back to top |
|
 |
DemocraticAnarchist Sleep Deprived

Joined: 26 Apr 2003 Posts: 137 Location: :noitacoL
|
Posted: Tue Nov 11, 2003 12:59 pm Post subject: |
|
|
Havent tested this yet but it seems okay. To define:
define script (autonumber, jump, 1, 0)
and to use:
jump (me) # where me is the hero's number/name
Code: | script, jump, hero, begin
variable (counter)
counter :=0
if (key is pressed (37))
then (
if (counter <= 6)
then (
set hero z (hero, counter)
increment (counter)
wait (1)
)
else (
if (counter >= 0)
then (
set hero z (hero, counter)
decrement (counter)
wait (1)
)
else (end)
)
end |
Yaay, a function! _________________ What cruel person decided lisp should have an s in it? |
|
Back to top |
|
 |
Sephyroth Renegade Rebel Redmage Class A Minstrel

Joined: 04 Feb 2003 Posts: 644 Location: Schmocation
|
Posted: Tue Nov 11, 2003 1:14 pm Post subject: |
|
|
Do you have a keypress script? The way I see it... I don't think the script will work at all without a keypress script. something like this...
Quote: |
global variable(999, button)
script,keypress,key,begin
write global(999,key) #or "button:=key". I just like write global a lot.
end
|
Then you replace "button" every time you need to check which key is pressed on the map. This probably isn't the best way but you have to set the "run script on keypress" thing in the map data menu to something. _________________ im realy ded  |
|
Back to top |
|
 |
Mad Cacti Guest
|
Posted: Tue Nov 11, 2003 11:35 pm Post subject: |
|
|
*smacks forehead at the general nonsensualness of the replys*
First, about the scan codes, I recomend including scancode.hsi at the put of your files, just like you would plotscr.hsd. That way you can use write
if (key is pressed (key:l))
without having to look up the number each time.
Secondly, you CAN'T use scancodes with wait for key! It only accepts constants like 'anykey', 'cancel key' and 'upkey'. See the dictionary definition. That's why your script doesn't work.
Finally, for a jump script:
Code: | script, jump, hero, begin
variable (counter)
counter :=0
if (key is pressed (37))
then (
if (counter <= 6)
then (
set hero z (hero, counter)
increment (counter)
wait (1)
)
else (
if (counter >= 0)
then (
set hero z (hero, counter)
decrement (counter)
wait (1)
)
else (end)
)
end |
why increment ordecrement the counter if its a local and is always at zero? There is no way to check hero z, you have to store it in a global if you want to use it across scripts. Don't forget whether you've already set it at somethign under the general map options.
Now, if you want a jump script with a physical correct smooth curve:
Code: |
script, jump, begin
variable (current height, ctr)
while (current map == 5) do ( #change this to the map number or other criteria
if (key is pressed(key:j)) then(
current height := 0 #adjust this to the height offset under map options
for (ctr, 3, -3, -1) do(
increment(current height, ctr)
set hero z(me, current height)
wait(1)
)
)
)
|
This code will also allow the hero to jump forwards or backward, as player is not suspended.
Feel free to change the 3, -3 to change the height of the jump. But there must be opposite in value, or the hero will end up in the sky or floor.
Not its for hero 0 only, but its not hard to change.
Misc:
Leroy_leo: you don't need chenge the direction of the hero, hero z is just the amount of pixels above the tile the hero is drawn. But you may want to change the heros palette to draw him in mid jump.
Sephy: That would only be needed if you had more than one thing that needed to check the key presses every second, or you could run thenm all into one loop. |
|
Back to top |
|
 |
Mad Cacti Guest
|
Posted: Tue Nov 11, 2003 11:41 pm Post subject: |
|
|
PS: That script would only jump the hero up 6 pixels. You may want to change 3,-3 to 4,-4, 5,-5, or 6,-6 for a 10, 15 or 21 pixel high jump.
Hmm... I think I'll add that script to my library... |
|
Back to top |
|
 |
Uncommon His legend will never die

Joined: 10 Mar 2003 Posts: 2503
|
Posted: Tue Nov 11, 2003 11:46 pm Post subject: |
|
|
If you want, you could also have the script so it had the hero levitate while the button is held, as problems can sometimes arise from toggle keys (note: this is edited from James' old optimization of my run script:
Code: | if,begin
key is pressed (37) #change this to choose your own key
end
then,begin
if (hero is walking (me)==false)
then,begin
# levivation stuff
end
end
else,begin
if (hero is walking (me)==false)
then,begin
# non-levivitation stuff
end
end
end |
|
|
Back to top |
|
 |
Flamer The last guy on earth...

Joined: 04 Feb 2003 Posts: 725 Location: New Zealand (newly discovered)
|
Posted: Wed Nov 12, 2003 3:00 am Post subject: |
|
|
that'll work... until you run into an NPC triggering another script...
oh well, i doubt it'll be an issue. _________________ If we were a pack of dogs, IM would be a grand Hound, CN would be a very ficious little pitball, and Giz...well, it doesn't matter breed he is, he'd still be a bitch
(no offense to anyone that was mentioned) |
|
Back to top |
|
 |
Ysoft_Entertainment VB Programmer

Joined: 23 Sep 2003 Posts: 810 Location: Wherever There is a good game.
|
Posted: Wed Nov 12, 2003 8:09 am Post subject: |
|
|
I agree with mad cacti
for the following reasons
1. For command goes from automatically increases the variable.
2. out of all the scripts I have seen in this post, this one seems less buggy.
3. and finally, levitate means you stay in the sky, not jump(sorry for any inconvenience.  _________________ Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals. |
|
Back to top |
|
 |
Uncommon His legend will never die

Joined: 10 Mar 2003 Posts: 2503
|
Posted: Wed Nov 12, 2003 9:16 am Post subject: |
|
|
Well, Flamer, it goes in the "on keypress" map script. I guess I forgot to mention that... |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|