Jump to content

Photo

Power Bomb


  • Please log in to reply
21 replies to this topic

#16 Blackpaintbowser

Blackpaintbowser

    Go Bowser Go

  • Members
  • Location:somewhere in the world

Posted 26 December 2021 - 01:03 PM

here's my script:

int NewFFCScript(int scriptNum, float args){
    // Invalid script
    if(scriptNum<0 || scriptNum>511)
        return 0;
    
    ffc theFFC;
    
    // Find an FFC not already in use
    for(int i=FFCS_MIN_FFC; i<=FFCS_MAX_FFC; i++){
        theFFC=Screen->LoadFFC(i);
        
        if(theFFC->Script!=0){
// if(theFFC->Script!=BLANK_SCRIPT)
continue;
if(theFFC->Data!=0){
if(theFFC->Data!=FFCS_INVISIBLE_COMBO)
continue;
}
if(theFFC->Flags[FFCF_CHANGER])
continue;
        }
        // Found an unused one; set it up
        theFFC->Data=FFCS_INVISIBLE_COMBO;
theFFC->TileWidth = 1;
theFFC->TileHeight = 1;
        theFFC->Script=scriptNum;
        
        if(args!=NULL){
            for(int j=Min(SizeOfArray(args), 8)-1; j>=0; j--)
                theFFC->InitD[j]=args[j];
        }
        theFFC->Flags[FFCF_ETHEREAL]= true;
        return i;
    }
    
    // No FFCs available
    return 0;
}
 
//Test if one location is between two others.
//D0- Location to test
//D1- Lower bound
//D2- Higher bound
 
bool Between(int loc,int greaterthan, int lessthan){
if(loc>=greaterthan && loc<=lessthan)return true;
return false;
}
 
const int POWER_BOMB_CENTER_X= 1;
const int POWER_BOMB_CENTER_Y= 2;
const int POWER_BOMB_RADIUS  = 3;
 
int GameVars[65536];
 
const int GEN_MISC_FLAGS = 0;//Index used to set various flags. Shared by all objects.
const int NPC_F_PB         = 00000000100b;//An enemy hit by a power bomb.
const int SPRITE_NULL = 0;
 
item script PowerBomb{
void run(int script_num, int damage, int sfx){
if(Game->Counter[CR_SBOMBS]>=1){
Game->Counter[CR_SBOMBS]--;
//Start power bomb wave.
if(GameVars[POWER_BOMB_RADIUS]==0)
GameVars[POWER_BOMB_RADIUS]=8;
                        Game->PlaySound(sfx);
if(CountFFCsRunning(script_num)==0){
int Args[8]= {damage};
NewFFCScript(script_num, Args);
}
}
}
}
 
