Well, my idea principally is this:
· If an specific enemy touches an item the item disappear, and when the item disappear -> Play a certain SFX
I need this :( please I need help. :(
Edited by Cereal Guy, 18 July 2016 - 12:13 PM.
Posted 18 July 2016 - 12:12 PM
Well, my idea principally is this:
· If an specific enemy touches an item the item disappear, and when the item disappear -> Play a certain SFX
I need this :( please I need help. :(
Edited by Cereal Guy, 18 July 2016 - 12:13 PM.
Posted 18 July 2016 - 12:34 PM
Try this:
D0: NPC ID for enemy that can steal items.
D1: Sound effect for stealing.
D2: The time that the npc carries item around before hey vanish, in seconds.
Accepts decimal values, so 1.250 is 1.25 seconds.
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 ); } }
AutoGhost version
const int NPC_MISC_HOLDING_ITEM = 12; const int GHOST_STEALITEM_HOLDING_ITEM = 3; const int GHOST_STEALITEM_STEAL_SFX = 43; const float GHOST_STEALITEM_DRAGDUR = 1.5; ffc script AutoghostBasicThief{ void run(int enemyid){ npc ghost = Ghost_InitAutoGhost(this, enemyid); item i; itemdata it; int a[4]; int itemlist[]={ IC_RUPEE, IC_HEART, IC_ARROWAMMO, IC_MAGIC, IC_BOMBAMMO }; while(true){ for ( a[0] = 1; a[0] <= Screen->NumItems(); a[0]++){ if ( !a[GHOST_STEALITEM_HOLDING_ITEM] ) { i = Screen->LoadItem( a[0] ); it = Game->LoadItemData(i->ID); for ( a[1] = 0; a[1] < SizeOfArray(itemlist); a[1]++){ if ( it->Family == itemlist[ a[1] ] ) { if ( __DistX(ghost,i,4) && __DistY(ghost,i,4) ){ a[GHOST_STEALITEM_HOLDING_ITEM] = 1; for ( a[2] = 0; a[2] < (GHOST_STEALITEM_DRAGDUR * 60); a[2]++ ) { i->X = ghost->X; i->Y = ghost->Y; Ghost_Waitframe2(this,ghost); } Game->PlaySound(GHOST_STEALITEM_STEAL_SFX); Remove(i); a[GHOST_STEALITEM_HOLDING_ITEM] = 0; } } } } } Ghost_Waitframe2(this,ghost); } } 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 ); } }
Edited by ZoriaRPG, 24 July 2016 - 06:58 AM.
Posted 18 July 2016 - 02:34 PM
Unexpected identifier, on token npc id
Edited by Cereal Guy, 18 July 2016 - 02:35 PM.
Posted 18 July 2016 - 02:40 PM
Unexpected identifier, on token npc id
Replace it with int npc_ID
Posted 18 July 2016 - 03:08 PM
Replace it with int npc_ID
Edited by ZoriaRPG, 24 July 2016 - 01:01 AM.
Posted 19 July 2016 - 12:31 AM
Error T29: 'That pointer type does not have a variable isValid
Posted 19 July 2016 - 11:54 AM
Edited by ZoriaRPG, 24 July 2016 - 01:02 AM.
Posted 19 July 2016 - 08:01 PM
Another error now on the line 9 "That pointer type does not have a FUNCTION isValid" D:
Posted 21 July 2016 - 03:15 AM
Edited by ZoriaRPG, 24 July 2016 - 01:02 AM.
Posted 21 July 2016 - 11:00 PM
error t29: that pointer type does not have a variable class.
Oggg
Posted 22 July 2016 - 05:12 AM
Posted 22 July 2016 - 11:57 AM
Posted 22 July 2016 - 12:26 PM
Sigh. Another inconsistent thing for me to fix in ZScript. There is no reason whatever, that item->Type shouldn't be a thing, and pointer->Class should exist too, as that's how ZC defines them in the editor, which is why when I was making these--on me phone--I used that.Items also don't have a Type variable. The IC_ constants are meant for item families, which you'll have to load itemdata for.
Edited by ZoriaRPG, 22 July 2016 - 12:29 PM.
Posted 22 July 2016 - 04:40 PM
Syntax error, unexpected identifier, expecting semicolon or or, on token it
npc n; item i; int q; int w; int e; itemclass it;
Edited by Cereal Guy, 22 July 2016 - 04:41 PM.
Posted 22 July 2016 - 09:35 PM
Change itemclass to itemdata, and then I'll shoot meself in the foot again. Fixed above.Syntax error, unexpected identifier, expecting semicolon or or, on token it
npc n; item i; int q; int w; int e; itemclass it;
Edited by ZoriaRPG, 22 July 2016 - 09:39 PM.
0 members, 0 guests, 0 anonymous users