Jump to content

Photo

Small script request.


  • Please log in to reply
19 replies to this topic

#16 Cereal Guy

Cereal Guy

    Senior

  • Members
  • Location:ConcepciĆ³n, CHL

Posted 22 July 2016 - 10:31 PM

'That pointer type does not have a variable type'

if ( it->Type == itemlist[e] ) {


#17 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 23 July 2016 - 03:04 AM

const int NPC_MISC_HOLDING_ITEM = 12; 

ffc script BasicStealItem{
	void run(int npc_ID, int stealsfx, float dragdur){
		npc n; item i; int q; int w; int e; int r; itemdata it;
		if ( !dragdur ) dragdur = 1; 
		int itemlist[]={	IC_RUPEE, IC_HEART, IC_ARROWAMMO, IC_MAGIC, IC_BOMBAMMO};
		while(true){
			for ( w = 1; w <= Screen->NumItems(); w++){
				for ( q = 1; q <= Screen->NumNPCs(); q++) {
					n = Screen->LoadNPC(q);
					if ( n->isValid() )	{
						if ( n->ID == npc_ID && !n->Misc[NPC_MISC_HOLDING_ITEM]) {
							i = Screen->LoadItem(w);
							if ( i->isValid() ) {
								if ( __DistX(n,i,4) && __DistY(n,i,4) ){
								
									it = Game->LoadItemData(i->ID);
									for ( e = 0; e < SizeOfArray(itemlist); e++){
										if ( it->Family == itemlist[e] ) {
											n->Misc[NPC_MISC_HOLDING_ITEM] = 1; 
											for ( r = 0; r < (dragdur * 60); r ++ ) {
												i->X = n->X;
												i->Y = n->Y;
												Waitframe();
											}
											Game->PlaySound(stealsfx);
											Remove(i);
											n->Misc[NPC_MISC_HOLDING_ITEM] = 0;
										}
									}									
								}
							}
						}
					}
				}
			}
			Waitframe();
		}
	}
	bool __DistX(npc a, item b, int distance) {
		int dist;
		if ( a->X > b->X ) dist = a->X - b->X;
		else dist = b->X - a->X;
		return ( dist <= distance );
	} 
	bool __DistY(npc a, item b, int distance) {
		int dist;
		if ( a->Y > b->Y ) dist = a->Y - b->Y;
		else dist = b->Y - a->Y;
		return ( dist <= distance );
	} 

}

 
Checked on the laptop. Compiles. Works. Demo.



#18 Cereal Guy

Cereal Guy

    Senior

  • Members
  • Location:ConcepciĆ³n, CHL

Posted 23 July 2016 - 04:10 PM

yeah, works amazing! :D, but it is possible to make the enemy steals every item and not only the rupees, hearts, magic, arrow ammo and bomb ammo? :D

 

EDIT: I fixed the problem, now another question, it is possible this?

 

- If an enemy picks a clock Link's cannot move 5 seconds


Edited by Cereal Guy, 23 July 2016 - 05:23 PM.


#19 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 23 July 2016 - 07:29 PM

yeah, works amazing! :D, but it is possible to make the enemy steals every item and not only the rupees, hearts, magic, arrow ammo and bomb ammo? :D
 
EDIT: I fixed the problem, now another question, it is possible this?
 
- If an enemy picks a clock Link's cannot move 5 seconds


That'd be possible, but a bit..unfair. I didn't add IC_CLOCK to the list, as it is a very uncommon item in modern quests.

It's possible to change the duration, before the items are absorbed, as well. That's arg d2. Set it to the delay in seconds. It accepts decimals, so '1.5000' is 1.5 seconds. Link can still get the items if he hits the enemy when it is grabbing them.

Instantaneous stealing was too broken, because of the inability to handle Waitdraw() timing in the ffc, which is why I added the carrying animation. I think it turned out for the best.

Freezing Link, should probably be a second ffc, but I could use a timer, in that one. I need to clear the unfinished code from the thread, and move the complete ffc to the front; and probably drop it in the database.

What I was already going to add, were fields for additional npc IDs, and npc classes, so that one ffc worked for more than one npc per screen, and make a global version of this.

Edited by ZoriaRPG, 24 July 2016 - 01:19 AM.

  • Cereal Guy likes this

#20 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 24 July 2016 - 06:59 AM

I added an autoghost version to my initial reply. It is untested (compiles, but unverified in operation).


Edited by ZoriaRPG, 24 July 2016 - 07:00 AM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users