[REQUEST] Flares/Extra Lighting

Started by SleepyFox, February 28, 2014, 04:18:10 AM

Previous topic - Next topic

SleepyFox

So this reminds me of a tactic I used in the pre-alpha, but I set up 'light traps' outside of my base. Because illumination helps with targeting accuracy. So instead of putting lights in my bunkers where my colonists would be shooting from, I ran wiring out into the wastes and put up lightbulbs so raiders trying to shoot my guys would be all lit up and ripe for shooting gallery funtimes.

I don't know if it's possible to mod in items that illuminate just yet (or temporary lifespan items) but I would like to see a mod that focuses on 'extra' lighting. Maybe tiny internal battery solar lamps that you can place for decorative purposes (like on walkways but they only last like 2 hours into the night, like real solar lights in the garden do) or throw 'em in the wasteland as shinies for targeting raiders.

Or a throwable grenade-type item that instead of going boom, lights up a radius. You could have a colonist that's 'armed' with them hurl flares at raiders to shine some light on the problem. While we're at it, projected lights? Spotlights that shine a cone in a direction? There's gotta be someone out there tinkering with this!
Streaming Games 24/7 @ InsomniacGamers.net

Cala13er

Quote from: SleepyFox on February 28, 2014, 04:18:10 AM
So this reminds me of a tactic I used in the pre-alpha, but I set up 'light traps' outside of my base. Because illumination helps with targeting accuracy. So instead of putting lights in my bunkers where my colonists would be shooting from, I ran wiring out into the wastes and put up lightbulbs so raiders trying to shoot my guys would be all lit up and ripe for shooting gallery funtimes.

I don't know if it's possible to mod in items that illuminate just yet (or temporary lifespan items) but I would like to see a mod that focuses on 'extra' lighting. Maybe tiny internal battery solar lamps that you can place for decorative purposes (like on walkways but they only last like 2 hours into the night, like real solar lights in the garden do) or throw 'em in the wasteland as shinies for targeting raiders.

Or a throwable grenade-type item that instead of going boom, lights up a radius. You could have a colonist that's 'armed' with them hurl flares at raiders to shine some light on the problem. While we're at it, projected lights? Spotlights that shine a cone in a direction? There's gotta be someone out there tinkering with this!

That is currently hardcoded. However due to the availability of dll modding on alpha 2. When I finish my current project. I will work to attempting this :) (it's on my to-do list now).

Rokiyo

#2
I'm not really comfortable with declaring everything as hard-coded at this stage... The truth is that we don't really know just yet.

How about we hold off on replying to these threads and ruling out so many ideas on the basis of what we've discovered in a single day...

Architect

Im pretty sure it can be done? I know for a fact that more lights of different colours can be put in because ive done it. Whether they could be made throwable is another matter, though again, i think i could do it. The only issue would be making it disappear...
Check out BetterPower+ and all its derivatives by clicking the picture below.

It adds many new methods of power generation and uses for it, as well as other things such as incidents.


SleepyFox

I know nothing about coding but maybe check out the weapons and see what makes the projectiles for the grenades vanish or whatnot?
Streaming Games 24/7 @ InsomniacGamers.net

Evul

I can take a look at it. :) If no one else have taken a look at it cause I am currently remaking a grenade for other purposes so why not try make a flare also. :)

Rokiyo

I've been looking into that as well: I want to make a healing version of the blasting charge, which you can set up and treat like a one-off consumable to get you through a particularly tough fight.

At this stage, it appears we will need to be able to define custom Thing classes before we can do this. I'll show you what's going on with the frag grenade, but it's a similar story for everything else that goes boom as well:

First up, here's the XML def in ThingDefs\Weapons_Grenades.xml
<ThingDef ParentName="BaseGrenade">
<defName>Proj_GrenadeFrag</defName>
<label>Frag grenade</label>
<thingClass>Projectile_Explosive</thingClass>
<texturePath>Things/Projectile/Grenade</texturePath>
<projectile>
<explosionRadius >1.9</explosionRadius >
<damageType>Bomb</damageType>
<explosionDelay>100</explosionDelay>
<randomMissRadius>1.0</randomMissRadius>
</projectile>
</ThingDef>


The two that I want to focus on here are <thingClass>Projectile_Explosive</thingClass> and <damageType>Bomb</damageType>.


