PDA

View Full Version : Some scripts from Grikarugun.



Gleeok
05-18-2008, 10:47 PM
Some scripts and ideas from the quest "Grikarugun (http://www.armageddongames.net/forums/showthread.php?threadid=102675)".

The whole game is a work in progress, but some definative concepts on how to go about making everything work together have emerged for me, and I pretty much have a kind of set Archtype I follow for certain things, plus there's some cool scripts too! :p I'm going to try and post all of these at some point and in a cohesive manner..(at some point also :p)


Some pretty sweet functions to start:



void spawn(int data, int x, int y, int spawned_ffc){

ffc F = Screen->LoadFFC(spawned_ffc);
F->Data = data;
F->X = x; F->Y = y;
}

Use by: spawn(data,x,y,ffc_number); To gain control over that ffc and move it around fast.


void Homing(int speed, int ffc_num, int target_x, int target_y){
ffc F=Screen->LoadFFC(ffc_num);
int dx = target_x - F->X;
int dy = target_x - F->Y;
float norm = Sqrt(dx*dx+dy*dy);
if(norm > 0){
F->Vx = dx/norm*speed;
F->Vy = dy/norm*speed;
}
}

Turns an ffc into a homing missile. 'Nuff said. :cool: Call to it once for a fireball effect, or every frame for unavoidable death.


int getFFC(int min, int max){
ffc F;int i=min-1;
while(i++ < max){
F=Screen->LoadFFC(i);
if(F->Data<=1){return i;i=max;}
else if(i==max)return 0;
}
}

Returns an unused ffc. INVALUABLE. Huge space saver to boot. use it by:


FFC = Screen->LoadFFC(getFFC(1,32));



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;
}

Returns the nearest enemy to inputted x,y locations. Or:


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;
}
Use this if you're not hiding enemies off-screen.


Bullets: :heart:


void HomingShot(int lx, int ly, int tx, int ty){

eweapon laser;
laser = Screen->CreateEWeapon(EW_MAGIC);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=0;
laser->Angular=true;laser->Angle = ArcTan(lx-tx,ly-ty);
}

Just like a fire statue, but smaller.


void ClusterBomb(int tx, int ty){

eweapon laser;
for(int i;i<30;i++){
laser = Screen->CreateEWeapon(EW_MAGIC);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=1;laser->Damage=2;laser->CSet=0;
laser->Angular=true;laser->Angle = (i*12)*(PI/180);
}
//Game->PlaySound(SFX_BOMB2);
}

Explodes into a perfect cluster of death.



target=Screen->LoadNPC(nearest_enemy(m1->X,m1->Y));
missile_angle=ArcTan(target->X-m1->X,target->Y-m1->Y);
if(m->Angle>missile_angle)m->Angle-=0.4;
else m1->Angle+=0.4;

Homing sprites..still a bit buggy, but I'm working on them.



For backgrounds this works great:


ffc script Bg_stars{

void run(){

int delay = 0; int cset = 0;
this->X = 0; this->Y = -16;
int t = 38460;
while(true){

Waitframe();

int tx = this->X; int ty = this->Y;

Screen->DrawTile(0,tx,ty,t,16,13,cset,1,0,0,0,0,true,128);

delay++;
if(delay >= 4){ this->Y++; delay=0;}

if(this->Y >= 0){this->Y = -16; t -= 20;}
if(t < 37700)t=38460;
}
}
}

Also basic code for the option:


int save_link_x[40];
int save_link_y[40];

n=1;
int init_pos=0;
while(init_pos++<=40){
save_link_x[init_pos]=lx;
save_link_y[init_pos]=ly;
}


if(n>40)n=1;
if(input_up){save_link_x[n]=lx;save_link_y[n]=ly;n++;}
else if(input_down){save_link_x[n]=lx;save_link_y[n]=ly;n++;}
else if(input_left){save_link_x[n]=lx;save_link_y[n]=ly;n++;}
else if(input_right){save_link_x[n]=lx;save_link_y[n]=ly;n++;}

int ns;
if(n>20)ns=n-20;
else ns=n+20;
shield->X=save_link_x[ns];shield->Y=save_link_y[ns];

Will follow behind the player by 20 frames. It's controlled by the Global script which is why it may look akward, and that may be true, but the ffcs are multitasking! Also "shield" is referring to FFC 7.


Also, I apologize for right now, as you'd have to have some scripting knowledge to use these, but we're making progress!








