Mod Question Repository... Questions come in, answers go out - Page 20

Mod Question Repository... Questions come in, answers go out

Resources to get you going on your new project, or to help you over some emergent problems during your development cycle.

Moderator: Moderators

Locked
[Krogoth86]
Posts: 1176
Joined: 23 Aug 2007, 19:46

Post by [Krogoth86] »

Snipawolf wrote:Use trajectoryheight=1; with turnrate.

Trajectory height is... a percentage (0-100=.0-1.0) of how high it aims out of 90 degrees. 0 is forward, .5 is a 45 degree angle, and 1 is straight up.
Well that method has its problems as well. I just tried it out again - one thing is that the trajectory hight isn't (anymore?) a percentage. A value of 1 gave me a 45 to 55° starting angle. With a value of 2 it's ok and with a value of 4 it was pretty good. The big downside is that with values over 2 you get pretty bad "miscalculations" as your rockets won't hit the targeted area but one with a bit less distance. Though to be true you already have some minor troubles with max range at a value of 2...

Another thing is that you still have good close combat abilities as I can't seem to figure out how to give it a low turnrate. It seems that rockets come with some standard value (as in close combat they immediately turn down in no time) and the turnrate is something that adds to it...
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Post by Pressure Line »

trajectoryheight is actually just how many times higher the trajectory is than it will be long.

for example:

=1 means the trajectory will be as high as it is long, will give you a ~45* angle on your launcher on level terrain. ie target 500 units away, missile travels vert 500 and hor 500

=2 means the missile/rocket will travel 2x as far vertically as it will horizontally. ie target 500 units away, missile travels vert 1000 and hor 500

=0.5 will travel half as far vertically as it will horizontally. ie target 500 units away, missile travels vert 250 and hor 500
[Krogoth86]
Posts: 1176
Joined: 23 Aug 2007, 19:46

Post by [Krogoth86] »

I know that there was a problem with hovercraft aiming when they actually are on water. Do you still know what to do when you hovercrafts have a strange behaviour when being on water (i.e. they randomly decide not to fire anymore)?
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Post by Pressure Line »

possibly a faulty AimFromWeaponX() call. if the piece called in that part of the script is on/in the water the weapon probably wont fire (unless its a torpedo/depthcharge which im assuming is not your issue here)
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Actually it should check QueryWeaponX to see if the weapon is underwater.
[Krogoth86]
Posts: 1176
Joined: 23 Aug 2007, 19:46

Post by [Krogoth86] »

