Jump to content

Photo

Glue FFC to Enemy?


  • Please log in to reply
7 replies to this topic

#1 Zagut

Zagut

    Experienced Forumer

  • Members
  • Location:Somewhere in the universe.

Posted 30 March 2017 - 04:31 PM

Hey everyone

i would like to make a script request

 

What the FFC would do, is it would take another FFC and attach it to an onscreen enemy.

D0 would be the freeform combo to attach, and D1 would be the enemy to attach it to.

after attached, the FFC would stay attached to the enemy even if the enemy moves.

 

If this doesn't sound like it'd be too hard to script, could someone take it on for me? thanks!  :D



#2 cavthena

cavthena

    Apprentice

  • Members
  • Real Name:Clayton
  • Location:I wish I knew

Posted 30 March 2017 - 04:44 PM

Difficult no, problematic maybe.
The issue is the number given to enemies, the UID, is not always the same number nor does it always match the enemies position in the editor. As an example if you assign a stalfos to slot 0 and a Gel to slot 1 in the editor, in game the Stalfos could be enemy 1 while the Gel is enemy 0. The result would be the ffc assigning the target ffc to the wrong npc.

It would be helpful if you could tell us what the goal is of having a ffc stick another ffc to an npc.

#3 Zagut

Zagut

    Experienced Forumer

  • Members
  • Location:Somewhere in the universe.

Posted 30 March 2017 - 05:00 PM

Cavthena said:

 

It would be helpful if you could tell us what the goal is of having a ffc stick another ffc to an npc.

 

There are some database scripts, like your spinner arm script, that i was going to use in my quest, and i would like to make them mobile.

 

