Page 1 of 1

Attacking/Spellcasting Buildings

Posted: Sun Jan 04, 2015 2:08 pm
by JanuszPawulon
I came up with a method for adding new simple spells for units which doesn't have any other spells. Example: I gave dragoon a button for ensnare, but changed its icon and label to let's say NewSkill. Then added a spellcasting animation for dragoon, but instead of using the castspell opcode I used:
useweapon 108
wait 20
useweapon 84
The result was that dragoon got a spell that maelstormed enemy units and psi stormed them after a while. The cons of this are that it doesn't create a bullet, it doesn't show the energy cost when you point on the spell icon an if you want to change its energy cost you have to change ensnare's energy cost.
It was ok until I tried to force a building to cast ANY spell. All I was able to do was to make a photon cannon cast ensnare only while the target had the same looking direction. Then I tried with Xelnaga Temple and realised that I can't even remake it into an attacking building. Tried replacing it's .dat entries and iscript with photon cannons' and it made it attack only when an enemy was in its range, so if I wanted to attack a friendly unit or just change the target from one enemy or another it wouldn't react to my orders. Are attacking buildings hardcoded or what? The furthest I got was to make SC freeze when target got in the same direction as the temple.

tl;dr I want my XelNaga Temple to cast spells.

Re: Attacking/Spellcasting Buildings

Posted: Fri Jan 09, 2015 2:25 am
by IskatuMesk
The unit needs to be able to turn. Buildings technically aren't able to turn (I believe it's both images.dat and flingy.dat you need to change). Since their sprites and iscripts aren't set up to do that, they'll promptly crash when you change them.

Thus, the easiest way to change it would probably be to make their iscripts use a frameset instead of a single frame (0x00 as opposed to 0), edit their grps accordingly, and mess with the dats. Make note I can't actually remember if this is the case, and fire overlays tend to crash when you change building animations. Feel free to experiment.

The photon cannon calls frames the temple doesn't have. That's usually a pretty solid way to crash the game.

And yeah, Useweapon spawns the weapon onto its target. So does Attackprojangle (the target being the distance) iirc though I may be wrong.

Re: Attacking/Spellcasting Buildings

Posted: Sat Jan 10, 2015 6:09 am
by JanuszPawulon
I added the framesets in iscript so it's not the issue. I think the problem is that buildings can't face other directions than initial. No idea how scanner sweep works then though.

Re: Attacking/Spellcasting Buildings

Posted: Sat Jan 10, 2015 4:07 pm
by IskatuMesk
Command centers are really weird in general. I remember trying to add an attack to one in UF, and it broke all kinds of shit. I'm sure I knew the exact specifics of how to get all this stuff working, but I've long forgotten.

Re: Attacking/Spellcasting Buildings

Posted: Sat Jan 10, 2015 5:58 pm
by JanuszPawulon
I'm too tired to experiment with this now, but I think the attack angle in weapon's properties is the issue. STS/STA Photon cannon has it set to 128. DatEdit:
Angle within which the weapon can be fired without waiting for the unit's graphics to turn. 128 = 180 degrees.
Ok, setting attack angle to 128 worked. All works fine now.

Re: Attacking/Spellcasting Buildings

Posted: Sun Jan 11, 2015 1:52 am
by IskatuMesk
I thought that might have been the case, and I was going to suggest it, but then I thought "wait, did starcraft even have an option like that?"

Weird that fixed it, but whatevs.

Re: Attacking/Spellcasting Buildings

Posted: Wed Jan 14, 2015 6:19 pm
by mark_009_vn
Angle within which the weapon can be fired without waiting for the unit's graphics to turn. 128 = 180 degrees.
Pretty sure most defense buildings use this property, Sunkens in particular actually use a special iscript opcode that determine it's attack direction and play the according frameset, it doesn't turn at all.

Re: Attacking/Spellcasting Buildings

Posted: Wed Jan 14, 2015 9:37 pm
by NigelTittysh
IIRC that's how the Hydralisk was in beta (remnants can still be seen in the fact that it's the only unit to get stuck in the middle of its attack animation because Blizzard was too retarded to clean up all the goatse bits after they swapped it back in favour of the updated iscript).