Well it happens just with a VLaunch Hovercraft of mine. It might be something with the Aiming / Firing Code (You don't know of a way to let a weapon with burst fire each one from a different object do you? That would simplifiy it a lot.) but when not hovering on water it works just fine. When being on water and you try to fire about 50-75% of the units just refuse to. You also canot make them firing at a random position by telling them so. When you keep em moving around they somewhen decide to shoot at last but I can't really tell when or how the problem gets solved. What's odd too is that when you go into the FPS mode the aiming works fine and you have a green "READY" clearance to fire but nothing happens when you click...

I still knew that the Halberd for a long time had some problems in BA when it came to firing on water and so I hoped that there might be a detail which can cause those problems...
[Krogoth86]
Posts: 1176
Joined: 23 Aug 2007, 19:46

Post by [Krogoth86] »

Well I think I'm going to use a burst fire weapon now - that should solve the problem although each rocket coming from a different position would have been nice...

But now for something more "serious" which now has consumed hours of my time:
How the hell do you give a unit two Anti-Air weapons? I wanted to give my unit a flak and a rocket launcher and at first it was business as usual. I added the Primary weapon script and made it the Flak-Gun. It worked fine ingame. Then I added the Secondary weapon but it just refuses to get locked on a target. After trying out various combinations I had a look into existing units which all have this strange "Bogus_Missile". I have no idea what it really does but as pretty much all AA-units have that I has to be s.th. important. But this also gave me no success - I tried various combinations of weapon slots and ways to call the aiming but most times I just got a unit that fires those Bogus plasma balls instead of the actual weapon. Sometimes I got it to not fire that but only one of the weapons and in one case I had a strange behaviour as after the enemy unit flew right over the AA-unit the second weapon suddenly switched on. I even did plain copies out of other BOS scripts but somehow it still refuses to work...

So - can someone please explain to me what's about that Bogus_Missile and what's needed to have two AA weapons for one unit. Thanks in advance (BTW: sorry for double posting)...
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post by Gnomre »

It's fairly simple to make bursts fire from different points mid-burst. For reference, this is the unit using this code. First the top barrels fire, then the bottom barrels. It uses the projectiles weapon tag instead of burst, but as far as I understand they work basically the same way (projectiles just spawns all the projectiles in one frame) so it should work on a burst weapon. Just keep in mind that I'm only speaking in terms of svn; I don't remember or care to find out how much of this was in 75b2.

First, initialize the static-var you're using for the barrel switch to -1. This can be done differently, depending on where your "++gun_1;" is later in the script, but it really makes no difference if it works.

Code: Select all

Create() {
	...
	gun_1 = -1;
	....
}
Then set up queryweapon normally. Nothing special here.

Code: Select all

QueryWeapon1(piecenum) {
	if(gun_1 == 0) {
		piecenum = firept1;
	}
	if(gun_1 == 1) {
		piecenum = firept3;
	}
	if(gun_1 == 2) {
		piecenum = firept2;
	}
	if(gun_1 == 3) {
		piecenum = firept4;
	}
}
Here's the interesting bit. ShotX() is called for each projectile in the burst, unlike FireWeaponX(), which is only called once per burst. We first increase gun_1 by one, and if it's greater than 3 (remember, gun_1 = 0 is barrel1, = 3 is barrel4) we reset it to 0 so the process begins again. As you can see, I do this at the beginning of the function, which is why we had to initialize to -1 above; putting it at the end and initializing to 0 should work just as well. Because ShotX is called for each projectile, gun_1 is increased for each projectile, meaning QueryWeaponX above fires from the correct spot.

Since the unit uses the projectiles tag, I only have to check for two specific values of gun_1 here: 0 and 2, and then play the animations in a block. But checking for gun_1 == 1 and so on should work just as well. Finally, note that FireWeapon1() has nothing.

Code: Select all

Shot1() {
	++gun_1;
	if(gun_1 > 3) {
		gun_1 = 0;
	}
	if(gun_1 == 0) {
		emit-sfx MED_MUZZLE_FLASH_FX_GREEN from firept1;
		emit-sfx MED_MUZZLE_FLASH_FX_GREEN from firept3;
		move barrel1 to z-axis [-7.5] now;
		move barrel3 to z-axis [-7.5] now;
		sleep 150;
		move barrel1 to z-axis [0] speed [37.5];
		move barrel3 to z-axis [0] speed [37.5];
	}
	if(gun_1 == 2) {
		emit-sfx MED_MUZZLE_FLASH_FX_GREEN from firept2;
		emit-sfx MED_MUZZLE_FLASH_FX_GREEN from firept4;
		move barrel2 to z-axis [-7.5] now;
		move barrel4 to z-axis [-7.5] now;
		sleep 150;
		move barrel2 to z-axis [0] speed [37.5];
		move barrel4 to z-axis [0] speed [37.5];
	}
}

FireWeapon1() {
}
That's pretty much it for iterating through barrels mid-burst. I don't know why your hovercraft can't fire over water without seeing the model and script.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

You don't know of a way to let a weapon with burst fire each one from a different object do you? That would simplifiy it a lot.
Replace FireWepaonX with ShotX...

Code: Select all

piece	fp1, fp2, fp3, fp4, ...
static-var firepoint, activeGunX;
QueryWeaponX(piecenum)
{
	piecenum = firepoint
}
ShotX()
{
	if (activeGunX == 0) {
		firepoint = fp1;
		++activeGunX;
		<other emit-sfx/move/turn/etc stuff>
	}
	else if (activeGunX == 1) {
		firepoint = fp2;
		++activeGunX;
		<other emit-sfx/move/turn/etc stuff>
	}
	else if (activeGunX == 2) {
		firepoint = fp3;
		++activeGunX;
		<other emit-sfx/move/turn/etc stuff>
	}
	else if (activeGunX == 3) {
		firepoint = fp4;
		activeGunX = 0;
		<other emit-sfx/move/turn/etc stuff>
	}
	...
}
...
Create()
{
	firepoint = fp1;
	activeGunX = 0;
	...
}
edit: eww my bad, though you could get rid of a var but can't, apparently.
Last edited by rattle on 12 Dec 2007, 00:47, edited 1 time in total.
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Post by Pressure Line »

[Krogoth86] wrote:So - can someone please explain to me what's about that Bogus_Missile and what's needed to have two AA weapons for one unit. Thanks in advance (BTW: sorry for double posting)...
english not being your first language i can understand how you may have missed it. bogus is another word for fake. its probably a dummy weapon. use another AA missile weapon, cortruck_missile or something like that (since iirc you're doing a TA mod)
Last edited by Pressure Line on 11 Dec 2007, 23:52, edited 1 time in total.
[Krogoth86]
Posts: 1176
Joined: 23 Aug 2007, 19:46

Post by [Krogoth86] »

Thank you very much! :-)
I didn't know the ShotX command yet...

Now I just need some help on that AA-problem and then I'm 100% happy... :-)
I really should consider writing a tutorial about all this... :wink:

Edit:
@Pressure Line:
I know that it's a fake weapon but I assume it has something to do with the aiming as pretty much all of the AA-units use this as first weapon. Why should they all use that if it's of no use?

Especially if you put it as weapon 1 and give it no firing code in your bos it's strange that only that weapon fires and for all the other unit which handle it the same way it doesn't...
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Post by Pressure Line »

[Krogoth86] wrote:Thank you very much! :-)
I didn't know the ShotX command yet...