Taking a look inside the code for Projectile_Explosive, we find the following:
public class Projectile_Explosive : Projectile
{
...

protected virtual void Explode()
{
this.Destroy();
Explosion.DoExplosion(base.Position, this.def.projectile.explosionRadius, this.def.projectile.damageType);
}
}



When the grenade explodes, it calls Explosion.DoExplosion, passing in a Position, an explosionRadius and a damageType:
public class Explosion
{
...

public static void DoExplosion(IntVec3 Loc, float radius, DamageType damType)
{
int amount = 0;
if (damType == DamageType.Bomb)
{
amount = 65;
}
if (damType == DamageType.Flame)
{
amount = 10;
}
if (damType == DamageType.Stun)
{
amount = 35;
}
Explosion explosion = new Explosion(Loc, radius, new DamageInfo(damType, amount));
explosion.Explode();
}

...
}



This is where I owe an apology Cala13er: Even under the strictest definitions of "hard coding" (which refers to the practice of embedding config into your code, as opposed to exposure of that data to a modding API) this would still be considered an example of that.

As you can see, the damaged caused by each type of explosion is currently defined in the code. A damage type of Bomb always deals 65 base damage, and Stun always deals 35 base damage... And if your damage type isn't listed there (e.g. Healing, or Mining), then it won't deal any damage at all.

Once Alpha 3 hits, we should be able to define our ThingClasses (E.g. <thingClass>Projectile_Explosive_Custom</thingClass>, and the code for those can then point to our own version of Explosion.DoExplosion(), allowing us to create whatever whacky AoE effects we want.

Hopefully this would also allow us to define the damage amounts/etc in the XML defs as well.

Architect

A shame, but surely a flare should still be possible using light parameters in the sun lamp xml files on a modded grenade, and setting its explosion radius to 0?
Check out BetterPower+ and all its derivatives by clicking the picture below.

It adds many new methods of power generation and uses for it, as well as other things such as incidents.


Rokiyo

That should be fairly easy to do once custom ThingDefs via .dll modding becomes a reality.

The thing that makes the lamps glow is defined in the XML as follows:
<comps>
<li>
<compClass>CompPowerTrader</compClass>
<basePowerConsumption>150</basePowerConsumption>
<powerOnSound>PowerOnSmall</powerOnSound>
<powerOffSound>PowerOffSmall</powerOffSound>
</li>
<li>
<compClass>CompGlower</compClass>
<glowRadius>12</glowRadius>
<glowColor>(217,217,217,0)</glowColor>
</li>
</comps>


And then in the Building_Glower code it does this with the above:
CompPowerTrader comp = base.GetComp<CompPowerTrader>();
CompGlower glowerComp = base.GetComp<CompGlower>();
comp.PowerStartedCallback = delegate
{
glowerComp.GlowOn = true;
};
comp.PowerStoppedCallback = delegate
{
glowerComp.GlowOn = false;
};


When the CompPowerTrader receives power, it then turns the CompGlower on. When the CompPowerTrader loses power, it turns the CompGlower back off. Even if we add a CompGlower to a grenade, we'll still need some way to turn it on and off.

Once we can define new Things in our mods, we should (in theory) be able to make a special grenade type that doesn't explode, but instead turns a CompGlower on for a minute or so before fizzling out.

SleepyFox

So basically it's doable in a future version when modding becomes more moddable. Wow, the future is going to be awesome.
Streaming Games 24/7 @ InsomniacGamers.net

Serrate Bloodrage

I spent about 10 hours trying to make a fire place/flame lamp/brazier/glowing fungal growth for my luddite trio. I think my lowest moment was when I attempted to join my plant pot with a sun lamp in xml and in the description wrote "It glows while it fricken grows". I honestly didn't want a glowing plant pot...I just wanted a light source not reliant on electricity  :'(
I'm so damn excited for alpha 3
_______________________________________

If only my colonist could have 'personal time' to reduced stress =D

Darker

QuoteI just wanted a light source not reliant on electricity
Really not possible until Alpha 3. The problem is, that even if you define CompGlower  in  <comps> something must turn glowing on. Which is impossible without programming.
Please... Throw human readable errors on savefile parsing failure!!!
Rim world editor Editor on GIT