The lweapon data type represents a scriptable weapon that can be used to damage enemeies. The eweapon data type represents a scriptable weapon that can be used by enemies to damage Link. These objects can be created/loaded as necessary in a script, and provide a means of letting Zelda Classic figure out a portion of the weapon's control, visual effects, and damage effects (versus having to track all these things "manually" in the script).
- 1 Sytax and Usage
- 2 Methods and Properties
- 2.1 Methods
- 2.2 Properties
- 2.2.1 bool isValid()
- 2.2.2 int ID
- 2.2.3 int X
- 2.2.4 int Y
- 2.2.5 int Z
- 2.2.6 int Jump
- 2.2.7 int DrawStyle
- 2.2.8 int Dir
- 2.2.9 int OriginalTile
- 2.2.10 int Tile
- 2.2.11 int OriginalCSet
- 2.2.12 int CSet
- 2.2.13 int FlashCSet
- 2.2.14 int NumFrames
- 2.2.15 int Frame
- 2.2.16 int ASpeed
- 2.2.17 int Damage
- 2.2.18 int Step
- 2.2.19 int Angle
- 2.2.20 bool Angular
- 2.2.21 int DeadState
- 2.2.22 bool Flash
- 2.2.23 int Flip
- 2.2.24 int Extend
- 3 See Also
Sytax and Usage
Declare a variable of type lweapon and/or eweapon as follows:
// A weapon that will damage enemies. lweapon ProjectileWeapon; // An enemy weapon that will damage Link. eweapon EnemyBlast;
Until you initialze the variable, it does not actually "point to" any particular lweapon or eweapon, and thus any properties or methods you attempt to use will be invalid. You must initialize the variable by using the appropariate Load or Create method of the Screen object. For example:
// You can initialize at declaration... lweapon ProjectileWeapon = Screen->CreateLWeapon(LW_ARROW); // ...or you can initialize later. ProjectileWeapon = Screen->LoadLWeapon(1);
Refer to the following Screen methods:
Note that you can use the LoadWeapon functions to gain control of weapons that you did not create with the CreateWeapon functions. For instance, with a "normal" Zora on the screen, you can use the LoadEWeapon function manipulate the fireballs she spits out.
Methods and Properties
lweapons and eweapons possess exactly the same attributes, although their designation affect how they are treated by the engine. The values here correspond to both the lweapon and eweapon type.
There are no methods associated with lweapon and eweapon.
Returns whether this weapon pointer is still valid. A weapon pointer becomes invalid when the weapon fades away or disappears or Link leaves the screen. Accessing any variables using an invalid weapon pointer prints an error message to allegro.log and does nothing.
The weapon's ID number. The effect of writing to this field is currently undefined.
The weapon's X position on the screen, in pixels.
The weapon's Y position on the screen, in pixels.
The weapon's Z position on the screen, in pixels.
The weapon's falling speed on the screen. Bombs, Bait and Fire weapons obey gravity, although this may only be noticable in sideview.
An integer representing how the weapon is to be drawn. Use one of the DS_ constants in std.zh to set or compare this value.
The direction of the weapon momement. This is used by certain weapon types to determine movement, shield deflection and such.
For projectile type weapons (such as arrows) set this to the direction the projectile should travel. For melee weapons (such as a hammer) this will be the direction of the attack. If Angular is true, then the value of Angle is used to determine the direction of movement - however, Dir is still required to determine shield deflection.
Note that for some weapons, you may also need to flip the tile to acheive the desired look. For example, arrows are evidently always spwaned with the shaft oreiented veritcally, which can look rather silly when the arrow is moving from right to left.
The starting tile of the weapon's animation.
The current tile associated with this weapon.
The starting CSet of the weapon's animation.
This weapon's current CSet.
The CSet used during this weapon's flash frames, if this weapon flashes.
The number of frames in this weapon's animation.
The weapon's current animation frame.
The speed at which this weapon animates, in screen frames.
The amount of damage that this weapon causes to Link/an enemy upon contact.
Usually associated with the weapon's velocity.
The weapon's current angle, in radians. Angular must be set to true before setting this property. In this case, the Angle overrides Dir for the direction of movement; however, Dir must still be specified to determine shield deflection.
Specifies whether a weapon has angular movement. Must be set to true before attributing the weapon an angle.
The current state of the weapon. A value of -1 indicates that it is active, and moves according to the weapon's Dir, Step, Angular, and Angle values (in other words, set DeadState to -1 if you want the engine to handle movement). Use any value below -1 if you want a dummy weapon that you can control on your own.
If you want to remove the weapon, write one of the WDS_ constants in std.zh (appropriate for the weapon) to this variable.
Whether or not the weapon flashes. A flashing weapon alternates between its CSet and its FlashCSet.
Whether and how the weapon's tiles should be flipped.
- 0: No flip
- 1: Vertical flip
- 2: Horizontal flip
- 3: Rotate 180 degrees
- 4: Rotate clockwise 90 degrees
- 7: Rotate counter-clockwise 90 degrees
Whether to extend the sprite of the weapon.