Also worth mentioning are some early crappy versions of the scripts from This Post. (http://www.armageddongames.net/forums/showpost.php?p=1159297&postcount=4) And the early bullet code I made before jman2050 gave us sprite weapons. thanks jman!

Don't use this script! it sucks....:(

const int CIRCLE=0;
const int CIR_ROTATE=99;
const int SPREAD_D=0;

ffc script bullet{

void run(){

int b_enemy=38;
int delay=0;
bool init;
int rand = Rand(20);

//========================================
// ~BULLET DATA~
//========================================

int a1x; int a1y; int a2x; int a2y;
int a3x; int a3y; int a4x; int a4y;

int a5x; int a5y; int a6x; int a6y;
int a7x; int a7y; int a8x; int a8y;

int a9x; int a9y; int a10x; int a10y;
int a11x; int a11y; int a12x; int a12y;

int a13x; int a13y; int a14x; int a14y;
int a15x; int a15y; int a16x; int a16y;

npc e1; npc e2; npc e3; npc e4;
npc e5; npc e6; npc e7; npc e8;

npc e9; npc e10; npc e11; npc e12;
npc e13; npc e14; npc e15; npc e16;

bool init_bullet;int bullet_delay;int slow_lag;int bullet=0;


while(true){

Waitframe();
int tx = this->X; int ty = this->Y;
int lx = Link->X; int ly = Link->Y;



//=======================
// ~ENEMY CREATION~
//=======================

if(!init_bullet){

Waitframes(6);
e1 = Screen->CreateNPC(b_enemy);
e2 = Screen->CreateNPC(b_enemy);
e3 = Screen->CreateNPC(b_enemy);
e4 = Screen->CreateNPC(b_enemy);

e5 = Screen->CreateNPC(b_enemy);
e6 = Screen->CreateNPC(b_enemy);
e7 = Screen->CreateNPC(b_enemy);
e8 = Screen->CreateNPC(b_enemy);

e9 = Screen->CreateNPC(b_enemy);
e10 = Screen->CreateNPC(b_enemy);
e11 = Screen->CreateNPC(b_enemy);
e12 = Screen->CreateNPC(b_enemy);

e13 = Screen->CreateNPC(b_enemy);
e14 = Screen->CreateNPC(b_enemy);
e15 = Screen->CreateNPC(b_enemy);
e16 = Screen->CreateNPC(b_enemy);

e1->X=-48; e1->Y=-48;e2->X=-48; e2->Y=-48;
e3->X=-48; e3->Y=-48;e4->X=-48; e4->Y=-48;
e5->X=-48; e5->Y=-48;e6->X=-48; e6->Y=-48;
e7->X=-48; e7->Y=-48;e8->X=-48; e8->Y=-48;
e9->X=-48; e9->Y=-48;e10->X=-48; e10->Y=-48;
e11->X=-48; e11->Y=-48;e12->X=-48; e12->Y=-48;
e13->X=-48; e13->Y=-48;e14->X=-48; e14->Y=-48;
e15->X=-48; e15->Y=-48;e16->X=-48; e16->Y=-48;

init_bullet = true;
}

//=======================
// ~BULLET HANDLING~
//=======================

if(this->Data>1){

if(!init){

a1x=tx;a1y=ty;a2x=tx;a2y=ty;a3x=tx;a3y=ty;a4x=tx;a 4y=ty;
a5x=tx;a5y=ty;a6x=tx;a6y=ty;a7x=tx;a7y=ty;a8x=tx;a 8y=ty;

a9x=tx;a9y=ty;a10x=tx;a10y=ty;a11x=tx;a11y=ty;a12x =tx;a12y=ty;
a13x=tx;a13y=ty;a14x=tx;a14y=ty;a15x=tx;a15y=ty;a1 6x=tx;a16y=ty;
init=true;
}



if(this->Data==CIRCLE){ //8way

a1y++;
a2x-=0.35; a2y+=0.85;
a3x-=0.7; a3y+=0.7;
a4x-=0.85; a4y+=0.35;

a5x--;
a6x-=0.85; a6y-=0.35;
a7x-=0.7; a7y-=0.7;
a8x-=0.35; a8y-=0.85;

a9y--;
a10x+=0.35; a10y-=0.85;
a11x+=0.7; a11y-=0.7;
a12x+=0.85; a12y-=0.35;

a13x++;
a14x+=0.85; a14y+=0.35;
a15x+=0.7; a15y+=0.7;
a16x+=0.35; a16y+=0.85;
}
else if(this->Data==CIR_ROTATE){ //rotating circle

a1y++;
if(delay>2){ a2x-=0.4; a2y+=0.85;}
if(delay>4){ a3x-=0.7; a3y+=0.7;}
if(delay>6){ a4x-=0.85; a4y+=0.4;}

if(delay>8){ a5x--; }
if(delay>10){ a6x-=0.85; a6y-=0.4; }
if(delay>12){ a7x-=0.7; a7y-=0.7;}
if(delay>14){ a8x-=0.4; a8y-=0.85;}

if(delay>16){ a9y--; }
if(delay>18){ a10x+=0.4; a10y-=0.85;}
if(delay>20){ a11x+=0.7; a11y-=0.7;}
if(delay>22){ a12x+=0.85; a12y-=0.4; }

if(delay>24){ a13x++; }
if(delay>28){ a14x+=0.85; a14y+=0.4; }
if(delay>30){ a15x+=0.7; a15y+=0.7;}
if(delay>32){ a16x+=0.4; a16y+=0.85;}
delay++;
}
else if(this->Data==SPREAD_D){ //downward spread

a1y++; a1x-=0.18; a2y++; a2x+=0.18;
a3x--; a4x++;

a5x-=0.8; a5y+=0.35; a6x+=0.8; a6y+=0.35;
a7x-=0.7; a7y+=0.7; a8x+=0.7; a8y+=0.7;
}

//=======================
// ~ENEMY MAINTENANCE~
//=======================

bullet_delay++;
if(bullet_delay>60){

if(a1x>270)a1x=270; else if(a1x<-20)a1x=-20; if(a1y>180)a1y=180; else if(a1y<-20)a1y=-20;
if(a2x>270)a2x=270; else if(a2x<-20)a2x=-20; if(a2y>180)a2y=180; else if(a2y<-20)a2y=-20;
if(a3x>270)a3x=270; else if(a3x<-20)a3x=-20; if(a3y>180)a3y=180; else if(a3y<-20)a3y=-20;
if(a4x>270)a4x=270; else if(a4x<-20)a4x=-20; if(a4y>180)a4y=180; else if(a4y<-20)a4y=-20;
if(a5x>270)a5x=270; else if(a5x<-20)a5x=-20; if(a5y>180)a5y=180; else if(a5y<-20)a5y=-20;
if(a6x>270)a6x=270; else if(a6x<-20)a6x=-20; if(a6y>180)a6y=180; else if(a6y<-20)a6y=-20;
if(a7x>270)a7x=270; else if(a7x<-20)a7x=-20; if(a7y>180)a7y=180; else if(a7y<-20)a7y=-20;
if(a8x>270)a8x=270; else if(a8x<-20)a8x=-20; if(a8y>180)a8y=180; else if(a8y<-20)a8y=-20;
if(a9x>270)a9x=270; else if(a9x<-20)a9x=-20; if(a9y>180)a9y=180; else if(a9y<-20)a9y=-20;
if(a10x>270)a10x=270; else if(a10x<-20)a10x=-20; if(a10y>180)a10y=180; else if(a10y<-20)a10y=-20;
if(a11x>270)a11x=270; else if(a11x<-20)a11x=-20; if(a11y>180)a11y=180; else if(a11y<-20)a11y=-20;
if(a12x>270)a12x=270; else if(a12x<-20)a12x=-20; if(a12y>180)a12y=180; else if(a12y<-20)a12y=-20;
if(a13x>270)a13x=270; else if(a13x<-20)a13x=-20; if(a13y>180)a13y=180; else if(a13y<-20)a13y=-20;
if(a14x>270)a14x=270; else if(a14x<-20)a14x=-20; if(a14y>180)a14y=180; else if(a14y<-20)a14y=-20;
if(a15x>270)a15x=270; else if(a15x<-20)a15x=-20; if(a15y>180)a15y=180; else if(a15y<-20)a15y=-20;
if(a16x>270)a16x=270; else if(a16x<-20)a16x=-20; if(a16y>180)a16y=180; else if(a16y<-20)a16y=-20;
bullet_delay=0;
}

e1->X=a1x; e1->Y=a1y;
e2->X=a2x; e2->Y=a2y;
e3->X=a3x; e3->Y=a3y;
e4->X=a4x; e4->Y=a4y;

e5->X=a5x; e5->Y=a5y;
e6->X=a6x; e6->Y=a6y;
e7->X=a7x; e7->Y=a7y;
e8->X=a8x; e8->Y=a8y;

e9->X=a9x; e9->Y=a9y;
e10->X=a10x; e10->Y=a10y;
e11->X=a11x; e11->Y=a11y;
e12->X=a12x; e12->Y=a12y;

e13->X=a13x; e13->Y=a13y;
e14->X=a14x; e14->Y=a14y;
e15->X=a15x; e15->Y=a15y;
e16->X=a16x; e16->Y=a16y;
}
else{
slow_lag++;init=false;
if(slow_lag>100+rand){

e1->X=-48; e1->Y=-48;e2->X=-48; e2->Y=-48;
e3->X=-48; e3->Y=-48;e4->X=-48; e4->Y=-48;
e5->X=-48; e5->Y=-48;e6->X=-48; e6->Y=-48;
e7->X=-48; e7->Y=-48;e8->X=-48; e8->Y=-48;
e9->X=-48; e9->Y=-48;e10->X=-48; e10->Y=-48;
e11->X=-48; e11->Y=-48;e12->X=-48; e12->Y=-48;
e13->X=-48; e13->Y=-48;e14->X=-48; e14->Y=-48;
e15->X=-48; e15->Y=-48;e16->X=-48; e16->Y=-48;
slow_lag=0;
}
}
}
}
}
Man, it's come a long way.

Gleeok
05-18-2008, 11:17 PM
Script that controls the *bonus boss*. You know, that Giant Crystal that kills you faster than you can mash buttons. :P


To see it in action just go play the demo. It's right after level 1b. You can't miss it!

cheat code is: <#@$%%^#!!> *censored* :mad:


ffc script boss_Crystal_1{
void run(){

int d=1;
int delay=60;
int attack_delay;
int dir;

float b_deg;
float r_deg=36;
float g_deg;

int n;
int f;
int v;
int rx; int ry; // x,y radius
int rand;
int bullet_state;
int attack_state;
int attack_switch;
int state;
int state_counter;
int counter;
int tile_delay;

int t = 17420;

int lx = Link->X;int ly = Link->Y;
int tx = this->X;int ty = this->Y;

ffc F;

Link->HP=Link->MaxHP;
Screen->Wavy=150;wait(150);

this->Y=-16;
for(int i=0;i<48;i++){
Screen->DrawTile(5,this->X-16,this->Y-32,t,3,5,2,1,0,0,0,0,true,128);
Waitframe();this->Y++;
}

Screen->Quake=240;

for(int i=0;i<240;i++){

if(Rand(15)==0)Screen->DrawTile(6,0,24,12740,16,8,0,1,0,0,0,0,true,128);
else Screen->DrawTile(6,0,24,12740,16,8,0,1,0,0,0,0,true,64);
Screen->DrawTile(5,tx-16,ty-32,t,3,5,2,1,0,0,0,0,true,128);
Waitframe();
}

for(int i=0;i<240;i++){
Screen->DrawTile(5,this->X-16,this->Y-32,t,3,5,2,1,0,0,0,0,true,128);
Waitframe();
}

polarity_shield=true;

eweapon laser;

while(true){

Waitframe();
lx = Link->X;ly = Link->Y;
tx = this->X;ty = this->Y;

Link->InputA=false;
Link->InputL=false;

if(tile_delay>30){
Screen->DrawTile(5,tx-16,ty-32,t,3,5,2,1,0,0,0,0,true,128);
tile_delay--;
}
else if(tile_delay>0){
Screen->DrawTile(5,tx-16,ty-32,t+3,3,5,2,1,0,0,0,0,true,128);
tile_delay--;
}
else{
Screen->DrawTile(5,tx-16,ty-32,t+3,3,5,2,1,0,0,0,0,true,128);
tile_delay=60;
}

if(state==0){

if(delay>0)delay--;
else{
if(attack_delay>0)attack_delay--;
else if(counter>0)counter--;
else{
Game->PlaySound(2);

if(attack_switch==0){

for(int i;i<36;i++){
laser = Screen->CreateEWeapon(EW_MAGIC);laser->ColWidth=2;laser->ColHeight=1;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=11;
laser->Tile=1660;laser->Angular=true;laser->Angle = (i*10)*(PI/180);
}
attack_delay=2;
attack_switch=1;
}
else if(attack_switch==1){

for(int i;i<36;i++){
laser = Screen->CreateEWeapon(EW_MAGIC);laser->ColWidth=2;laser->ColHeight=1;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=11;
laser->Tile=1660;laser->Angular=true;laser->Angle = ((i*10)+2)*(PI/180);
}
attack_delay=2;
attack_switch=2;
}
else if(attack_switch==2){


if(bullet_state<48){

for(int i;i<36;i++){
laser = Screen->CreateEWeapon(EW_MAGIC);laser->ColWidth=2;laser->ColHeight=1;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=11;
laser->Tile=1660;laser->Angular=true;laser->Angle = ((i*10)+4)*(PI/180);
}
}
attack_delay=2;
attack_switch=3;
}
else if(attack_switch==3){

if(bullet_state<36){

for(int i;i<36;i++){
laser = Screen->CreateEWeapon(EW_MAGIC);laser->ColWidth=2;laser->ColHeight=1;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=11;
laser->Tile=1660;laser->Angular=true;laser->Angle = ((i*10)+6)*(PI/180);
}
}
attack_delay=2;
attack_switch=4;
}
else if(attack_switch==4){

if(bullet_state<30){

for(int i;i<36;i++){
laser = Screen->CreateEWeapon(EW_MAGIC);laser->ColWidth=2;laser->ColHeight=1;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=11;
laser->Tile=1660;laser->Angular=true;laser->Angle = ((i*10)+8)*(PI/180);
}
}
attack_delay=2;
attack_switch=0;
state=1;
delay=60-bullet_state;
}
}
}
}
else if(state==1){

if(delay>0)delay--;
else{
if(attack_delay>0)attack_delay--;
else if(counter>0)counter--;
else{
Game->PlaySound(2);

if(attack_switch==0){

for(int i;i<36;i++){
laser = Screen->CreateEWeapon(EW_MAGIC);laser->ColWidth=2;laser->ColHeight=1;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=11;
laser->Tile=1660;laser->Angular=true;laser->Angle = (i*10)*(PI/180);
}
attack_delay=2;
attack_switch=1;
}
else if(attack_switch==1){

for(int i;i<36;i++){
laser = Screen->CreateEWeapon(EW_MAGIC);laser->ColWidth=2;laser->ColHeight=1;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=11;
laser->Tile=1660;laser->Angular=true;laser->Angle = ((i*10)-2)*(PI/180);
}
attack_delay=2;
attack_switch=2;
}
else if(attack_switch==2){

for(int i;i<36;i++){
laser = Screen->CreateEWeapon(EW_MAGIC);laser->ColWidth=2;laser->ColHeight=1;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=11;
laser->Tile=1660;laser->Angular=true;laser->Angle = ((i*10)-4)*(PI/180);
}
attack_delay=2;
attack_switch=3;
}
else if(attack_switch==3){

if(bullet_state<42){

for(int i;i<36;i++){
laser = Screen->CreateEWeapon(EW_MAGIC);laser->ColWidth=2;laser->ColHeight=1;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=11;
laser->Tile=1660;laser->Angular=true;laser->Angle = ((i*10)-6)*(PI/180);
}
}
attack_delay=2;
attack_switch=4;
}
else if(attack_switch==4){

if(bullet_state<32){

for(int i;i<36;i++){
laser = Screen->CreateEWeapon(EW_MAGIC);laser->ColWidth=2;laser->ColHeight=1;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=11;
laser->Tile=1660;laser->Angular=true;laser->Angle = ((i*10)-8)*(PI/180);
}
}
attack_delay=2;
attack_switch=0;
state=0;
delay = 60-bullet_state;
if(bullet_state>54){state=2;delay=120;Game->PlayMIDI(4);}
bullet_state+=2;
}
}
}
}
else if(state==2){

if(delay>0)delay--;
else{
if(attack_delay>0)attack_delay--;
else if(counter>0)counter--;
else{

if(attack_switch>=0){

laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=0;
laser->Angular=true;laser->Angle = (b_deg)*(PI/180);

laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=1;
laser->Angular=true;laser->Angle = (r_deg)*(PI/180);


laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=0;
laser->Angular=true;laser->Angle = (b_deg+72)*(PI/180);

laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=1;
laser->Angular=true;laser->Angle = (r_deg+72)*(PI/180);


laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=0;
laser->Angular=true;laser->Angle = (b_deg+144)*(PI/180);

laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=1;
laser->Angular=true;laser->Angle = (r_deg+144)*(PI/180);


laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=0;
laser->Angular=true;laser->Angle = (b_deg+216)*(PI/180);

laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=1;
laser->Angular=true;laser->Angle = (r_deg+216)*(PI/180);


laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=0;
laser->Angular=true;laser->Angle = (b_deg+288)*(PI/180);

laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=1;
laser->Angular=true;laser->Angle = (r_deg+288)*(PI/180);

if(bullet_state>6000){state=3;delay=180;bullet_state=0;attack_swit ch=90;}
else if(bullet_state>5000){b_deg+=7;r_deg-=7;}
else if(bullet_state>4000){b_deg+=6;r_deg-=6;}
else if(bullet_state>3000){b_deg+=5;r_deg-=5;}
else if(bullet_state>2000){b_deg+=4;r_deg-=4;}
else if(bullet_state>1000){b_deg+=3;r_deg-=3;}
else{b_deg+=2;r_deg-=2;}

attack_delay=2;
attack_switch++;
bullet_state+=3;
}
if(attack_switch>5 && bullet_state>5000){

Game->PlaySound(40);

laser = Screen->CreateEWeapon(129);laser->ColWidth=6;laser->ColHeight=6;
laser->X=lx+(90*Sin(Rand(360)));laser->Y=ly+(80*Cos(Rand(360)));
laser->Step=Rand(2)+1;laser->Damage=2;laser->CSet=6;
laser->OriginalTile=1740;laser->NumFrames=12;laser->ASpeed=3;
laser->Angular=true;laser->Angle = ArcTan(lx-laser->X,ly-laser->Y);

attack_switch=0;
}
else if(attack_switch>7 && bullet_state>4000){

Game->PlaySound(40);

laser = Screen->CreateEWeapon(129);laser->ColWidth=6;laser->ColHeight=6;
laser->X=lx+(90*Sin(Rand(360)));laser->Y=ly+(80*Cos(Rand(360)));
laser->Step=Rand(2)+1;laser->Damage=2;laser->CSet=6;
laser->OriginalTile=1740;laser->NumFrames=12;laser->ASpeed=3;
laser->Angular=true;laser->Angle = ArcTan(lx-laser->X,ly-laser->Y);

attack_switch=0;
}
else if(attack_switch>10 && bullet_state>3000){

Game->PlaySound(40);

laser = Screen->CreateEWeapon(129);laser->ColWidth=6;laser->ColHeight=6;
laser->X=lx+(90*Sin(Rand(360)));laser->Y=ly+(80*Cos(Rand(360)));
laser->Step=Rand(2)+1;laser->Damage=2;laser->CSet=6;
laser->OriginalTile=1740;laser->NumFrames=12;laser->ASpeed=3;
laser->Angular=true;laser->Angle = ArcTan(lx-laser->X,ly-laser->Y);

attack_switch=0;
}
else if(attack_switch>60){

Game->PlaySound(40);

for(int i=0;i<360;i+=30){
laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=lx+(80*Sin(i));laser->Y=ly+(80*Cos(i));
laser->Step=1;laser->Damage=2;laser->CSet=6;
laser->OriginalTile=1740;laser->NumFrames=12;laser->ASpeed=3;
laser->Angular=true;laser->Angle = ArcTan(lx-laser->X,ly-laser->Y);
}
attack_switch=0;
}
}
}
}
else if(state==3){

if(delay>0)delay--;
else{
// MOVEMENT

if(tx>140){
dir=2;
if(this->Vx>0)this->Vx-=0.05;
else if(this->Vx>-2)this->Vx-=0.05;
}
else if(tx<100){
dir=3;
if(this->Vx<0)this->Vx+=0.05;
else if(this->Vx<2)this->Vx+=0.05;
}
else{

if(dir==2){
if(this->Vx>0)this->Vx-=0.05;
else if(this->Vx>-2)this->Vx-=0.05;
}
else if(dir==3){
if(this->Vx<0)this->Vx+=0.05;
else if(this->Vx<2)this->Vx+=0.05;
}
else dir=Rand(2)+2;
}

if(attack_delay>0)attack_delay--;
else if(counter>0)counter--;
else{

if(attack_switch==0){

for(int i;i<36;i++){
laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=0;
laser->Angular=true;laser->Angle = (i*10)*(PI/180);
}
for(int i;i<36;i++){
laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=1;laser->Damage=2;laser->CSet=0;
laser->Angular=true;laser->Angle = (5+i*10)*(PI/180);
}

attack_delay=50-bullet_state;
attack_switch=1;

}
else if(attack_switch==1){

for(int i;i<36;i++){
laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=1;
laser->Angular=true;laser->Angle = (i*10)*(PI/180);
}
for(int i;i<36;i++){
laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=1;laser->Damage=2;laser->CSet=1;
laser->Angular=true;laser->Angle = (5+i*10)*(PI/180);
}

attack_delay=50-bullet_state;
attack_switch=2;
}
else if(attack_switch==2){

for(int i;i<36;i++){
laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=2;laser->Damage=2;laser->CSet=6;
laser->Angular=true;laser->Angle = (i*10)*(PI/180);
}
for(int i;i<36;i++){
laser = Screen->CreateEWeapon(142);laser->ColWidth=6;laser->ColHeight=6;
laser->X=tx;laser->Y=ty;laser->Step=1;laser->Damage=2;laser->CSet=6;
laser->Angular=true;laser->Angle = (5+i*10)*(PI/180);
}

attack_delay=50-bullet_state;
attack_switch=0;
bullet_state++;
if(bullet_state>28)state=4;
}
}
}
}
else if(state==4){

for(int i; i<400;i++){
Screen->DrawTile(5,this->X-16,this->Y-32,t,3,5,2,1,0,0,0,0,true,128);
this->Vx=0;this->Vy=-0.1;
if(this->X>121)this->X--;
else if(this->X<119)this->X++;
Waitframe();
}
Screen->Message(1);wait(9999);
}
}
}
}

Gleeok
06-08-2008, 05:26 AM
Alright, minor update for the time being. This post is all about fun with Sin and Cos! Lot's of cool things you can do with these in ZScript.


The first one is the final boss from level one, now playable in the demo, and moves entirely in circular patterns. Sorry again, these are not commented really, but if you've played the boss in the game then you can get a good idea on exactly what's going on here.



ffc script boss_patralike{
void run(){

int d=2590;int delay;
float wii;bool lasers;
int n;int f;bool normal=true;
int r=80;int radx;int rady;
this->X=112;this->Y=80;

int outer_state;
int inner_state;
int movement;

int counter;
int attack_counter;
int speed1;int speed2;

int deg;int s;

int color=2;

int z;int q;

for(int i=1;i<=32;i++){
boss_check[i]=0;
}


Screen->Quake=210;

int play_sfx;
for(int i=0;i<160;i++){

if(Rand(15)==0)Screen->DrawTile(6,0,24,12740,16,8,0,1,0,0,0,0,true,128);
else Screen->DrawTile(6,0,24,12740,16,8,0,1,0,0,0,0,true,64);

if(play_sfx>0)play_sfx--;
else{ play_sfx=50; Game->PlaySound(SFX_DOOMHORN1);}
Waitframe();
}

if(GAME_MODE<4)Refill();

int x=112; int y=-80;

int eye_x=15;int eye_y=10;

for(int p;p<640||y<80;p++){

Waitframe();

for(int i;i<12;i++){

Screen->DrawTile(2,x+(120*Sin(i*30)),y+(80*Cos(i*30)),7558 ,2,2,11,1,0,0,0,0,true,128);
if(i<10)Screen->DrawTile(2,120+(15*Sin(i*36)),y+(10*Cos(i*36)),564 1,1,1,11,1,0,0,0,0,true,128);

}

y+=0.25;
}


ffc F;

int fx;int fy;

float w;

for(int i;i<10;i++){

F=Screen->LoadFFC(i+22);
F->Data=2576;
}
ffc boss=Screen->LoadFFC(2);
boss->Data=2578;
boss->CSet=0;

x=112;y=80;

ffc f10 = Screen->LoadFFC(10);f10->Data=d;f10->CSet=0;
f10->TileWidth=2;f10->TileHeight=2;f10->EffectWidth=32;f10->EffectHeight=32;
ffc f11 = Screen->LoadFFC(11);f11->Data=d+40;f11->CSet=1;
f11->TileWidth=2;f11->TileHeight=2;f11->EffectWidth=32;f11->EffectHeight=32;
ffc f12 = Screen->LoadFFC(12);f12->Data=d+80;f12->CSet=6;
f12->TileWidth=2;f12->TileHeight=2;f12->EffectWidth=32;f12->EffectHeight=32;
ffc f13 = Screen->LoadFFC(13);f13->Data=d;f13->CSet=0;
f13->TileWidth=2;f13->TileHeight=2;f13->EffectWidth=32;f13->EffectHeight=32;
ffc f14 = Screen->LoadFFC(14);f14->Data=d+40;f14->CSet=1;
f14->TileWidth=2;f14->TileHeight=2;f14->EffectWidth=32;f14->EffectHeight=32;
ffc f15 = Screen->LoadFFC(15);f15->Data=d+80;f15->CSet=6;
f15->TileWidth=2;f15->TileHeight=2;f15->EffectWidth=32;f15->EffectHeight=32;
ffc f16 = Screen->LoadFFC(16);f16->Data=d;f16->CSet=0;
f16->TileWidth=2;f16->TileHeight=2;f16->EffectWidth=32;f16->EffectHeight=32;
ffc f17 = Screen->LoadFFC(17);f17->Data=d+40;f17->CSet=1;
f17->TileWidth=2;f17->TileHeight=2;f17->EffectWidth=32;f17->EffectHeight=32;
ffc f18 = Screen->LoadFFC(18);f18->Data=d+80;f18->CSet=6;
f18->TileWidth=2;f18->TileHeight=2;f18->EffectWidth=32;f18->EffectHeight=32;
ffc f19 = Screen->LoadFFC(19);f19->Data=d;f19->CSet=0;
f19->TileWidth=2;f19->TileHeight=2;f19->EffectWidth=32;f19->EffectHeight=32;
ffc f20 = Screen->LoadFFC(20);f20->Data=d+40;f20->CSet=1;
f20->TileWidth=2;f20->TileHeight=2;f20->EffectWidth=32;f20->EffectHeight=32;
ffc f21 = Screen->LoadFFC(21);f21->Data=d+80;f21->CSet=6;
f21->TileWidth=2;f21->TileHeight=2;f21->EffectWidth=32;f21->EffectHeight=32;


eweapon ew_sprite;
eweapon laser;

npc enemy=Screen->CreateNPC(255);
enemy->HP=500;enemy->CSet=11;
enemy->ColWidth=6;enemy->ColHeight=6;
enemy->ColXOffset=5;enemy->ColYOffset=5;

bool invulnerability=true;

float cx; float cy; float a;
int sprite_state;
bool final_attack;


while(true){

Waitframe();

int lx = Link->X;int ly = Link->Y;
int tx = this->X;int ty = this->Y;

boss->X=tx+8;boss->Y=ty;

boss_check[1]=tx+8;boss_check[2]=ty;

delay++;

if(invulnerability){
enemy->X=boss->X;enemy->Y=boss->Y;
if(enemy->HP<500)enemy->HP=500;
Screen->Rectangle(5,20,2,20+((enemy->HP)/2.3),4,104,1,0,0,0,true,128);

}
else{
if(enemy->isValid()){
Screen->Rectangle(5,20,2,20+((enemy->HP)/2.3),4,104,1,0,0,0,true,128);
enemy->X=boss->X;enemy->Y=boss->Y;

}
else{

wait(120);
for(int v;v<5;v++){

Game->PlaySound(SFX_BOMB2);

for(int i=10;i<32;i++){
F=Screen->LoadFFC(i);
F->TileWidth=3;F->TileHeight=3;
F->Data=EXPLODE3+Rand(12);
wait(5);
if(Rand(22)==0)Game->PlaySound(SFX_BOMB3);
}

Game->PlaySound(SFX_BOMB3);
}

this->Data = Y_EXPLODE;

int screen=Game->GetCurDMapScreen();

wait(120);
Link->PitWarp(10,screen+1);
}
}



if(movement==1){

}
else if(movement==2){

this->X = (112) + ((z) * Sin(q));
this->Y = (80) + ((z) * Cos(q));

z+=0.1;q++;

if(z==50)movement=3;
}
else if(movement==3){

this->X = (112) + ((z) * Sin(q));
this->Y = (80) + ((z) * Cos(q));

z-=0.1;q++;

if(z==0)movement=4;
}
else if(movement==4){

this->X = (112) + ((z) * Sin(q));
this->Y = (80) + ((z) * Cos(q));

z+=0.1;q++;

if(z==50)movement=5;
}
else if(movement==5){

this->X = (112) + ((z) * Sin(q));
this->Y = (80) + ((z) * Cos(q));

z-=0.1;q++;

if(z==0)movement=6;
}
else if(movement==6){

this->X = (112) + ((z) * Sin(q));
this->Y = (80) + ((z) * Cos(q));

z+=0.1;q++;

if(z==50)movement=7;
}
else if(movement==7){

this->X = (112) + ((z) * Sin(q));
this->Y = (80) + ((z) * Cos(q));

z-=0.1;q++;

if(z==0){
movement=1;
outer_state=4;
inner_state=4;
}
}

if(outer_state==0){

for(int i=0;i<12;i++){

F=Screen->LoadFFC(i+10);
F->X = tx+(x*Sin(wii+(i*30)));
F->Y = ty+(y*Cos(wii+(i*30)));
}


if(delay<200)wii-=0.1;
else if(delay<300)wii-=0.15;
else if(delay<400)wii-=0.24;
else if(delay<500)wii-=0.33;
else if(delay<600)wii-=0.42;
else wii-=0.5;

if(delay>750){

delay=0;

outer_state=1;
inner_state=1;

for(int i=0;i<12;i++){

F=Screen->LoadFFC(i+10);
if(F->Data>200)F->Data+=6;
}
}
}
else if(outer_state==1){

for(int i=0;i<12;i++){

F=Screen->LoadFFC(i+10);
F->X = tx+(x*Sin(wii+(i*30)));
F->Y = ty+(y*Cos(wii+(i*30)));
}

if(delay<100)wii-=0.5;
else if(delay<200)wii-=0.6;
else if(delay<300)wii-=0.7;
else if(delay<400)wii-=0.8;
else if(delay<500)wii-=0.9;
else wii--;

if(delay>1000){

delay=0;

outer_state=2;
inner_state=2;

Game->PlaySound(SFX_DOOMHORN2);

for(int i=0;i<12;i++){

F=Screen->LoadFFC(i+10);
if(F->Data>200)F->Data+=2;
}
}
}
else if(outer_state==2){ // Retracting

for(int i=0;i<12;i++){

F=Screen->LoadFFC(i+10);
F->X = tx+(x*Sin(wii+(i*30)));
F->Y = ty+(y*Cos(wii+(i*30)));
}

wii--;
x-=0.3;
y-=0.2;

if(y<=28){

delay=0;
outer_state=3;
inner_state=3;
movement=2;
}
}
else if(outer_state==3){

for(int i=0;i<12;i++){

F=Screen->LoadFFC(i+10);
F->X = tx+(x*Sin(wii+(i*30)));
F->Y = ty+(y*Cos(wii+(i*30)));
}

if(delay<100)wii-=1.0;
else if(delay<200)wii-=1.1;
else if(delay<300)wii-=1.2;
else if(delay<400)wii-=1.3;
else if(delay<500)wii-=1.4;
else wii-=1.5;

}
else if(outer_state==4){ // Expanding

for(int i=0;i<12;i++){

F=Screen->LoadFFC(i+10);
F->X = tx+(x*Sin(wii+(i*30)));
F->Y = ty+(y*Cos(wii+(i*30)));
}

wii-=1.5;
x+=0.3;
y+=0.2;

if(y>=80){

delay=0;
outer_state=5;
inner_state=5;

Game->PlaySound(SFX_WARPED2);
}
}
else if(outer_state==5){

for(int i=0;i<12;i++){

F=Screen->LoadFFC(i+10);
F->X = tx+(x*Sin(wii+(i*30)));
F->Y = ty+(y*Cos(wii+(i*30)));
}

wii-=1.5;

if(delay>800){

delay=0;

outer_state=2;
inner_state=2;

Game->PlaySound(SFX_DOOMHORN2);

}
}

if(inner_state==0){

for(int i;i<10;i++){

F=Screen->LoadFFC(i+22);
F->X=(tx+8)+(eye_x*Sin(w+(i*36)));
F->Y=ty+(eye_y*Cos(w+(i*36)));
}

if(delay<200)w+=0.1;
else if(delay<350)w+=0.15;
else if(delay<550)w+=0.2;
else if(delay<750)w+=0.25;
else if(delay<950)w+=0.4;
else w+=0.5;
}
else if(inner_state==1){

for(int i;i<10;i++){

F=Screen->LoadFFC(i+22);
F->X=(tx+8)+(eye_x*Sin(w+(i*36)));
F->Y=ty+(eye_y*Cos(w+(i*36)));
}

if(delay<100)w+=0.5;
else if(delay<200)w+=0.6;
else if(delay<300)w+=0.7;
else if(delay<400)w+=0.8;
else if(delay<500)w+=0.9;
else w++;
}
else if(inner_state==2){

for(int i;i<10;i++){

F=Screen->LoadFFC(i+22);
F->X=(tx+8)+(eye_x*Sin(w+(i*36)));
F->Y=ty+(eye_y*Cos(w+(i*36)));
}

w++;

eye_x+=0.3;
eye_y+=0.2;
}
else if(inner_state==3){

for(int i;i<10;i++){

F=Screen->LoadFFC(i+22);
F->X=(tx+8)+(eye_x*Sin(w+(i*36)));
F->Y=ty+(eye_y*Cos(w+(i*36)));
}


if(delay<150)w+=1.0;
else if(delay<300)w+=1.1;
else if(delay<450)w+=1.2;
else if(delay<600)w+=1.3;
else if(delay<750)w+=1.4;
else w+=1.5;

}
else if(inner_state==4){

for(int i;i<10;i++){

F=Screen->LoadFFC(i+22);
F->X=(tx+8)+(eye_x*Sin(w+(i*36)));
F->Y=ty+(eye_y*Cos(w+(i*36)));
}

w+=1.5;

eye_x-=0.3;
eye_y-=0.2;
}
else if(inner_state==5){

for(int i;i<10;i++){

F=Screen->LoadFFC(i+22);
F->X=(tx+8)+(eye_x*Sin(w+(i*36)));
F->Y=ty+(eye_y*Cos(w+(i*36)));
}

w+=1.5;
}


if(lasers){


if(!final_attack){

cx = boss->X;
cy = boss->Y;

Game->PlaySound(SFX_LIGHTNING);

if(enemy->HP<320){final_attack=true;counter=90;}

if(sprite_state==0){ // blue

if(counter>0){

counter--;

laser = Screen->CreateEWeapon(EW_MAGIC);
laser->ColWidth=4;laser->ColHeight=4;laser->ColXOffset=6;laser->ColYOffset=6;
laser->X=cx + 30 * Sin(a);laser->Y=cy + 30 * Cos(a);
laser->Step=1;laser->Damage=2;laser->CSet=0;
laser->Angular=true;laser->Tile=1300;
laser->Angle=ArcTan(cx-laser->X,cy-laser->Y);

a-=6;
}

else{sprite_state=1;counter=60;}

}
if(sprite_state==1){ // red

if(counter>0){

counter--;

laser = Screen->CreateEWeapon(EW_MAGIC);
laser->ColWidth=4;laser->ColHeight=4;laser->ColXOffset=6;laser->ColYOffset=6;
laser->X=cx + 30 * Sin(a);laser->Y=cy + 30 * Cos(a);
laser->Step=1;laser->Damage=2;laser->CSet=1;
laser->Angular=true;laser->Tile=1320;
laser->Angle=ArcTan(cx-laser->X,cy-laser->Y);

a-=6;
}

else{sprite_state=2;counter=60;}

}
if(sprite_state==2){ // green

if(counter>0){

counter--;

laser = Screen->CreateEWeapon(EW_MAGIC);
laser->ColWidth=4;laser->ColHeight=4;laser->ColXOffset=6;laser->ColYOffset=6;
laser->X=cx + 30 * Sin(a);laser->Y=cy + 30 * Cos(a);
laser->Step=1;laser->Damage=2;laser->CSet=6;
laser->Angular=true;laser->Tile=1340;
laser->Angle=ArcTan(cx-laser->X,cy-laser->Y);

a-=6;
}

else{sprite_state=0;counter=60;}

}
}

else{


if(GAME_MODE>EASY){

int tx_r = tx+16;
r = ty;

Screen->Rectangle(2,tx-120,r ,tx+136,r+10,2,1,tx_r,r+5,n,true,64);
Screen->Rectangle(2,tx-120,r+1,tx+136,r+9,5,1,tx_r,r+4,n,true,64);
Screen->Rectangle(2,tx-120,r+2,tx+136,r+8,7,1,tx_r,r+3,n,true,64);
Screen->Rectangle(2,tx-120,r+3,tx+136,r+8,10,1,tx_r,r+2,n,true,64);

Screen->Rectangle(2,tx-110,r ,tx+146,r+10,17,1,tx_r,r+5,n+90,true,64);
Screen->Rectangle(2,tx-110,r+1,tx+146,r+9,19,1,tx_r,r+4,n+90,true,64);
Screen->Rectangle(2,tx-110,r+2,tx+146,r+8,21,1,tx_r,r+3,n+90,true,64);
Screen->Rectangle(2,tx-110,r+3,tx+146,r+8,23,1,tx_r,r+2,n+90,true,64);

for(int i=8;i<128;i+=8){

radx = tx_r + (i * Sin(n-90));
rady = r + (i * Cos(n+90));
if(Abs(lx-radx)<9&&Abs(ly-rady)<9){
if(white && polarity_shield){
if(Link->MP<Link->MaxMP)Link->MP++;
Game->PlaySound(23);
}
else {Link->HP--;Game->PlaySound(19);}
}
radx = tx_r - (i * Sin(n-90));
rady = r - (i * Cos(n+90));
if(Abs(lx-radx)<9&&Abs(ly-rady)<9){
if(white && polarity_shield){
if(Link->MP<Link->MaxMP)Link->MP++;
Game->PlaySound(23);
}
else {Link->HP--;Game->PlaySound(19);}
}
radx = tx_r + (i * Sin(n));
rady = r + (i * Cos(n+180));
if(Abs(lx-radx)<9&&Abs(ly-rady)<9){
if(black && polarity_shield){
if(Link->MP<Link->MaxMP)Link->MP++;
Game->PlaySound(23);
}
else {Link->HP--;Game->PlaySound(19);}
}
radx = tx_r - (i * Sin(n));
rady = r - (i * Cos(n+180));
if(Abs(lx-radx)<9&&Abs(ly-rady)<9){
if(black && polarity_shield){
if(Link->MP<Link->MaxMP)Link->MP++;
Game->PlaySound(23);
}
else {Link->HP--;Game->PlaySound(19);}
}

}
n++;
}

if(counter>0){

for(int i;i<10;i++){

F=Screen->LoadFFC(i+22);

fx=F->X+8;fy=F->Y+8;

Screen->Circle(5,fx,fy,counter/2,color,1,0,0,0,false,128);
Screen->Circle(5,fx,fy,counter,color,1,0,0,0,false,128);

}

counter--;

Game->PlaySound(SFX_SKEW);

}
else{

if(attack_counter>0){

for(int i;i<10;i++){

F=Screen->LoadFFC(i+22);
fx=F->X+8;fy=F->Y+8;
Screen->Line(5,lx+8,ly+8,fx,fy,color,1,0,0,0,64);
}
if(color==2){
if(white && polarity_shield){
if(Link->MP<Link->MaxMP)Link->MP++;
Game->PlaySound(23);
}
else {Link->HP--;Game->PlaySound(19);}
}
else{
if(black && polarity_shield){
if(Link->MP<Link->MaxMP)Link->MP++;
Game->PlaySound(23);
}
else {Link->HP--;Game->PlaySound(19);}
}

attack_counter--;
}
else{

if(color==2){
color=20;
for(int i;i<10;i++){
F=Screen->LoadFFC(i+22);
F->Data++;
}
boss->Data++;
boss->CSet++;
}
else{
color=2;
for(int i;i<10;i++){
F=Screen->LoadFFC(i+22);
F->Data--;
}
boss->Data--;
boss->CSet--;
}


speed1+=0.5;speed2+=0.25;

if(speed1>30)counter=30;
else counter=60-speed1;

if(speed2>15)attack_counter=15;
else attack_counter=30-speed2;

Game->PlaySound(SFX_EVILGUN);
}
}
if(GAME_MODE==HARD){

if(s>0)s--;
else{
laser = Screen->CreateEWeapon(EW_MAGIC);laser->ColWidth=4;laser->ColHeight=4;
laser->X=tx+8;laser->Y=ty;laser->Step=2;laser->Damage=2;
laser->CSet=boss->CSet;laser->ColXOffset=6;laser->ColYOffset=6;
laser->Angular=true;laser->Angle = deg*(PI/180);

laser = Screen->CreateEWeapon(EW_MAGIC);laser->ColWidth=4;laser->ColHeight=4;
laser->X=tx+8;laser->Y=ty;laser->Step=2;laser->Damage=2;
laser->CSet=boss->CSet;laser->ColXOffset=6;laser->ColYOffset=6;
laser->Angular=true;laser->Angle = (deg+180)*(PI/180);

deg-=4;s=2;

Game->PlaySound(SFX_SUMMON);
}
}
}
}

else{

int ew_num = Screen->NumEWeapons();

for(int e = ew_num; e>0; e--){

ew_sprite = Screen->LoadEWeapon(e);

if(Abs((tx+8)-ew_sprite->X)<10 && Abs(ty-ew_sprite->Y)<10){

ew_sprite->DeadState=0;
}
}

for(int i=0;i<12;i++){

F=Screen->LoadFFC(i+10);

if(F->Data==1 && boss_check[i+10]!=99){
boss_check[i+10]=99;
boss_check[32]++;
}
}
if(boss_check[32]>=12){lasers=true;counter=60;attack_counter=30;invu lnerability=false;}
}

// BUGFIX

for(int i;i<10;i++){

F=Screen->LoadFFC(i+22);
if(F->Data<4){
if(F->CSet==0)F->Data=2576;
else F->Data=2577;
}
}
}
}
}



And secondly using Sin and Cos for Direct movement rather than direct placement. Movement pattern for the ships that fly in from the sides of the screen and circle around in an oval pattern from stage 3:



if(!init){
if(tx<120)horiz=1;if(tx>120)horiz=0;if(ty<80)vert=1;if(ty>80)vert=0;delay=30;
init=true;enemy->CSet=0;this->CSet=0;enemy->HP=enemyHP;p=80;counter=0;
}
enemy->X=tx;enemy->Y=ty;

if(delay>0){
delay--;

if(horiz==0)this->Vx=-4;
else this->Vx=4;

if(delay==20) B_HomingShot(lx,ly,tx,ty);
}
else if(p>28){
if(horiz==1){
if(vert==1){
this->Vx = (5-(80/p)) * Sin(counter+90);
this->Vy = (3.8-(80/p)) * Cos(counter+90);
}
else{
this->Vx = (5-(80/p)) * Sin(counter+90);
this->Vy = (3.8-(80/p)) * Cos(counter+270);
}
}
else{
if(vert==1){
this->Vx = -(5-(80/p)) * Sin(counter+90);
this->Vy = -(3.8-(80/p)) * Cos(counter+270);
}
else{
this->Vx = -(5-(80/p)) * Sin(counter+90);
this->Vy = -(3.8-(80/p)) * Cos(counter+90);
}
}
p-=0.239;
counter-=2;
}


And lastly; Anyone notice that the background in the select screen was a rotating Yin/Yang pattern using hundreds of single pixels? Well here it is:



if(z<1200){


for(int i;i<120;i++){

Screen->PutPixel(2,x+(a*Sin(b-i)),y+(c*Cos(d-i)),8,0,0,0,64);
Screen->PutPixel(2,x+(a*Sin(b-i+180)),y+(c*Cos(d-i+180)),7,0,0,0,64);

a++;c++;

cir_x = x + (44*Sin(b+90));
cir_y = y + (44*Cos(d+90));

Screen->PutPixel(2,cir_x+(8*Sin((b*3)+(i*2.5))),cir_y+(8*C os((b*3)+(i*2.5))),9,0,0,0,64);

cir_x = x + (44*Sin(b+270));
cir_y = y + (44*Cos(d+270));

Screen->PutPixel(2,cir_x+(8*Sin((b*3)-(i*2.5))),cir_y+(8*Cos((d*3)-(i*2.5))),9,0,0,0,64);

}

for(int i;i<360;i++){

Screen->PutPixel(1,x+(z*Sin(i)),y+(z*Cos(i)),8,0,0,0,64);
}
z++;
if(z>160)z=0;

}
a=0;c=0;
b+=2;d+=2;


Waitframe();

Joe123
06-08-2008, 05:36 AM
:eek: Are you insane?!


ffc f10 = Screen->LoadFFC(10);f10->Data=d;f10->CSet=0;
f10->TileWidth=2;f10->TileHeight=2;f10->EffectWidth=32;f10->EffectHeight=32;
ffc f11 = Screen->LoadFFC(11);f11->Data=d+40;f11->CSet=1;
f11->TileWidth=2;f11->TileHeight=2;f11->EffectWidth=32;f11->EffectHeight=32;
ffc f12 = Screen->LoadFFC(12);f12->Data=d+80;f12->CSet=6;
f12->TileWidth=2;f12->TileHeight=2;f12->EffectWidth=32;f12->EffectHeight=32;
ffc f13 = Screen->LoadFFC(13);f13->Data=d;f13->CSet=0;
f13->TileWidth=2;f13->TileHeight=2;f13->EffectWidth=32;f13->EffectHeight=32;
ffc f14 = Screen->LoadFFC(14);f14->Data=d+40;f14->CSet=1;
f14->TileWidth=2;f14->TileHeight=2;f14->EffectWidth=32;f14->EffectHeight=32;
ffc f15 = Screen->LoadFFC(15);f15->Data=d+80;f15->CSet=6;
f15->TileWidth=2;f15->TileHeight=2;f15->EffectWidth=32;f15->EffectHeight=32;
ffc f16 = Screen->LoadFFC(16);f16->Data=d;f16->CSet=0;
f16->TileWidth=2;f16->TileHeight=2;f16->EffectWidth=32;f16->EffectHeight=32;
ffc f17 = Screen->LoadFFC(17);f17->Data=d+40;f17->CSet=1;
f17->TileWidth=2;f17->TileHeight=2;f17->EffectWidth=32;f17->EffectHeight=32;
ffc f18 = Screen->LoadFFC(18);f18->Data=d+80;f18->CSet=6;
f18->TileWidth=2;f18->TileHeight=2;f18->EffectWidth=32;f18->EffectHeight=32;
ffc f19 = Screen->LoadFFC(19);f19->Data=d;f19->CSet=0;
f19->TileWidth=2;f19->TileHeight=2;f19->EffectWidth=32;f19->EffectHeight=32;
ffc f20 = Screen->LoadFFC(20);f20->Data=d+40;f20->CSet=1;
f20->TileWidth=2;f20->TileHeight=2;f20->EffectWidth=32;f20->EffectHeight=32;
ffc f21 = Screen->LoadFFC(21);f21->Data=d+80;f21->CSet=6;
f21->TileWidth=2;f21->TileHeight=2;f21->EffectWidth=32;f21->EffectHeight=32;


ffc f[22];
int i;
for(i=0;i<22;i++){
f[i] = Screen->LoadFFC(i+10);
f[i]->CSet = 0;
f[i]->TileWidth = 2;
f[i]->TileHeight = 2;
f[i]->EffectWidth = 32;
f[i]->EffectHeight = 32;
f[i]->Data = d+((i%3)*40)
}

We have arrays for a reason goddamnit! =P



And you also need a little maths too to get it to work, but it's not that complex maths really =P
d+((i%3)*40) will sort out your 'd+0, d+40, d+80' problem.

Gleeok
06-08-2008, 05:51 AM
:eek: Are you insane?!


Do you really want me to answer that? ;)




