Baddy challenge

Thought I might share this script I wrote with the spare 30 mins i had.
// Graal2002 NPC by Tricxta
//#clientside
if (created) {
// Initialize the attributes
showcharacter;
setcharprop #3,head10.png;
setcharprop #C0,cynober;
setcharprop #C1,yellow;
setcharprop #C2,white;
setcharprop #C3,black;
setcharprop #C4,white;
setcharprop #2,no-shield.gif;
shieldpower = 1;
dir = 2;
}
timeout=0.1;
if (timeout){
if (tricxtahouse1_1fight=1){
if (this.stage=1){
message stage1;
sleep 2;
message ;
}
if (this.stage=2){
message stage2;
sleep 2;
message ;
}
if (this.stage=3){
message stage3;
sleep 2;
message ;
}
if (this.stage=4){
message stage4;
sleep 2;
message ;
}
if (this.stage=5){
message stage5;
sleep 2;
message ;
}
if (this.stage>5){
message Winner!;
sleep 2;
message ;
playerruppees+=100;
tricxtahouse1_1fight=0;
setlevel2 tricxtahouse1-1.nw,22,44;
}
}
this.maxbaddy=3*this.stage;
while (this.baddycount<this.maxbaddy){
this.randombaddy=random(1,5);
this.xaxis=random(17,55);
this.yaxis=random(17,35);
if (this.randombaddy=1){
putcomp goldenwarrior,this.xaxis,this.yaxis;
this.baddycount+=1;
}
if (this.randombaddy=2){
putcomp graysoldier,this.xaxis,this.yaxis;
this.baddycount+=1;
}
if (this.randombaddy=3){
putcomp redsoldier,this.xaxis,this.yaxis;
this.baddycount+=1;
}
if (this.randombaddy=4){
putcomp bluesoldier,this.xaxis,this.yaxis;
this.baddycount+=1;
}
if (this.randombaddy=5){
putcomp shootingsoldier,this.xaxis,this.yaxis;
this.baddycount+=1;
}
}
if (playerdies){
message Loser;
sleep 2;
message ;
tricxtahouse1_1fight=0;
setlevel2 tricxtahouse1-1.nw,22,44;
}
if (compsdead){
this.stage+=1;
this.baddycount=0;
}
timeout=0.1;
return;
}

Please let me know what you think of my script, Im good with other programming languages but still fairly new to graal scriptingx_x
BTW its triggered by a seperate NPC so please dont point that out lol and in the trigger npc it declares this.stage as 1

There are a couple issues. First, you should really get into the habit of using == for comparisons. if (this.stage == 3)

Second, this. variables are local only to the current NPC. NPCs cannot access another NPC’s this. variables. If your trigger NPC doesn’t work, that is why.

Third, you should use [noparse][/noparse] tags around your code. That will preserve code indentation.
[pre][noparse] if (test) { this.works = 1; } [/noparse][/pre]if (test) { this.works = 1; }

my trigger does work, tricxtahouse1_1fight=1 is not local… i thought u could work that out lol, but thank you so much for the advice, like i said im new to gscript >.>

edit:Oh gawd to anyone looking at this post I was wrong, you can blame my stupid nooby self, im sorry Nalin :frowning: