Jump to content

Photo

Sand Wand


  • Please log in to reply
10 replies to this topic

#1 Kivitoe

Kivitoe

    Sponsored by Taco Bell

  • Members
  • Location:Beyond Sagittarius A*

Posted 28 July 2016 - 11:03 AM

I'm creating a custom weapon called the sandione rod which basically is basically a sand wand.

 

I need an item script that, when the sand magic touches an enemy it buries it in a pile of sand for a given amount of time. When the enemy is about to break free it will start to shake, similar to the boomerang except it will also damage the enemy.

 

Is it possible to do this?


Edited by Kivitoe, 28 July 2016 - 02:41 PM.


#2 Kivitoe

Kivitoe

    Sponsored by Taco Bell

  • Members
  • Location:Beyond Sagittarius A*

Posted 28 July 2016 - 07:47 PM

I hate to bump this thread, but I REALLY need a script for this to continue development on my quest.



#3 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 28 July 2016 - 08:37 PM

You do realise, that this is a pretty complicated request, and list of effects; right? It's not something I can just write out in five minutes, and being overly demanding doesn't work on us request djinns.
  • ywkls likes this

#4 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 29 July 2016 - 12:09 AM

const int NPC_MISC_SAND = 0;
const int NPCD_SAND = 15; // Stomp Boots defense, change to something otherwise unused if necessary
const int TILE_SAND = 700;
const int CSET_SAND = 8;
const int SPRITE_SAND = 90;
const int SFX_SAND = 11;

item script SandWand
{
	void run()
	{
		Link->Action = LA_ATTACKING;
		int sand_wand[] = "SandWandFFC";
		int script_num = Game->GetFFCScript(sand_wand);
		lweapon sand_shot = NextToLink(LW_SCRIPT1, 0, 0);
		sand_shot->CollDetection = false;
		sand_shot->Damage = this->Power;
		sand_shot->Dir = Link->Dir;
		sand_shot->Step = 300;
		sand_shot->UseSprite(SPRITE_SAND);
		sand_shot->Misc[0] = 9997;
		int args[8] = {sand_shot->Damage, 0, 0, 0, 0, 0, 0, 0};
		
		if (CountFFCsRunning(script_num) == 0)
		{
			RunFFCScript(script_num, args);
		}
	}
}

ffc script SandWandFFC
{
	void run(int sand_damage)
	{
		lweapon sand_shot;
		npc enemy;
		
		int sand_shake[4] = {1, -1, -1, 1};
		int sand_offset;
		
		while (true)
		{
			for (int i = 1; i <= Screen->NumLWeapons(); i++)
			{
				sand_shot = Screen->LoadLWeapon(i);
				if (sand_shot->ID == LW_SCRIPT1 && sand_shot->Misc[0] == 9997)
				{
					for (int j = 1; j <= Screen->NumNPCs(); j++)
					{
						enemy = Screen->LoadNPC(j);
						if (CollisionMod(sand_shot, enemy) && enemy->Misc[NPC_MISC_SAND] == 0)
						{
							if (enemy->Defense[NPCD_SAND] == NPCDT_NONE)
							{
								enemy->DrawXOffset -= 1000;
								Game->PlaySound(SFX_SAND);
								enemy->Misc[NPC_MISC_SAND] = 1;
								enemy->Stun = 180;
								enemy->CollDetection = false;
								Remove(sand_shot);
							}
							else
							{
								Game->PlaySound(SFX_CLINK);
								Remove(sand_shot);
							}
						}
					}
				}
			}
			
			for (int i = 1; i <= Screen->NumNPCs(); i++)
			{
				enemy = Screen->LoadNPC(i);
				if (enemy->Misc[NPC_MISC_SAND] != 0)
				{
					sand_offset = 0;
					if (enemy->Stun <= 30 && enemy->Stun > 0)
					{
						sand_offset = sand_shake[enemy->Stun % 4];
					}
					Screen->FastTile(2, enemy->X + enemy->DrawXOffset + 1000 + sand_offset, enemy->Y + enemy->DrawYOffset, TILE_SAND, CSET_SAND, OP_OPAQUE);
					if (enemy->Stun == 0)
					{
						enemy->Misc[NPC_MISC_SAND] = 0;
						enemy->DrawXOffset += 1000;
						enemy->CollDetection = true;
						enemy->HP -= sand_damage;
					}
				}
			}
			
			Waitframe();
		}
	}
}
Implementation is 100% flawless as far as anyone is aware.
  • ywkls likes this

#5 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 29 July 2016 - 03:10 AM

int args[8] = {sand_shot->Damage, 0, 0, 0, 0, 0, 0, 0};
		
		if (CountFFCsRunning(script_num) == 0)
		{
			RunFFCScript(script_num, args);
		}
	}
