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:
Code:
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!!!
Hhaha! OK, now that's over with: Here's my findings:
Code:
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:
Code:
//==============================================
// 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.