Making a trap

Okay, for the past few days (few hours, really), I’ve been working on getting a mod up and running. Currently I am working on adding a few new traps.

I’ve already created them in trapdef, created the effects in trapfunc, created them in itypedef, and updated iuse( don’t quote me on that one). It lets me “place” the trap, but it is invisible (or simply not there), and when I walk on it it shows a sssssss in the announcement box and sometimes spawns shadow snakes.

Any ideas on what is happening here?

It sounds like your pointing to the wrong trapfunc, honestly. Can you paste your trapdef and trapfunc code snippets here?

trap def

keys.clear(); id++; keys.push_back("tape_trap"); traps.push_back(new trap(id, "TAPETRAP", "tape trap", c_dkgray, '_', 1, 6, 0, &trapfunc::tape, &trapfuncm::tape, keys));;

[code]void trapfunc::tape(game *g, int x, int y)
{
g->add_msg(“You get tangled in tape!”);
g->u.moves -=150;
}

trap func
void trapfuncm::tape(game *g, monster *z, int x, int y)
{
if (g->u_see(z))
g->add_msg(“The %s gets tangled in tape!”, z->name().c_str());
z->moves -= 150;
}[/code]

For some reason they are just defaulting to snakes.

[quote=“drake1storm, post:3, topic:1149”]keys.clear(); id++; keys.push_back("tape_trap"); traps.push_back(new trap(id, "TAPETRAP", "tape trap", c_dkgray, '_', 1, 6, 0, &trapfunc::tape, &trapfuncm::tape, keys));;

[code]void trapfunc::tape(game *g, int x, int y)
{
g->add_msg(“You get tangled in tape!”);
g->u.moves -=150;
}

void trapfuncm::tape(game *g, monster *z, int x, int y)
{
if (g->u_see(z))
g->add_msg(“The %s gets tangled in tape!”, z->name().c_str());
z->moves -= 150;
}[/code][/quote]
I added your tape functions to trap.h and trapfuncs.cpp, and then applied them to the bubblewrap in trapdef.cpp. I spawned in a Zombie Brute and it sent the correct “tangled in tape” message and slowed it down a turn or so.
I’m not familiar enough with CDDA to figure out how the adding of stuff works yet, I’m guessing you failed to initialize/include something, somewhere.

[quote=“Weyrling, post:4, topic:1149”][quote=“drake1storm, post:3, topic:1149”]keys.clear(); id++; keys.push_back("tape_trap"); traps.push_back(new trap(id, "TAPETRAP", "tape trap", c_dkgray, '_', 1, 6, 0, &trapfunc::tape, &trapfuncm::tape, keys));;

[code]void trapfunc::tape(game *g, int x, int y)
{
g->add_msg(“You get tangled in tape!”);
g->u.moves -=150;
}

void trapfuncm::tape(game *g, monster *z, int x, int y)
{
if (g->u_see(z))
g->add_msg(“The %s gets tangled in tape!”, z->name().c_str());
z->moves -= 150;
}[/code][/quote]
I added your tape functions to trap.h and trapfuncs.cpp, and then applied them to the bubblewrap in trapdef.cpp. I spawned in a Zombie Brute and it sent the correct “tangled in tape” message and slowed it down a turn or so.
I’m not familiar enough with CDDA to figure out how the adding of stuff works yet, I’m guessing you failed to initialize/include something, somewhere.[/quote]

So it works with bubblewrap, eh?

Hmm, give me a minute. I might be able to fix this if that is true.

This is really odd. Everywhere bubblewrap is, my trap stuff is as well. I double checked, and everything is using my trap functions.

Oddly, though, all existing traps can use my trap functions, but anything that uses tr_tapetrap seems to default to the snake function. I tried changing it over to using tr_bubblewrap, but then it simply became bubble wrap.

This is very odd.

So then devs… no ideas, or is this going to be one of the things pumped out to a json, thus making any fixes here obsolete?

No ideas, it looks like everything should be in order. Maybe post larger chunks of code, possibly inside spoiler tags (for space reasons) or on pastebin?

I’m planning on trying to plug it all back together again after the latest git version is up. Chances are high the things they are changing will break any trap modifications I come up with.

I don’t think the current wave of changes is going to directly affect traps, at least not to the extent that things break catastrophically. The traps files haven’t been touched in… 8 days in one case, 19 days in another. And although we ARE moving lots of items to JSON, the original macro definitions are still present, albeit deprecated (mostly because random pseudo-items use some of those macros).

Is there anything in particular that you think will end up breaking stuff for you?

Just seems like moving the trap items themselves out to a json would be the next logical step, considering what has been done so far. If not, I guess I’d better download the latest (hopefully working) source code tomorrow and start putting up the various updates and tests items I’ve got collecting dust.

The in-inventory trap items should already have been moved over, just like all the other tools. The trap definitions, on the other hand, aren’t on any immediate list for conversion.

So, yeah, the current code should be more-or-less stable with regards to traps, at least for a little while.

Ok, guess I have a plan for what to do tommorrow:

  1. Wake up and take my last AP exam
  2. Pass out until the school day is over
  3. Get these bleeding things working (which is well overdue).