Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Gani play while moving (https://forums.graalonline.com/forums/showthread.php?t=493)

LordIceDragon 03-24-2001 09:46 AM

i have tried the freeze player and play a gani and make it move when holding a key down but how come it doesn't work

grim_squeaker_x 03-24-2001 08:37 PM

Blah:
NPC Code:
if (created||timeout) {
if (this.active==1) {
//movement script
if (keydown(0)) {
y-=0.5;
dir = 0;
}
if (keydown(1)) {
x-=0.5;
dir = 1;
}
if (keydown(2)) {
y+=0.5;
dir = 2;
}
if (keydown(3)) {
x+=0.5;
dir = 3;
}
setani whatever,;
freezeplayer 0.05;
}
//Activating or deactivating script.
if (keydown(4)) {
if (this.pressed==0) {
if (this.active==0) this.active=1;
else this.active=0;
this.pressed=1;
}
}
else {
this.pressed=0;
}
timeout = 0.05;
}



But anyways, you need to put in the keydown's in a constantly repeating loop, timeout is the best for that.

Thak2 03-24-2001 11:58 PM

Also freezeplayer will not react with warps, so hopefully your use of it will not involve multiple levels.

grim_squeaker_x 03-25-2001 06:06 AM

Quote:

Originally posted by Thak2
Also freezeplayer will not react with warps, so hopefully your use of it will not involve multiple levels.
Actualy there is the: "disabledefmovement;" command, works as freezeplayer only it allows levle linkage, you do need to disable it with "enabledefmovement" later though.

Thak2 03-25-2001 11:07 AM

yes I knew of that, but that can only be used for P2P servers.

grim_squeaker_x 03-25-2001 06:43 PM

Yup.
 
So it's only posible in pay servers right now, except if I can do some research myself... So nblah I'll spend some time digging out .graal files to see if I can find a way of deciphering warps into variables.

LordIceDragon 03-26-2001 01:12 PM

thanks but
SAY WHAT!?!?!?
i have been programing on graal since it's release and well i got kinda cunfused ever since thisspeed came out(kinda dumb aint i) but easily put i just do:
if (playerenters) {toweapons -Bomy}
if (hasweapon(-Bomy)) {sethead Bomy_visio6.png;
disabledefmovement;
setani Bomy_idle,;}
if ( if (keydown(0)) {
y-=0.5;
dir = 0;
}
if (keydown(1)) {
x-=0.5;
dir = 1;
}
if (keydown(2)) {
y+=0.5;
dir = 2;
}
if (keydown(3)) {
x+=0.5;
dir = 3;
}
setani Bomy_walk,;
}




is that how a basic (very very basic) bomy
just the walking part right?

grim_squeaker_x 03-26-2001 07:46 PM

Quote:

Originally posted by LordIceDragon
thanks but
SAY WHAT!?!?!?
i have been programing on graal since it's release and well i got kinda cunfused ever since thisspeed came out(kinda dumb aint i) but easily put i just do:
if (playerenters) {toweapons -Bomy}
if (hasweapon(-Bomy)) {sethead Bomy_visio6.png;
disabledefmovement;
setani Bomy_idle,;}
if ( if (keydown(0)) {
y-=0.5;
dir = 0;
}
if (keydown(1)) {
x-=0.5;
dir = 1;
}
if (keydown(2)) {
y+=0.5;
dir = 2;
}
if (keydown(3)) {
x+=0.5;
dir = 3;
}
setani Bomy_walk,;
}




is that how a basic (very very basic) bomy
just the walking part right?

Almost...
For the keydown part you'll need to use:
if (timeout||created) {
[keydownstuffhere]
timeout=0.05;
}

Otherwise it won't work.

kyle0654 03-27-2001 07:22 AM

Actually....I think the keydown stuff (checking if keys are down) took three lines...then most of it was mathematical based on what keys were down...

Hint: Use an Array
NPC Code:

if (created) {
this.cKeyDown = {0,0,0,0,0,0,0,0,0,0,0};
timeout = .05;
}
if (timeout) {
for (this.z = 0; this.z < 11; this.z++)
this.cKeyDown[this.z] = (keydown(this.z));
}



You could also have it store how long a key has been down...

LordIceDragon 03-27-2001 08:11 AM

ok so...
if (timeout||created) {
if (playerenters) {toweapons -Bomy}
if (hasweapon(-Bomy)) {sethead Bomy_visio6.png;
disabledefmovement;
setani Bomy_idle,;}
if ( if (keydown(0)) {
y-=0.5;
dir = 0;
}
if (keydown(1)) {
x-=0.5;
dir = 1;
}
if (keydown(2)) {
y+=0.5;
dir = 2;
}
if (keydown(3)) {
x+=0.5;
dir = 3;
}
setani Bomy_walk,;
}
if (playerisdead){
setani bomy_dead,;
timeout=0.05;
}

LordIceDragon 03-27-2001 12:28 PM

Darn it that doesnt work either
GRR...EVER SINCE THISSPEED CAME OUT I CANT MAKE ANYTHING!!!

Thak2 03-27-2001 07:39 PM

Ok, here is my version of the bomy script... I made it awhile back but stopped working on it when I discovered non-p2p servers cant use bomy stuff or complex ganis, Ill continue working on it later, and refine the onwall so it is the same as a humans/normal bomies.
NPC Code:

// NPC made by Thak
if (playerhearts = playerfullhearts&&!notbomy)
{callweapon selectedweapon, weaponfired;
}
if (playerenters) {
}
if (playertouchsme) {toweapons bomy;
}
if (weaponfired) {sethead bomy_birce0.png;
setani bomy_idle,;
disabledefmovement;
unset notbomy;
timeout=0.05;}
if (playersays(bomy1)) {sethead bomy_birce0.png;}
if (playersays(bomy2)) {sethead bomy_herm0.png;}
if (playersays(bomy3)) {sethead bomy_golg0.png;}
if (playersays(bomy4)) {sethead bomy_draktha0.png;}
if (timeout) {setani bomy_walk,;
playery-=0;
timeout=0.05;
}
if (timeout&&keydown(2)&&!bomyduck) {playery+=0.7;
playerdir=2;
setani bomy_walk,;
timeout=0.05;
}

if (timeout&&keydown(3)&&!bomyduck) {playerx+=0.7;
playerdir=3;
setani bomy_walk,;
timeout=0.05;
}

if (timeout&&keydown(0)&&!bomyduck) {playery-=0.7;
playerdir=0;
setani bomy_walk,;
timeout=0.05;
}

if (timeout&&keydown(1)&&!bomyduck) {playerx-=0.7;
playerdir=1;
setani bomy_walk,;
timeout=0.05;
}

if (timeout&&!keydown(1)&&!keydown(0)&&!keydown(2)&&! keydown(3))
{setani bomy_idle,;
timeout=0.05;
}

if (keydown(2)&&timeout&&onwall(playerx+1.5,playery+2 .4)) {
playery-=0.3;
sleep 0.05;
playery-=0.3;
sleep 0.05;
playery-=0.3;
timeout=0.05;
}

if (keydown(0)&&timeout&&onwall(playerx+1.5,playery+0 .4)) {
playery+=0.3;
sleep 0.05;
playery+=0.3;
sleep 0.05;
playery+=0.3;
timeout=0.05;
}

if (keydown(1)&&timeout&&onwall(playerx+0.2,playery+1 .1)) {
playerx+=0.25;
sleep 0.05;
playerx+=0.25;
sleep 0.05;
playerx+=0.25;
timeout=0.05;
}
if (keydown(3)&&timeout&&onwall(playerx+2.7,playery+1 .1)) {
playerx-=0.25;
sleep 0.05;
playerx-=0.25;
sleep 0.05;
playerx-=0.25;
timeout=0.05;
}
if (keydown(3)&&timeout&&onwall(playerx+2.7,playery+2 .4)) {
playerx-=0.25;
sleep 0.05;
playerx-=0.25;
sleep 0.05;
playerx-=0.25;
timeout=0.05;
}
if (keydown(1)&&timeout&&onwall(playerx+0.2,playery+2 .4)) {
playerx+=0.25;
sleep 0.05;
playerx+=0.25;
sleep 0.05;
playerx+=0.25;
timeout=0.05;
}
if (timeout&&keydown(5)&&!keydown(1)&&!keydown(0)&&!k eydown(2)&&!keydown(3)&&!bomyduck)
{setani bomy_duck,;
sleep 0.5;
set bomyduck;
timeout=0.05;}
if (bomyduck&&timeout) {
setani bomy_hide,;
timeout = 0.05;
}
if (!keydown(5)) {
unset bomyduck;
}
if (playerhearts<=0&&timeout) {
setani bomy_dead,;
}

if (playersays(off)) {sethead head41.gif;
setani idle,;
timeout=0;
freezeplayer=0;
enabledefmovement;
set notbomy;
}


There may be stuff I was fooling around with in there too that doesnt work, but it has been tested online and works pretty good.

grim_squeaker_x 03-27-2001 07:56 PM

Quote:

Originally posted by kyle0654
Actually....I think the keydown stuff (checking if keys are down) took three lines...then most of it was mathematical based on what keys were down...

Hint: Use an Array
NPC Code:

if (created) {
this.cKeyDown = {0,0,0,0,0,0,0,0,0,0,0};
timeout = .05;
}
if (timeout) {
for (this.z = 0; this.z < 11; this.z++)
this.cKeyDown[this.z] = (keydown(this.z));
}



You could also have it store how long a key has been down...

Hmm, thanks for that script I can probably use it to reduce the amountof scripting I have now in some cases.

grim_squeaker_x 03-28-2001 07:18 PM

Re: Buhaha
 
Quote:

Originally posted by Gspeed2000
Looks like someones forgetting the dreadfull onwall detection ;)
Blah, that was example scripting GodSpeed ^^

Komieko 03-29-2001 01:40 PM

This is my version..I got alot of problems with it sucha s walking (it sets it to the first animation of bomy_walk each time so it doesn't play full)on horses same and water I got no clue about....Can anyone help with the walking thing?
Quote:

if (playertouchsme) {
sethead bomy_birce0.png;
setani bomy_idle,;
timeout=.05}

if (timeout){

setani bomy_idle,;

if (keydown(0)||keydown(1)||keydown(2)||keydown(3))
{setani bomy_walk,};

timeout=.05}
if (playerdies) {setani bomy_dead,;}
if (playeronhorse){setani bomy_ride,};
if (keydown(5)){setani bomy_hide,; freezeplayer .1;}
if (keydown(6)){setani bomy_attack,; freezeplayer .1;}

Thak2 03-29-2001 08:19 PM

To make it work good and be fluid you are going to have to disabledefmovement and set your own movement... I dont see any other way for yours to function accuratly.

Komieko 03-30-2001 01:10 AM

um...*runs*
 
So what does disabledfmovemnt do?LikeI tried ur script and I was invis and if it actually showed the bomy (like once) it was flashing alot..

Komieko 03-30-2001 01:32 AM

example?
 
Could someone give me an example f making the feet move when the arrow key is pushed?It'd help me out beccause I got no clue where to really start with the feet movement..Except I do got new main bomy script but I ain't no l33t scripter and some of it is just damn confusing!TOO many numbers!@_@

Thak2 03-30-2001 06:09 AM

Ok, first for the keydown to work best with what you want to do you would either have to freeze the player or disable default movement (animations).

You could make a full functioning script of it with freezeplayer except that freezeplayer makes it so the player doesnt detect anything such as warps...
so disabledefmovement must be used, as it turns off the default animations and movement.

With that set use something like this as an example of one movement:
NPC Code:

if (timeout && keydown(0)) {
playerdir=0;
playery -= 0.5;
setani bomy_walk,;
timeout=0.05;
}


keydown 0 is up as you should know, and the player moves approximetly 0.5 tiles every timeout which is same as normal... just set your beginning code which disablesdefmovement and sets the player head to a bomy head and a timeout, then add onwall code, and you have basic movement transformation script...

oh and what parts of my script didnt work? it should...


All times are GMT +2. The time now is 06:24 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.