experience activating a weapon

experience activating a weapon

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
1v0ry_k1ng
Posts: 4656
Joined: 10 Mar 2006, 10:24

experience activating a weapon

Post 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
tombom
Posts: 1933
Joined: 18 Dec 2005, 20:21

Post 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.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post 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.
User avatar
1v0ry_k1ng
Posts: 4656
Joined: 10 Mar 2006, 10:24

Post 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?
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post 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...
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post 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.
User avatar
1v0ry_k1ng
Posts: 4656
Joined: 10 Mar 2006, 10:24

Post 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 ?
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post 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?
User avatar
1v0ry_k1ng
Posts: 4656
Joined: 10 Mar 2006, 10:24

Post by 1v0ry_k1ng »

is this the cob or the 3do?
SpikedHelmet
MC: Legacy & Spring 1944 Developer
Posts: 1948
Joined: 21 Sep 2004, 08:25

Post 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.
Post Reply

Return to “Game Development”