1 registered members (AndrewAMD),
1,519
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Unequip weapons?
#394390
02/12/12 18:53
02/12/12 18:53
|
Joined: Nov 2009
Posts: 70
Siwler
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2009
Posts: 70
|
Hey guys. Can anyone give me an example on how to unequip weapons? I looked around Aum and Wiki and haven't found anything useful. Please
Honesty will get you far, were dishonesty will get you only so far in life.
|
|
|
Re: Unequip weapons?
[Re: Siwler]
#394399
02/12/12 21:49
02/12/12 21:49
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Totally depends on how you equip them. Where exactly is your problem with unequipping?
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Unequip weapons?
[Re: Siwler]
#394405
02/12/12 22:47
02/12/12 22:47
|
Joined: Aug 2011
Posts: 58 Colombia/Bogotá
wdakfenixx
Junior Member
|
Junior Member
Joined: Aug 2011
Posts: 58
Colombia/Bogotá
|
Well you should have a variable like Wequip that is set to 1 when you get the gun, to 0 when you don´t have it and to when is unnequiped, so you have a function managing this variable like
while(1)//for ever or until a break
{
switch(Wequip)//acording to Wequip
{
case 0://if its 0
// put here the commands
break;
case 1://if its 0
// put here the commands
break;
case 2://if its 0
// put here the commands
break;
}
}
if you have many weapons you can use an array like Wequip[x] where x is the number of the weapons
CAUTION :The content above could blow your mind
|
|
|
Re: Unequip weapons?
[Re: wdakfenixx]
#394512
02/13/12 23:54
02/13/12 23:54
|
Joined: Nov 2009
Posts: 70
Siwler
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2009
Posts: 70
|
I just don't get it. here is some parts of the codes that do the equip part, I don't know how to unequip them.
if (t_shooter_weapon == 1) // the 1st weapon (pistol) is selected?
{
t_shooter_pistol.flags2 |= SHOW; // then show the pistol entity
t_shooter_machinegun.flags2 &= ~SHOW; // hide the machine gun entity
t_shooter_crosshair_pan.flags &= ~SHOW; // hide the crosshair
t_shooter_snipergun.flags2 &= ~SHOW; // hide the sniper gun
}
case 1: // the player has got the pistol here
if (t_shooter_pistol_bullets < 1) // we ran out of pistol bullets?
{
SND_CREATE_STATIC(no_weapon, noweapon_wav);
snd_play(no_weapon, 100, 0); // then play the "no weapon" sound once
return; // get out of this function, no need to play the "no weapon" sound more than once
}
else // we've got at least a bullet here
{
t_shooter_pistol_bullets -= 1; // let's subtract 1 from the number of pistol bullets
t_shooter_pistol_bullets = maxv(0,t_shooter_pistol_bullets); // but let's make sure that we don't go below zero no matter what (would look bad on the screen)
}
I'm trying to unequip weapons by cretin level_load and if possible by on_button(0). And even if under unequip mode I still need to be able to buy more weapons and ammo and store them as unequipped until otherwise... I did manege to do something like store weapons and ammo as unequipped when I got to work with the buy_weapon code I managed to make it: when weapon bought, weapon will not automatically equip unless key pressed 1-3. But this only works when weapon bought the first time. Can anyone help please.
Honesty will get you far, were dishonesty will get you only so far in life.
|
|
|
Re: Unequip weapons?
[Re: Siwler]
#394515
02/14/12 00:16
02/14/12 00:16
|
Joined: Nov 2009
Posts: 70
Siwler
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2009
Posts: 70
|
Wait a minute I think I'm on to something but with a glitch. This code below dose half of what I was looking for, it hides weapon only after I buy it and exit the weapon shoppe and then I enter back in to weapon shoppe, bought weapon is not active, I can even collect ammo and when exiting weapon shoppe I have to press 1-3 to bring the weapon in to actions. Code it activated only when in contact with entity that has code load_level
switch(t_shooter_weapon)//
{
case 0://if its 0
if (t_shooter_weapon == 0)// check if any weapons selected
t_shooter_weapon = 0; // no weapons equipped
break;
case 1://if its 1
if (t_shooter_weapon == 1)// check if any weapons selected
t_shooter_weapon = 0; // if weapon selected do not equip in this level
break;
case 2://if its 2
if (t_shooter_weapon == 2) // check if any weapons selected
t_shooter_weapon = 0; //if weapon selected do not equip in this level
break;
case 3://if its 3
if (t_shooter_weapon == 3) // check if any weapons selected
t_shooter_weapon = 0; //if weapon selected do not equip in this level
break;
}
Glitch is that I can still equip weapons in weapon shoppe level by pressing 1-3. So my next question is how do I code this: if key_pressed 1 ignore key_pressed 1 just for this level
Honesty will get you far, were dishonesty will get you only so far in life.
|
|
|
Re: Unequip weapons?
[Re: Siwler]
#394531
02/14/12 02:55
02/14/12 02:55
|
Joined: Aug 2011
Posts: 58 Colombia/Bogotá
wdakfenixx
Junior Member
|
Junior Member
Joined: Aug 2011
Posts: 58
Colombia/Bogotá
|
thats the shooter template so you should put the question in the right forum, however thats not the code that unnequip weapon its somewhere when use the var got_weapon, to answer your question I think that the best willi be an array as i told you before lets see var Weapon[100];//this create an array that is a group of 100 vars
you asign the value of each var according to the "state" of the weapon like 0 if it is not selected and not possesed 1 if it is selected 2 if it is not selected but possesed
Weapon[4] = 2;//this mean that you have the weapon number 4 but its not equiped
so with switch and if statements you can run the commands that you desire according to the "state" of the weapon
I also add that that piece of code is redundant you should just write t_shooter_weapon = 0; because any result becomes into 0
CAUTION :The content above could blow your mind
|
|
|
Re: Unequip weapons?
[Re: wdakfenixx]
#394717
02/16/12 01:13
02/16/12 01:13
|
Joined: Nov 2009
Posts: 70
Siwler
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2009
Posts: 70
|
Thanks for trying to help me and have me understand arrays, but I just cant figure out how to unequip weapons with array. I tried your method in many various ways and no luck.
To tell you the truth I do understand your method by using arrays, its my ability to code is very limited, there fore I try to go around pointers/arrays as much as possible until I get full sense of them.
The only way that I think can help me is to try and disable key 1,2 and 3 temporarily while player in weapon shoppe lvl. To avoid being able to equip weapons in that specific level.
Honesty will get you far, were dishonesty will get you only so far in life.
|
|
|
Re: Unequip weapons?
[Re: darkinferno]
#394845
02/16/12 21:35
02/16/12 21:35
|
Joined: Nov 2009
Posts: 70
Siwler
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2009
Posts: 70
|
Yea, looks like I have no other choice but to do that.
Honesty will get you far, were dishonesty will get you only so far in life.
|
|
|
Re: Unequip weapons?
[Re: Siwler]
#394864
02/17/12 01:40
02/17/12 01:40
|
Joined: Aug 2011
Posts: 58 Colombia/Bogotá
wdakfenixx
Junior Member
|
Junior Member
Joined: Aug 2011
Posts: 58
Colombia/Bogotá
|
Well in the sed manual is well explained,but you should two what this guys says, also visit tutorial.3dgamestudio.com , you will learn the most basics things there
CAUTION :The content above could blow your mind
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|