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:
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.

I see.. yes I think it would be useful in certain situation, thank you for sharing
and about your mod I hope all goes well  :)
 
machok said:
Daniele Spadoni said:
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.

I see.. yes I think it would be useful in certain situation, thank you for sharing
and about your mod I hope all goes well  :)
Thanks to you! sure it will be fine! The game is in progress but it is as if you have already finished it because the future has already happened! ;)
 
machok said:
Interesting, is this some kind of openbor bug or something? but yes it woks

It works cause player isn't holding any weapon after getting the weapon; yet player changes weapon model.
Is it a bug? no. Is it buggy? yes  ::).

Thank you for posting the script although it's still a bit complicated for me, still has to be learned first

The complexity comes from weapon set. The script has to accommodate all available weapons in the game. Basically there's one section for each weapon in the scripts.

But the benefit of this is it allows carrying weapon to next stage/level and allows getting two or more weapons  8).
 
Hey there good people,

Suppose we have a character that is already wielding a weapon (weapon1 - e.g. a bat or a knife) while another weapon item (weapon2 - e.g. a gun or grenade) is flashing on the ground.

Is it possible for me to make this character grab and wield weapon2, while dropping weapon1 item on the floor, similar to what happens in most Capcom beat'em ups?

I have tried to adapt and use Bloodbane's scripts weapo.c (as didhitscript for each weapon item model) and weaplo.c (as takedamagescript for the player and "player with weapon" models) but so far I didn't manage to make the player try and grab the weapon2 item on the floor - it ignores weapon2 and just keeps attacking and swinging weapon1 in the air.

Are these scripts really intended to implement the Capcom behaviour described above or did I miss something in my implementation?

Thanks in advance! 💀💀💀
 
Hey kimono, thank you so much for your help!

Shadows of Death is a really cool mod and it really helped me with this "pick another weapon" thing. The scripts are working fine now that I removed the "weapon" subtype from the weapon's item models.

So far I made two weapon models for my player. One of them is a bat which works 100% OK with the custom weapons system. The other one is a "gun" projectile that can be thrown up to 5 times, much like a finite shuriken bundle. Well, the thing is that now, after these changes on the weapons system, the projectile's ammo became simply infinite.

Will it be necessary to implement a custom ammo system as well or is there some property I can change to achieve that?

Thanks in advance again, bro! 💀 💀 💀
 
Last edited:
Yes. Shuriken weapon in Shadows of Death uses custom ammo system.

Do you need different ammo system than that?

Hi there, BloodBane

After looking a bit further I think I finally managed to figure out how Shadows of Death's ammo system works internally. There were a couple of things I was missing here with my mod, like using the weapon's attack animation to explicitly decrease the ammo and change back to the player's "unarmed" model after the final shot. Without these fixes it would just keep shooting and shooting ad aeternum.

Anyways, it works perfectly now, and I would really like to thank you guys for all your support!

💀(y)
 
You are welcome Dr.Cranium. Do we have any clue on what kind of game you are currently developing? :)

Hey kimono, thanks for the interest.

I don't really have a strong final concept yet, but it is intended to be a political satire, pretty much in the vein of Streets of Russia, with a Capcom-style playability.

I'll make some videos and post a topic about it when I have something minimally worth looking.

👊💀👊
 
Hi Dr.Cranium, you can take a look at my Shadows of Death game and see how it's implemented: Complete - Shadows of Death
I can help you if you don't manage to do it.
Well, after swapping my player's weapons quite successfully, I finally came to find out that my weapon-dropping system (takedamagescript Data/Scripts/weaplo.c) is broken.
When my player takes damage, his weapon simply disappears and he reverts back to its default model, without actually dropping the weapon to the ground.
After a few hours of debugging (that came to an end thanks to the tips that DCurrent and Bloodbane gave me in this topic) I found out that this behaviour is being caused by the player's "model" property (shown below), which is always returning the player's default model name, making it impossible for my script to identify the weapon the player is carrying and therefore making it impossible to find the correct item to drop.
C:
getentityproperty(self, "model")

Any ideas on how to trace the origin of this problem and fix it?
 
Last edited:
Have you loaded the weapon entity before in models.txt?
It's essential for this scripted weapon pickup to work properly.
Hey Bloodbane, thanks for the reply.

Yeah, I'm pretty sure I did declare the entities, both for the item and the model in models.txt:
Code:
load Cobra-01  Data/Entities/Players/Cobra-01/Cobra-01.txt      #default model
load Cobra-Pau Data/Entities/Players/Cobra-01/Pau/Cobra-Pau.txt #weapon model
know Pau       Data/Entities/Items/Pau/Pau.txt                  #item

I even have an obstacle that drops the item after being broken and my player successfully picks the item, changes to weapon model and is even able to pick other weapons and swap to these other weapon models, while dropping the item for the current weapon before getting the new one. In other words, the wepo.c script is working fine. It is only weplo.c that is giving me a hard time:
C:
#import "data/scripts/library/spawn.h"