The Freeform combo would take a different ffc (like cavthena's spinner arm) and attach it to an enemy.

The enemy would be unkillable, therefore only functioning as a component to make the ffcs mobile.

(plus, sorry about the shoddy Quote here, still trying to figure out how to use them)  :D


Edited by Zagut, 30 March 2017 - 05:02 PM.


#4 Jamian

Jamian

    ZC enthusiast

  • Members

Posted 30 March 2017 - 08:45 PM

If the enemy is unkillable, you can just place it first in the enemy list, and it will always be there. (con: if there are other enemies in the room, once they have been killed, they won't respawn because the room will never be marked as being cleared of enemies).

 

If you want something more complex, what you could do is have the script scan the enemies in the room and attach itself to the enemy with the correct enemy ID. You can create a new enemy for this (copy/pasting an existing one if you want) so it won't interfere with the regular enemies.



#5 Zagut

Zagut

    Experienced Forumer

  • Members
  • Location:Somewhere in the universe.

Posted 30 March 2017 - 09:41 PM

 

Jamian:

 

If the enemy is unkillable, you can just place it first in the enemy list, and it will always be there. (con: if there are other enemies in the room, once they have been killed, they won't respawn because the room will never be marked as being cleared of enemies).

(once again, sorry about the shoddy quote. still figuring out how to use quotes)

You can mark an enemy as "Doesn't count as beatable enemy", and it won't really count as an enemy.

It'll be counted as a hazard, like a trap, or bubble.



#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 31 March 2017 - 01:42 AM

Why do you need a second script here? You can use one ffc, and do:
 
this->X = n->X; this->Y = n->Y;
 
Here is a method to do what you want, but it doesn't have a perfect 'failsafe' method. You could look for an n->Attributes[] value on top of other checks if you wish.
 
This ffc will be kept at the coordinates of the npc that it finds, and if it fails to find one, it closes. The ffc closes when the npc dies, too.

D0: A positive number here will follow the first instance of an npc with this ID.
D0: A negative number will follow an npc that spawns on a flag equal to this * -1 (so, -16 is flag 16)
D1: If you want to mark the npc so that other scripts know that this is following it, select a Misc index from 1 to 15 and use it in this arg.
The script will mark that index with the value '45678.9012 + nmisc', so that you can scan for that npc.
D2: If you want to cause the ffc to wait before closing when the npc dies, this is how many frames it will wait before clearing and exiting.
D3: The ID of another ffc. If set between 1 and 32, the corresponding ffc will also move with this one.
 
/////////////////////////////////
/// FFC Follows NPC for Zagut ///
/// By: ZoriaRPG              ///
/// 31st march, 2017          ///
/////////////////////////////////

ffc script follownpc{
	void run(int nid, int nmisc, int death_frames, int otherffc){
		int q[5]; int loc = -1; npc n;
		//find the npc that spawns at a specific location (flag) if D0 is negative
		if ( nid == 0 ) {
			int ss[]="The ffc using script 'follownpc' cannot run with its D0 arg set to '0'.";
			TraceS(ss);
			this->Data = 0; this->Script = 0; Quit(); 
		}
		if ( nid < 0 ) {
			nid = nid * -1; //convert to a positive value, 
			//scan for the screen flag
			for ( q[0] = 0; q[0] < 176; q[0]++ ) {
				if ( ComboFI(q[0], nid ) {
					loc = q[0]; 
					break;
				}
			}
			//if there is no flag, then it is an error, so quit. 
			if ( loc < 0 ) {
				this->Data = 0; this->Script = 0; Quit();
			}
			else { 
				Waitframes(5); //Wait for npcs to spawn. 
				//scan to find the npc at the coordinates
				q[4] = Screen->NumNPCs(); 
				for ( q[0] = 1; q[0] <= q[4]; q[0]++ ) {
					n = Screen->LoadNPC(q[0]);
					//Check to see if the npc is on the flag tile. 
					if ( ComboAt(n->X, n->Y) == loc ) {
						q[1] = n->X; //store its coordinaes. 
						q[2] = n->Y;
						q[3] = 1; //mark it found. 
						if ( nmisc > 0 ) n->Misc[nmisc] = nmisc + 45678.9012; 
						//Mark a Misc index if desired to flag the enemy we are following. 
						break;
					}
				}
				if ( q[3] != 1 ) {
					//We didn;t find the npc, so quit. 
					this->Data = 0; this->Script - 0; Quit();
				}
			}
		}
		//otherwise, find an npc with this ID
		//check them in list order, so that the user may utilise the first on the list
		//with relative surety. 
		else {
			//Wait for npcs to spawn. 
			Waitframes(5);
			//scan the npcs. 
			q[4] = Screen->NumNPCs(); 
			for ( q[0] = 1; q[0] <= q[4]; q[0]++ ) {
				n = Screen->LoadNPC(q[0]);
				if ( n->ID == nid ) {
					q[1] = n->X; //store its coordinaes. 
					q[2] = n->Y;
					q[3] = 1; //mark it found. 
					if ( nmisc > 0 ) n->Misc[nmisc] = nmisc + 45678.9012; 
					//Mark a Misc index if desired to flag the enemy we are following. 
					break;
				}
			}
			if ( q[3] != 1 ) {
				//We didn;t find the npc, so quit. 
				this->Data = 0; this->Script - 0; Quit();
			}
		//or a specific npc type, if D0 is positive
		while(n->isValid()){
			this->X = n->X; 
			this->Y = n->Y;
			if ( otherffc > 0 && otherffc < 33 ) {
				ffc f = Screen->LoadFFC(otherffc);
				f->X = this->X;
				f->Y = this->Y;
			}
			Waitframe(); 
		}
		//The enemy is dead. 
		//Wait for death anim. 
		if ( death_frames ) Waitframes(death_frames);
		//Clean up the ffc. 
		this->Data = 0; this->Script = 0; Quit(); 
	}
}

Difficult no, problematic maybe.
The issue is the number given to enemies, the UID, is not always the same number nor does it always match the enemies position in the editor. As an example if you assign a stalfos to slot 0 and a Gel to slot 1 in the editor, in game the Stalfos could be enemy 1 while the Gel is enemy 0. The result would be the ffc assigning the target ffc to the wrong npc.

It would be helpful if you could tell us what the goal is of having a ffc stick another ffc to an npc.


I do not believe that is precisely true, or valid.

NPC 0, or 'first on the list', should be the first one spawned. In fact, my script would work better using a positive loop--I changed it, to reflect this benefit--if the enemy that does this will always be the first on the list.

As I recall, npcs are spawned in order, so the screen index, and the editor index, will always match for the first npc. Later nocs on the list, may change, when npcs in the middle of the list are killed.

Edited by ZoriaRPG, 31 March 2017 - 02:15 AM.


#7 Zagut

Zagut

    Experienced Forumer

  • Members
  • Location:Somewhere in the universe.

Posted 31 March 2017 - 12:42 PM

Thanks alot ZRPG!  :thumbsup:

 

===EDIT===

Uhh...

The script doesn't seem to wanna import into my quest.

it says there's a syntax error in line 26: Unexpected LBrace, Expecting RParen Or Or, On Token {

so... I'm a bit confused.

I tried opening the file and looking at it myself, but i'm not really good at scripting and i didn't wanna mess things up more.

But i do know a small amount of Zscript, and i don't see anything wrong with it, so i am at a loss on what to do.

do you think it might be something wrong with my ZQuest??


Edited by Zagut, 31 March 2017 - 02:07 PM.


#8 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 31 March 2017 - 12:54 PM

Thanks alot ZRPG!  :thumbsup:


Not a problem. Just remember, this is untested, and I will adjust it, if and as needed.


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users