SCRMaps
/
Sign in

Giving a building a weapon

Making a building that does not attack, attack. Five things have to line up.

9 min read

Some buildings, like the Ion Cannon, look the part and do nothing. Making one actually shoot means lining up five things - the weapon, the unit, the button, the requirement and the iscript. Miss any one and it quietly does not work.

Do not reuse an existing weapon. Take the Yamato Gun and you share it with the Battlecruiser's, so changing yours changes theirs. From index 117 there are unused dummy weapons - Gauss Rifle (Unused) - and that is where a new weapon goes. Copy the Yamato's appearance onto it instead.

  1. 1Pick an unused weapon past 117 and set its damage, cooldown, range, name and graphics.
  2. 2Point the building's ground and air weapon at it.
  3. 3Raise the building's sight range, and match its bonus range to the weapon's.
  4. 4In the advanced info, make it respond to combat and set its AI the way a Photon Cannon or Sunken is set.
  5. 5Copy the Photon Cannon's button set onto it.

Set the attack angle to 128. A building cannot turn - it always faces twelve o'clock - so a narrow angle means it only ever shoots what is directly above it.

The last one is the easy one to miss. The Attack (Building) order carries its own requirement, and that list is limited to Cannon, Sunken, Spore, Turret and the traps. Leave your building out of it and it will attack - but it will ignore the player's orders and pick its own targets.

If the requirement space runs out, free some by deleting the entries for traps you are not using. But do not rewrite the requirement table wholesale with values of your own - the order gets refused outright and the unit simply stops doing anything.

Do all of that, run it, and the moment an attack order lands the building turns invisible and a dolmen appears in its place. Nothing fires. That is the fifth thing: the building's iscript has no attack animation.

Most buildings have their ground and air attack animations set to 0, and script 0 is the dolmen. A dolmen means "there is no motion to play from here".

It also explains why a rock, of all things. StarCraft does not treat a 0 in an iscript header as "no animation" - it starts executing at address 0. There it finds 1,366 bytes of padding, and at the end of them it misreads the next entry's header as instructions: the header's type field holds 0x0F, which happens to be the sprol opcode, so it places sprite 0 some 132 pixels up. Sprite 0 is the Ashworld rock doodad. Before Remastered this mostly crashed; on Remastered the graphics are removed and the rock is left instead, which is why "the unit went invisible and a dolmen appeared" is one symptom rather than two.

So you borrow an iscript that does have attack animations - and among buildings there is almost nothing usable.

Which scripts can be borrowed does not have to be guessed. Read iscript.bin and 91 of the 398 have a ground attack animation; twelve of those are building or turret scripts. Line them up against whether their death leaves wreckage and the choice becomes obvious.

Building and turret scripts with an attack animation
76 Goliath(Turret)Ground and air, and leaves nothing on death. The best of them.
120 Missile Turret(Turret)Ground and air, and also leaves nothing. This is the one usually recommended, and checking it confirms the recommendation.
91 · 93 Siege Tank TurretGround only, but clean.
346 Floor Missile Trap TurretGround only, clean.
179 Photon CannonGround and air, but its death leaves wreckage.
46 Sunken ColonyGround only, and leaves wreckage.
119 Missile Turret(Base)Ground and air, but leaves wreckage. Do not confuse it with the turret script, 120.
Traps 345 · 347 · 348 · 349All ground only, and all leave wreckage.

Leaving wreckage is not fatal, but in a map where thousands of things die it fills the effect pool. Choosing a clean one means no destruction effect at all, so put one back with a trigger if the look matters.

If losing the death effect matters, put an explosion sprite there with a trigger. Adding the effect back is easier than removing the side effect.

An iscript change does not reach a unit that was already placed. The sprite's script pointer is fixed when the unit is put on the map, which happens before your code runs. A building that needs the new animations has to be created by a trigger.

FireGraft: button sets and requirements