ffc f[22];
int i;
for(i=0;i<22;i++){
f[i] = Screen->LoadFFC(i+10);
f[i]->CSet = 0;
f[i]->TileWidth = 2;
f[i]->TileHeight = 2;
f[i]->EffectWidth = 32;
f[i]->EffectHeight = 32;
f[i]->Data = d+((i%3)*40)
}

We have arrays for a reason goddamnit! =P



And you also need a little maths too to get it to work, but it's not that complex maths really =P
d+((i%3)*40) will sort out your 'd+0, d+40, d+80' problem.

[/quote]

Hrm...First thing is that I wrote a good portion before we had arrays though, plus I wasn't sure of the order I needed to get the ffcs lined up how I wanted them, so I don't mind a few segments of raw data. I'm pretty sure this script wouldn't be much smaller or easier with added arrays anyway.

And (i%3). When I look at this I think 3% of i, but are you saying that (i%3) will consistantly return 0,1,2,0,1,2,0,1,2.....? So if I had (i%5) it would return 0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1?

Joe123
06-08-2008, 05:56 AM
Yes.

Modulus, not percent.


((i%3)*40) maps to 0, 40, 80, 0, 40, 80.

so i%5 would indeed create 0, 1, 2, 3, 4, 0, 1, 2, 3, 4