ffc script PowerBombFX{
void run(int damage){
int i;
npc n;
this->X= Link->X+8;
this->Y= Link->Y+8;
GameVars[POWER_BOMB_CENTER_X]- this->X;
GameVars[POWER_BOMB_CENTER_Y]- this->Y;
while(true){
//The wave hasn't been created yet.
if(GameVars[POWER_BOMB_RADIUS]!=0){
//If the wave hasn't reached it's edge yet.
if(GameVars[POWER_BOMB_RADIUS]<200){
Screen->Circle(4, GameVars[POWER_BOMB_CENTER_X], 
GameVars[POWER_BOMB_CENTER_Y], GameVars[POWER_BOMB_RADIUS], 
((GameVars[POWER_BOMB_RADIUS]/10)%16), 1, 0, 0, 0, true, 64);
GameVars[POWER_BOMB_RADIUS]+=4;
}
//This power bomb has gone off.
else{
GameVars[POWER_BOMB_RADIUS]= 0;
for(i = Screen->NumNPCs();i>0;i--){
n = Screen->LoadNPC(i);
if((n->Misc[GEN_MISC_FLAGS]&NPC_F_PB)!=0)
n->Misc[GEN_MISC_FLAGS]&=~NPC_F_PB;
}
}
//Mark and damage enemies in range.
for(i = Screen->NumNPCs();i>0;i--){
n = Screen->LoadNPC(i);
if((n->Misc[GEN_MISC_FLAGS]&NPC_F_PB)==0  
&& Between(n->X+(n->HitWidth/2),GameVars[POWER_BOMB_CENTER_X]-GameVars[POWER_BOMB_RADIUS],GameVars[POWER_BOMB_CENTER_X]+GameVars[POWER_BOMB_RADIUS])
&& Between(n->Y+(n->HitHeight/2),GameVars[POWER_BOMB_CENTER_Y]-GameVars[POWER_BOMB_RADIUS],GameVars[POWER_BOMB_CENTER_Y]+GameVars[POWER_BOMB_RADIUS]) 
&& n->Defense[NPCD_SBOMB]==NPCDT_NONE){
lweapon w = CreateLWeaponAt(LW_SCRIPT3,n->X+(n->HitWidth/2),n->Y+(n->HitHeight/2));
w->Damage = damage;
w->UseSprite(SPRITE_NULL);
n->Misc[GEN_MISC_FLAGS]|=NPC_F_PB;
}
}
//Set off secrets if in range of blast.
for(i = 0;i<175;i++){
if(Abs(ComboX(i)-GameVars[POWER_BOMB_CENTER_X])<GameVars[POWER_BOMB_RADIUS]
&& Abs(ComboY(i)-GameVars[POWER_BOMB_CENTER_Y])<GameVars[POWER_BOMB_RADIUS]){
if(ComboFI(i,CF_SBOMB) && !Screen->State[ST_SECRET]){
Screen->State[ST_SECRET]= true;
Screen->TriggerSecrets();
}
}
}
}
Waitframe();
}
}
}


#17 ywkls

ywkls

    Master

  • Members

Posted 27 December 2021 - 12:29 AM

Change this code:

GameVars[POWER_BOMB_CENTER_X]- this->X;
GameVars[POWER_BOMB_CENTER_Y]- this->Y;

To this code:

GameVars[POWER_BOMB_CENTER_X]= this->X;
GameVars[POWER_BOMB_CENTER_Y]= this->Y;

That should make it spawn correctly.



#18 Blackpaintbowser

Blackpaintbowser

    Go Bowser Go

  • Members
  • Location:somewhere in the world

Posted 27 December 2021 - 12:56 PM

all right, now it's spawning in the right spot, but if I use the item again on the screen it comes from the original spawn point. it's also getting rid of one of the ffcs on the screen


Edited by Blackpaintbowser, 27 December 2021 - 12:57 PM.


#19 ywkls

ywkls

    Master

  • Members

Posted 27 December 2021 - 04:19 PM

all right, now it's spawning in the right spot, but if I use the item again on the screen it comes from the original spawn point. it's also getting rid of one of the ffcs on the screen

There's no way to avoid the problem with the ffcs that I know of without making the script a global one.

Or one where it uses the same ffc every time.

I'm not really sure about the other part.



#20 Blackpaintbowser

Blackpaintbowser

    Go Bowser Go

  • Members
  • Location:somewhere in the world

Posted 02 April 2022 - 01:28 PM

I can make the script global



#21 Blackpaintbowser

Blackpaintbowser

    Go Bowser Go

  • Members
  • Location:somewhere in the world

Posted 03 May 2022 - 03:47 PM

There's no way to avoid the problem with the ffcs that I know of without making the script a global one.

Or one where it uses the same ffc every time.

I'm not really sure about the other part.

I really need to make it not get rid of the ffcs on the screen 



#22 Blackpaintbowser

Blackpaintbowser

    Go Bowser Go

  • Members
  • Location:somewhere in the world

Posted 30 July 2022 - 06:08 PM

I noticed that when I use the power bomb it's placing a ffc on the screen and when I use it again it doesn't get rid of it, maybe that's why the explosion comes from the first spot you use it on the screen  




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users