ffc script SandWandFFC
{
	void run(int sand_damage)
	{
Does this not generate errors in operation? You are trying to assign eight values by passing them, without first pushing eight onto the stack.

#6 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 29 July 2016 - 03:25 AM

if(args!=NULL)
{
    for(int j=Min(SizeOfArray(args), 8)-1; j>=0; j--)
        theFFC->InitD[j]=args[j];
}
No errors here.

#7 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 29 July 2016 - 06:04 AM

Hmm... I suppose that's right. The ffc can never use those values, but its InitD[8] are still valid, so it won't error out, as it's purely a numeric assign. You aren't trying to push d1 through d7 onto the stack that way, at all.

I'm mostly noting, that declaring args[8] there shouldn't be required, nor does initialising indices 1 through 7 as '0' do anything, aside from run a lot of SetScriptRAM instructions.

I'm not sure why you did it that way, unless it's a habit.

int args[1] = {sand_shot->Damage}; would work there too.

P.S. Saffith's loop is a bit...odd. A positive iteration makes more sense, as although the result is the same, it would use one fewer calc.

Edited by ZoriaRPG, 29 July 2016 - 06:20 AM.


#8 Kivitoe

Kivitoe

    Sponsored by Taco Bell

  • Members
  • Location:Beyond Sagittarius A*

Posted 29 July 2016 - 07:59 AM

const int NPC_MISC_SAND = 0;
const int NPCD_SAND = 15; // Stomp Boots defense, change to something otherwise unused if necessary
const int TILE_SAND = 700;
const int CSET_SAND = 8;
const int SPRITE_SAND = 90;
const int SFX_SAND = 11;

item script SandWand
{
	void run()
	{
		Link->Action = LA_ATTACKING;
		int sand_wand[] = "SandWandFFC";
		int script_num = Game->GetFFCScript(sand_wand);
		lweapon sand_shot = NextToLink(LW_SCRIPT1, 0, 0);
		sand_shot->CollDetection = false;
		sand_shot->Damage = this->Power;
		sand_shot->Dir = Link->Dir;
		sand_shot->Step = 300;
		sand_shot->UseSprite(SPRITE_SAND);
		sand_shot->Misc[0] = 9997;
		int args[8] = {sand_shot->Damage, 0, 0, 0, 0, 0, 0, 0};
		
		if (CountFFCsRunning(script_num) == 0)
		{
			RunFFCScript(script_num, args);
		}
	}
}

ffc script SandWandFFC
{
	void run(int sand_damage)
	{
		lweapon sand_shot;
		npc enemy;
		
		int sand_shake[4] = {1, -1, -1, 1};
		int sand_offset;
		
		while (true)
		{
			for (int i = 1; i <= Screen->NumLWeapons(); i++)
			{
				sand_shot = Screen->LoadLWeapon(i);
				if (sand_shot->ID == LW_SCRIPT1 && sand_shot->Misc[0] == 9997)
				{
					for (int j = 1; j <= Screen->NumNPCs(); j++)
					{
						enemy = Screen->LoadNPC(j);
						if (CollisionMod(sand_shot, enemy) && enemy->Misc[NPC_MISC_SAND] == 0)
						{
							if (enemy->Defense[NPCD_SAND] == NPCDT_NONE)
							{
								enemy->DrawXOffset -= 1000;
								Game->PlaySound(SFX_SAND);
								enemy->Misc[NPC_MISC_SAND] = 1;
								enemy->Stun = 180;
								enemy->CollDetection = false;
								Remove(sand_shot);
							}
							else
							{
								Game->PlaySound(SFX_CLINK);
								Remove(sand_shot);
							}
						}
					}
				}
			}
			
			for (int i = 1; i <= Screen->NumNPCs(); i++)
			{
				enemy = Screen->LoadNPC(i);
				if (enemy->Misc[NPC_MISC_SAND] != 0)
				{
					sand_offset = 0;
					if (enemy->Stun <= 30 && enemy->Stun > 0)
					{
						sand_offset = sand_shake[enemy->Stun % 4];
					}
					Screen->FastTile(2, enemy->X + enemy->DrawXOffset + 1000 + sand_offset, enemy->Y + enemy->DrawYOffset, TILE_SAND, CSET_SAND, OP_OPAQUE);
					if (enemy->Stun == 0)
					{
						enemy->Misc[NPC_MISC_SAND] = 0;
						enemy->DrawXOffset += 1000;
						enemy->CollDetection = true;
						enemy->HP -= sand_damage;
					}
				}
			}
			
			Waitframe();
		}
	}
}
Implementation is 100% flawless as far as anyone is aware.

 

I get errors.



#9 coolgamer012345

coolgamer012345

    🔸

  • Members
  • Location:Indiana, USA

Posted 29 July 2016 - 12:02 PM

I get errors.

Could you elaborate on what kind of errors?


  • Avaro likes this

#10 Saffith

Saffith

    IPv7 user

  • Members

Posted 29 July 2016 - 12:15 PM

You can copy the errors from allegro.log.
 

P.S. Saffith's loop is a bit...odd. A positive iteration makes more sense, as although the result is the same, it would use one fewer calc.

It would take several more in most cases, because it redoes the calculation for each iteration.

#11 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 29 July 2016 - 08:45 PM

You can copy the errors from allegro.log.
 
It would take several more in most cases, because it redoes the calculation for each iteration.


Right... Pre-storing Min(SizeOfArray()) means that you don't need to fun the function calls every iteration, so you're lowering the instruction count quite a lot.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users