PDA

View Full Version : Remote Attack Weapon



Joe123
05-12-2008, 07:54 PM
Remote attack!
Shoot it out and Link freezes, then control the weapon with the direction keys.
Quite nice, even if I do say so myself.

It's called ice because it's meant to be FFA's Ice spell.
Fraid I haven't written a freezing enemy bit yet though, maybe I'll be able to when I see how C-'s works.


bool iceattack;

item script ice{
void run(){
iceattack = true;
}
}

global script slot_2{
void run(){
int icetile = 0; //Set the tile for your weapon here. Up, Down, Left, Right it should be on the tilepage.
int icecset = 0; //Set the CSet here
int icespeed = 2;//Set the speed here
int icedmg = 2; //Set the damage here
int icedir;
int icex; int icey;
while(true){
if(iceattack){
lweapon ice = Screen->CreateLWeapon(31);
icedir = Link->Dir;
ice->OriginalTile = icetile+icedir;
ice->Tile = icetile+icedir;
ice->NumFrames = 1;
ice->ASpeed = icespeed;
ice->CSet = icecset;
icex = 0; icey = 0;
if(icedir>1) icex = (((icedir-2)*2)-1)*16;
if(icedir<2) icey = ((icedir*2)-1)*16;
ice->X = Link->X+icex;
ice->Y = Link->Y+icey;
ice->Step = icespeed;
ice->Damage = icedmg;
Link->Action = LA_ATTACKING;
Waitframe();
while(ice->isValid()){
Link->Action = LA_FROZEN;
if(Link->InputUp) icedir = 0;
if(Link->InputDown) icedir = 1;
if(Link->InputLeft) icedir = 2;
if(Link->InputRight) icedir = 3;
ice->Dir = icedir;
ice->Tile = icetile+icedir;
ice->OriginalTile = icetile+icedir;
Waitframe();
}
Link->Action = 0;
iceattack = false;
}
Waitframe();
}
}
}

Takes 4 inputs, they're noted on the script.
Otherwise pretty self explanitory.

The_Amaster
05-12-2008, 07:59 PM
... Okay, forget the other script. This is going in level 8.

Joe123
05-12-2008, 08:01 PM
Doesn't hurt to have both ^_^

The other one could be a hidden wand upgrade?
It basically is the wand.



Oh, making this trigger secrets is going to be the same problem as the last one. Not impossible at all, but easier if you can sacrifice the bow or the wand or another projectile weapon though.

C-Dawg
05-12-2008, 11:48 PM
Well its in Zodiac, go check it out. Just stashes enemy location and existing combo and then retrieves it later.

Gleeok
05-13-2008, 12:02 AM
Cool stuff. Someone's been having alot of fun with these Link weapons, that's for sure. ;p If we can get bombs working then you can make them explode with a button press. There's you're lv2 item; remote controlled bombchus ftw.

Joe123
05-13-2008, 04:39 AM
Well its in Zodiac, go check it out. Just stashes enemy location and existing combo and then retrieves it later.

Well yeah, but how do you know which enemy to load :confused:


remote controlled bombchus ftw.
=D
Yes!

How'd I make explosions then?




Oh yeah, and LWeapons are so much fun =D

EDIT:
Right, so after having a look through Zodiac's script file, I came up with this:

int enum = Screen->NumNPCs();
int i; int h;
npc e[10];
int xd[10]; int yd[10];

for(i=0;i<enum;i++){
e[i] = Screen->LoadNPC(i+1);
xd[i] = Abs(e[i]->X-ice->X);
yd[i] = Abs(e[i]->Y-ice->Y);
if(xd[i]<8 && yd[i]<8){h = i+1; i = enum;}
}
e[0] = Screen->LoadNPC(h);

It should select the NPC closest to '(ice->X,ice->Y)', and then set it to e[0] right?

Joe123
05-13-2008, 08:34 AM
And now they freeze :cool:

item script Ice{
void run(){
iceattack = true;
}
}

bool iceattack;

