User Tag List

Results 1 to 3 of 3

Thread: ffcscript.zh

  1. #1
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    36
    Posts
    3,379
    Mentioned
    175 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,198
    Level
    24
    vBActivity - Bars
    Lv. Percent
    30.87%

    ffcscript.zh

    As of RC2, ffc->Script is writable. I made a header file with a few functions to take advantage of this. Specifically, these are for using FFCs as generic script vehicles. Nothing fancy, but I figure it'll be handy.

    ffcscript.zh 1.1.1


    The most obvious use of this is for items; most of them can launch an FFC script now instead of having to be worked into the global script. As an example, here's a simple item that homes in on a random enemy and explodes when it gets close enough or the item is used again:

    Code:
    item script HomingBomb_item
    {
    	void run(int ffcScriptNum, int sprite)
    	{
    		int ffcID=FindFFCRunning(ffcScriptNum);
    		
    		if(ffcID==0) // No bombs active
    		{
    			if(Screen->NumNPCs()==0)
    				Quit();
    			
    			int args[8]={this->Power, sprite};
    			RunFFCScript(ffcScriptNum, args);
    		}
    		else // Detonate
    		{
    			ffc f=Screen->LoadFFC(ffcID);
    			f->Misc[0]=1;
    		}
    	}
    }
    
    ffc script HomingBomb_ffc
    {
    	void run(int damage, int sprite)
    	{
    		if(Screen->NumNPCs()==0)
    			Quit();
    		
    		// Create the bomb, pick a random target
    		lweapon bomb=Screen->CreateLWeapon(LW_SCRIPT1);
    		npc target=Screen->LoadNPC(Rand(Screen->NumNPCs())+1);
    		
    		bomb->X=Link->X;
    		bomb->Y=Link->Y;
    		bomb->CollDetection=false;
    		bomb->UseSprite(sprite);
    		bomb->Angular=true;
    		bomb->Step=200;
    		
    		// Aim toward the enemy; detonate the bomb when it reaches the enemy,
    		// the enemy dies, or this->Misc[0] is set
    		while(target->isValid() && this->Misc[0]==0 && !Collision(bomb, target))
    		{
    			bomb->Angle=ArcTan(target->X-bomb->X, target->Y-bomb->Y);
    			Waitframe();
    		}
    		
    		// Detonate
    		lweapon blast=Screen->CreateLWeapon(LW_BOMBBLAST);
    		blast->Damage=damage;
    		blast->X=bomb->X;
    		blast->Y=bomb->Y;
    		bomb->DeadState=0;
    	}
    }
    Last edited by Saffith; 09-16-2016 at 11:30 PM.
    [tèknoláiz]

    ffcscript.zh 1.1.1 - Updated 2014-08-19
    ghost.zh 2.8.4 - Updated 2019-07-15
    tango.zh 1.3.2 - Updated 2019-08-01

  2. #2
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    36
    Posts
    3,379
    Mentioned
    175 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,198
    Level
    24
    vBActivity - Bars
    Lv. Percent
    30.87%
    Updated. Just two small changes:
    - Invalid script numbers now fail correctly, so you can use Game->GetFFCScript() without validating the result
    - The argument array no longer needs to be 8 elements
    [tèknoláiz]

    ffcscript.zh 1.1.1 - Updated 2014-08-19
    ghost.zh 2.8.4 - Updated 2019-07-15
    tango.zh 1.3.2 - Updated 2019-08-01

  3. #3
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    36
    Posts
    3,379
    Mentioned
    175 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,198
    Level
    24
    vBActivity - Bars
    Lv. Percent
    30.87%
    Updated. It will now make sure not to grab changers.
    [tèknoláiz]

    ffcscript.zh 1.1.1 - Updated 2014-08-19
    ghost.zh 2.8.4 - Updated 2019-07-15
    tango.zh 1.3.2 - Updated 2019-08-01

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social