% -> 'divide the first number by the second number, and return only the remainder'

so when i == 0, i%3 == 0.
i == 1, i%3 == 1
i == 2, i%3 == 2
i == 3, i%3 == 0
i == 4, i%3 == 1
etc.

Gleeok
06-08-2008, 06:18 AM
So if (15%3) returns 5, that translates into 2 how? By subtracting the % amount untill it's a smaller amount? I'm about (19%3)*12 percent following you. :p

Obviously I can see how to use it in scripts, but the specifics on how it returns only a number smaller than itself are playing hide.

Edit: Oh....that's right. Gotcha. Nevermind....I'll be sure to use that one. :D

Joe123
06-08-2008, 06:27 AM
So if (15%3) returns 5, that translates into 2 how? By subtracting the % amount untill it's a smaller amount? I'm about (19%3)*12 percent following you. :p

Obviously I can see how to use it in scripts, but the specifics on how it returns only a number smaller than itself are playing hide.




I don't think you're really getting this.

15%3.

15/3 == 5, remainder 0.
Therefore 15%3 == 0.
I never said it was 2.

19%3.

19/3 == 6, remainder 1.
Therefore 19%3 == 1.

19%3*12 == 12.

12 percent following me isn't good =P


It doesn't return 'only a number smaller than itself', the idea is that it returns a repeating cycle, which is why it's useful in the application I showed earlier.
You want a repeating cycle so that you get d, d+40, d+80.
You could do that with if's, but it'd be really awkward, and you might as well use your method without the array.
%3 creates a repeating cycle of 3.

