Autoswitch Weapons.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Autoswitch Weapons.
Is it possible when the player picks a weapon,the game to switch to the picked up weapon,instead of staying with the same weapon untill the player chooses the picked up weapon?
Re: Autoswitch Weapons.
A little piece of script to get you started:
Code: Select all
gun_variable [0]
gun_slot [5]
setup[ ()
{
gun_variable = GetAttribute("gun","Player");
think = "run";
} ]
run[ ()
{
ThinkTime = 0.1;
if(gun_variable = 0)
{
if(GetAttribute("gun","Player") > 0)
{
SetPlayerWeapon(gun_slot);
gun_variable = 1;
}
}
} ]
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Autoswitch Weapons.
thanks Juutis one more time and actually,that get's me done ! I think (have to finnish animating one of the weapons and than I'll test it!
Only if you can explain to me this part,it will be great!
I cant understand whant this line does and how it does it.
Only if you can explain to me this part,it will be great!
Code: Select all
gun_variable = GetAttribute("gun","Player");
Re: Autoswitch Weapons.
It just stores the amount of 'guns' the player has in the beginning. So if the player already has the weapon 'gun' (in level start for example) the script won't change the player's weapon. The main idea here is: If player has no 'gun' -> check if he has picked it up -> change weapon. If the player already has 'gun' don't bother checking the attribute anymore. Hope that's clear enough.
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Autoswitch Weapons.
Thanks,one more thing I learned from you !
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Autoswitch Weapons.
Amm...I'm terribly sorry for this,I should have posted earlier,but I completely forgot and that's important. I didn't manage to make the desired effect (the weapon autochange).
Here's the finnished script,I think it should be working,right? When the player picks up the attribute "sniper",the script should change he Player's weapon to the weapon that's in the 6-th position.I'm sorry again,it's totally stupid and incorrect of me to post this after all this time!
Code: Select all
{
gun_variable [0]
gun_slot [6]
Spawn[ ()
{
Console(true);
PawnRender(false);
LowLevel("setup");
} ]
setup[ ()
{
gun_variable = GetAttribute("sniper","Player");
think = "run";
} ]
run[ ()
{
ThinkTime = 0.1;
if(gun_variable = 0)
{
if(GetAttribute("sniper","Player") > 0)
{
SetPlayerWeapon(gun_slot);
gun_variable = 1;
}
}
} ]
Re: Autoswitch Weapons.
It's OK. Seriously, which is better: starting a new thread or posting in an old one?metal_head wrote:I'm sorry again,it's totally stupid and incorrect of me to post this after all this time!
And besides, I'm a terrible slowpoke too.
Anyway: PawnRender() is a low level command so it should be 'setup' order, not 'Spawn'. You're also missing the ending '}' for the script (probably another copy-paste mistake). But apart from those it worked for me. Also note that the weapon slot 6 is the weapon that has 'slot = 6' in its definition, not the one that's armed with the key 6.
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Autoswitch Weapons.
REally,really strange,the missed "}" wasn't a copy/paste mistake,I also removed the PawnRender command and before I put it into the "setup" order,I decided to test how is it working,but it wasn't working again...
it's really,really strange,I don't see nothing wrong:
The gun slot is 6 so the sniper rifle arms when I press "7":
the attribute entity gives the Player an ammount of 1 of attribute,which looks like this:
When I collect the sniper rifle,it jsut doesn't pick itself automaticly...I have to press "7",so that the weapon in the slot 6 will be activated (and that's the sniper).
it's really,really strange,I don't see nothing wrong:
Code: Select all
{
gun_variable [0]
gun_slot [6]
Spawn[ ()
{
Console(true);
LowLevel("setup");
} ]
setup[ ()
{
gun_variable = GetAttribute("sniper","Player");
think = "run";
} ]
run[ ()
{
ThinkTime = 0.1;
if(gun_variable = 0)
{
if(GetAttribute("sniper","Player") > 0)
{
SetPlayerWeapon(gun_slot);
gun_variable = 1;
}
}
}
} ]
Code: Select all
[sniper]
type = weapon
slot = 6
firerate = 2.5
catagory = projectile
projectile = rifle_shell
attribute = enemy_health
ammunition = rifle_shell
Code: Select all
[sniper]
initial = 0
low = 0
high = 1
Re: Autoswitch Weapons.
Code: Select all
...
run[ ()
{
ThinkTime = 0.1;
if(gun_variable = 0)
{
if(GetAttribute("sniper","Player") > 0)
{
SetPlayerWeapon(gun_slot);
gun_variable = 1;
}
}
}
} ]
Code: Select all
...
run[ ()
{
ThinkTime = 0.1;
if(gun_variable = 0)
{
if(GetAttribute("sniper","Player") > 0)
{
SetPlayerWeapon(gun_slot);
gun_variable = 1;
}
}
} ]
}
The syntax for a script is:
Code: Select all
{
order1 [ ()
{
} ]
order2 [ ()
{
} ]
}
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Autoswitch Weapons.
oh,silly me,I shouldn't be making such mistakes... that was really stupid of me,and I checked the script twice for this type of mistakes.