PDA

View Full Version : Spawning Enemy Weapons



pkmnfrk
03-16-2009, 11:19 PM
For some reason, this doesn't work quite right for me:


import "std.zh"

ffc script testShooter {

void run() {
eweapon fb;
while(true) {
fb = Screen->CreateEWeapon(EW_BEAM);
fb->X = this->Y;
fb->Y = this->X;
fb->Dir = DIR_RIGHT;
Waitframes(4);
}
}
}

It spawns the projectiles correctly, they are not aimed the right way. Er, the sprite isn't. They travel right, but they all face up.

A (slightly different script's) example:

http://zctut.com/zelda009.png

Am I missing something, or is this a bug?

jman2050
03-17-2009, 12:44 AM
it isn't really a bug as it is a part of the design. When weapons are loaded by the engine, they'll typically change their flip variables and, in rare cases, change their tiles based on the direction. The catch with scripted weapons is that you can't actually define their direction when they're created, you can only do it after the face. This means you have to set the flip and/or tile variables manually based on the direction you want.

pkmnfrk
03-17-2009, 01:31 AM
Oh, I thought that it would change its tile based on its direction.

...

Ok, I got it working now. But, man, this is far from intuitive... Nothing in the docs suggest you need to manually set the tile.

Now, granted, I figured out (in my other boss) that for Fireballs, the angle is set on creation (that is, top left -> Link), and must be manually calculated if they're spawned elsewhere.

Perhaps the weapons deserve a Restart() method, which makes the weapon act as if it was just spawned with all the current direction, etc. settings intact?

jman2050
03-17-2009, 02:30 AM
The plan is to include functions that'll load weapons, as well as other objects, with attributes that the engine itself is usually only able to do.