Solved Pick up a weapon

Question that is answered or resolved.

Daniele Spadoni

New member
I have a little problem.
When a player picks up a weapon he cannot pick up another weapon .... only if the bullets run out the weapon drops and I can pick up another weapon.
How can I solve the problem?
 
Daniele Spadoni said:
When a player picks up a weapon he cannot pick up another weapon

It's default feature from OpenBoR.
If you want player to pick up another weapon while holding a weapon, you'll have to use scripted weapon system.

kimono said:
Bloodbane has made a script for me to pick and exchange weapons on floor. If he agrees, I can post it here.

You have my permission  8). Feel free to share it here.
 
Bloodbane said:
Daniele Spadoni said:
When a player picks up a weapon he cannot pick up another weapon

It's default feature from OpenBoR.
If you want player to pick up another weapon while holding a weapon, you'll have to use scripted weapon system.

kimono said:
Bloodbane has made a script for me to pick and exchange weapons on floor. If he agrees, I can post it here.

You have my permission  8). Feel free to share it here.

Really nice thanks.
Hope to understand how it works.
 
Daniele Spadoni said:
I have a little problem.
When a player picks up a weapon he cannot pick up another weapon .... only if the bullets run out the weapon drops and I can pick up another weapon.
How can I solve the problem?

weaponframe !!! YEAH! He let the weapon drop !
I like the idea the most.
Resolved! !
Care to explain how you do it?
 
machok said:
Daniele Spadoni said:
I have a little problem.
When a player picks up a weapon he cannot pick up another weapon .... only if the bullets run out the weapon drops and I can pick up another weapon.
How can I solve the problem?

weaponframe !!! YEAH! He let the weapon drop !
I like the idea the most.
Resolved! !
Care to explain how you do it?

I create a weapon switch button.
I enter the command weaponframe ( loading the first player with standard weapon)....and YEAH! I can choose another weapon. ;) Magic!

 
Daniele Spadoni said:
I create a weapon switch button.
I enter the command weaponframe ( loading the first player with standard weapon)....and YEAH! I can choose another weapon. ;) Magic!
you can immediately switch while character still holding a weapon or you have to throw it first?
 
machok said:
Daniele Spadoni said:
I create a weapon switch button.
I enter the command weaponframe ( loading the first player with standard weapon)....and YEAH! I can choose another weapon. ;) Magic!
you can immediately switch while character still holding a weapon or you have to throw it first?

I just found out that if you enter the "weaponframe" command in GET you can change your weapon! YEAH!

----------------------
anim get

loop 0
delay 10
offset 15 37
weaponframe 2 1
frame data/chars/2P/04.png
bbox.position.x -1
bbox.position.y 12
bbox.size.x 36
bbox.size.y 31
        frame data/chars/2P/04.png
        frame data/chars/2P/04.png
----------------------------------------------
I don't know why it works. But it is spectacular!
You have to insert the weapon you have at that moment.
If you insert another weapon, OpenBor crashes.

I solved it without script! Incredible!

Today at 10:22:33 AM  Hmm..  1+0+2+2+3+3=11 " Thanks GOD "
 
With this method, you can only change to the weapon number 1 model.
Weaponframe is a fantastic command to make some character transformation too :).

So two scripts for the weapon change on floor, drop and keep during levels:
wepo.c:
Code:
#import "data/scripts/library/spawn.h"

void main()
{//Script for scripted weapon item
    void self = getlocalvar("self");
    char Item = getentityproperty(self,"defaultname");
    void target = getlocalvar("damagetaker");
    char PWep = getentityproperty(target, "model");
    char PName = getentityproperty(target, "defaultname");
    void Shur;

    if(PName=="Billy"){
      if(PWep=="Billynun"){
        shooter2("nunchaku", 0, 20, 0, 0, 1, 0);
      } else if(PWep=="Billyshu"){
        int BAmmo = getglobalvar("BilShur");
        Shur = shooter2("shuriken", 0, 20, 0, 0, 1, 0);

        changeentityproperty(Shur, "grabforce", BAmmo);
      } else if(PWep=="Billysickle"){
        shooter2("sickle", 0, 20, 0, 0, 1, 0);
      }

      if(Item=="nunchaku"){
        setglobalvar("BilWep", 1);
        changeentityproperty(target, "weapon", 1);
      } else if(Item=="shuriken"){
        int Ammo = getentityproperty(self,"grabforce");

        setglobalvar("BilWep", 2);
        setglobalvar("BilShur", Ammo);
        changeentityproperty(target, "weapon", 2);
      } else if(Item=="sickle"){
        setglobalvar("BilWep", 3);
        changeentityproperty(target, "weapon", 3);
      }
    } else {
      if(Item=="nunchaku"){
        shooter2("nunchaku", 0, 20, 0, 0, 1, 0);
      } else if(Item=="shuriken"){
        shooter2("shuriken", 0, 20, 0, 0, 1, 0);
      } else if(Item=="sickle"){
        shooter2("sickle", 0, 20, 0, 0, 1, 0);
      }
    }
}
An example with the nunchaku weapon:
Code:
name		nunchaku	#GROUND
health		1
type		item
nolife		1
gfxshadow	1
offscreenkill	5
stealth		100
didhitscript	data/scripts/wepo.c


