PDA

View Full Version : Various scripts of doom.



Gleeok
11-17-2007, 09:28 AM
These are pretty well explained in the footnotes so read them first and i'll be happy to answer any questions if you need help past that point.

And without further ado, I give you more scripts. Yay!


First item up for bid is the enemy_spawner mark III:




//================================================== =====
// ENEMY SPAWNER 3- Will spawn a preset amount of enemies
// from a pool of 3, chosen at random.
// Will place enemies at random locations if walkable.
// D0-D2; Enemies that might spawn,
// D3; Delay in ticks between spawns
// D4; Max number of enemies that will spawn.
// Thanks C-Dawg!
//================================================== =====


ffc script enemyspawner3 {
void run(int e1, int e2, int e3, int delay, int enemy_count ) {
int RandNum = Rand(3);
int en_count = enemy_count;
int counter = delay;

while(en_count > 0){

if ( counter == 0 && RandNum == 0){
putenemy(e1);
counter = delay;
RandNum = Rand(3);
en_count = en_count - 1;
}if ( counter == 0 && RandNum == 1){
putenemy(e2);
counter = delay;
RandNum = Rand(3);
en_count = en_count - 1;
}if ( counter == 0 && RandNum == 2){
putenemy(e3);
counter = delay;
RandNum = Rand(3);
en_count = en_count - 1;
}
counter--;
Waitframe();
} // end of while loop
}

void putenemy(int eid){

int x = Rand(12)+2;
int y = Rand(7)+2;
while(!is_walkable(x,y))
{
x = Rand(12)+2;
y = Rand(7)+2;
}
npc en = Screen->CreateNPC(eid);
if(en->isValid())
{
en->X = x*16;
en->Y = y*16;
}
}
bool is_walkable(int x, int y)
{
return Screen->ComboS[x+y*16]==0;
}
}

This ones sure to be popular with the ladies.


Our next item is the Sentry script. aka; the veg-o-matic! If you use this and still don't know why I call it the veg-o-matic, well, then I know something you don't know. :p



// FFC SCRIPT VEG-O-MATIC---------------------------------------
//D0- vertical guard set 1
//D1- horizontal guard set 1 *NOT BOTH!!!*
//D2- set 1 if can fire weapons
//D3- combo of weapon if d2
//D4- speed of weapon projectile if d2
//D5- time in tics between shots
//D6- CSet of weapon projectile
//D7- the starting ffc to use for projectiles
//---------------------------------------------------------

ffc script Veg_O_Matic{

void run(int vert, int horiz, int armed, int weapon_combo, int speed, int rapid, int cset, int ffc_to_use){

ffc shoot;
int ffc_cycle = ffc_to_use;
int delay = 0;

while(true){

delay++;
if(ffc_cycle >= ffc_to_use+4){ ffc_cycle = ffc_to_use;}

if(vert == 1){ if(this->Y > Link->Y+2){ this->Y--;} if(this->Y < Link->Y-2){ this->Y++;}}
if(horiz == 1){ if(this->X > Link->X+2){ this->X--;} if(this->X < Link->X-2){ this->X++;}}

if(armed == 1){
if(vert == 1){
if(delay == rapid && Link->X > this->X){
shoot = Screen->LoadFFC(ffc_cycle);
shoot->Data = weapon_combo;
shoot->Y = this->Y; shoot->X = this->X + 16;
shoot->Vx = speed;
shoot->CSet = cset;
ffc_cycle++;
delay = 0;
}
if(delay == rapid && Link->X < this->X){
shoot = Screen->LoadFFC(ffc_cycle);
shoot->Data = weapon_combo;
shoot->Y = this->Y; shoot->X = this->X - 16;
shoot->Vx = -speed;
shoot->CSet = cset;
ffc_cycle++;
delay = 0;
}
}
if(horiz == 1){
if(delay == rapid && Link->Y > this->Y){
shoot = Screen->LoadFFC(ffc_cycle);
shoot->Data = weapon_combo;
shoot->Y = this->Y + 16; shoot->X = this->X;
shoot->Vy = speed;
shoot->CSet = cset;
ffc_cycle++;
delay = 0;
}
if(delay == rapid && Link->Y < this->Y){
shoot = Screen->LoadFFC(ffc_cycle);
shoot->Data = weapon_combo;
shoot->Y = this->Y - 16; shoot->X = this->X;
shoot->Vy = -speed;
shoot->CSet = cset;
ffc_cycle++;
delay = 0;
}
}
}
Waitframe();
}
}
}


