Page 1 of 1

experience activating a weapon

Posted: 22 May 2007, 20:55
by 1v0ry_k1ng
sorry if this is a big ignorant but im pretty unskilled at modding atm,
Im trying to set the arm and core commanders (XTA) to have a weapon that unlocks at a level of experience and disactivates the old weapon.
now im guessing this is done through the scriptor but im not totally sure where to start.
ive got my hands on a copy of war evolution but its not that clear.
where do I start? any help at all would be very welcome

Posted: 22 May 2007, 21:28
by tombom
I'm not a scripting genius but as far as I can tell War Evo does it like this:
1) It has a constantly running script checking the experience using exp = GET VETERAN_LEVEL;
2) If the experience has reached a certain level, it activates one of the upgrades by setting one of the variables to 1.
3) In the AimWeapon script, if the variable for that weapon isn't 1, it will sleep so that the weapon never fires.

Posted: 22 May 2007, 22:01
by KDR_11k
In the AimWeaponX function use

if(value > get VETERAN_LEVEL) return 0;

for the weapon that deactivates and

if(value <= get VETERAN_LEVEL) return 0;

for the weapon that activates. Should be the first line in that function. Value is obviously the exp level at which you want the switch to occur, e.g. 100 for 1.00.

Posted: 22 May 2007, 22:26
by 1v0ry_k1ng
can you explain that further? maybe give an example?

AimPrimary(heading, pitch)
{
Static_Var_13 = get VETERAN_LEVEL;
if ( Static_Var_13 > 50 )
{
return (0);
}
if( Static_Var_4 == 1 )
{
return (0);
}
signal SIG_AIM;
set-signal-mask SIG_AIM;
bAiming = TRUE;
while( !Static_Var_3 )
{
sleep 100;
}
turn torso to y-axis heading speed <300.071429>;
turn luparm to x-axis <0.000000> - pitch - <30.005495> speed <45.005495>;
wait-for-turn torso around y-axis;
wait-for-turn luparm around x-axis;
return (1);
}
would that work?

Posted: 22 May 2007, 22:27
by rattle
I'd use a static var in the aim function instead...

Code: Select all

static-var weapon1_locked;
Create()
{
	weapon1_locked = TRUE;
	...
}
AimWeapon1(heading, pitch)
{
	if (weapon1_locked)
	{
		if (get VETERAN_LEVEL > some_value) weapon1_locked = FALSE;
		return FALSE;
	}
	else return TRUE;
}
Otherwise I'd perform an unecessary get each time it aims. Although it doesn't really matter that much...

Posted: 22 May 2007, 23:04
by KDR_11k
I doubt a get is any slower than a variable lookup. Keep in mind this code is running on an interpreter anyway.

Posted: 22 May 2007, 23:08
by 1v0ry_k1ng
tbh I only just found out that the order of the lines is important, that looks a bit beyond me :P
if its unclear, im attempting to bolt another hardpoint onto a commander script, in the same position as the laser weapon, and use the experince level to decide which one aims the arm and can fire.
stages to doing this:

1) figure out how to activate and disactive a weapon done

2) figure out how to add a new weapon using the script, ideally copy pasting an existing weapon and just giving it a higher number, while not breaking the script.

3) sort out which weapon aims the arm.

Im hoping there is a shoddy cut/paste solution to all of these because my coding skill is basicly negative.
How do I add a weapon to a script/what do i copy/paste ?

Posted: 22 May 2007, 23:32
by rattle
Just copypasta all those *WeaponX() functions and increase X by 1.
Also use a different signal in each AimWeaponX() function or one aim function will kill another which can prevent the unit from firing at all...

AimFromWeaponX()
AimWeaponX()
FireWeaponX()
EndBurstX() (if you happen to use that)

Did I miss one?

Posted: 22 May 2007, 23:37
by 1v0ry_k1ng
is this the cob or the 3do?

Posted: 22 May 2007, 23:59
by SpikedHelmet
Ask Nemo, he did this for 1944 awhile back. Quite well, actually. We even had a star appear over infantry heads when their weapon unlocked.