Code Help (Currently Solved)

So right now I’m working on a small light rework so that flags like LIGHT_4 actually have an effect without needing to be hacked into the game, but I’ve run into a small problem.

Here is the important part of my code right now:

[code] std::vector<item*> inv_active = inv.active_items();
for (std::vector<item*>::iterator iter = inv_active.begin(); iter != inv_active.end(); ++iter)
{
item *tmp_it = *iter;
temp_lumination = 0;

    if (tmp_it->has_flag("LIGHT_4")) {temp_lumination = 20;}

    int charges = active_item_charges("flashlight_on");
    if (tmp_it->has_flag("LIGHT_CHARGES_5") && charges * 5 < temp_lumination) {temp_lumination = charges * 5;}

    if (temp_lumination > lumination) {lumination = temp_lumination;}
}[/code]

The code above should iterate through a list of all of the active items, determine the current light value based on the iteration item, and then if that is above the current maximum it sets it as the new maximum. The problem comes in: active_item_charges("flashlight_on"); This line should use the current iteration item’s id, however I am unable to figure out how to retrieve the iteration item’s id. If anybody has a pointer method that will solve this problem (or an alternate method to get the charges of the iteration item) I would be very grateful for some advice.


That should do the trick.

That should do the trick.

Sweet, Thank you.

New question!
In C++ are you allowed to call non-void functions without having something to store the returned value in?

For example:

[code]int bob()
{
return 2
}

void main()
{
bob()
}[/code]
Or would that last line need to be something like “temp = bob()”?

Yes.

Yes I can call it without storing the value? Or yes I need to store the value?

I mean no, you don’t need to.
:stuck_out_tongue:

It’s very common to call non-void functions by themselves, since often times the return value isn’t something you need to care about.

Ok cool, makes fixing the “gets deep bite wound when armor absorbs all the damage” much easier. :slight_smile: