Jump to content

Photo

I would like some help on how if 3rd enemy Stalfos (Green Sword Shoote


  • Please log in to reply
3 replies to this topic

#1 LikeLike888

LikeLike888

    Spicy food lover!!

  • Members
  • Real Name:Jason
  • Location:North America

Posted 30 November 2016 - 12:20 PM

Let's say I am making a quest and I want to code

if in DMap 0 Map 1 Screen A6 if

enemy 3 is killed he has a percent chance of dropping something.

 

 

 

GML stands for Game Maker Language

 

 

 

Here is an example enemy list for DMap 0 Map 1 Screen A6

Wizardrobe (Fire)

Wizardrobe (Fire)

Stalfos (Green Sword Shooter)

Rope 2

Rope 1

Fire

Fire

Fire

Fire

Octorok L2 (Fast)

 

 

 

Here is a GML example of what I want to do

if (DMap = DMap 0)
{
  if (Map = Map 1)
  {
    if (Screen = A6)
    {
      if (enemy3 = Stalfos (Green Sword Shooter))
      {
        if (instance_exists(enemy3))
        {
          if (enemy3.hp < 1)
          {
            var Choice_Number;
            Choice_Number = floor(choose(1,2));
            if (Choice_Number = 1)
            {
              instance_create(16,16,Rupees(5));
            }
            else if (Choice_Number = 2)
            {
              instance_create(16,16,L4_Sword_Master);
            }
          }
        }
      }
    }
  }
}

 

 

 

What is the ZScript working version of GML up above to do what I want to do please?

Thank you very very much ;) ; ) : ) :)



#2 Theryan

Theryan

    Burrito

  • Members

Posted 30 November 2016 - 01:35 PM

I'm on my phone, so I'm not gonna try to write any specific code, but here are a few thoughts:

You can edit enemy item drop sets, so you could avoid scripting entirely by going that route. If you only want a few enemies of that type to have this drop set, you could create a copy of the stalfos and keep everything except the drop set the same.

This script, as you've written it, would only work on 1 specific screen of 1 specific map. It might be easier to make it a Freeform Combo Script and only place the scripted FFC in the rooms it needs to be run. Then you won't need to check the map or screen number. DMap shouldn't need to be checked unless the same screen can be accessed on 2 different DMaps and you want each DMap to behave differently.

That script will only work if the stalfos is the third enemy on the list. The player could kill a handful of enemies and leave. When they return to the screen, the enemies they killed may stay dead, in which case the enemy list will be reorganized and the stalfos might not be #3 on the list anymore (so the script would not have any effect). For example, if they killed the 2 fire wizzrobes, the stalfos would be #1 on the list

#3 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 30 November 2016 - 04:36 PM

I agree with Theryan's points.

 

I'm also not sure that you need a script for this, unless there's a specific mechanism you haven't told us about. You could just create a new green Stalfos enemy, give him the specific item set you want, and place it in the room.

 

If you don't want the Master Sword to spawn more than once (though this isn't something you've addressed in your script plan), have an FFC script that does this upon entering the room:

- IF the player has the master sword:

- scan the enemies in the room

- when/if you find the green Stalfos, give it a different item set


Edited by Jamian, 30 November 2016 - 04:40 PM.


#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 30 November 2016 - 06:40 PM

Just for amusement, this is how something like that would work in ZScript, with a number of precautionary conditions in place...

 
ffc script SpecialEnemyDrop{
	void run(int enemy_id, int special_drop, int special_percentage, int reg, int special_drop_sfx){
			//Each index is a 1% chamce f dropping a specific item.
		item i;
		int droplist[100]= { 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
					0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
		int factor = Rand(1,100); 
					
					
		npc n; int q[10];
					
		//Check to see if the special enemy is on the screen. If so, mark it. 
		for ( q[0] = Screen->NumNPCs(0; q[0] > 0; q[0]-- ) {
			n = Screen->LoadNPC(q[0]);
			if ( n->ID == enemy_id ) { q[1] = q[0]; break; }
		}
		
		//If the enemy is not on the screen, and Link had grabbed the special item, or it has never spawned, exit. 
		if ( !q[1] && Screen->D[reg] <= 0 ) { this->Script = 0; this->Data = 0; Quit(); }
		
		//Create the special item if the register values are set. This is so that if Link left the room without taking it,
		//that it reappears. 
		if ( !q[1] && Screen->D[reg] > 0 ) {
			if ( special_drop_sfx ) Game->PlaySound(special_drop_sfx); //Play the sound. 
			i = Screen->CreateItem(special_drop);
			i->X = Screen->D(reg) << 0; //Read the Screen->D[reg] values to position it precisely where it had fallen before. 
			i->Y = (Screen->D[reg] - (Screen->D[reg] << 0)) * 10000; 
		}
		
		//While the npc is alive, store is coordinates. 
		while(n->isValid()) {
			q[3] = n->X;
			q[4] = n->Y;
			q[5] = q[4] / 10000; //Save the coordinaes to Screen->D[reg]
			if ( n->HP <= 0 ) break;
			Waitframe();
		}
		
		//If we passed the percentage check, and we have not made the special item in the past...
		if ( special_drop && factor <= special_percentage && !Screen->D[reg] >= 0 ) {
			if ( special_drop_sfx ) Game->PlaySound(special_drop_sfx); //Play the special drop sound. 
			i = Screen->CreateItem(special_drop); 
			i->X = q[3];
			i->Y = q[4];
			q[6] = q[3]+q[5];
			Screen->D[reg] = q[6]
		}
		
		else { //The special item percentage roll failed, or the item was already created in the past. 
			i = Screen->CreateItem(droplist[factor]); //Make an item from the random drops list. 
			i->X = q[3];
			i->Y = q[4];
			i->Pickup = IP_TIMEOUT; //Make it an ordinary drop. 
			this->Script = 0; this->Data = 0; Quit();
		}
			
		//If the special item is on the screen:
		while(i->isValid()){
			if ( LinkCollision(i) ) {
				Screen->D[reg] = -1; //If Link picks it up, set the register to denote it is no loner to spawn. 
				this->Script = 0; this->Data = 0; Quit();
			}
			Waitframe();
		}
		
		//If we reach here, we're done.
		this->Script = 0; this->Data = 0; Quit();
	}
}
You would just place that ffc on the screem. If you used a global active script to do this, then you would check Game->CetCurScreen(), Game->GetCurDMap(), and change the while loops into statements.

Edited by ZoriaRPG, 30 November 2016 - 06:50 PM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users