global script slot_2{
void run(){
int i; //utility

int icetile = 48; //tile for ice attack
int icedmg = 0; //damage for ice attack to deal
int icedir; //ice movement utility
int icex; int icey;

int freezedur = 240; //freeze duration of enemys. 0 for infinite freeze time.

int icenum; //enemy freezing utility
npc icee[10];
int icexd[10]; int iceyd[10];
npc freeze[10];
int frx[10]; int fry[10];
bool frchk[10];
int frtimer[10];
int frstep[10]; int frate[10];
while(true){
if(iceattack){
lweapon ice = Screen->CreateLWeapon(31);
icedir = Link->Dir;
ice->OriginalTile = icetile+icedir;
ice->Tile = icetile+icedir;
ice->NumFrames = 1;
ice->CSet = 9;
icex = 0; icey = 0;
if(icedir>1) icex = (((icedir-2)*2)-1)*16;
if(icedir<2) icey = ((icedir*2)-1)*16;
ice->X = Link->X+icex;
ice->Y = Link->Y+icey;
ice->Step = 2;
ice->Damage = icedmg;
Link->Action = LA_ATTACKING;
Waitframe();
Game->PlaySound(32);
while(ice->isValid()){
Link->Action = LA_FROZEN;
if(Link->InputUp) icedir = 0;
if(Link->InputDown) icedir = 1;
if(Link->InputLeft) icedir = 2;
if(Link->InputRight) icedir = 3;
ice->Dir = icedir;
ice->Tile = icetile+icedir;
ice->OriginalTile = icetile+icedir;
icex = ice->X; icey = ice->Y;
Waitframe();
}
icenum = Screen->NumNPCs();
for(i=0;i<icenum;i++){
icexd[i] = 0; iceyd[i] = 0;
icee[i] = Screen->LoadNPC(i+1);
icexd[i] = Abs(icee[i]->X-icex);
iceyd[i] = Abs(icee[i]->Y-icey);
if(icexd[i]<24 && iceyd[i]<24){
frchk[i] = true;
freeze[i] = Screen->LoadNPC(i+1);
frx[i] = freeze[i]->X;
fry[i] = freeze[i]->Y;
frstep[i] = freeze[i]->Step;
frate[i] = freeze[i]->Rate;
i = icenum;
}
}
Link->Action = 0;
iceattack = false;
}
for(i=0;i<10;i++){
if(frchk[i]){
if(freeze[i]->isValid()){
freeze[i]->Step = 0;
freeze[i]->Rate = 0;
freeze[i]->X = frx[i];
freeze[i]->Y = fry[i];
frtimer[i]++;
}else frchk[i] = false;
}
if(frtimer[i] > freezedur && freezedur !=0){
freeze[i]->Step = frstep[i];
freeze[i]->Rate = frate[i];
frchk[i] = false;
frtimer[i] = 0;
}
}
Waitframe();
}
}
}

Gleeok
05-13-2008, 10:10 AM
I thought those npc attributes were read-only? Does it work? They still shoot weapons while frozen though I'm guessing.

I was using this to find the nearest enemy. Works like a charm.


int nearest_enemy(int x, int y){
int d;int p=9999;int e;
int e_num = Screen->NumNPCs();
for(int i = e_num; i>0; i--){
npc enemy = Screen->LoadNPC(i);
if(enemy->X>-4){
int ex = enemy->X;int ey = enemy->Y;
d = Distance(x,y,ex,ey);
if(p>d){p=d;e=i;}
}
}
return e;
}

Joe123
05-13-2008, 10:20 AM
I thought those npc attributes were read-only? Does it work? They still shoot weapons while frozen though I'm guessing.

It appears to.
They were doing the whole 'jumping around' thing before, but when I put in that step and rate bit they stopped.
I've only actually tried with with Gibdos though =P


int nearestnpc(int x, int y){
int enum = Screen->NumNPCs();
int xd[10]; int yd[10];
npc e[10];
for(i=0;i<enum;i++){
xd[i] = 0; yd[i] = 0;
e[i] = Screen->LoadNPC(i+1);
xd[i] = Abs(e[i]->X-x);
yd[i] = Abs(e[i]->Y-y);
if(xd[i]<24 && yd[i]<24){return i; i = enum;}
}
}
That would be the one I wrote earlier.

Except I don't acutally need the arrays do I.
That's a bit different to the one I'm actually using in my script, my script's one does I think.


int npcdist(int x, int y, int dist){
int enum = Screen->NumNPCs();
int xd; int yd;
for(i=0;i<enum;i++){
xd = 0; yd = 0;
npc e = Screen->LoadNPC(i+1);
xd = Abs(e->X-x);
yd = Abs(e->Y-y);
if(xd<dist && yd<dist){return i; i = enum;}
}
}

Returns the first npc that's dist pixels from (x,y).

