Jump to content

Photo

Eweapons ignoring Link


  • Please log in to reply
8 replies to this topic

#1 Mr. Z

Mr. Z

    Old Bastard is back!

  • Members
  • Real Name:Erik
  • Location:The Netherlands

Posted 12 June 2013 - 12:49 PM

I was working on custom damaging sprites, starting with the well known spinning wall of fire, but for some reason the fireballs aren't damaging Link.

 

const int FIREBALL_COMBO=48;

ffc script SpinningFireballs{
    void run(int amount, int distance, float angle, float speed, int damage){

        while(true){
        int radius=distance*16;

            for(int i=1; i<=amount; i++){

            eweapon e=Screen->CreateEWeapon(EW_SCRIPT1);
            e->X=this->X+(distance*radius)*Cos(angle);
            e->Y=this->Y+(distance*radius)*Sin(angle);
            e->Damage=damage;
            e->Tile=EMPTY_TILE;
            e->CollDetection=true;
            e->DeadState=2;

            Screen->FastCombo(3,this->X+(distance*radius)*Cos(angle),this->Y+(distance*radius)*Sin(angle),FIREBALL_COMBO,0,128);

            radius+=16;
            }

        angle+=speed;

        Waitframe();
        }
    }
} //SpinningFireballs
 

 

When I turn cheating on and check for hitboxes, ZC confirms that there are hitboxes, but Link doesn't interact with the fireballs at all. What am I doing wrong? I made sure Collision Detection is true, and even if I try using a longer Deadstate nothing happens.



#2 grayswandir

grayswandir

    semi-genius

  • Members

Posted 12 June 2013 - 12:57 PM

As far as I know, you need DeadState to be -1 for collision detection to work.



#3 Mr. Z

Mr. Z

    Old Bastard is back!

  • Members
  • Real Name:Erik
  • Location:The Netherlands

Posted 12 June 2013 - 01:06 PM

As far as I know, you need DeadState to be -1 for collision detection to work.

 

If I do that, the screen fills up with permanent hitboxes. This script creates a hitbox every frame and then deletes it 2 frames later. Which should work normally, but it doesn't work like zscript.txt or the wiki says it should. If I make a weapon that disappears after a certain amount of time, the hitbox never works.



#4 grayswandir

grayswandir

    semi-genius

  • Members

Posted 12 June 2013 - 01:10 PM

Exactly so. I just keep track of the timers manually.

 

I have something like this, with CLW_Update() in my global loop.

(But for eweapons, obviously)

Spoiler


#5 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 12 June 2013 - 01:11 PM

I recommend adding a timeout function to your global script, and then setting a timeout on each flame. To save time, here's my timeout code:

 

//Misc weapon stuff
const int LW_MISC_TIMEOUT = 7;
const int LW_MISC_PIERCE = 6;
 
//Put this in your global while(true)
            //Weapon checks
            for ( int i = Screen->NumLWeapons(); i > 0; i-- ){
                lweapon weap = Screen->LoadLWeapon(i);
                
                //Pierce
                if ( weap->Misc[LW_MISC_PIERCE] > 0 ){
                    weap->DeadState = WDS_ALIVE;
                }
                
                //Timeout
                if ( weap->Misc[LW_MISC_TIMEOUT] > 0 ){
                    weap->Misc[LW_MISC_TIMEOUT]--;
                    if ( weap->Misc[LW_MISC_TIMEOUT] <= 0 )
                        weap->DeadState = WDS_DEAD;
                }
            }


#6 Mr. Z

Mr. Z

    Old Bastard is back!

  • Members
  • Real Name:Erik
  • Location:The Netherlands

Posted 12 June 2013 - 01:23 PM

All right, thanks both, so I should use the Misc data as a countdown instead.

Somehow this worked properly on its first try, which is very unusual for me, so I'm still a bit sceptic...



#7 Moosh

Moosh

    The Mush

  • Moderators

Posted 12 June 2013 - 09:14 PM

Is there any reason you can't just move the fireball instead of creating a new one and then create a new one on the spot it should be every time it dies? It seems like an easier solution than timer shenanigans and I imagine not having to create and delete weapons every frame would be more eco friendly.



#8 Mr. Z

Mr. Z

    Old Bastard is back!

  • Members
  • Real Name:Erik
  • Location:The Netherlands

Posted 13 June 2013 - 01:56 AM

Is there any reason you can't just move the fireball instead of creating a new one and then create a new one on the spot it should be every time it dies? It seems like an easier solution than timer shenanigans and I imagine not having to create and delete weapons every frame would be more eco friendly.

 

I tried to by using arrays, but arrays in Zscript don't have the same possibilities and ways of working as I'm used to, so this was easier for me.



#9 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 13 June 2013 - 09:33 AM

What do you mean by that? Arrays work for me.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users