couple questions about particle effects...

Users who are viewing this thread

HokieBT

Grandmaster Knight
I'm trying to put the flame staff from the Curtains of Fire Magic Mod into my Midkemia mod.  The code is below and as you see from the screenshots it works fine with the musket animation.  However, I'd rather use the pistol animation so the flame is coming out of my right hand.  However, when I do this it shoots at about a 45 degree angle up....  I've tried messing with some of the numbers in the code and those don't see to effect the direction.  Does anybody know what does?  It almost looks like it is either: 
    1) the angle of my right-hand
    2) the angle between my left-hand and right-hand
    3) other?

any idea's how I could change this or maybe a better 2h animation?  I'd prefer the single hand, but maybe the first few frames of draw_bow might work.....

["flame_strike","Flame Strike", [("wooden_staff",0)],itp_type_musket |itp_merchandise|itp_primary|itp_bonus_against_shield,itcf_shoot_musket|itcf_reload_pistol, 1000 , weight(0.01)|abundance(90)|spd_rtng(89) | shoot_speed(160) | thrust_damage(60, pierce)|max_ammo(:cool:|accuracy(95)|weapon_length(10),imodbits_none,
[(ti_on_weapon_attack, [
(try_for_range,reg5,1,500),
                            (particle_system_burst, "psys_torch_fire", pos1, 15), #duration?
(position_move_y,pos1,10), #spacing?
                            (copy_position,pos2,pos1),
                            (position_set_z_to_ground_level, pos2),
                            (get_distance_between_positions,":dist",pos1,pos2),
                            (lt,":dist",10),
(particle_system_burst, "psys_cooking_fire_1", pos1, 25), #?
(particle_system_burst, "psys_cooking_smoke", pos1, 10),
(play_sound,"snd_magic_flame_strike"),
(get_player_agent_no, ":player_agent"),  #SW modified
                            (try_for_agents,":agent"),
                              (agent_get_position,pos2,":agent"),
                              (get_distance_between_positions,":dist",pos1,pos2),
                              (lt,":dist",300),
                              (agent_set_hit_points,":agent",0,0),
                              #(agent_deliver_damage_to_agent,":agent",":agent"), #SW modified
  (agent_deliver_damage_to_agent,":player_agent",":agent"),
                            (end_try),
                            (scene_prop_get_instance,":instance", "spr_explosion", 0),
                            (position_copy_origin,pos2,pos1),
                            (prop_instance_set_position,":instance",pos2),
                            (position_move_z,pos2,1000),
                            (prop_instance_animate_to_position,":instance",pos2,175), #?
                            (assign,reg5,1000),
                          (end_try),],)]],

               
 
[(ti_on_weapon_attack, [
                  (position_rotate_x,pos1,-45),

                  (try_for_range,reg5,1,500),

Not exactly sure, if you have to rotate around x, y or z, try it out.
 
First, I'd just like to point out that your code causes the player to kill the target even if it's not the player firing the weapon.  So if an NPC has the weapon, walks up to the player and pulls the trigger, they fall over dead.  It looks like the player should fall over dead too from the code... since you never check to exclude the player...

As for your question,
(position_move_y,pos1,10),  #spacing?
That line sets the starting point, add any move_x and move_z bits you need to line the start point up with where you want.
(position_move_z,pos2,1000),
That line sets the end point of the explosion.  Again, add any move_y and move_x lines you might need to line it up.  Keep in mind the axis are all relative to the item, which is why changing it from musket to pistol seems to make the direction change, the axis for pistols are in a different local orientation than muskets.
 
I had the same problem when adding it to my mod. I had trouble getting the flame to shoot where I was aiming. I got it close, but it still fires slightly above where I am aiming, as you can see in this screenie:

Here is the code I used. To get it close to where I was aiming, I added the line in red:
["firestone", "Fire_Stone", [("throwing_stone",0)], itp_type_crossbow |itp_primary|itp_bonus_against_shield ,itcf_shoot_pistol, 230 , weight(1.5)|difficulty(0)|spd_rtng(3:cool: | shoot_speed(999) | thrust_damage(30 ,pierce)|max_ammo(999)|accuracy(99),imodbits_missile,
[(ti_on_weapon_attack, [
    (try_begin),
      (gt, "$g_uses2", 0),
      (play_sound,"snd_pistol_shot"),(particle_system_burst, "psys_massive_fire", pos1, 15),
  (try_for_range,reg5,1,500),
        (get_player_agent_no,":player_no"),
        (particle_system_burst, "psys_torch_fire", pos1, 15),
        (position_move_x, pos1,10),
    (position_move_y, pos1,10),
        (copy_position,pos2,pos1),
        (position_set_z_to_ground_level, pos2),
        (get_distance_between_positions,":dist",pos1,pos2),
        (lt,":dist",10),
        (particle_system_burst, "psys_massive_fire", pos1, 15),
        (particle_system_burst, "psys_war_smoke_tall", pos1, 15),
        (try_for_agents,":agent"),
      (neq,":agent",":player_no"),
      (neg|agent_is_ally,":agent"),
  (agent_is_alive,":agent"),
          (agent_is_human,":agent"),
          (agent_get_look_position, pos2, ":agent"),
          (get_distance_between_positions,":dist",pos1,pos2),
          (lt,":dist",300),
          (agent_deliver_damage_to_agent,":player_no",":agent"),
        (end_try),
        (scene_prop_get_instance,":instance", "spr_explosion", 0),
        (position_copy_origin,pos2,pos1),
        (prop_instance_set_position,":instance",pos2),
        (position_move_z,pos2,1000),
        (prop_instance_animate_to_position,":instance",pos2,200),
        (assign,reg5,1000),
      (end_try),
  (val_sub, "$g_uses2", 1),
(else_try),
  (display_message, "@This item must recharge before it can be used again."),
(try_end),
],)]],
The player can adjust their aim to shoot it where they want, but if I give the item to a companion or troop, they don't aim the flame correctly.

EDIT: And yeah, I had to modify it so the player doesn't kill himself or his allies. :mrgreen:
 
thanks guys, my python skills are limited, and I know just enough to be dangerous.  :wink:    Playing with Highlander's solution I should be able to fix the direction.  I switched the "agent_deliver_damage_to_agent" since in the original code the agent always killed themselves, but I hadn't noticed until Jinnai pointed out that this doesn't work for other troops...  I had also noticed the issue with the aim being off, so I will try Keedo's suggestion as well.  Overall, it looks like I'll be switching to Keedo's code as a base, since it does some neat things, and since you removed the part where hit points go to zero that may allow me to actually deliver blunt damage for the concussion weapon...  overall, this was a very very helpful thread, thx!

Edit:  anyway to make it so it doesn't also fire any "ammo" you have ?  If I have a pistol, bullets, and this flame item in my weapon slots, when I fire it I will see the bullet traveling in the middle of the particle effects.  I fixed this in my star wars mod by making transparent ammo, but I wasn't sure if there was a better option...
 
Well, I can fire it without any ammo, but if I give it to a companion/troop they won't even equip it unless they have the appropriate ammo for the weapon type (pistol in my case). I just made the max ammo 999 and set up a global variable for the number of charges/uses it has.
 
thanks Keedo, you're correct that they have to have ammo in their inventory, good suggestion on the global variable.  Anyway, using your code and the other suggestions I was able to get this working great! 



But, I did have a few more questions if anybody has time to give some feedback...

1) right now this code only seems to do damage when it hits the ground, not when the particle effect passes through an agent's body.  The Player can intentionally aim at their feet, but the AI troops shoot straight at you.  I can use Keedo's height adjustment to somewhat fix this, but is there anyway to code the particle effect to do damage when it passes through their bodies?

2) I'd like to create several variations of this code with different colors, behavior, and size of the beam itself (lighting bolt, energy bolt, fireball, etc).  I've been playing with changing different numbers in this code and figured out some stuff like the area effect radius, but I haven't been able to get the flame beam to be bigger or possible to only have a flame effect every X miliseconds as it travels, etc.  I was also trying to change the color in module_particle_systems.py, and I've read the header at the top, but I still can't figure out how those red/green/blue keys translate to a RGB code or something like that....  if somebody would be willing to document some of the important numbers in the code, and possible explain particle systems a little more, it would be appreciated.

 
Hey HokieBT I was able to change the fire trail into a smoke trail for a cannon.  So you can set the trail to be whatever kind of particle effect you want.  I'm not great at editting the individual effects of the particles though.  You can probably change the size of the beam by editting the emit_box_size.  That determines the starting position of all the particles before they start floating around.
 
HockieBT,

With the basic code you can test if pos2 is near the pos of an agent.  if the distance between pos2 (which is on the ground) is say, within 30 distance of an agent's pos, make a small explosion and do damage to the agent.  If you want the beam to be powerful enough, you could keep it going (hitting several in a row).

The only thing about this is that you would have to find each agent's pos and then test it.  So each step of the "beam" would test the pos of every agent (or just the enemies) on the field.

BTW I disagree with preventing friendly first with a weapon like that....

 
jik suggestion is great.  Sounds like force lightning in the making.  I kinda agree about the friendly fire.  Its not like the emperor cared about his own troops he'd fry them for sure. In answer to your transparent ammo question if you use bullets for the weapon just set the speed or the weapon to 999 that way it won't be seen and it will clip through the enemies.
 
HokieBT said:
thanks guys, after the next release of my star wars mod I want to play with this more and will see if I can get it working.

Any update on that release? :grin:
 
Ok I'm pretty sure I'm necroing this thread; sorry about that.  In Keedo's example above he has the global variable for ammo amount but I'm not sure where I would intially assign the variable.  The actual max ammo of the weapon must be defined somewhere. I'm not sure where the best place to do that is.
 
I haven't tried this yet, but maybe you can just put something like the following in module_simple_triggers.py ?  Otherwise you may have to assign it in your mission template or something like that....?

Code:
    (0.1,
     [
	(assign,"$g_uses2",5),
     ]),
 
Dang I was able to get my head round the partical system as well I never managed to get the fire arrows script or this to work the fire just never appeared and as for the magic mod, never even managed to get it to run, real pain as the mod I am working on is very fantasy with magic, new races ect and the only thing I could never work out (well from the stuff I have attempted so far) was the magic which is a pain never mind I will have to continue work on the yetis In the time being or maybe development on the undead lots to finish there, along with a storyline shock horror, oh congrates to Berserk very well done, and hopefully someone could clear up this and maybe help me, I have cookies... sometimes though seriously look forward to seeing the finished product.
 
Back
Top Bottom