anim	idle
	loop	1
	delay	200
	offset	23 5
	bbox	0 0 48 12
	frame	data/chars/weapons/nunchaku.png
	nodrawmethod
	frame	data/chars/weapons/nunchaku.png
	delay	6
	drawmethod tintmode 1
	drawmethod tintcolor 150_150_150
	frame	data/chars/weapons/nunchaku.png

weaplo.c for the weapon loss :

Code:
#import "data/scripts/library/spawn.h"

void main()
{//Billy's damagescript for scripted weaponloss
    void self = getlocalvar("self");
    void PWep = getentityproperty(self, "model");
    char Weap;

    if(PWep=="Billynun"){
      Weap = "nunchaku";
    } else if(PWep=="Billyshu"){
      Weap = "shuriken";
    } else if(PWep=="Billysickle"){
      Weap = "sickle";
    }

    shooter2(Weap, 0, 20, 0, 0, 1, 0);
    setglobalvar("BilWep", 0);
    changeentityproperty(self, "weapon", 0);
}
You need to spawn an entity in your level like this:
Code:
name    	reweap
type    	none


anim	idle
@script
  if(frame==1){
    int BWeap = getglobalvar("BilWep");
    void P1 = getplayerproperty(0, "entity");
    char PName = getentityproperty(P1, "defaultname");

    if(PName=="Billy" && BWeap!=0){
      changeentityproperty(P1, "weapon", BWeap);
    }
  }
@end_script
	delay	1
	offset	1 1
	frame	data/chars/misc/empty.gif
	frame	data/chars/misc/empty.gif
	frame	data/chars/misc/empty.gif

@Bloobane can correct me if I forget something :) .


 
Daniele Spadoni said:
I just found out that if you enter the "weaponframe" command in GET you can change your weapon! YEAH!

I've just tested it and although it does change your weapon, it has unwanted sideeffect: clone weapon falls on ground  :-[.
And I'm afraid it could cause problem if you GET non-weapon items.

I suggest you use scripted version which kimono has posted in previous page to avoid problems in the future :).

kimono said:
Bloobane can correct me if I forget something

Thanks for posting those stuffs for me ;)

I should mention that Reweap is to allow carrying weapon from level to level. If you don't allow that, then no need to use reweap.
 
Bloodbane said:
Daniele Spadoni said:
I just found out that if you enter the "weaponframe" command in GET you can change your weapon! YEAH!

I've just tested it and although it does change your weapon, it has unwanted sideeffect: clone weapon falls on ground  :-[.
And I'm afraid it could cause problem if you GET non-weapon items.

I suggest you use scripted version which kimono has posted in previous page to avoid problems in the future :).

kimono said:
Bloobane can correct me if I forget something

Thanks for posting those stuffs for me ;)

I should mention that Reweap is to allow carrying weapon from level to level. If you don't allow that, then no need to use reweap.

Wrong. if used " typeshot 0 ", the weapon does not fall. ;) YEAH !
There is only the problem of ammunition. but in my game they are not necessary. ;)
I advise you to You have to delete out the ammo to make it work. ;)
 
Daniele Spadoni said:
I just found out that if you enter the "weaponframe" command in GET you can change your weapon! YEAH!

----------------------
anim get
 
  loop  0
  delay  10
  offset  15 37
weaponframe 2 1
  frame  data/chars/2P/04.png
  bbox.position.x -1
  bbox.position.y 12
  bbox.size.x 36
  bbox.size.y 31
        frame  data/chars/2P/04.png
        frame  data/chars/2P/04.png
----------------------------------------------
I don't know why it works. But it is spectacular!
You have to insert the weapon you have at that moment.
If you insert another weapon, OpenBor crashes.

I solved it without script! Incredible!
Interesting, is this some kind of openbor bug or something? but yes it woks
the only thing is, with typeshot 0 when you switching to another weapon the first weapon you hold will be lost

kimono Bloodbane
Thank you for posting the script although it's still a bit complicated for me, still has to be learned first
 
machok said:
Daniele Spadoni said:
I just found out that if you enter the "weaponframe" command in GET you can change your weapon! YEAH!

----------------------
anim get
 
  loop  0
  delay  10
  offset  15 37
weaponframe 2 1
  frame  data/chars/2P/04.png
  bbox.position.x -1
  bbox.position.y 12
  bbox.size.x 36
  bbox.size.y 31
        frame  data/chars/2P/04.png
        frame  data/chars/2P/04.png
----------------------------------------------
I don't know why it works. But it is spectacular!
You have to insert the weapon you have at that moment.
If you insert another weapon, OpenBor crashes.

I solved it without script! Incredible!
Interesting, is this some kind of openbor bug or something? but yes it woks
the only thing is, with typeshot 0 when you switching to another weapon the first weapon you hold will be lost

It depends what kind of game you want to create. in my new game that will be released soon he will use the first weapon only at the beginning of the level or when he dies.
 
Back
Top Bottom