PDA

View Full Version : Stab/Slash choice.



Russ
10-29-2007, 11:31 PM
Can somebody please make a (hopefully) simple script for me. What I need is this a script that detects which button (A or B) the sword is assigned to, and then makes Link stab the sword if it is attached to A, and makes Link slash if it is attached to B. Sorry, that sentance was horribly confusing. Basicly, if the sword is attached to the A button, and you press the button, Link stabs. If the sword is attached to B, and you press the button, Link slashes the sword.

And by the way, POST 400!

Gleeok
10-30-2007, 12:18 AM
Hmm. That's a good idea, but I'm not sure if a script can read the subscreen data. I do have an inquiry on item properties though: Is it possible that you can have two or more swords at once on the subscreen and select one to A and the other to B. I really haven't messed with the item editor a whole lot. If that's possible perhaps one can have "use slash tiles" and leave the other one unchecked.

I did really only find this for slash;

const int GEN_CANSLASH = 2;

Meaning you can change slash, but I'm not sure to what extent right now. That would suck if you could only have one sword type selectable at a time...


It might be a matter of if(Link->InputA)...

yeah, i'll look into it.

ShadowMancer
10-30-2007, 08:07 PM
Well, I did just make an FFC weapon that is a 'stab sword' Its not exactly what you want but it could work exactly like the sword when stabbing. As far as I know you can't change Link's slash abilty via script (not yet anyway, but it may be added eventually) and you cannot detect / set A / B buttons via script (this is planned after 2.5 i beleive)
So its not exactly possible to do what you want at the moment but an FFC sword may be a solution for now.

Russ
10-30-2007, 08:14 PM
Wait, you can script swords? So this would allow for more than one sword at a time? Could you give me the code for this freeform sword?

ShadowMancer
10-30-2007, 08:27 PM
Sure, I'm going to be putting up a very small demo with both the stab sword and the burn->next combo (both requests) I Was going to wait until I had a few more FFC weapons before posting the demo, but seems I got a handfull of people who want them very soon. Sooo give me about 30 - 60 min. to modify, test, and upload the file. I suppose I can post it in showcase, I can always update the file in the future.

Russ
10-30-2007, 09:08 PM
Okay. But what exactly is a freeform combo weopon?

Gleeok
10-30-2007, 11:48 PM
Damn, ShadowMancer beat me to the punch. I was going to say the same thing. Really can't be done like that. I looked through the Item editor, and yeah....


Okay. But what exactly is a freeform combo weopon?

It's an ffc AND item (maybe global) script whoes effects emulate stardard hard coded weapons, damage to enemies, knockback, flashing, etc. BUT are not limited in any other aspect. For example lets say you want a item that lets you fire lightning bolts across the screen then explode on impact instantly dealing 400 HP of damage. Wouldn't be much harder than scripting an ffc sword.

But that's the tricky part. There is alot of moving parts to these scripts, and alot of work. It is by no means simple to make it work really well and be flexible




Sure, I'm going to be putting up a very small demo with both the stab sword and the burn->next combo (both requests) I Was going to wait until I had a few more FFC weapons before posting the demo, but seems I got a handfull of people who want them very soon. Sooo give me about 30 - 60 min. to modify, test, and upload the file. I suppose I can post it in showcase, I can always update the file in the future.


Super. I'd love to see those.
I've begun working on THE all powerful global wepon thingy, and realized "why do I need this global?" Instead of global int that relay commands to preset ffc's it's easier just to make them ffc's! Cut out the middleman. This is more setup in game, but I think the results are quicker and easier to impliment. Plus I can still use the global int for ffc and item. The bit that's tedious is the fact that no D or A arguments will be used, though I'm making progress.

ShadowMancer
10-31-2007, 12:23 AM
WARNING,Prepare for DATA DUMP!

heh, well here is the FFC weapon scriptz thus far.
SSMW: (Standard ShadowMancer Warning)
This is untested, so there may be errors, unexpected results and/ or uncontrolable urges to attack your computer. use only as directed.
um... anyway give it a whirl see what you think, report any erros (not includeing my bad spelling) :p



import "std.zh"

