Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up(WIP) Gunmod support for crossbows! #5101
Conversation
This comment has been minimized.
This comment has been minimized.
|
Just realized this doesn't differentiate between crossbows and regular bows, anyone know how to implement this? |
This comment has been minimized.
This comment has been minimized.
|
New flag on crossbows? Or perhaps check the ammo type? Arrows == Bow, Bolts == Crossbow |
This comment has been minimized.
This comment has been minimized.
|
That's what I'm thinking, I'm just not certain how to implement it. |
desrik
reviewed
Dec 16, 2013
| @@ -8301,6 +8300,10 @@ void player::use(int pos) | |||
| g->add_msg(_("That %s cannot be attached to a rifle."), | |||
| used->tname().c_str()); | |||
| return; | |||
| } else if (guntype->skill_used == Skill::skill("archery") && !mod->used_on_crossbow) { | |||
This comment has been minimized.
This comment has been minimized.
desrik
Dec 16, 2013
Contributor
Yeah I see what you have to do now... You need another else if:
} else if (guntype->skill_used == Skill::skill("archery") && mod->used_on_crossbow && !guntype->ammo == "bolt") {
g->add_msg(_("That %s can only be attached to a crossbow."),
used->tname().c_str());
return;
}
This will prevent any mods from ever being installed on anything that uses arrows for ammo.
This comment has been minimized.
This comment has been minimized.
|
This doesn't seem to work, still lets me put a laser on a compound bow. |
This comment has been minimized.
This comment has been minimized.
|
See my updated line comment? Sorry about that :) Although a laser on a compund bow should be allowed :) I have seen them IRL. |
This comment has been minimized.
This comment has been minimized.
|
Adding mods for regular bows was going to be my next PR, I just wanted to keep to categories separate. For example, I want underbarrel mods like bayonets and grenade launchers to work on crossbows, but not on regular bows. I guess these both really need to be sorted out at the same time, huh? |
This comment has been minimized.
This comment has been minimized.
|
In that case you most likely would need to set up the mod categories first. New json field perhaps? "location": "underbarrel", "location": "scope", etc. Then in-code assign different weapon types a set of valid locations. When installing the mod check the mod location against the target weapon types valid mod locations. |
This comment has been minimized.
This comment has been minimized.
|
I like the idea of having mods being based on location on the weapon as opposed to the current blanket fields, but I think something like that is beyond my coding ability. I wonder if I should make an issue request asking if someone could implement it? It would be a big improvement, not just for bows but for all guns. For the moment, maybe I'll just change this to a more general "archery" mod category that covers both bows and crossbows. That could at least allow laser sight, improved iron sights and scopes for these. Either that, or maybe I can just stick a "IS_CROSSBOW" flag on all the crossbows in the .json, and have it look for it? |
This comment has been minimized.
This comment has been minimized.
|
For now you could just check the id and if it's not one you want compatible then message the player and return. Crude but it will work until mod locations get implemented. Might actually take it on myself here in a bit. Need a break on the construction expansion anyways. Spent around an hour and a half last night coding a deconstruct menu only to find out I need to write a few new functions before it would work :P |
This comment has been minimized.
This comment has been minimized.
|
Right now I'm trying to implement a "CROSSBOW" flag on items in the .json that the code can check for, but it doesn't seem to be working. Here's what I got so far; } else if (guntype->skill_used == Skill::skill("archery") && !mod->used_on_crossbow) && !gun->item_tags.count("CROSSBOW") { What am I missing here? This is the error I'm getting; C:\Documents and Settings\Mason\My Documents\GitHub\Cataclysm-DDA\src\player.cpp||In member function 'void player::use(int)':| |
This comment has been minimized.
This comment has been minimized.
|
Try: !gun->has_flag("CROSSBOW") |
This comment has been minimized.
This comment has been minimized.
|
Ah :) Your right @Rivet-the-Zombie. Also seems to be a double left parenthesis. g->add_msg(("That Oh and @NaturesWitness, here is what I came up with for mod locations: ammo |
This comment has been minimized.
This comment has been minimized.
|
Yeah looks to be simple separator errors. |
This comment has been minimized.
This comment has been minimized.
|
Rivet's pedantic nitpick of the day:
Sorry, that was too funny for me to resist. |
This comment has been minimized.
This comment has been minimized.
|
Lol. That's the Firefox auto-spellcheck for you :P |
This comment has been minimized.
This comment has been minimized.
|
Thanks to desrik's awesome work, this PR is no longer necessary, so I'm closing it. |
NaturesWitness
closed this
Dec 17, 2013
This comment has been minimized.
This comment has been minimized.
|
I don't think there is one right now, but we've been planning on moving |
NaturesWitness commentedDec 16, 2013
Adds a new mod category, crossbow. I think this is something people have wanted for a while, and as it turns out it wasn't nearly as hard as i thought it would be. Currently, only the laser sight is flagged as being compatible with crossbows, I used it for testing. I could use some guidance as to what gunmods should be flagged as crossbow-compatible, so please tell me what you think I should add!
Tested and works, I'll enable more gunmods for crossbows and see if anything breaks.