PDA

View Full Version : Editable Ganon enemy script?



Binx
04-30-2013, 05:20 AM
Ok, I already asked about this in a help thread, but for the sake of clarity, I was looking for a Ganon-like enemy script that would behave exactly like Ganon, but *not* be attached to a specific room type. and Zim was kind enough to give me this script:




import std.zh;
int HS;//Has Spawned.
void ES(int a, int b, int c,int d,int e,int f, int g) //ES stands for Enemy Spawn
{
if(Game->GetCurScreen()==d&&Game->GetCurDMap==e&&HS==f)
{npc En=Screen->CreateNPC(a);En->X=b;En->Y=c;}
if(Screen->NumNPCs>0)
{HS=g;
if(Link->HP==0){HS=f;}//This line is so that if Link dies on the screen HS returns to it's previous state so
//Ganon will spawn again if Link fails to defeat him.
}//resets HS to g, so that 1)Ganon won't spawn twice,
//2)so that HS can be reused on a different screen AFTER this num is changed.
//this function places NPC #A at coordinates (b,c) on Screen d of DMap e if HS is equal to f.
}

global script GANON
void run()
{
while(true)
{
ES(78,64,64,1,2,0,1);//Ganon's Enemy # is 78,
//so this script would Spawn Ganon at (64,64) x,y, on Screen 1, Dmap 2, while HS==F, resets HS to numeral g, and back to f if Link fails.
Waitframe(); //Waitframe is a must usually, or the game will freeze.
}
//the void ES itself could also fit into this space instead of out of the global script, making it exclusive to the global, which is not optimum
//if the scripter likes to use voids inside of other voids that aren't in the global itself.
}


Now, I haven't implemented it yet, for two reasons: A) I'm not that far into the quest, yet and B) I'm a little confused on how it works... Would this enemy be editable in the ordinary sense? Like could I alter its weaknesses, graphics or csets? or would it just give me the ability to use the "Ganon" enemy already present without a "Ganon" room? Ideally, I'd like to have 4 different final boss enemies, each with a weakness to a different type of weapon, rather than the silver arrow for all of them. I also plan to use Ganon himself, as an ultimate boss, but I wanted to upgrde his weakness to the golden arrow, since by that point in the game, the silver arrow would be almost weak.

Which brings me to the major point of this whole thread, and the reason I need all those questions answered: Assuming I CAN make an "Ultimate Ganon" with crazy hp and power, and different weaknesses, would it be possible to make a script that will connect THAT enemy with the "Ganon" room type?

EDIT: The demo is currently here:
http://armageddongames.net/showthread.php?95609-The-Legend-of-Zelda-Trials-of-the-Gods
if my rambling is unclear.

Zim
05-01-2013, 05:59 PM
The code would spawn an enemy at the screen and dmap of enemy # as per the args of the script.


global script GANON
void run()
{
while(true)
{
ES(78,64,64,1,2,0,1);//Ganon's Enemy # is 78, X is 64, Y is 64, on screen 1 of Dmap 2, happens only if HS == 1 (is equal to 0), and then sets HS=1; if and when Ganon is defeated.
ES(78,80,80,11,3,1,2);//Ganon's Enemy #, X is 80, Y is 80, on screen 11 of Dmap 3, happens only if HS == 1 (is equal to 1), and then sets HS=1; if and when Ganon is defeated again.
ES(138,80,80,4,2,2,3);//Spawns enemy # 138 (which could be a Ganon clone) at 80,80 x,y, screen 4 of DMap 2 if HS==2; Sets HS to 3.
ES(139,80,80,50,3,3,2);//Spawns enemy # 139 (which could be a Ganon clone) at 80,80 x,y, screen 50 of DMap 3 if HS==3; Sets HS to 2.
ES(50,80,80,0,0,3,0);//Spawns enemy # 150 (which is by default a darknut) at 80,80 x,y, screen 0 of DMap 0 if HS==3; Sets HS to 0.
InfiniteEnemies(50,15,40,3, 120);//spawns a Darknut, up to 15 darknuts, on screen 40, dmap 3, every 2 seconds
Vulnerability(78,57,16, 60)//Makes Enemy 78 (Ganon) vulnerable to weapon 57 (Golden Arrow) for 16 additional damage, and can happen every 60 tics (one second)
Waitframe();
}
}


This code in as your global would spawn 4 different Ganons at the 4 locations indicated by the args in the script as described.
2 of them being the same original Ganon, enemy number 78, the second two would be doubles of ganon with perhaps different homing, HP, damage, etc, that are basically duplicate enemies with different graphics even or whatever that use the Ganon Enemy type, just use a custom enemy, also the enemy could be any number.
The fifth call to the script is just another example for your learning sake, the enemy number is 50, so that line would spawn a Darknut at coordinates 80,80 x,y, on screen 0 of dmap 0 IF HS is equal to 3 already, (which would be after the first three ganons are defeated already in sequence if set this way), and then would reset the HS digit back to 0 if this spawned darknut is defeated, making the other Ganons respawn again once their rooms are entered starting with number 1. (Just wanted to show you an example of how the last trigger-set trigger digits in the parenthesis can be used for other methods aside from a sequential enemy placement/defeat system.)
like this:


void InfiniteEnemies(int a,int b, int c, int d, int e)
{
if(Screen->NumNPCs()<b)
{ES(a,Rand(239),Rand(159),c,d,1,1); Waitframes(e);}
}

That script will put endless amounts of enemy #a until at least b of them are there on screen c of dmap d every e tics.
60 tics is one second so setting e to 120 would spawn an enemy of number a every two seconds that there isn't already a maximum of b on the screen.

So yes, it does spawn an enemy regardless of the Ganon will spawn flag of the enemy, this script will spawn any enemy of any number on any screen, as long as the other prerequisites are met.



void Vulnerability(int a, int b, int c, int d)
{
for(int i=1;i<=Screen->NumNPCs();i++)
{
for(int z=1;z<=Screen->NumLWeapons();z++)
{
lweapon AnyL=Screen->LoadLWeapon(z);
npc Enemy=Screen->LoadNPC(i);
if(Enemy->ID==a&&AnyL==b&&Collision(Enemy,AnyL))
{
Enemy->HP-=c;Waitframes(d);
}
}
}
}

I haven't tried this but I'm pretty sure this other code

Binx
05-01-2013, 07:13 PM
Thanks a ton! I've been trying to get through Saffith's tutorial, but I keep getting lost on functions with a lot of arguments, like rectangles and circles, it's nice to see them all explained for us dummies, lol.