Edited by XMuppetSB, 18 August 2010 - 08:08 PM.
Another request...
#16
Posted 18 August 2010 - 08:01 PM
#17
Posted 18 August 2010 - 08:09 PM
#18
Posted 18 August 2010 - 08:11 PM
Edited by XMuppetSB, 18 August 2010 - 08:14 PM.
#19
Posted 18 August 2010 - 08:18 PM
#20
Posted 18 August 2010 - 08:20 PM
#21
Posted 18 August 2010 - 08:40 PM
Mmm. Found the problem. In my allegro log, mounds of this:
Invalid value (12) passed to 'npc->Attributes'
One sec and I'll fix it for you
Alright so. What happened was... NPC->Attributes does in fact have 12 values. But it's read as NPC->Attributes[0] being attribute 1. So on and so forth.
I simply added a variable to edit in the top of the file.
int delayframes = 30;
global script Slot2
{
void run()
{
while(true)
{
NPCs();
Waitframe();
}
}
void NPCs()
{
npc n;
for(int i = Screen->NumNPCs(); i > 0; i--)
{
n = Screen->LoadNPC(i);
if(n->Type == NPCT_KEESE)
NPC_Keese(n);
}
}
}
//Might need to change this if it's interefering with other scripts
//Also make sure its not set to 1
const int NPCM_KEESESHOOTCLK = 0;
void NPC_Keese(npc Keese)
{
int ShootDelay = delayframes;
if(ShootDelay <= 0)
return;
Keese->Misc[NPCM_KEESESHOOTCLK]++;
if(Keese->Misc[NPCM_KEESESHOOTCLK] >= ShootDelay)
{
CreateEWeaponAt(Keese->Attributes[11], Keese->X, Keese->Y);
Keese->Misc[NPCM_KEESESHOOTCLK] = 0;
}
}
Misc value 12 is your eweapon type.
Although, the only thing this script does is shoot the weapon upwards. Not sure how to shoot it at Link, since it doesn't automatically do it. And the weapons by default deal no damage.
If we had something like Eweapon->Vx and Eweapon->Vy, I could make it work the way you want. Unfortunately, we don't. =(
Joe, if you want to look at this and make it shoot at Link, that would be great. I may just have to steal it for my quest
Also, a funny. Check it out. This is when I was debugging the script:
Edited by Master Maniac, 18 August 2010 - 09:04 PM.
#22
Posted 18 August 2010 - 09:37 PM
#23
Posted 18 August 2010 - 09:41 PM
#24
Posted 18 August 2010 - 09:47 PM
Edited by XMuppetSB, 18 August 2010 - 09:48 PM.
#25
Posted 19 August 2010 - 04:40 AM
What's happening in the picture exactly? Do you just have misc12 set to 0 or something?
OK, Weapon Damage in the first screen does the damage. I will handle shooting in the right direction soon(ish).
{
void run()
{
while(true)
{
NPCs();
Waitframe();
}
}
void NPCs()
{
npc n;
for(int i = Screen->NumNPCs(); i > 0; i--)
{
n = Screen->LoadNPC(i);
if(n->Type == NPCT_KEESE)
NPC_Keese(n);
}
}
}
//Might need to change this if it's interfering with other scripts
const int NPCM_KEESESHOOTCLK = 0;
void NPC_Keese(npc Keese)
{
int ShootDelay = Keese->Attributes[11];
int WeaponType = Keese->Attributes[10];
if(ShootDelay <= 0 || WeaponType <= 0)
return;
Keese->Misc[NPCM_KEESESHOOTCLK]++;
if(Keese->Misc[NPCM_KEESESHOOTCLK] >= ShootDelay)
{
eweapon e = CreateEWeaponAt(WeaponType, Keese->X, Keese->Y);
e->Damage = Keese->WeaponDamage;
Keese->Misc[NPCM_KEESESHOOTCLK] = 0;
}
}
#26
Posted 19 August 2010 - 05:26 AM
#27
Posted 19 August 2010 - 05:45 AM
You're supposed to be able to get that effect by setting the Misc12 to 1 ;-)
{
void run()
{
while(true)
{
NPCs();
Waitframe();
}
}
void NPCs()
{
npc n;
for(int i = Screen->NumNPCs(); i > 0; i--)
{
n = Screen->LoadNPC(i);
if(n->Type == NPCT_KEESE)
NPC_Keese(n);
}
}
}
//Might need to change this if it's interfering with other scripts
const int NPCM_KEESESHOOTCLK = 0;
void NPC_Keese(npc Keese)
{
int AimType = Keese->Attributes[10];
int ShootDelay = Keese->Attributes[11];
if(ShootDelay <= 0 || Keese->Weapon <= 0)
return;
Keese->Misc[NPCM_KEESESHOOTCLK]++;
if(Keese->Misc[NPCM_KEESESHOOTCLK] >= ShootDelay)
{
eweapon e = CreateEWeaponAt(WeaponTypeToID(Keese->Weapon), Keese->X, Keese->Y);
AimEWeapon(e, AimType);
e->Damage = Keese->WeaponDamage;
Keese->Misc[NPCM_KEESESHOOTCLK] = 0;
}
}
const int AT_NONE = 0;
const int AT_4DIR = 1;
const int AT_8DIR = 2;
const int AT_ANGULAR = 3;
const int AT_RAND4DIR = 4;
const int AT_RAND8DIR = 5;
const int AT_RANDANGULAR = 6;
void AimEWeapon(eweapon e, int aimtype)
{
int angle = RadianAngle(e->X, e->Y, Link->X, Link->Y);
if(aimtype == AT_4DIR)
{
e->Dir = RadianAngleDir4(angle);
}
else if(aimtype == AT_8DIR)
{
e->Dir = RadianAngleDir8(angle);
}
else if(aimtype == AT_ANGULAR)
{
e->Angular = true;
e->Angle = angle;
}
else if(aimtype == AT_RAND4DIR)
{
e->Dir = AngleDir4(Rand(360));
}
else if(aimtype == AT_RAND8DIR)
{
e->Dir = AngleDir8(Rand(360));
}
else if(aimtype == AT_RANDANGULAR)
{
e->Angular = true;
e->Angle = Randf(PI2);
}
}
int WeaponTypeToID(int wpnt)
{
if(wpnt == WPN_NONE) return -1; //Can't create this
else if(wpnt == WPN_ENEMYFLAME) return EW_FIRE:
else if(wpnt == WPN_ENEMYWIND) return EW_WIND;
else if(wpnt == WPN_ENEMYFIREBALL) return EW_FIREBALL;
else if(wpnt == WPN_ENEMYARROW) return EW_ARROW;
else if(wpnt == WPN_ENEMYBRANG) return EW_BRANG;
else if(wpnt == WPN_ENEMYSWORD) return -1; //Eh? Should be a constant for this...
else if(wpnt == WPN_ENEMYROCK) return EW_ROCK;
else if(wpnt == WPN_ENEMYMAGIC) return EW_MAGIC;
else if(wpnt == WPN_ENEMYBOMB) return EW_BOMB;
else if(wpnt == WPN_ENEMYSBOMB) return EW_SBOMB;
else if(wpnt == WPN_ENEMYLITBOMB) return EW_BOMBBLAST;
else if(wpnt == WPN_ENEMYLITSBOMB) return EW_SBOMBBLAST;
else if(wpnt == WPN_ENEMYFIRETRAIL) return EW_FIRETRAIL;
else if(wpnt == WPN_ENEMYFLAME2) return EW_FIRE; //Is this right?
else if(wpnt == WPN_ENEMYFIREBALL2) return EW_FIREBALL2;
return -1;
}
And now with aiming!
My intention is to include AimEWeapon and WeaponTypeToID in std.zh, so in the next build you'll have to delete those functions from your script file Pokegamer.
Now it uses the weapon droplist in the first pane for weapon type, weapon damage box for damage, Misc11 for AimType (see AT_ constants), and Misc12 for shoot speed.
#28
Posted 19 August 2010 - 07:36 AM
Yet, for some strange reason, it still only fires the weapon upward.
Edited by XMuppetSB, 19 August 2010 - 07:53 AM.
#29
Posted 19 August 2010 - 07:54 AM
#30
Posted 19 August 2010 - 07:55 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users