void main()
{
    void self   = getlocalvar("self");
    void PWep   = getentityproperty(self, "model");

    log("weaplo.c => " + PWep); //RESULT: weaplo.c => Cobra-01

    if(PWep=="Cobra-Pau") //Pwep is always "Cobra-01", so the code below never executes
    {
       shooter2("Pau", 0, 20, 0, 0, 1, 0);
       //setglobalvar("Cobra-Arma", 0);
       //changeentityproperty(self, "weapon", 0);
    }
}

By the way, if I comment out the "if" line, the "shooter" command works perfectly, but you know, if I take that as a solution I'll have to make a different takedamagescript for each weapon, which doesn't make much sense considering that in Shadows of Death the same script works just fine. I'm pretty sure I'm doing something wrong here, but I can't figure out what exactly. Could this be that I messed up with my models? I can post them here if you'd like.

Thanks in advance for all your support! 💀🙏
 
Last edited:
Actually I meant this line:


which should be using load like this:


Try it :D

Bloodbane, thank you so very much for your support, man.

I changed the know for load, but unfortunately the wrong behavior persisted: PWep is still getting "Cobra-01" as a value, so no weapon drop for me. :(

I even thought this might be related to the fact that the weapon model doesn't have a pain animation, so I tried to copy it from the base model, but it didn't work either.

I have also implemented that drawstring(50, 100, 2, PWep) script in the base model's header as you suggested in the other topic and, in this other scope, PWep is getting the "Cobra-Pau" value correctly.

So, after all, I'm still clueless... why would a takedamagescript declared in the weapon model return me the default model's name when I call getentityproperty(self, "model")?
 
I'm kinda puzzled here 😵‍💫.

Weplo.c works fine here.
Have you tried something such as renaming Cobra-Pau into CobraPau and adjusting related scripts?

If that doesn't work, I'd need to try your mod myself to understand the issue.
 
I'm kinda puzzled here 😵‍💫.

Weplo.c works fine here.
Have you tried something such as renaming Cobra-Pau into CobraPau and adjusting related scripts?

If that doesn't work, I'd need to try your mod myself to understand the issue.

Thank you so much for your support, man.

Just renamed the weapon model the way you said but unfortunately the behavior stays the same. Tried to use
Code:
getentityproperty(self, "weapnum")
instead of
Code:
getentityproperty(self, "model")
, again, to no avail - just like model, wepnum keeps returning 0.
I even tried to use a different takedamagescript for each weapon model. This seemed to work at first - player dropped weapon item and reverted back to default unarmed model - but after a few tests I realized that the workaround made the player keep on dropping the weapon item over and over again undefinately each time he got hit by the enemy.

What would be the most convenient way for me to send you my mod?

Once again, thanks in advance!
 
Hi Dr.Cranium, you can take a look at my Shadows of Death game and see how it's implemented: Complete - Shadows of Death
I can help you if you don't manage to do it.

I know it's been awhile, but since I edited my weapons' item entity files in order to reproduce the same behavior from Shadows of Death, the default sound played by the engine whenever the player grabs one of these items from the ground was similarly changed from get.wav to 1up.wav.

I order to fix that, I have already tried the solution proposed by O Ilusionista in his [SCRIPT] Custom sounds for picking itens + animations topic, but what I got here in my mod is both get.wav and 1up.wav being played simultaneously.

Considering it wouldn't be necessary for me to implement the animation part included in O Ilusionista's solution, I felt that it might something of an overkill solution for my case and tried add the subtype weapon property back to my item entities, but then the weapon system breaks (dropped weapon item can't be picked back).

Is there any other property or another scripting solution that I can add to my item entity files in order to revert that?

💀 Gratias in Antecessum! 💀
 
Last edited:
I know it's been awhile, but since I edited my weapons' item entity files in order to reproduce the same behavior from Shadows of Death, the default sound played by the engine whenever the player grabs one of these items from the ground was similarly changed from get.wav to 1up.wav.

I order to fix that, I have already tried the solution proposed by O Ilusionista in his [SCRIPT] Custom sounds for picking itens + animations topic, but what I got here in my mod is both get.wav and 1up.wav being played simultaneously.

Considering it wouldn't be necessary for me to implement the animation part included in O Ilusionista's solution, I felt that it might something of an overkill solution for my case and tried add the subtype weapon property back to my item entities, but then the weapon system breaks (dropped weapon item can't be picked back).

Is there any other property or another scripting solution that I can add to my item entity files in order to revert that?

💀 Gratias in Antecessum! 💀

Solved the conflicting sounds issue by removing the 1up.wav file and forcing get.wav in the weapo.c script, as proposed by @O Ilusionista .

And by the way, my previous issue was solved by @Bloodbane which added the weaploss 3 stat on all my player entities.
 
Back
Top Bottom