//Don't touch these global varibles!!
bool actStab = false; bool bushBurn = false;
ffc weap1; ffc weap2; ffc weap3; ffc weap4; ffc weap5; ffc weap6;
//************************************************** *******
//You will want to set these varibles to suit your quest
//stamImg: the combo of your stabby sword (see below)
//stamDam: the damage your stabby sword inflicts
//Burnable bushes: any combo between bshFst and bshLst is burnable (yay!)
//Undercombo of burned bush = (bush combo) + bshNext
int stabImg = ; int stabDam = ;
int bshFst = ; int bshLst = ; int bshNext = ;
//************************************************** *******
//This is the weapon script for the stabby sword
//you will need to setup a few things to make it work:
//Make 4 combos, each showing a sword stabbing (animated if you want)
//the combos need to be in sequencal order on the combo page
//make the images depect: stab up, down, left, right in that order
//You will need to make extra Link tiles depecting him stabbing
//create an invisible item with the class 255 and add it to your subscreen
//set the LTM for this item to your Link stabbing tiles
item script stabWeap{
void run (int img, int dam){
actStab = true;
stabImg = img;
stabDam = dam;
}

global script main_script{
void run(){
while(true){

//Handle the stabby sword
if (stabing == 1) {
weap = Screen->LoadFFC(getWeap());
if (Link->Dir == 0) {weap->X = Link->X ; weap->Y = Link->Y-16;}
if (Link->Dir == 1) {weap->X = Link->X ; weap->Y = Link->Y+16;}
if (Link->Dir == 2) {weap->X = Link->X-16 ; weap->Y = Link->Y;}
if (Link->Dir == 3) {weap->X = Link->X+16 ; weap->Y = Link->Y;}
weap->Data = (stabImg+Link->Dir);
//Setup item 255 to use LTM to make Link appear to be stabbing
Link->Item[255] = true;
for (int n=0;n<=3;n++){
ene_damage(stabDam,weap->X,weap->Y);
//Waitframe();
}
weap->Data = 0;
Link->Item[255] = false;
}


Waitframe();
}
}}

//Function to find an unused FFC, call it like so:
//weap = Screen->LoadFFC(getWeap());
//You will be able to use up to 6 FFC weapons at once so, ideally you will never run out
//Just be sure when you are done with an FFC weapon you set its Data back to 0
int getWeap(){
weap1 = Screen->LoadFFC(32);
weap2 = Screen->LoadFFC(31);
weap3 = Screen->LoadFFC(30);
weap4 = Screen->LoadFFC(29);
weap5 = Screen->LoadFFC(28);
weap6 = Screen->LoadFFC(27);
if (weap1->Data != 0) {return 32;}
if (weap2->Data != 0) {return 31;}
if (weap3->Data != 0) {return 30;}
if (weap4->Data != 0) {return 29;}
if (weap5->Data != 0) {return 28;}
if (weap6->Data != 0) {return 27;}
}


//Attach to Blue/Red candle
//Set arguments:
//D0: Combo ID of first burnable bush
//D1: Combo ID of last burnable bush
//Any combo between D0 - D1 is treated as a burnable bush
//D2: Modifier for 'Undercombo' Combo#(bush + D2) = Undercombo
item script burnNext{
void run (){
bushBurn = true;
}}

//This function will cause an (invisible) FFC to follow
//the candle flame and check for bushes to burn
void flameEnhance (){
ffc flame1; ffc flame2;
//Id of invisible combo
int cmbId = 2;
flame = Screen->LoadFFC(getWeap());
flame->Data = cmbId;
if (flame->Data == 0) {
flame->Data = cmbId;
flame->X = Link->X;
flame->Y = Link->Y;
for (int move = 0; move < 3; move++){
if (Screen->ComboD[ComboAt(flame1->X,flame1->Y)] >= bshFst && Screen->ComboD[ComboAt(flame1->X,flame1->Y)] <= bshLst) {
Screen->ComboD[ComboAt(flame1->X,flame1->Y)] += bshNext;
}
if (Link->Dir == 0) { flame1->Y -= 2;}
if (Link->Dir == 1) { flame1->Y += 2;}
if (Link->Dir == 2) { flame1->X -= 2;}
if (Link->Dir == 3) { flame1->X += 2;}
Waitframe();

}

}

bool ene_damage(int damage,int xn, int yn) {
int ene_chk = 1;
bool result = false;
int push_dir = 0;
if (xn<0 || xn>240 || yn<0 || yn>160) {result = true;}
while (ene_chk <= Screen->NumNPCs()) {
npc trg_ene = Screen->LoadNPC(ene_chk);
if (trg_ene->X+8 >= xn-8 && trg_ene->X+8 <= xn+24 && trg_ene->Y+8 >= yn-8 && trg_ene->Y+8 <= yn+24) {
//Enemy is Hit
result = true;
int timer = 10;
trg_ene->HP -= damage;
int def_cset = trg_ene->CSet;

while(timer > 0) {
//Flash CSet
if (trg_ene->CSet <9) {trg_ene->CSet++;} else {trg_ene->CSet = 0;}
//Push enemy back
//Up,Dn,Lt,Rt
if (trg_ene->Y < yn) {
if (is_walkable(trg_ene->X,trg_ene->Y-4)) {trg_ene->Y-=4;}
}
if (trg_ene->Y > yn) {
if (is_walkable(trg_ene->X,trg_ene->Y+4)) {trg_ene->Y+=4;}
}
if (trg_ene->X < xn) {
if (is_walkable(trg_ene->X-4,trg_ene->Y)) {trg_ene->X-=4;}
}
if (trg_ene->X > xn) {
if (is_walkable(trg_ene->X+4,trg_ene->Y)) {trg_ene->X+=4;}
}
timer -= 1;
Waitframe();
}
trg_ene->CSet = def_cset;
}
ene_chk += 1;


} //ends while (ene_chk <= Screen->NumNPCs())
return result;
}

bool is_walkable(int x, int y)
{
if(x<0 || x>240 || y<0 || y>160)
{
return false;
}
return Screen->ComboS[y+(x>>4)]==0;
}


There are instructions within the code, so read please!

forgot to metion, you will need to make a custom item for the 'stabby sword' use one of the z### IDs and don't forget to add that class to your subscreen or you won't be able to use it! Then just attach the weapon script to this weapon and viola! (crosses fingers and hopes for the best)

Gleeok
10-31-2007, 12:50 AM
Hey that's better than what i've got so far...I always forget about bool. :(
I've got a question: Would Link->Action[2] not work for stabbing instead of the Link tile mods. (I haven't messed with that yet). Or is it buggy?

ShadowMancer
10-31-2007, 12:54 AM
Would Link->Action[2] not work for stabbing instead of the Link tile mods
That was my original thinking as well, but it dun wurk right, so workaround city we go.
I did a bug report on the Link->Action thingy, DD said he will be makeing Link->Action = 2 Read Only until a better solution can be found :shrug:

Gleeok
10-31-2007, 01:11 AM
Well shit. I planned on using those eventually. By read only do you mean that if(Link->Action == 2){ Link->Action = 2;} hehe...Oh where was I ....Oh yeah , you mean read only like that.

Damnit all. Now i'll have to...
Wait, You can set the action tab in the item properties, right?



Edit: It doesn't compile. Russdawn: I would holdout a bit longer as there is currently some scripts under construction.

SM: Any idea's as too the ffc problem? It'd be a shame to not use the getweapon function you made.

ShadowMancer
10-31-2007, 04:05 PM
I got your PM Gleeok, I will be working on fixing the script today. It should work just as well if the ffc's are defined within the global script, instead of makeing them a global vairble (which does not work, damn) I did not get a chance to look over your revisions yet but I will, then I'll re-post a working version. I kind of skipped the testing phase entirely and just posted a script that looked like it was going to work, so back to scripting.

Well here is try#2:



import "std.zh"

//Don't touch these global varibles!!
bool actStab = false; bool bushBurn = false;
//************************************************** *******
//You will want to set these varibles to suit your quest
//For the Stabby Sword:
//stabImg is the first combo of the sword (faceing up)
//stabDam is the damage of the stabby sword
int stabImg = 0; int stabDam = 0;
//For the Burn->Next script:
//any combo between bshFst and bshLst is burnable
//undercombo of burned bush = (bush combo) + bshNext
int bshFst = 0; int bshLst = 0; int bshNext = 0;
//************************************************** *******


global script main_script{
void run(){

while(true){
//Handle the stabby sword
if (actStab == true) {
weap = Screen->LoadFFC(getWeap());
if (Link->Dir == 0) {weap->X = Link->X ; weap->Y = Link->Y-16;}
if (Link->Dir == 1) {weap->X = Link->X ; weap->Y = Link->Y+16;}
if (Link->Dir == 2) {weap->X = Link->X-16 ; weap->Y = Link->Y;}
if (Link->Dir == 3) {weap->X = Link->X+16 ; weap->Y = Link->Y;}
weap->Data = (stabImg+Link->Dir);
//Setup item 255 to use LTM to make Link appear to be stabbing
Link->Item[255] = true;
for (int n=0;n<=3;n++){
ene_damage(stabDam,weap->X,weap->Y);
//Waitframe();
}
weap->Data = 0;
Link->Item[255] = false;
}

//Handle burn->next
if (bushBurn == true) {
ffc flame;
//Id of invisible combo. change it for your own quest
int cmbId = 2;
flame = Screen->LoadFFC(getWeap());
flame->Data = cmbId;
flame->X = Link->X;
flame->Y = Link->Y;
for (int move = 0; move < 3; move++){
if (Screen->ComboD[ComboAt(flame1->X,flame1->Y)] >= bshFst && Screen->ComboD[ComboAt(flame1->X,flame1->Y)] <= bshLst) {
Screen->ComboD[ComboAt(flame1->X,flame1->Y)] += bshNext;
}
if (Link->Dir == 0) { flame1->Y -= 2;}
if (Link->Dir == 1) { flame1->Y += 2;}
if (Link->Dir == 2) { flame1->X -= 2;}
if (Link->Dir == 3) { flame1->X += 2;}
}
}
Waitframe();
}
}
}

//************************************************** ********************
//Item scripts

//This is the weapon script for the stabby sword
//you will need to setup a few things to make it work:
//Make 4 combos, each showing a sword stabbing (animated if you want)
//the combos need to be in sequencal order on the combo page
//make the images depect: stab up, down, left, right in that order
//You will need to make extra Link tiles depecting him stabbing
//************************************************** *******

item script stabWeap{
void run (int img, int dam){
actStab = true;
stabImg = img;
stabDam = dam;
}}

//Attach to Blue/Red candle
item script burnNext{
void run (){
bushBurn = true;
}}

//************************************************** *********************
//Functions

//Function to find an unused FFC, call it like so:
//weap = Screen->LoadFFC(getWeap());
//You will be able to use up to 6 FFC weapons at once so, ideally you will never run out
//Just be sure when you are done with an FFC weapon you set its Data back to 0
int getWeap(){
ffc weap1; ffc weap2; ffc weap3; ffc weap4; ffc weap5; ffc weap6;
weap1 = Screen->LoadFFC(32);
weap2 = Screen->LoadFFC(31);
weap3 = Screen->LoadFFC(30);
weap4 = Screen->LoadFFC(29);
weap5 = Screen->LoadFFC(28);
weap6 = Screen->LoadFFC(27);
if (weap1->Data != 0) {return 32;}
if (weap2->Data != 0) {return 31;}
if (weap3->Data != 0) {return 30;}
if (weap4->Data != 0) {return 29;}
if (weap5->Data != 0) {return 28;}
if (weap6->Data != 0) {return 27;}
}

bool ene_damage(int damage,int xn, int yn) {
int ene_chk = 1;
bool result = false;
int push_dir = 0;
if (xn<0 || xn>240 || yn<0 || yn>160) {result = true;}
while (ene_chk <= Screen->NumNPCs()) {
npc trg_ene = Screen->LoadNPC(ene_chk);
if (trg_ene->X+8 >= xn-8 && trg_ene->X+8 <= xn+24 && trg_ene->Y+8 >= yn-8 && trg_ene->Y+8 <= yn+24) {
//Enemy is Hit
result = true;
int timer = 10;
trg_ene->HP -= damage;
int def_cset = trg_ene->CSet;

while(timer > 0) {
//Flash CSet
if (trg_ene->CSet <9) {trg_ene->CSet++;} else {trg_ene->CSet = 0;}
//Push enemy back
//Up,Dn,Lt,Rt
if (trg_ene->Y < yn) {
if (is_walkable(trg_ene->X,trg_ene->Y-4)) {trg_ene->Y-=4;}
}
if (trg_ene->Y > yn) {
if (is_walkable(trg_ene->X,trg_ene->Y+4)) {trg_ene->Y+=4;}
}
if (trg_ene->X < xn) {
if (is_walkable(trg_ene->X-4,trg_ene->Y)) {trg_ene->X-=4;}
}
if (trg_ene->X > xn) {
if (is_walkable(trg_ene->X+4,trg_ene->Y)) {trg_ene->X+=4;}
}
timer -= 1;
Waitframe();
}
trg_ene->CSet = def_cset;
}
ene_chk += 1;


} //ends while (ene_chk <= Screen->NumNPCs())
return result;
}

bool is_walkable(int x, int y)
{
if(x<0 || x>240 || y<0 || y>160)
{
return false;
}
return Screen->ComboS[y+(x>>4)]==0;
}

Test it out, this one should work properly
(I'm just too busy playing DragonFable to test it :p )

Gleeok
11-01-2007, 12:06 AM
Well...that script works great!!!!

...wait, it's a script that crashes zc, right?


No...a weapon script?

..well then it doesn't work so good. :p



Well here's the fixed version. Just a few typo's and undeclared stuff fixed:


import "std.zh"

//Don't touch these global varibles!!
bool actStab = false; bool bushBurn = false;
//************************************************** *******
//You will want to set these varibles to suit your quest
//For the Stabby Sword:
//stabImg is the first combo of the sword (faceing up)
//stabDam is the damage of the stabby sword
int stabImg = 0; int stabDam = 0;
//For the Burn->Next script:
//any combo between bshFst and bshLst is burnable
//undercombo of burned bush = (bush combo) + bshNext
int bshFst = 0; int bshLst = 0; int bshNext = 0;
//************************************************** *******


global script main_script{
void run(){

while(true){
//Handle the stabby sword
if (actStab == true) {
ffc weap = Screen->LoadFFC(getWeap());
if (Link->Dir == 0) {weap->X = Link->X ; weap->Y = Link->Y-16;}
if (Link->Dir == 1) {weap->X = Link->X ; weap->Y = Link->Y+16;}
if (Link->Dir == 2) {weap->X = Link->X-16 ; weap->Y = Link->Y;}
if (Link->Dir == 3) {weap->X = Link->X+16 ; weap->Y = Link->Y;}
weap->Data = (stabImg+Link->Dir);
//Setup item 255 to use LTM to make Link appear to be stabbing
Link->Item[255] = true;
for (int n=0;n<=3;n++){
ene_damage(stabDam,weap->X,weap->Y);
//Waitframe();
}
weap->Data = 0;
Link->Item[255] = false;
}

//Handle burn->next
if (bushBurn == true) {
ffc flame1;
//Id of invisible combo. change it for your own quest
int cmbId = 2;
flame1 = Screen->LoadFFC(getWeap());
flame1->Data = cmbId;
flame1->X = Link->X;
flame1->Y = Link->Y;
for (int move = 0; move < 3; move++){
if (Screen->ComboD[ComboAt(flame1->X,flame1->Y)] >= bshFst && Screen->ComboD[ComboAt(flame1->X,flame1->Y)] <= bshLst) {
Screen->ComboD[ComboAt(flame1->X,flame1->Y)] += bshNext;
}
if (Link->Dir == 0) { flame1->Y -= 2;}
if (Link->Dir == 1) { flame1->Y += 2;}
if (Link->Dir == 2) { flame1->X -= 2;}
if (Link->Dir == 3) { flame1->X += 2;}
}
}
Waitframe();
}
}
}

//************************************************** ********************
//Item scripts

//This is the weapon script for the stabby sword
//you will need to setup a few things to make it work:
//Make 4 combos, each showing a sword stabbing (animated if you want)
//the combos need to be in sequencal order on the combo page
//make the images depect: stab up, down, left, right in that order
//You will need to make extra Link tiles depecting him stabbing
//************************************************** *******

item script stabWeap{
void run (int img, int dam){
actStab = true;
stabImg = img;
stabDam = dam;
}}

//Attach to Blue/Red candle
item script burnNext{
void run (){
bushBurn = true;
}}

//************************************************** *********************
//Functions

//Function to find an unused FFC, call it like so:
//weap = Screen->LoadFFC(getWeap());
//You will be able to use up to 6 FFC weapons at once so, ideally you will never run out
//Just be sure when you are done with an FFC weapon you set its Data back to 0
int getWeap(){
ffc weap1; ffc weap2; ffc weap3; ffc weap4; ffc weap5; ffc weap6;
weap1 = Screen->LoadFFC(32);
weap2 = Screen->LoadFFC(31);
weap3 = Screen->LoadFFC(30);
weap4 = Screen->LoadFFC(29);
weap5 = Screen->LoadFFC(28);
weap6 = Screen->LoadFFC(27);
if (weap1->Data != 0) {return 32;}
if (weap2->Data != 0) {return 31;}
if (weap3->Data != 0) {return 30;}
if (weap4->Data != 0) {return 29;}
if (weap5->Data != 0) {return 28;}
if (weap6->Data != 0) {return 27;}
}

bool ene_damage(int damage,int xn, int yn) {
int ene_chk = 1;
bool result = false;
int push_dir = 0;
if (xn<0 || xn>240 || yn<0 || yn>160) {result = true;}
while (ene_chk <= Screen->NumNPCs()) {
npc trg_ene = Screen->LoadNPC(ene_chk);
if (trg_ene->X+8 >= xn-8 && trg_ene->X+8 <= xn+24 && trg_ene->Y+8 >= yn-8 && trg_ene->Y+8 <= yn+24) {
//Enemy is Hit
result = true;
int timer = 10;
trg_ene->HP -= damage;
int def_cset = trg_ene->CSet;

while(timer > 0) {
//Flash CSet
if (trg_ene->CSet <9) {trg_ene->CSet++;} else {trg_ene->CSet = 0;}
//Push enemy back
//Up,Dn,Lt,Rt
if (trg_ene->Y < yn) {
if (is_walkable(trg_ene->X,trg_ene->Y-4)) {trg_ene->Y-=4;}
}
if (trg_ene->Y > yn) {
if (is_walkable(trg_ene->X,trg_ene->Y+4)) {trg_ene->Y+=4;}
}
if (trg_ene->X < xn) {
if (is_walkable(trg_ene->X-4,trg_ene->Y)) {trg_ene->X-=4;}
}
if (trg_ene->X > xn) {
if (is_walkable(trg_ene->X+4,trg_ene->Y)) {trg_ene->X+=4;}
}
timer -= 1;
Waitframe();
}
trg_ene->CSet = def_cset;
}
ene_chk += 1;


} //ends while (ene_chk <= Screen->NumNPCs())
return result;
}

bool is_walkable(int x, int y)
{
if(x<0 || x>240 || y<0 || y>160)
{
return false;
}
return Screen->ComboS[y+(x>>4)]==0;
}


Now to figure out why it instantly crashes ZC....

I'm thinking even more ffc woes, as the script fails while trying to place an ffc.....hmm....





EDIT: --------------------

The good: After some debugging i've tracked down the problem, and the ffc's are fine.


The bad: I'm trying to go through your enemy damage system which is confusing. :googly:


The ugly:




HAPPY HALLOWEEN!!!
http://www.grimmemennesker.dk/data/media/2/HPIM02062.jpg




Hhaha! OK, now that's over with: Here's my findings:


import "std.zh"


int weapon_ffc = 24;



bool is_walkable(int x, int y)
{
return Screen->ComboS[x+y*16]==0;
}

int stabing = 0;
int stabImg = 0;
int stabDam = 0;

//----------------global variables------------------------------------------



item script stabWeap{
void run (int img, int dam){
stabImg = img;
stabDam = dam;
stabing = 1;
}
}


//================================================== =====
//GLOBAL SCRIPT
//================================================== =====


global script main_script{
void run(){

//ffc weap1; ffc weap2; ffc weap3; ffc weap4; ffc weap5; ffc weap6;


ffc weapon;

int stabby_combo = 4;



while(true){


//========================
// FFC RECYCLING FUNCTION
//========================

if(weapon_ffc >= 29){ weapon_ffc = 24;}



//================================================== ==========
// WEAPON SCRIPTS
//================================================== ==========

if (stabing == 1) {
weapon = Screen->LoadFFC(weapon_ffc);
if (Link->Dir == 0) {weapon->X = Link->X ; weapon->Y = Link->Y-16;}
if (Link->Dir == 1) {weapon->X = Link->X ; weapon->Y = Link->Y+16;}
if (Link->Dir == 2) {weapon->X = Link->X-16 ; weapon->Y = Link->Y;}
if (Link->Dir == 3) {weapon->X = Link->X+16 ; weapon->Y = Link->Y;}
weapon->Data = (stabby_combo+Link->Dir);
weapon_ffc++;

for (int n=0;n<=3;n++){

ene_damage(stabDam,weapon->X,weapon->Y);
}

weapon->Data = 0; stabing = 0;
}

//================================================== ==========
// END WEAPON SCRIPTS
//================================================== ==========

Waitframe();

}
}
}

Was unnecesarry....:( ..It's the next part:




//==============================================
// ENEMY DAMAGE
//==============================================

bool ene_damage(int damage,int xn, int yn) {

int ene_chk = 1;
bool result = false;
int push_dir = 0;

if (xn<0 || xn>240 || yn<0 || yn>160) {result = true;}

while (ene_chk <= Screen->NumNPCs()) {

npc trg_ene = Screen->LoadNPC(ene_chk);

if (trg_ene->X+8 >= xn-8 && trg_ene->X+8 <= xn+24 && trg_ene->Y+8 >= yn-8 && trg_ene->Y+8 <= yn+24) {
//Enemy is Hit
result = true;
int timer = 10;
trg_ene->HP -= damage;
int def_cset = trg_ene->CSet;

while(timer > 0) {
//Flash CSet
if (trg_ene->CSet <9) {trg_ene->CSet++;} else {trg_ene->CSet = 0;}
//Push enemy back
//Up,Dn,Lt,Rt
if (trg_ene->Y < yn) {
if (is_walkable(trg_ene->X,trg_ene->Y-4)) {trg_ene->Y-=4;}
}
if (trg_ene->Y > yn) {
if (is_walkable(trg_ene->X,trg_ene->Y+4)) {trg_ene->Y+=4;}
}
if (trg_ene->X < xn) {
if (is_walkable(trg_ene->X-4,trg_ene->Y)) {trg_ene->X-=4;}
}
if (trg_ene->X > xn) { if (is_walkable(trg_ene->X+4,trg_ene->Y)) {trg_ene->X+=4;}
}
timer -= 1;
Waitframe();
}
trg_ene->CSet = def_cset;
}
ene_chk += 1;


} //ends while (ene_chk <= Screen->NumNPCs())
return result;

}

Which should be fixed in no time at all. :) ..now that we know where the problem is..

Oh, and I'll include the guard function for shooters and guys also. Don't need any more crashes right.

ShadowMancer
11-01-2007, 11:04 AM
Wait a minute, what actually caused it to crash ZC?
Yeah, it crashes instantly! I am going to test some things...

Also, enemy damage should work fine, its the same script i've been useing for awhile. Although I don't remeber why I have it return a value.. I used it for an old script but why??

grrr, no wonder it does not work, I posted the wrong version.. I gotta find it(hope I saved it) or just fix it up again...

C-Dawg
11-01-2007, 02:02 PM
Regarding the Crash : I've had problems with Zelda Classic crashing randomly on certain screens where FFCs and/or scripts are used. Try setting up the script on a different screen and seeing what happens. I have no clue how this happens and I can't reproduce the bug predictably. I think it's some sort of room-based corruption.

Regarding Slash/Stab :You can set individual Sword items to allow slash or not. So just make two identical swords for each sword you want in the game, and have a script switch the inventory depending on the player's choice to stab or slash.

Gleeok
11-02-2007, 12:51 AM
Uh, oh. Well more info and It seems that there's another thing I just ran into.

I rewrote the entire damage code into the while loop of the global itself...It crashed.

I rewrote a simple sword item ffc script to replace stabby sword; It crashed.

I re-rewrote the damage code to a basic version: IE no cset flash, no knockback, a set 2 damage......It still crashed.


So I give up on the idea of making it global. I suggest an ffc script instead. I'm starting on that right now.

May god have mercy...

Gleeok
12-01-2007, 12:06 AM
Would you still like an ffc sword?

I'm going to start posting scripts eventually of ffc weapons so anyone with a little scripting know-how could make their own custom weapons.

The ffc sword i'm making can be lttp style slash, spear thrust, axe club, whatever you make the animation to be. It uses combo cycling and multi slash ability, with alternate graphics for quick button presses. Sound good?

Russ
12-01-2007, 01:44 AM
That sounds good. So basically it allows you to stab or slash?

Gleeok
12-02-2007, 12:43 AM
Custom weapon script #1. This uses the built in hit detection of the game. allows multi slashing. Good for LTTP slash, or spear, or whatever animation you can draw. Yes, you have to draw. :p



int sword_delay = 0;

item script slash{

void run(){

int sword = 16; //set to combo of sword
ffc this1 = Screen->LoadFFC(24); // set to whatever you want

if(sword > 8 && sword_delay == 0){

if(Link->Dir == 0) {
this1->X = Link->X;
this1->Y = Link->Y - 16;
this1->Data = sword;
}
if(Link->Dir == 1) {
this1->X = Link->X;
this1->Y = Link->Y + 16;
this1->Data = sword+1;
}
if(Link->Dir == 2) {
this1->X = Link->X - 16;
this1->Y = Link->Y;
this1->Data = sword+2;
}
if(Link->Dir == 3) {
this1->X = Link->X + 16;
this1->Y = Link->Y;
this1->Data = sword+3;
}
sword_delay = 15;
}
}
}



ffc script sword_slash{

void run(){

int sword = 20;

while(true){

if(sword_delay > 0){sword_delay--;}
Waitframe();

if(this->Data > 6 && sword_delay > 0){

if(sword_delay <= 10 && sword_delay > 5){

if(Link->Dir == 0){
this->X = Link->X;
this->Y = Link->Y - 16;
this->Data = sword;
}
if(Link->Dir == 1){
this->X = Link->X;
this->Y = Link->Y + 16;
this->Data = sword+1;
}
if(Link->Dir == 2){
this->X = Link->X - 16;
this->Y = Link->Y;
this->Data = sword+2;
}
if(Link->Dir == 3){
this->X = Link->X + 16;
this->Y = Link->Y;
this->Data = sword+3;
}
}
if(sword_delay <= 5){

if(Link->Dir == 0){
this->X = Link->X;
this->Y = Link->Y - 16;
this->Data = sword+4;
}
if(Link->Dir == 1){
this->X = Link->X;
this->Y = Link->Y + 16;
this->Data = sword+5;
}
if(Link->Dir == 2){
this->X = Link->X - 16;
this->Y = Link->Y;
this->Data = sword+6;
}
if(Link->Dir == 3){
this->X = Link->X + 16;
this->Y = Link->Y;
this->Data = sword+7;
}
}
}
}
}
}

Set combos like so:


XXXX-------combo cycles to ---UDLR - :Main attack:- finish by combo cycling to third row.
XXXX-------combo cycles to ---UDLR - :Quick attack:
UDLR-------ending animation of main attack

You need five rows of combos.
-first row: frames 0, speed 0. cycles to fourth row,f rames 6, speed 3, then that row cycles to the third row.
-second row: frames 0 speed 0,cycles to fifth row: frames 3 speed 3.
-third row: frames 3, speed 2.

You can change these as it's just a suggestion...just don't make the animation too long....

So to recap:

B-blank, E-ending animation, U-up,D-down, L-left,R-right animation.

BBBB
BBBB
EEEE
UDLR
UDLR

...oh and DISABLE SLASH!!!!! AND SET ITEM SPRITES TO BLANK!


...Have fun.