|
Re: Request: light stick improvement[message #337813]
|
Tue, 18 November 2014 13:26
|
|
Flugente |
|
Messages:3509
Registered:April 2009 Location: Germany |
|
|
In short: Thought about that before, this is trickier than it seems, but possible.
To anyone wishing to code this and looking for (helpful?) pointers:
- Take a look at my flashlight code thingy, might be helpful.
- When a flashlight is thrown, it spawns light and the object vanishes. You need to change this so that the object still exists (as long as the light lasts, I presume). You also need to tie the light id to the object. This requires a new member variable for the light ID on OBJECTTYPE. This will break savegame compatibility and map compatibility unless you adapt to that. Do that. Maintain map compatibility at all costs!
- There are several ways to handle the object vanishing:
- A) Set a timer on the stick (new variable, see above). If that hits 0, destroy object, whether it is in the sector inventory or someone's inventory. Also requires a new flag to mark that this thing has already been activated and cannot be activated again.
- B) Create new object - activated light stick - that light stick turns into upon activation, and tie them together via buddyitem-tag in Items.xml. This needs a timer like in A.
- C) Alternative to timers: reduce object status by 100/light duration every turn. Once this hits zero, destroy object and light it is tied too. Has to bonus/malus that light stick status determines the light duration this way - light sticks in better status will provide light longer.
- Update the light like in the flashlight code - if someone picks that thing up, remove light source on the floor and have one at the mobile merc.
- It would be reasonable to have the light first appear when the merc breaks the stick, which is immediately before throwing it. At that point, however, nothing has been activated in the code - but if you've gotten here, I'm sure you can figure that out on your own
Note that my current assumption (without looking at the code) is that light IDs do not get resorted at any point. You also have to deal with the AI - you need routines for them to pick up such an object, but only if they can throw it away in the same turn, and to force the AI to indeed throw away such an object if they ever have it in their inventory (as this will be at least 2 separate AI decisions calls).
Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|