Ok, Ok, I know what you're thinking right now: "How can I get 255(or is that 256?) enemies on the screen at once and center them on an enemy and set that enemies HP to any obscene amount I want"? Well alrighty then, ask and ye shall recieve.


Flamethrower script:



//=======================================
// FFC SCRIPT FLAMETHROWER
//D0- minions to spawn (id number)
//D1- HP of the summoner
//D2- Max enemies on screen at once
//=======================================


ffc script Flamethrower{

void run(int enemy_id, int enemyHP, int enemy_swarm){

int enemy_number = 0;
npc enemy;

int slow_slowdown=0;
int death = 0;

Waitframes(4);

npc fire_master = Screen->LoadNPC(1);
npc firestorm;
fire_master->HP = enemyHP;

while(true){

if(fire_master->isValid() || fire_master->HP >0){

this->X = fire_master->X; this->Y = fire_master->Y;

if(Screen->NumNPCs() < enemy_swarm){ npc firestorm = Screen->CreateNPC(enemy_id);}

firestorm->X = this->X;
firestorm->Y = this->Y;
}
else{ death = 1;}

enemy_number = Screen->NumNPCs();

while(enemy_number > 1){

enemy = Screen->LoadNPC(enemy_number);
enemy->X = this->X; enemy->Y = this->Y;

if(death == 1){enemy->HP = 0;Screen->ClearSprites(2);}

enemy_number--;

if(enemy_number > 30){
if(slow_slowdown == 0){ slow_slowdown = enemy_number; Waitframe();}
slow_slowdown--;
}
}
Waitframe();
}
}
}

And now to make sure Link walks around in circles while being forced to repeadedly battle these baddies:

Random door generator:




//------------------------------------------------------
// Creates 1-3 closed shutters in a random direction as
// long as there is a wall.-along with a one-way wherever link enters from.
// Once the enemies have been killed the shutter will open.
// This will not overwrite essential doors added for specific dungeon map layouts :)
// For best results run at *SCREEN INIT*
// Not used yet/ -random locked doors, boss doors, open doors-
//------------------------------------------------------

ffc script random_door_generator{ //ver2.1

void run(){

int ddoor = 0;
int udoor = 0;
int ldoor = 0;
int rdoor = 0;
int RandNum = Rand(4);

if (Link->Dir == 0 && Screen->Door[DIR_DOWN] == D_WALL){ ddoor = 1;}
if (Link->Dir == 1 && Screen->Door[DIR_UP] == D_WALL){ udoor = 1;}
if (Link->Dir == 2 && Screen->Door[DIR_RIGHT] == D_WALL){ rdoor = 1;}
if (Link->Dir == 3 && Screen->Door[DIR_LEFT] == D_WALL){ ldoor = 1;}

if (RandNum == 0 && Screen->Door[DIR_DOWN] == D_WALL){ Screen->Door[DIR_DOWN] = D_SHUTTER;}
if (RandNum == 0 && Screen->Door[DIR_UP] == D_WALL){Screen->Door[DIR_UP] = D_SHUTTER;}
if (RandNum == 1 && Screen->Door[DIR_RIGHT] == D_WALL){Screen->Door[DIR_RIGHT] = D_SHUTTER;}
if (RandNum == 1 && Screen->Door[DIR_LEFT] == D_WALL){Screen->Door[DIR_LEFT] = D_SHUTTER; }
if (RandNum == 2 && Screen->Door[DIR_DOWN] == D_WALL){Screen->Door[DIR_DOWN] = D_SHUTTER;}
if (RandNum == 2 && Screen->Door[DIR_UP] == D_WALL){Screen->Door[DIR_UP] = D_SHUTTER;}
if (RandNum == 2 && Screen->Door[DIR_RIGHT] == D_WALL){Screen->Door[DIR_RIGHT] = D_SHUTTER;}
if (RandNum == 3 && Screen->Door[DIR_LEFT] == D_WALL){Screen->Door[DIR_LEFT] = D_SHUTTER;}
if (RandNum == 3 && Screen->Door[DIR_RIGHT] == D_WALL){Screen->Door[DIR_RIGHT] = D_SHUTTER;}
if (RandNum == 3 && Screen->Door[DIR_UP] == D_WALL){Screen->Door[DIR_UP] = D_SHUTTER; }

if (ddoor == 1){Screen->Door[DIR_DOWN] = D_1WAYSHUTTER;}
if (udoor == 1){Screen->Door[DIR_UP] = D_1WAYSHUTTER;}
if (rdoor == 1){Screen->Door[DIR_RIGHT] = D_1WAYSHUTTER;}
if (ldoor == 1){Screen->Door[DIR_LEFT] = D_1WAYSHUTTER; }
}
}