Gleeok
06-08-2008, 06:34 AM
Yeah, I just figured that out, Thanks though.

You see, there's plenty of books on the shelf, but most of them are pretty dusty and need to be wiped off a good deal before you can make sense of them.


..Others have too much water damage and aren't legible at all. XD




Also the point was that the data, cset were unknown for all 12 ffcs, so it was easier to just press Ctrl-V 11 times than to re-write a loop god knows how many times....it's happened before.


EDIT: ..Also I think you've gone array-happy or something. Maybe just tone down the arrays just a little.

Joe123
06-08-2008, 06:44 AM
Using arrays is much easier =P

If you can generalise and use maths instead of writing out lots of code, it's much better.

Gleeok
06-08-2008, 06:52 AM
Using arrays is much easier =P

If you can generalise and use maths instead of writing out lots of code, it's much better.

Hindsight is always 20/20. ;) You can't write out an impromptu before it's played.


I still disagree with the arrays though. Everything else besides that one chunk of code is in it's own little tidy loop.



...And fine, I'll edit in your 'condensed' modulous version. ...Actually, nope. :tongue: You forgot the modulous maths for the csets. :P

Joe123
06-08-2008, 06:57 AM
Heh, I didn't actually read through the rest of it I'm afraid.
It's too big and there's nothing to show what it actually does.

