Author Topic: Custom flare item  (Read 610 times)

Legacy_HipMaestro

  • Hero Member
  • *****
  • Posts: 2849
  • Karma: +0/-0
Custom flare item
« on: January 03, 2012, 09:28:35 pm »


               I've had a request for a flare item and have no clue where to start so am hoping for a boot in the best direction.

Here are the details as clear as I can render:

A small, light or weightless item, preferably stackable like gems, that emit a small-radius point of bright light when placed on the ground. Ideally, I would like a selection of different items with individual colors but even just one white version would be a great start. 

The plan is to use them to mark pathways like droppping breadcrumbs in dark areas like dungeons.  In brighter areas, modified gold pieces can be used, though even those are tough to spot depending on the tileset, so flares would be better.

Assuming this request can even be filled, I would need some way to "clean them up" after a specified time or set controlling circumstances so that they wouldn't bog down the module.  For the sake of evaluation, let's assume that about a hundred of these items could exist within the bounds of all the content areas in total.

Have any of you guys seen anything like this in action before and, if so, where and how does it affect the framerate during gameplay?  Does it require special graphic redesign to pull it off or can it be done with existing resources?

Any suggestions will be appreciated.

TIA,
Hip
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Custom flare item
« Reply #1 on: January 03, 2012, 10:21:02 pm »


               Are you looking for hak or non-hak options?

For non-hak, you could alter your module's "on item loss" script.  Perhaps something along the lines of:
1. check tag of object lost for match to "flare" object
2. if a match, create a small placeable flame at the object's location
3. after a delay, destroy the flare object and the placeable

For hak version:
1. new item (gem?) icon and matching model, with the model having a light emitter and a visible light emitter.  When put on the ground it should automatically light things up for you.
2. in on lost script, set a delayed destruction of said item to remove the flare from the area

Some other modifications might be needed if you want the flares to be able to be picked up again by PCs.

Rough ideas, I know, but a more formal (fully scripted, possibly modeled) solution would require knowing exactly how you intend for these to work.
               
               

               
            

Legacy_HipMaestro

  • Hero Member
  • *****
  • Posts: 2849
  • Karma: +0/-0
Custom flare item
« Reply #2 on: January 03, 2012, 11:36:34 pm »


               Actually, the hak version is the one that best fits the nature of the request but none of us have any experience modeling so I think I will follow your non-hak suggestion which should be able to suffice for our needs.  It seems to be one that our novice scripting experimenters could get working without too much fuss.

We have a group of regular LAN players of various content which can be adapted to MP, ancient folk all, who either suffer from glaucoma or are otherwise visually-impaired, hence easily dazzled by intricate mazes and seek some sort of equalizer to more easily keep track of other party members' trodden paths especially when separated in darker environments (we have been sticking to "brighter" content in the past, but would like to enjoy those with darker themes as well with an adequate visual "crutch").  The mini-map helps, naturally, but not enough.

As for picking flares up to reuse... that is probably not needed as they would be made available for a pittance, like mundane ammo, for instance.  Though if they could be made bashable, a misplaced one could be destroyed on the spot.  One concern was with the latency they might cause being spread around profusely but with the non-hak idea, that would probably not factor in.

In any event, thanks for the speedy response and direction, AD! '<img'>
               
               

               
            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Custom flare item
« Reply #3 on: January 04, 2012, 06:28:25 am »


               I took your idea and put together a little model that might work for you.  Tested in-game and it worked out well (no light while in inventory, instant light when on the ground).  I'll be reducing the amount of illumination a little and will make a few more color variations (red, yellow, orange, magenta, blue, cyan, white), then post them on the Vault tomorrow.

I'll include 2 versions: a) a hak version that adds a few new gem icons/models, and 'B)' an override version that simply changes the default bag for several of the normal gems to the glowing version.

Here's a couple screenshots I took while testing with the initial green version (normal rural tileset with grass turned on in 1 and off in the 2nd). The stones hover slightly (so that most of the circle of light around each is more visible when viewed from the side), so I'm calling them magical "faerie stones".

'Image

'Image
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Custom flare item
« Reply #4 on: January 04, 2012, 09:16:50 am »


               We did something like this too. We have CEP implemented so we just used the small flame visual effects that already exist with it.

Made six blueprints for the flame objects (just useable box checked so they can be bashed, also just gave em 1 hp).

Made six blueprints for the flare items (these can be whatever items you want to use). And very important, all of the six items have the same tag but different resrefs. This way you only need to have 1 tag based script run for all of them. Then the script checks the resref of the item used and makes the flame object that corresponds. Aslo make sure the items have the property Cast Spell, Unique Power. And give it unlimited uses per day as the script will take care of destroying the item itself. Or you can just get rid of the line that destroys the item and they really can use it unlimited amount of times.

And then the tag based script for it:


#include "x2_inc_switches"

const float DELAY = 20.0;