2.6 Armos script:



//======================================
// -ffc script Armos-
//D0 - id of enemy to create
//D1 - HP of created enemy
//======================================

ffc script Armos{

void run(int enemy_id, int enemyHP){

int trigger = 0;
npc armos;

while(true){

if(trigger == 0){

if( Abs(Link->X - this->X) <= 16 && Abs(Link->Y - this->Y) <= 16){
npc armos = Screen->CreateNPC(enemy_id);
armos->X = this->X; armos->Y = this->Y;
armos->HP = enemyHP;
this->Data=0;trigger=1;
}
}
Waitframe();
}
}
}


New one, Custom Armos. This one will get used...alot. I'm sure of it. ;)

I guess it's true with scripts anyway; It's not how big it is, it's how you use it. :laughing:



//================================================== ================================
// FFC SCRIPT SENTRY
//
// D0 - Direction can shoot / values greater than 3 return up,down,left,right.
// D1 - combo of weapon projectile
// D2 - speed of projectile
// D3 - CSet of projectile
// D4 - First of 3 ffc's to use as projectiles
//================================================== ================================

ffc script Sentry{

void run(int shoot_dir, int weapon_combo, int speed, int cset, int ffc_to_use){

ffc shoot;
int ffc_cycle = ffc_to_use;
int delay = 0;

while(true){

if(ffc_cycle >= ffc_to_use+3){ ffc_cycle = ffc_to_use;}
if(delay > 0){delay--;}


if(shoot_dir > 3 && delay == 0){

if(Abs(Link->X-this->X)<14 && Link->Y < this->Y && canMove(this->X, this->Y-16)) // Up
{
shoot = Screen->LoadFFC(ffc_cycle);
shoot->Data = weapon_combo;
shoot->Y = this->Y - 16; shoot->X = this->X;
shoot->Vy = -speed; shoot->Vx=0;
shoot->CSet = cset;
ffc_cycle++;
delay = 30;
}
else if(Abs(Link->X-this->X)<14 && Link->Y > this->Y && canMove(this->X, this->Y+16)) // Down
{
shoot = Screen->LoadFFC(ffc_cycle);
shoot->Data = weapon_combo;
shoot->Y = this->Y + 16; shoot->X = this->X;
shoot->Vy = speed; shoot->Vx=0;
shoot->CSet = cset;
ffc_cycle++;
delay = 30;
}
else if(Abs(Link->Y-this->Y)<14 && Link->X < this->X && canMove(this->X-16, this->Y)) // Left
{
shoot = Screen->LoadFFC(ffc_cycle);
shoot->Data = weapon_combo;
shoot->Y = this->Y; shoot->X = this->X - 16;
shoot->Vx = -speed; shoot->Vy=0;
shoot->CSet = cset;
ffc_cycle++;
delay = 30;
}
else if(Abs(Link->Y-this->Y)<14 && Link->X > this->X && canMove(this->X+16, this->Y)) // Right
{
shoot = Screen->LoadFFC(ffc_cycle);
shoot->Data = weapon_combo;
shoot->Y = this->Y; shoot->X = this->X + 16;
shoot->Vx = speed; shoot->Vy=0;
shoot->CSet = cset;
ffc_cycle++;
delay = 30;
}
}
else{
if(shoot_dir==0 && delay == 0){
if(Abs(Link->X-this->X)<14 && Link->Y < this->Y && canMove(this->X, this->Y-16)){
shoot = Screen->LoadFFC(ffc_cycle);
shoot->Data = weapon_combo;
shoot->Y = this->Y - 16; shoot->X = this->X;
shoot->Vy = -speed; shoot->Vx=0;
shoot->CSet = cset;
ffc_cycle++;
delay = 30;
}
}
else if(shoot_dir==1 && delay == 0){
if(Abs(Link->X-this->X)<14 && Link->Y > this->Y && canMove(this->X, this->Y+16)){
shoot = Screen->LoadFFC(ffc_cycle);
shoot->Data = weapon_combo;
shoot->Y = this->Y + 16; shoot->X = this->X;
shoot->Vy = speed; shoot->Vx=0;
shoot->CSet = cset;
ffc_cycle++;
delay = 30;
}
}
else if(shoot_dir==2 && delay == 0){
if(Abs(Link->Y-this->Y)<14 && Link->X < this->X && canMove(this->X-16, this->Y)){
shoot = Screen->LoadFFC(ffc_cycle);
shoot->Data = weapon_combo;
shoot->Y = this->Y; shoot->X = this->X - 16;
shoot->Vx = -speed; shoot->Vy=0;
shoot->CSet = cset;
ffc_cycle++;
delay = 30;
}
}
else if(shoot_dir==3 && delay == 0){
if(Abs(Link->Y-this->Y)<14 && Link->X > this->X && canMove(this->X+16, this->Y)){
shoot = Screen->LoadFFC(ffc_cycle);
shoot->Data = weapon_combo;
shoot->Y = this->Y; shoot->X = this->X + 16;
shoot->Vx = speed; shoot->Vy=0;
shoot->CSet = cset;
ffc_cycle++;
delay = 30;
}
}
}
Waitframe();
}
}
bool canMove(int x, int y)
{
if(x<0 || x>240 || y<0 || y>160)
return false;

return Screen->ComboS[y+(x>>4)]==0;
}
}