Now I just need some help on that AA-problem and then I'm 100% happy... :-)
I really should consider writing a tutorial about all this... :wink:
ShotX() is currently svn only (im not 100% sure on that tho)

you could also use a scripted burst.
[Krogoth86]
Posts: 1176
Joined: 23 Aug 2007, 19:46

Post by [Krogoth86] »

Pressure Line wrote:you could also use a scripted burst.
That's what I have done right now though it gives me that strange sea behaviour...
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Post by Pressure Line »

hmmm. the fake weapon is to do with the slightly wonky way spring handles targetting for weapons with the tag toairweapon=1;
[Krogoth86]
Posts: 1176
Joined: 23 Aug 2007, 19:46

Post by [Krogoth86] »

Yeah - that's what I assumed too but I don't really understand how it works or why it works because with just one anti-air weapon everything's fine (i.e. without that Bogus_Missile). I only get problems with the second one. Then there is the Epoch for example which seems to be an exception to the rule as it has two flaks which work but no Bogus_Missile... :?
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

Be sure to switch the firepoints in ShotX or FireWeaponX.
I already made an idiot of myself about it.

Scripted bursts are easy to do, just lock the weapon after X rounds in the AimWeapon function, then unlock it after Y seconds. Then again the reload time will be hardcoded into the unit's script.

Though it's kind of unecessary now that we've got ShotX.

Generally, consulting the changelog is a good idea, though it's somewhat outdated.
[Krogoth86]
Posts: 1176
Joined: 23 Aug 2007, 19:46

Post by [Krogoth86] »

rattle wrote:Scripted bursts are easy to do, just lock the weapon after X rounds in the AimWeapon function, then unlock it after Y seconds. Then again the reload time will be hardcoded into the unit's script.
Well I did it this way:
I gave my unit the same weapon three times (as I wanted a triple burst). Now only the first weapon works like usual. The FireWeapon1 function controls everything: I put in 2 gun variables which get set to 1 after some sleep timers which trigger a while function in the other two weapons' Aim setting and they thus only get clearance while the specific gun variable is =1 . After some more seconds the FireWeapon1 function resets the gun variables to zero again and thus blocks the other two weapons...

Maybe not the best way to do it. What I learned from some previous hours is that you really shouldn't put those sleep timers in the Aim function... :mrgreen:

Thanks for those links btw... :-)
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

Code: Select all

#define BURST_LIMIT	5
#define RELOAD_TIME	1000

static-var shots;

Reload(delay)
{
	sleep delay;
	shots = 0;
}
AimWeapon1(h, p)
{
	if (shots >= BURST_LIMIT) return FALSE;
	...
	return TRUE;
}
FireWeapon1()
{
	++shots;
	if (shots == BURST_LIMIT) start-function Reload(RELOAD_TIME);
}
This is basically how I've done fake burst weapons before the introduction of ShotX since you couldn't spread burst weapons over mutliple firepoints. Which I was doing wrong as well but never mind. :P
You never stop learning.
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Post by bobthedinosaur »

is it possible to create weapons with random damage ranges?
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Not really but you can use Lua to trigger on UnitDamaged and add random extra damage.
Locked

Return to “Game Development Tutorials & Resources”