Apart from actually opening up the quest, and I'm far too lazy to do that.

Gleeok
06-08-2008, 07:20 AM
Unfortunately, that's always going to be a problem for custom scripts. But what's the alternative? Not post anything at all? I've been trying to reduce lots of code into functions, as that's something that is easy to use and customise, but you still need to know some scripting to use them. Some of this is completely useless to someone who knows nothing about zscript, but really though, bottom line is that the code is here. In a year from now someone will play the game and want to know what the scripts look like, and they'll be here.



It's too big and there's nothing to show what it actually does.

Pssh!! You need to read outside the code tags. Link is in my sig. :)

Joe123
06-08-2008, 07:24 AM
Oh...

Read outside the code tags.
Now why didn't I think of that *slaps self*

C-Dawg
06-08-2008, 11:59 AM
Those first few utility functions rock the fucking house and I am going to be abusing them immediately for use in Zodiac.

Hooray for re-making code from scratch as stuff improves!

lucas92
06-08-2008, 02:17 PM
Am I dreaming or the screen is scrolling?! If it is the case, is there some hope of z3 screen scrolling?

C-Dawg
06-08-2008, 02:25 PM
Screen scrolling : Sorta.

Z3 Movement : Nope, unless you feel like re-scripting solidity, enemy movement, and combo types from scratch.