Gleeok
05-13-2008, 10:33 AM
We'll that's why we need all these in one place, for that very reason. ...Though there is a problem with those I think, they won't always return the closest enemy, just a close enemy that's closest to Screen->LoadNPC(1); ...Use mine instead :p +2 jackass_points[infinity];


int nearest_enemy(int x, int y){
int d;int p=9999;int e;
int e_num = Screen->NumNPCs();
for(int i = e_num; i>0; i--){
npc enemy = Screen->LoadNPC(i);
int ex = enemy->X;int ey = enemy->Y;
d = Distance(x,y,ex,ey);
if(p>d){p=d;e=i;}
}
return e;
}

*runs away*

C-Dawg
05-13-2008, 11:13 AM
Why freeze the closest enemy? Don't you want it to freeze on impact? Or is that not the behavior you're going for?

Joe123
05-13-2008, 11:40 AM
It loads the closest enemy...

...to where the lweapon was, just before it was still valid.
So it appears to freeze on impact.

It works fine Gleeok, no need to use yours =P
Sorry =P

C-Dawg
05-13-2008, 11:43 AM
Oooooooooooh I get it. Because you're using LWeapons instead of FFCs, the LWeapon vanishes when it hits an enemy. Right. Gotchya.

Now that I think about it, I bet your way of doing it has some pretty big advantages in processor time. Your method only checks enemies once, when it impacts; my FFCs check each enemy on the screen for collisions every frame.

Not bad.

Joe123
05-13-2008, 12:06 PM
Heh, thanks.

I'm not too worried about processor speed though, I doubt my scripts are going to come anywhere near to slowing down the system.


I'm also just messing around really, dunno that I'll actually use these.
How'd you make the bombs that explode the moment you create them?
Mine appear as bombs and then wait for the timer to go down, which is pretty lame.
I'm trying to make another missile attack a bit like that one you have going in Zodiac.

Aha!
Fuse Duration = 2;
Gotcha.

Gleeok
05-13-2008, 12:19 PM
So... what, are you spawning bombs directly, or bombblasts? ..'cause I still can't get bombs to work.

C-Dawg
05-13-2008, 12:38 PM
Well, as I said in my thread on the subject, using bombs is tricky. You need to spawn a bomb and set LWeapon damage for it to work. But what bomb spawns is dependant on Link's inventory. I couldn't get bombblasts to deal damage for some reason.

So what I've done now is given Link level 1 bombs with a fuse of 2. Then, when I spawn a bomb, it immediately explodes. If Link has higher level bombs with a longer fuse, it all goes to shit because the spawned bomb copies whatever is in Link's inventory.

Note: its important for the fuse to be 2. A fuse of 0 is a remote bomb, and a fuse of 1 doesn't do shit. No idea whats up there.

SpacemanDan
07-21-2008, 02:42 PM
Does this work with bombs, (from what I'm gathering, it doesn't, but I want to make sure.) because if it does, I have could use this quite well. :D Sorry for kicking, by the way.

Joe123
07-21-2008, 05:52 PM
So you want to move it around, then have it explode?

Yes, if you don't use bombs in your quest.

_L_
07-22-2008, 12:33 PM
I couldn't get bombblasts to deal damage for some reason.
Tell me more!
(Actually, now that I look at it, I think I can find the problem.)

SpacemanDan
07-22-2008, 12:50 PM
So you want to move it around, then have it explode?

Yes, if you don't use bombs in your quest.

So it does work, then. Thanks! :D
In my quest, I replaced my super bombs with prinnies. Schwa came up with a great idea to have them move around before exploding, and then I remembered this script.

Joe123
07-23-2008, 04:54 AM
Ahhh, that's quite possible.
They'd be able to go through walls and flags though, did you not want that?
I can add some solidity checks and things if you like.

SpacemanDan
07-25-2008, 10:35 AM
If it's not a problem, that'd be awsome! :D

Joe123
07-25-2008, 11:01 AM
If you remind me in urmm....

A week =P
On the monday after next.
I'll see what I can do.
I'm on holiday next week though I'm afraid.

Joe123
08-04-2008, 06:08 AM
Right!

So.
Bombchus.

I'll see what I can do ;-)

EDIT: Woooo they're going good!
I have the explosions sorted!
I'm gonna add some solidity detection, and a flag which bombchus can go over even if the tile is solid, and then call it done probably.