PDA

View Full Version : New Emotions


Clockwork
10-10-2008, 10:04 PM
Script that will replace the old emotions with new ones! :O
Made awhile ago, but decided to release it... (I don't like the old ones x.x; )

But yea, credits to Dusty, chompy and myself. o_O..


//#CLIENTSIDE

function onCreated() {
enablefeatures(allfeatures-0x1000);
this.emote_timer = 0;
setTimer(0.05);
}

function GraalControl.onKeyDown(keymod, char, keynumber) {
if (keymod == 577){ this.emote = "aeko-crtl_a.gif";} else
if (keymod == 578){ this.emote = "aeko-crtl_b.gif";} else
if (keymod == 579){ this.emote = "aeko-crtl_c.png";} else
if (keymod == 580){ this.emote = "aeko-crtl_d.png";} else
if (keymod == 581){ this.emote = "aeko-crtl_e.gif";} else
if (keymod == 582){ this.emote = "aeko-crtl_f.png";} else
if (keymod == 583){ this.emote = "aeko-crtl_g.png";} else
if (keymod == 584){ this.emote = "aeko-crtl_h.png";} else
if (keymod == 585){ this.emote = "aeko-crtl_i.gif";} else
if (keymod == 586){ this.emote = "aeko-crtl_j.gif";} else
if (keymod == 587){ this.emote = "aeko-crtl_k.png";} else
if (keymod == 588){ this.emote = "aeko-crtl_l.gif";} else
if (keymod == 589){ this.emote = "aeko-crtl_m.png";} else
if (keymod == 590){ this.emote = "aeko-crtl_n.gif";} else
if (keymod == 591){ this.emote = "aeko-crtl_o.png";} else
if (keymod == 592){ this.emote = "aeko-crtl_p.png";} else
if (keymod == 593){ this.emote = "aeko-crtl_q.png";} else
if (keymod == 594){ this.emote = "aeko-crtl_r.gif";} else
if (keymod == 595){ this.emote = "aeko-crtl_s.png";} else
if (keymod == 596){ this.emote = "aeko-crtl_t.png";} else
if (keymod == 597){ this.emote = "aeko-crtl_u.png";} else
if (keymod == 598){ this.emote = "aeko-crtl_v.png";} else
if (keymod == 599){ this.emote = "aeko-crtl_w.png";} else
if (keymod == 600){ this.emote = "aeko-crtl_x.png";} else
if (keymod == 601){ this.emote = "aeko-crtl_y.png";} else
if (keymod == 602){ this.emote = "aeko-crtl_z.gif";} else
{this.emote = "None";}

if (this.emote != "None") {
this.emote_timer = 6;
showimg(1, this.emote, player.x + 1.5, player.y - 1.5);
changeimgMode(1, 1);
changeimgVis(1, 3);
changeimgColors(1, 1, 1, 1, .65);
}
}
function onTimeout() {
if (!this.emote.ends("gif")) {
if (this.emote_timer >= 0.1) {
this.emote_timer -= 0.05;
}else if (this.emote_timer < 0.1) {
hideimg(1);
}
}
with(findimg(1)) {
if (x != player.x + 1.5 || y != player.y - 1.5) {
hideimg(1);
}
}
setTimer(0.05);
}


I think that's it...
Attached the images in a .zip

Chompy
10-10-2008, 10:12 PM
Hmm, I just realized that the Timeout event could of been different, so it don't have to run the loop all the time, but instead only do it when you actually do an emote..


//#CLIENTSIDE
function onCreated() {
enablefeatures(allfeatures-0x1000);
this.emote_timer = 0;
}

function GraalControl.onKeyDown(keymod, char, keynumber) {
if (keymod == 577){ this.emote = "aeko-crtl_a.gif";} else
if (keymod == 578){ this.emote = "aeko-crtl_b.gif";} else
if (keymod == 579){ this.emote = "aeko-crtl_c.png";} else
if (keymod == 580){ this.emote = "aeko-crtl_d.png";} else
if (keymod == 581){ this.emote = "aeko-crtl_e.gif";} else
if (keymod == 582){ this.emote = "aeko-crtl_f.png";} else
if (keymod == 583){ this.emote = "aeko-crtl_g.png";} else
if (keymod == 584){ this.emote = "aeko-crtl_h.png";} else
if (keymod == 585){ this.emote = "aeko-crtl_i.gif";} else
if (keymod == 586){ this.emote = "aeko-crtl_j.gif";} else
if (keymod == 587){ this.emote = "aeko-crtl_k.png";} else
if (keymod == 588){ this.emote = "aeko-crtl_l.gif";} else
if (keymod == 589){ this.emote = "aeko-crtl_m.png";} else
if (keymod == 590){ this.emote = "aeko-crtl_n.gif";} else
if (keymod == 591){ this.emote = "aeko-crtl_o.png";} else
if (keymod == 592){ this.emote = "aeko-crtl_p.png";} else
if (keymod == 593){ this.emote = "aeko-crtl_q.png";} else
if (keymod == 594){ this.emote = "aeko-crtl_r.gif";} else
if (keymod == 595){ this.emote = "aeko-crtl_s.png";} else
if (keymod == 596){ this.emote = "aeko-crtl_t.png";} else
if (keymod == 597){ this.emote = "aeko-crtl_u.png";} else
if (keymod == 598){ this.emote = "aeko-crtl_v.png";} else
if (keymod == 599){ this.emote = "aeko-crtl_w.png";} else
if (keymod == 600){ this.emote = "aeko-crtl_x.png";} else
if (keymod == 601){ this.emote = "aeko-crtl_y.png";} else
if (keymod == 602){ this.emote = "aeko-crtl_z.gif";} else
{this.emote = "None";}

if (this.emote != "None") {
this.emote_timer = 6;
showimg(1, this.emote, player.x + 1.5, player.y - 1.5);
changeimgMode(1, 1);
changeimgVis(1, 3);
changeimgColors(1, 1, 1, 1, .65);
setTimer(0.05);
}
}
function onTimeout() {
if (!this.emote.ends("gif")) {
if (this.emote_timer > 0) {
this.emote_timer -= 0.05;
}
if (this.emote_timer <= 0) {
hideimg(1);
}
}
with(findimg(1)) {
if (x != player.x + 1.5 || y != player.y - 1.5) {
hideimg(1);
this.emote_timer = 0;
}
}
if (this.emote_timer > 0)
setTimer(0.05);
}


But, nice release Aeko :D
Have to spread some reputation before I can give to you :o

DustyPorViva
10-10-2008, 10:16 PM
lol, I get credits for the enablefeatures line?

Anyways, got rid of the nesting and replaced it with an array:

//#CLIENTSIDE
function onCreated() {
this.keymaps = {
577,"aeko-crtl_a.gif",
578,"aeko-crtl_b.gif",
579,"aeko-crtl_c.png",
580,"aeko-crtl_d.png",
581,"aeko-crtl_e.gif",
582,"aeko-crtl_f.png",
583,"aeko-crtl_g.png",
584,"aeko-crtl_h.png",
585,"aeko-crtl_i.gif",
586,"aeko-crtl_j.gif",
587,"aeko-crtl_k.png",
588,"aeko-crtl_l.gif",
589,"aeko-crtl_m.png",
590,"aeko-crtl_n.gif",
591,"aeko-crtl_o.png",
592,"aeko-crtl_p.png",
593,"aeko-crtl_q.png",
594,"aeko-crtl_r.gif",
595,"aeko-crtl_s.png",
596,"aeko-crtl_t.png",
597,"aeko-crtl_u.png",
598,"aeko-crtl_v.png",
599,"aeko-crtl_w.png",
600,"aeko-crtl_x.png",
601,"aeko-crtl_y.png",
602,"aeko-crtl_z.gif",
};

enablefeatures(allfeatures-0x1000);
this.emote_timer = 0;
setTimer(0.05);
}

function GraalControl.onKeyDown(keymod, char, keynumber) {
Customize();
if (keymod in this.keymaps) this.emote = this.keymaps[this.keymaps.index(keymod)+1];
else this.emote = "None";

if (this.emote != "None") {
this.emote_timer = 6;
showimg(1, this.emote, player.x + 1.5, player.y - 1.5);
changeimgMode(1, 1);
changeimgVis(1, 3);
changeimgColors(1, 1, 1, 1, .65);
}
}
function onTimeout() {
if (!this.emote.ends("gif")) {
if (this.emote_timer >= 0.1) {
this.emote_timer -= 0.05;
}else if (this.emote_timer < 0.1) {
hideimg(1);
}
}
with(findimg(1)) {
if (x != player.x + 1.5 || y != player.y - 1.5) {
hideimg(1);
}
}
setTimer(0.05);
}

I could have done it with subarrays, which would have looked a lot more organized and sensible, but that would have involved loop checks and all since you can't use .index for checking subarrays. This reminds me of GS1's make-shift subarrays :P

Tolnaftate2004
10-10-2008, 11:01 PM
temp.keymaps = {
"aeko-crtl_a.gif",
"aeko-crtl_b.gif",
"aeko-crtl_c.png",
etc.
};
Then the index you want is keymod-577, 576<keymod<603. Then there's no searching and no cacading else-ifs.
On top of that, you don't need the "aeko-crtl_" in every line, just put it in the showimg.


And since when did the r come before the t in control (ctrl)? :)

