but how do I modify it to place a level 2 bomb?
Level 2 bomb as in more powerful? As in super bomb? Or as in, sets off different triggers and yet still does all the stuff a normal bomb does?
The first one doesn't needs a script. You can do that with item editor and just apply the existing script to its item action slot.
The second one would need to be an alteration of the script that you have.
//D0: SFX to play when Link places a Bomb
item script SpawnLWeaponSBomb{
void run(int sound){
//You have more than one bomb and there are no bombs on screen.
if(Game->Counter[CR_SBOMBS] >0 && NumLWeaponsOf(LW_SBOMB)==0){
Game->PlaySound(sound);//Play the sound.
//Spawn the bomb in front of Link and set the damage.
lweapon bomb = Screen->CreateLWeapon(LW_SBOMB);
bomb->X = Link->X+ InFrontX(Link->Dir,0);
bomb->Y = Link->Y+ InFrontY(Link->Dir,0);
bomb->Damage = SBOMB_DAMAGE;
//Reduce in-game counter.
Game->Counter[CR_SBOMBS]--;
}
}
}
The third would be a bit more complex, but it's also doable. Here's a sample script, which allows for the interaction of multiple scripted items and a triggering ffc.
ffc script Variable_Index_Trigger{
void run(int type, int level, int perm){
lweapon thing;
int i;
bool triggered = false;
if(Screen->D[perm]!=0)triggered = true;
while(!triggered){
for(i = 1;i<=Screen->NumLWeapons();i++){
thing = Screen->LoadLWeapon(i);
if(thing->ID ==type && thing->Misc[LW_MISC_LEVEL_INDEX]>=level
&& Collision(this,thing))triggered = true;
}
Waitframe();
}
Screen->TriggerSecrets();
Screen->State[ST_SECRET]= true;
Screen->D[perm] = 1;
}
}
To get this to work with bombs and super bombs, you'd need to assign a value to the Misc index of an LW_BOMBBLAST and LW_SBOMBBLAST that corresponded to the correct level of the item. To do that requires some shenanigans.
First, change the item script like so...
item script SpawnLWeaponSBomb{
void run(int sound,int level){
//You have more than one bomb and there are no bombs on screen.
if(Game->Counter[CR_BOMBS] >0 && NumLWeaponsOf(LW_BOMB)==0){
Game->PlaySound(sound);//Play the sound.
//Spawn the bomb in front of Link and set the damage.
lweapon bomb = Screen->CreateLWeapon(LW_BOMB);
bomb->X = Link->X+ InFrontX(Link->Dir,0);
bomb->Y = Link->Y+ InFrontY(Link->Dir,0);
bomb->Damage = BOMB_DAMAGE;
bomb->Misc[LW_MISC_LEVEL_INDEX]= level;
//Reduce in-game counter.
Game->Counter[CR_BOMBS]--;
}
}
}
Then add this to the global script...
void Bomb_Level(){
for(i = 1;i<=Screen->NumLWeapons();i++){
thing = Screen->LoadLWeapon(i);
if(thing->ID ==LW_BOMB && thing->DeadState ==0){
lweapon other = CreateLWeapon(LW_BOMBBLAST);
other->X = thing->X;
other->Y = thing->Y;
other->Damage = thing->Damage;
other->Misc[LW_MISC_LEVEL_INDEX] = thing->Misc[LW_MISC_LEVEL_INDEX];
}
}
All of this is untested. I'm not even sure you can check for the value of the weapon's deadstate that way. I'll have to experiment with it on my own time.
Edited by ywkls, 17 June 2016 - 06:51 PM.