Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

Multiple inputs not working?

8 replies · 3,439 views · Started 08 November 2007

What the heck is wrong with this???

if((Link->InputRight) && (Link->InputDown)) {

This is the only if statement that actually does anything.
...So you can input directionally down-right and down-right only!?

				if((Link->InputLeft) && (Link->InputUp)) {
fire1->X = Link->X - 16;
fire1->Y = Link->Y - 16;
fire1->Vy = -2;
fire1->Vx = -2;
fire1->Data = fcombo;
fire1->CSet = cset;
}
if((Link->InputRight) && (Link->InputUp)) {
fire1->X = Link->X + 16;
fire1->Y = Link->Y - 16;
fire1->Vy = -2;
fire1->Vx = 2;
fire1->Data = fcombo;
fire1->CSet = cset;
}
if((Link->InputLeft) && (Link->InputDown)) {
fire1->X = Link->X - 16;
fire1->Y = Link->Y + 16;
fire1->Vx = -2;
fire1->Vy = 2;
fire1->Data = fcombo;
fire1->CSet = cset;
}
if((Link->InputRight) && (Link->InputDown)) {
fire1->X = Link->X + 16;
fire1->Y = Link->Y + 16;
fire1->Vx = 2;
fire1->Vy = 2;
fire1->Data = fcombo;
fire1->CSet = cset;
}

How does the boomerang code work?

I'm basically trying to make the Metal Saw from Megaman 2, minus the boomerang part.

Heh, from your post i'm guessing this is supposed to work. It is an item script, and I have tested the directional keys as well as the gamepad directions as well. The boomerang works fine.

I also tried if(Link->Dir == 4,5,6,7){ which didn't work.

How can Link's Direction be equal to 4, 5, 6 and 7?
It's an integer that ZC reads, it can't be equal to four values.

I see no reason at all why it shouldn't work. Entirely possible it's just a bug in the compiler, but I haven't been able to reproduce it so far.
You've already tried rewriting the same thing different ways, I take it? Maybe throw in some traces to be sure everything is as you'd expect... I don't know what else to suggest.

Joe123 wrote:How can Link's Direction be equal to 4, 5, 6 and 7?
It's an integer that ZC reads, it can't be equal to four values.

Thank you captain obvious. 😛 But seriously though...I'm just that good. :googly:

Saffith wrote:I see no reason at all why it shouldn't work. Entirely possible it's just a bug in the compiler, but I haven't been able to reproduce it so far.

You may be right. I admit that I must have been using trace wrong, so I debugged the old-fashioned way: I split every if statement into it's own script, which worked fine.


item script test1{

void run(int cset){

int fire_animation = 8;

ffc fire1 = Screen->LoadFFC(29);

if((Link->InputLeft) && (Link->InputUp)) {
fire1->X = Link->X - 16;
fire1->Y = Link->Y - 16;
fire1->Vy = -2;
fire1->Vx = -2;
fire1->Data = fire_animation;
fire1->CSet = cset;
}}}

item script test2{

void run(int cset){

int fire_animation = 8;

ffc fire1 = Screen->LoadFFC(29);
if((Link->InputRight) && (Link->InputUp)) {
fire1->X = Link->X + 16;
fire1->Y = Link->Y - 16;
fire1->Vy = -2;
fire1->Vx = 2;
fire1->Data = fire_animation;
fire1->CSet = cset;
}}}
item script test3{

void run(int cset){

int fire_animation = 8;

ffc fire1 = Screen->LoadFFC(29);

if((Link->InputLeft) && (Link->InputDown)) {
fire1->X = Link->X - 16;
fire1->Y = Link->Y + 16;
fire1->Vx = -2;
fire1->Vy = 2;
fire1->Data = fire_animation;
fire1->CSet = cset;
}}}

item script test4{

void run(int cset){

int fire_animation = 8;

ffc fire1 = Screen->LoadFFC(29);

if((Link->InputRight) && (Link->InputDown)) {
fire1->X = Link->X + 16;
fire1->Y = Link->Y + 16;
fire1->Vx = 2;
fire1->Vy = 2;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
}
}

I might just need to change the if statements to else if's, but I don't really understand why. In any case, here was the other version :

item script Halito{

void run(int cset){

int fire_animation = 8;

ffc fire1 = Screen->LoadFFC(29);
ffc fire2 = Screen->LoadFFC(28);
ffc fire3 = Screen->LoadFFC(27);
ffc fire4 = Screen->LoadFFC(26);
ffc fire5 = Screen->LoadFFC(25);

if(Link->MP >= 1 && halito_level == 1){

if(!(fire1->Data == fire_animation)){

Game->PlaySound(13);
Link->MP -= 1;
halito_exp++;

if((Link->InputLeft) && (Link->InputUp)) {
fire1->X = Link->X - 16;
fire1->Y = Link->Y - 16;
fire1->Vy = -2;
fire1->Vx = -2;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
if((Link->InputRight) && (Link->InputUp)) {
fire1->X = Link->X + 16;
fire1->Y = Link->Y - 16;
fire1->Vy = -2;
fire1->Vx = 2;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
if((Link->InputLeft) && (Link->InputDown)) {
fire1->X = Link->X - 16;
fire1->Y = Link->Y + 16;
fire1->Vx = -2;
fire1->Vy = 2;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
if((Link->InputRight) && (Link->InputDown)) {
fire1->X = Link->X + 16;
fire1->Y = Link->Y + 16;
fire1->Vx = 2;
fire1->Vy = 2;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
else{

if(Link->Dir == 0) {
fire1->X = Link->X;
fire1->Y = Link->Y - 16;
fire1->Vy = -2;
fire1->Vx = 0;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
if(Link->Dir == 1) {
fire1->X = Link->X;
fire1->Y = Link->Y + 16;
fire1->Vy = 2;
fire1->Vx = 0;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
if(Link->Dir == 2) {
fire1->X = Link->X - 16;
fire1->Y = Link->Y;
fire1->Vx = -2;
fire1->Vy = 0;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
if(Link->Dir == 3) {
fire1->X = Link->X + 16;
fire1->Y = Link->Y;
fire1->Vx = 2;
fire1->Vy = 0;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
}
}
else{
if(!(fire2->Data == fire_animation)){

Game->PlaySound(13);
Link->MP -= 1;

if(Link->Dir == 0) {
fire2->X = Link->X;
fire2->Y = Link->Y - 16;
fire2->Vy = -2;
fire2->Vx = 0;
fire2->Data = fire_animation;
fire2->CSet = cset;
}
if(Link->Dir == 1) {
fire2->X = Link->X;
fire2->Y = Link->Y + 16;
fire2->Vy = 2;
fire2->Vx = 0;
fire2->Data = fire_animation;
fire2->CSet = cset;
}
if(Link->Dir == 2) {
fire2->X = Link->X - 16;
fire2->Y = Link->Y;
fire2->Vx = -2;
fire2->Vy = 0;
fire2->Data = fire_animation;
fire2->CSet = cset;
}
if(Link->Dir == 3) {
fire2->X = Link->X + 16;
fire2->Y = Link->Y;
fire2->Vx = 2;
fire2->Vy = 0;
fire2->Data = fire_animation;
fire2->CSet = cset;
}
if(Link->Dir == 4) {
fire2->X = Link->X - 16;
fire2->Y = Link->Y - 16;
fire2->Vy = -2;
fire2->Vx = -2;
fire2->Data = fire_animation;
fire2->CSet = cset;
}
if(Link->Dir == 5) {
fire2->X = Link->X + 16;
fire2->Y = Link->Y - 16;
fire2->Vy = -2;
fire2->Vx = 2;
fire2->Data = fire_animation;
fire2->CSet = cset;
}
if(Link->Dir == 6) {
fire2->X = Link->X - 16;
fire2->Y = Link->Y + 16;
fire2->Vx = -2;
fire2->Vy = 2;
fire2->Data = fire_animation;
fire2->CSet = cset;
}
if(Link->Dir == 7) {
fire2->X = Link->X + 16;
fire2->Y = Link->Y + 16;
fire2->Vx = 2;
fire2->Vy = 2;
fire2->Data = fire_animation;
fire2->CSet = cset;
}
}
}
}
}
}

I should be able to fix it up now at least. Thanks for the help.

Ah. I think I see the problem now...

				if((Link->InputLeft) && (Link->InputUp)) {
fire1->X = Link->X - 16;
fire1->Y = Link->Y - 16;
fire1->Vy = -2;
fire1->Vx = -2;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
if((Link->InputRight) && (Link->InputUp)) {
fire1->X = Link->X + 16;
fire1->Y = Link->Y - 16;
fire1->Vy = -2;
fire1->Vx = 2;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
if((Link->InputLeft) && (Link->InputDown)) {
fire1->X = Link->X - 16;
fire1->Y = Link->Y + 16;
fire1->Vx = -2;
fire1->Vy = 2;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
if((Link->InputRight) && (Link->InputDown)) {
fire1->X = Link->X + 16;
fire1->Y = Link->Y + 16;
fire1->Vx = 2;
fire1->Vy = 2;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
else{

if(Link->Dir == 0) {
fire1->X = Link->X;
fire1->Y = Link->Y - 16;
fire1->Vy = -2;
fire1->Vx = 0;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
if(Link->Dir == 1) {
fire1->X = Link->X;
fire1->Y = Link->Y + 16;
fire1->Vy = 2;
fire1->Vx = 0;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
if(Link->Dir == 2) {
fire1->X = Link->X - 16;
fire1->Y = Link->Y;
fire1->Vx = -2;
fire1->Vy = 0;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
if(Link->Dir == 3) {
fire1->X = Link->X + 16;
fire1->Y = Link->Y;
fire1->Vx = 2;
fire1->Vy = 0;
fire1->Data = fire_animation;
fire1->CSet = cset;
}
}
}

That [font="Courier New"]else[/font] is only associated with the last of the four [font="Courier New"]if[/font] statements. They are working, but since you're not holding down and right, it goes into the [font="Courier New"]else[/font] part and overrides whatever it did earlier.
So just changing the [font="Courier New"]if[/font]s to [font="Courier New"]else if[/font]s should fix it.

I was able to get diagonal firing by checking Link->Dir and Link->Input(whatever). So if he's facing up and pushing left, it throws up and to the left. This gives you a little more control over the projectile, too. (12 directions instead of 8)

C-Dawg wrote:I was able to get diagonal firing by checking Link->Dir and Link->Input(whatever). So if he's facing up and pushing left, it throws up and to the left. This gives you a little more control over the projectile, too. (12 directions instead of 8)

How the heck did you do that?

if Link->Dir up, and Link->InputRight. Then Link will be Dir right because Link->InputRight = false; ...only lasts for one frame on item scripts...I feel like i'm missing something though.

Is this a global script perhaps? I'll seriously be impressed if you got a 12 direction item script that works.