DustyPorViva
10-10-2008, 11:04 PM
I'm really not following where you're getting at, heh.

Clockwork
10-10-2008, 11:05 PM
And since when did the r come before the t in control (ctrl)? :)

awe, yea... I always say "circle" instead of control..so...>>;

Tolnaftate2004
10-10-2008, 11:19 PM
I'm really not following where you're getting at, heh.
this.emote = (keymod in |577,602|)?this.keymap[keymod-577]:"None";
1 evaluation, order unity runtime.
vs.
if (keymod in this.keymaps) this.emote = this.keymaps[this.keymaps.index(keymod)+1];
else this.emote = "None";
1 evaluation, linear runtime. This would take on average more than 13.5 evaluations. (compare below).
vs. (on average 13.5) if/elseif/else statements:
1-27 evaluations, each of order unity runtime.

awe, yea... I always say "circle" instead of control..so...>>;
There's no t in circle, silly. :p

DustyPorViva
10-10-2008, 11:22 PM
this.emote = (keymod in |577,602|)?this.keymap[keymod-577]:"None";
1 evaluation, order unity runtime.
I thought of that, but I wanted to leave the possibility open for emotes that may not fit in the order already there.

Tolnaftate2004
10-10-2008, 11:25 PM
I thought of that, but I wanted to leave the possibility open for emotes that may not fit in the order already there.

You can also have another array that maps keymod -> keymap index (in other words this.keymap[this.keyfunc[keymod]]). Allows for such things and it still doesn't need to search. :)

xXziroXx
10-11-2008, 12:52 AM
That's some ****ed up stying in the first script :megaeek:

DarkReaper0
10-11-2008, 01:08 AM
I have nothing to really say about the script (There's hundreds of ways to do it).

But I absolutely love the emoticons you provided.

Clockwork
10-11-2008, 02:44 AM
lol, thanks I guess ^^;

xfazex
02-26-2009, 07:07 AM
This doesn't work for me for some reason, put the images in the emotions folder, and put the NPC script in the level, and nothing. (Using Graal Editor)

02-26-2009, 07:13 PM
This is GS2, all of the scripts in the code gallery are GS2. They won't work offline, you'll need a server.

xfazex
02-26-2009, 09:08 PM
Yeah I have one, I figured that out. lol

WhiteDragon
03-01-2009, 11:58 PM
I know the thread is kind of old, but since it's already been brought back to the top, it would make most sense to use a TStaticVar as a hash table and get O(1) time complexity and still have the ability to specify the exactly key codes.