lucas92
06-08-2008, 07:46 PM
^Hum, what's about that?

http://youtube.com/watch?v=NudLNcHcrcs

o:

The_Amaster
06-08-2008, 07:58 PM
Unfortunatly thats more jury-rigged eye-candy than anything. Solidity is non-existent and I don't think enemies even worked. Extremely impressive techniclly, but not much use practicaly...

*sigh* Maybe someday...

C-Dawg
06-08-2008, 10:00 PM
Like I said before... yes, you can do scrolling graphics fairly easily. But to get true Z3 scrolling you'd need to scrap almost everything ZC does for you. Possible? Absolutely. But it'd be a ton of work, and you'd be scripting from scratch everything from solidity to secret flags, combos to enemy spawning.

Gleeok
06-11-2008, 06:26 PM
Psuedo solidity, coming soon. Useful for moving walls that can crush the player, multiple paths (decide quick!!) in scrolling shooters, and much much more.


In the meanwhile, these fun little things are used in level 2 by the "tank like" enemies and a wip 'no-tile enemy' boss. Aptly named "Degree_Buster, and Degree_Buster_Buster". Anyone get the reference?

The first will take a degree, modify it so that it is ten degrees closer to target x,y, and finally return that modified number.

The second will take a radian value, compare that with target x,y, and return that value with a difference of 1/36th.