void main()
{
    int iEvent = GetUserDefinedItemEventNumber();
    if (iEvent != X2_ITEM_EVENT_ACTIVATE) return;

    object oPC = GetItemActivator();
    object oItem = GetItemActivated();
    object oTarget = GetItemActivatedTarget();
    if (GetIsObjectValid(oTarget))
    {
        FloatingTextStringOnCreature("Target must be a location.", oPC);
        return;
    }
    location lTarget = GetItemActivatedTargetLocation();
    string sResRef = GetResRef(oItem);
    string sLight;

    if (sResRef == "flare1") sLight = "flareflame1";//blue
    if (sResRef == "flare2") sLight = "flareflame2";//green
    if (sResRef == "flare3") sLight = "flareflame3";//purple
    if (sResRef == "flare4") sLight = "flareflame4";//red
    if (sResRef == "flare5") sLight = "flareflame5";//white
    if (sResRef == "flare6") sLight = "flareflame6";//yellow

    object oLight = CreateObject(OBJECT_TYPE_PLACEABLE, sLight, lTarget);

    DestroyObject(oItem);
    DestroyObject(oLight, DELAY);
}


There is a constant float toward the top of the script that is used for the delay before the flare on the ground is auto-destroyed. You can set it to whatever you prefer. Currently it is set to 20.0 seconds for testing.
It also has a check to make sure that the target of the flare is a location only.

Just another way of doing it. Good luck.

P.S. That is a neat idea Amethyst.
               
               

               


                     Modifié par GhostOfGod, 04 janvier 2012 - 09:43 .
                     
                  


            

Legacy_HipMaestro

  • Hero Member
  • *****
  • Posts: 2849
  • Karma: +0/-0
Custom flare item
« Reply #5 on: January 04, 2012, 03:12:22 pm »


               That's perfect AD!  Exactly as needed.  Can't wait to start using them in our old fogie LAN games. '<img'>

I was wondering if CEP had done something like this and now I know.  Just need to understand where to look (it is such an extensive mod I get lost hunting down specific customizations).  That's a slick solution to our problem, GOG.

It's great that we still have experienced problem-solvers like you guys onboard.  Sweet!
               
               

               


                     Modifié par HipMaestro, 04 janvier 2012 - 03:16 .
                     
                  


            

Legacy_The Amethyst Dragon

  • Hero Member
  • *****
  • Posts: 2981
  • Karma: +0/-0
Custom flare item
« Reply #6 on: January 04, 2012, 07:18:47 pm »


               I just posted the completed hak to the Vault, so it will likely become available today.  I opted to leave out the override version and just do a hak, that way it doesn't mess with existing gem items.

Really simple merge.  8 inventory icons (iit_gem_231.tga to iit_gem_238.tga) and 8 matching item models (it_gem_231.mdl to it_gem_238.mdl).  Includes a copy of baseitems.2da with the max range for gems pushed up to 255 to make space for the higher numbered gem appearances.

Mops, topiary guardians, bunny ears for PCs (yes, really), altered health bar for color-blind players, a book for tracking in-game kills, and now glowing gems for marking a trail...you just never know when a content maker will get inspired by a simple question posted in the forums and make something for everyone.  If you have a need or idea for something, ask around.  There are many knowledgeable peeps that stop by here, and I'm not the only one that will make something relatively small to fill a need...the community is what keeps this game going.

Just look at this question...everyone ends up with both a way to do it with new content (the gems) and existing content (the script posted above).
':wizard:'

Edit: Here's the link and a preview pic of all eight colors.  Enjoy!

'Image
               
               

               


                     Modifié par The Amethyst Dragon, 05 janvier 2012 - 03:35 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Custom flare item
« Reply #7 on: January 04, 2012, 07:30:53 pm »


               I really like this. I imagine one could use these as props in a retelling of Hansel and Gretel.
               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
Custom flare item
« Reply #8 on: January 05, 2012, 05:55:03 am »


               Those look superb, Amethyst Dragon!
               
               

               
            

Legacy_HipMaestro

  • Hero Member
  • *****
  • Posts: 2849
  • Karma: +0/-0
Custom flare item
« Reply #9 on: January 07, 2012, 10:42:55 pm »


               Just a follow-up on this request, folks...

After AD was kind enough to furnish me a hak user's How-to tutorial (me --> a hak dummy), I was able to begin setting up our games with the faerie stones and the entire group is thrilled.  There is no longer any guess work and constant messaging to determine the next move or losing track of which areas have been explored by who and to what extent.  We have worked out a nifty signal system using the color scheme that resembles posting a road sign for others to read and react to.  Now we'll be giving those low-light crawls a go!

Thanks again Amethyst Dragon for your efforts and speedy posting of the new models for all to use and enjoy!
               
               

               
            

Legacy_Alex Warren

  • Sr. Member
  • ****
  • Posts: 326
  • Karma: +0/-0
Custom flare item
« Reply #10 on: January 08, 2012, 05:53:20 pm »


               O.O
I really can't tell how such a small thing can bring so much joy. Love it!
Thank you AD!
I was so fascinated that I even made my own (a bit prettier imo) icons:
'Image
               
               

               


                     Modifié par Alex Warren, 08 janvier 2012 - 05:55 .