Unlike the Veg-O-Matic, this one is stationary.


Enjoy!




.

Gleeok
11-19-2007, 08:08 AM
Update: Two more scripts plus a slight revision to another one.

Custom Armos, and Sentry. The sentry is stationary and only fires if link is within it's line of fire. The Armos script will make standard ZC armos obsolete untill at least zc ver3.0.

Gleeok
12-21-2007, 08:36 PM
Another minor update:


ffc script f_throw_cycle{

void run(int target_ffc, int offset){

ffc target = Screen->LoadFFC(target_ffc);
int og_data = target->Data;
npc shooter;
npc remove_shooter;
int enemy_number;
int shooter_number = 0;

while(true){

if(target->Data == og_data+offset){

while(shooter_number < 25){

npc shooter = Screen->CreateNPC(83);
shooter->X=this->X;shooter->Y=this->Y;
shooter_number++;
}
enemy_number = Screen->NumNPCs();

while(enemy_number > 1){

npc remove_shooter = Screen->LoadNPC(enemy_number);

if(remove_shooter->Tile==0){
remove_shooter->X=this->X;
remove_shooter->Y=this->Y;
}
enemy_number--;
}

}
else{

enemy_number = Screen->NumNPCs();

while(enemy_number > 1){

npc remove_shooter = Screen->LoadNPC(enemy_number);

if(remove_shooter->Tile==0) remove_shooter->HP = 0;
enemy_number--;
}
shooter_number = 0;
}
Waitframe();
}
}
}

Flamethrower mark II;

Will create a fire stream if the ffc's combo has cycled to the appropriate combo. Much faster than mark I, as all the shooters are generated instantaniously.

D0 - target ffc to watch for change.
D1 - offset of combo to trigger th fire stream.




ffc script string_defeated{

void run(int m){

Waitframes(6);
while(Screen->NumNPCs() > 0) Waitframe();
Screen->Message(m);
Waitframe();

}
}

A simple script that will play a message when all the screen enemies are killed.

D0 - string to play.



//================================================== ======================
// FFC SCRIPT AUTO-FORK
//D0 - proximity to Link at which this ffc forks *in pixels*
//D1 - speed of this ffc velocity during pursuit
// leaving these values at 0 will let the script set them automatically!
//================================================== ======================

ffc script ffc_auto_fork{

void run(int speed){

int delay = 30;
int state = 0;

if(speed == 0){speed = 2;}

while(true){


if(this->Y > 168||this->Y < 0||this->X > 248||this->X < 0){
this->X = 0; this->Y = 0; this->Vx = 0; this->Vy = 0;
this->Data = 1; state = 0; delay = 60;
}
if(state == 0){

if(this->Vx > 0 || this->Vy > 0 || this->Vx < 0 || this->Vy < 0){

if(delay > 0){ delay--;}

if(delay == 0){state = 1;delay = 30;}
}
}
if(state == 1){

if(delay > 0){
delay--;
this->Vx = 0;
this->Vy = 0;
}
if(delay == 0){

int dx = Link->X - this->X;
int dy = Link->Y - this->Y;
float norm = Sqrt(dx*dx+dy*dy);
if(norm > 0)
{
this->Vx = dx/norm*speed;
this->Vy = dy/norm*speed;
}
state = 2;
}
}
Waitframe();
}
}
}


Will automaticall re-route the ffc toward Link after 30 ticks if it's velocity is non-zero.


Enjoy!

C-Dawg
12-23-2007, 08:55 PM
Awesome stuff. I'll check some of these out after the holidays.