You gotta love flying tanks. :D



int Degree_Buster(int targetx, int targety, int originx, int originy, int firing_degree){

int atan = ArcTan(targetx-originx,targety-originy)*(180/PI);
while(atan<0)atan+=360;
while(firing_degree<0)firing_degree+=360;
while(firing_degree>360)firing_degree-=360;
if(Abs(firing_degree-atan)>180){
if(atan>firing_degree)return (firing_degree-10);
else return (firing_degree+10);
}
else if(Abs(firing_degree-atan)>10){
if(atan>firing_degree)return (firing_degree+10);
else return (firing_degree-10);
}
else return atan;
}



int Degree_Buster_Buster(int targetx, int targety, int originx, int originy, int rad_angle){

int atan = ArcTan(targetx-originx,targety-originy);
if(Abs(rad_angle-atan)>PI){
if(atan>rad_angle)return (rad_angle-0.1745);
else return (rad_angle+0.1745);
}
else if(Abs(rad_angle-atan)>0.1745){
if(atan>rad_angle)return (rad_angle+0.1745);
else return (rad_angle-0.1745);
}
else return atan;
}

Joe123
06-11-2008, 06:29 PM
So the second one is just the same, but in radians?

Gleeok
06-11-2008, 06:38 PM
So the second one is just the same, but in radians?

Yep. They do the same exact thing exept for the type of value you input and they return. ^_^

I realized after using the first one that I'd need the second to save on space for some other stuff, and for a boss. Betcha can't eat just one!

Schwa
07-01-2008, 03:18 AM
GEEZ, you guys are hardcore! :odd: I know enough scripting to get by, but this stuff is overkill... I feel like I don't belong here at AGN... X_X

I wish I could tell you how great you are, Gleeok, but you lost me a few pages ago...