Particle precidence?

  • Videogamer555
    11th Feb 2012 Member 0 Permalink
    How do you determine which particle has precidence over others when placing them? For example when a photon or neutron is on screen and you place a block of metal over the other particle, it litterally REPLACES the other particle because the metal has precidence over the other particle. I am making a new energy particle for experimentation, and wish it to behave like a PHOT or NEUT when a non-energy type particle is placed there. I thought the way to set precidence was in the "properties" column of the elementdata.c file set it to TYPE_ENERGY, but my particle STILL won't GET OUT OF THE WAY when I place other stuff on top of it. How do you make it do that for the other energy particles?
  • jacksonmj
    11th Feb 2012 Developer 0 Permalink
    Placing a block of metal doesn't replace photons/neutrons. They are still there (although they do die when the game is unpaused because they are trapped in the middle of the block of metal).

    Most particles are indexed using the pmap array. However, energy particles are indexed using a separate array that works exactly the same way, called photons (because PHOT was the first element to use it and no-one has bothered to rename it). This isn't controlled by ptypes[t].properties at the moment, there's a couple of if statements in powder.c that check particle type. If you search for one of the other elements that uses it, like PHOT or NEUT, you should be able to find all the if statements and add your element to them. Or you could change the if statements to use ptypes[t].properties :-)

    create_part only blocks creation of normal particles if there is an entry in pmap[y][x]. PHOT/NEUT/ELEC are in photons[y][x], so they don't block creation of normal particles.
  • Videogamer555
    11th Feb 2012 Member 0 Permalink
    Then why is my energy particle keeping metal from being made when I draw a solid square on top of the metal? You say they die, but it's INSTANT for PHOT and NEUT. They don't run out of "life", they go away instantly when the game is unpaused.
  • plead-for-destruction
    11th Feb 2012 Member 0 Permalink
    @Videogamer555 (View Post)
    life isn't Health though, not all particles die when at 0 Life it just forces a state change of some kind.
  • Pilihp64
    11th Feb 2012 Developer 0 Permalink
    @Videogamer555 (View Post)
    You need to make sure the elements are placed in the photons array, and not the pmap, as jacksonmj said, search.
    They die because they hit a wall and can't bounce (because its on top of them).
  • airstrike52
    11th Feb 2012 Member 0 Permalink
    @cracker64 (View Post)
    Cracker! You're still alive!
  • Videogamer555
    11th Feb 2012 Member 0 Permalink
    What is the syntax of accessing the photon array? Is it photons[i].type= or more like photons[y][x]= or something else?
  • jacksonmj
    11th Feb 2012 Developer 0 Permalink

    jacksonmj:

    Most particles are indexed using the pmap array. However, energy particles are indexed using a separate array that works exactly the same way, called photons

    Instead of pmap[y][x], pmap[y][x]>>8 and pmap[y][x]&0xFF
    use photons[y][x], photons[y][x]>>8 and photons[y][x]&0xFF
  • Videogamer555
    11th Feb 2012 Member 0 Permalink
    So if I wish to create an energy particle how would I do it using the PHOTONS array? Do I still use the pmap thing to initiate the new particle and then read its properties with photons? Or do I use the photons array to create the particle as well? Please explain.