Problem With Assigning Factions to sell Items

Users who are viewing this thread

poo

Regular
Hello my dear hearts and Gentle People,

I am a little bit stumped with something that should be quite easy.I know that to assign an item to only sell in one kingdom you have to put this at the end of an item.
Python:
["steppe_horse","Steppe Horse", [("steppe_horse",0)], itp_merchandise|itp_type_horse, 0, 192,abundance(80)|hit_points(120)|body_armor(10)|difficulty(2)|horse_speed(40)|horse_maneuver(51)|horse_charge(8)|horse_scale(98),imodbits_horse_basic, [], [fac_kingdom_2, fac_kingdom_3]],

This would give me an error while compiling so I changed it to this and it worked
Python:
["suiton","Water Style Raging Waves",[("toxic_mist",0)],itp_type_thrown |itp_merchandise|itp_primary|itp_bonus_against_shield ,itc_staff, 4938 , weight(4)|spd_rtng(80) | shoot_speed(50) | thrust_damage(150 ,  pierce)|max_ammo(1)|weapon_length(65),imodbits_missile, [], [fac_kingdom_4],

The problem is that this code Is usually supposed to shoot out a stream of water.It is only after that I put the second type(without the extra bracket at the end) that ingame it doesnt shoot out the stream anymore.This is the Code.(Dont worry this code is OSP from the Naruto mod by Sundiata made from mirathei magic osp source).

Python:
["suiton","Water Style Raging Waves",[("toxic_mist",0)],itp_type_thrown |itp_merchandise|itp_primary|itp_bonus_against_shield ,itc_staff, 4938 , weight(4)|spd_rtng(80) | shoot_speed(50) | thrust_damage(150 ,  pierce)|max_ammo(1)|weapon_length(65),imodbits_missile, [], [fac_kingdom_4],
  [(ti_on_weapon_attack, [


   ## The it_on_weapon_attack trigger stores the location where the weapon was used in the register 'pos1'
   ## The following block of code looks throught all the agents and finds the one closest to where the weapon was used.  (Ie. the one who used it.)
                (assign,":distance",99999),
                (display_message,"str_suiton",0x6efdff),
                    
                (try_for_agents,":agent"),
                    (agent_is_alive,":agent"),
                    (neg|agent_is_wounded,":agent"), ## add this to not re-count wounded people
                    (agent_is_human,":agent"),
                    (agent_get_look_position, pos2, ":agent"),
                    (get_distance_between_positions,":dist",pos1,pos2),
                    (lt,":dist",":distance"),
                    (assign,":chosen",":agent"), # 'chosen' is the shooter
                    (assign,":distance",":dist"),
                (try_end),
   ## End find weapon user. (The weapon user's agent_id is stored in ":chosen")

   ## You then find the agent_id of their horse. (Assuming they have one.) And their team. (Will keep your lightning strike from killing teammates, if that's what you desire.)
                (agent_get_horse, ":chosen_horse", ":chosen"),
                (agent_get_team, ":chosen_team", ":chosen"),

                 #Lightning Strike (do damage based on how close agent is to the blast)


   ## Initialize some variables...
                (assign, ":times_near_ground", 0),
                (assign, ":near_enemy", 0),

   ## This try statement will basically 'draw' a line going forward from the agent who shot the lightning. The line will consist of 500 points.

                (try_for_range,reg5,1,500),  ### 500 is the number of iterations of the loop
                (eq, ":times_near_ground", 0),  ### loop will run as long as the line doesn't get close to the level of the ground.
                    (particle_system_burst, "psys_suiton", pos1, 10),  ## Every iteration of the loop, it will make a 'burst' of lightning w/ duration 15
                    (position_move_y,pos1,30),  ## It moves forward 30 each iteration

                    # added for gravity effect (Causes the lightning to have an 'arc'. So the lightning will 'fall' like an arrow and computer agents can hit targets at range.)
                    (store_mod, ":fall", reg5, 2),  ## basically every 2 iterations, the position will drop by 3
                    (try_begin),
                    (eq, ":fall", 0),
                        (position_move_x,pos1,3),
                    (try_end),
          # end gravity code

          # This adds a random left/right weave to the path of the lightning.  It makes it look a little more natural
                    (store_mod, ":weave", reg5, 5),
                    (try_begin),
                    (eq, ":weave", 0),
                        (store_random_in_range, ":random", -8, 8),
                        (position_move_z,pos1,":random"),
                    (try_end),
                    # end flight randomness code

                    # This writes the distance between where the lightning is and where the ground is into ":dist"           
                    (copy_position,pos2,pos1),
                    (position_set_z_to_ground_level, pos2),
                    (get_distance_between_positions,":dist",pos1,pos2),
              
                    # This sets up two measurements that approximately span the vertical length of the human body.
                    (position_get_z, ":z_ground", pos2),
                    (store_add, ":z_ground_low", ":z_ground", 200),
                    (store_add, ":z_ground_high", ":z_ground", 2000),

                    # This will check to see if the lightning is near an agent's body (all conditionals must be true for the variables at the end to be assigned)
                    (try_for_agents, ":agent"),
                    (eq, ":near_enemy", 0),
                        (neq, ":chosen", ":agent"), # this makes the agent who shot the lightning doesn't kill himself
                        (neq, ":chosen_horse", ":agent"), # makes sure they don't kill their horse
                        (agent_get_team, ":agent_team", ":agent"), # Optional: part 1
                        (teams_are_enemies, ":chosen_team", ":agent_team"), # Optional: part 2: makes sure lightning doesn't 'explode' on teammates
                        (agent_is_alive, ":agent"), # makes sure lightning doesn't hit dead agents
                        (neg|agent_is_wounded, ":agent"), # makes sure lightning doesn't hit wounded agents
                        (agent_get_look_position, pos4, ":agent"), # sets up a new position
                        (get_distance_between_positions, ":dist_2", pos2, pos4), # checks relative horizontal distance between lightning and agent
                        (position_get_z, ":z_attack_trail", pos1), # gets height of lightning
                        (lt, ":dist_2", 50), # conditional: if lightning within 50 of agent (x-y) then proceed
                        (is_between, ":z_attack_trail", ":z_ground_low", ":z_ground_high"), # if lightning is vertically within the agent's height, (ie. shouldn't explode if it's way above their head)
                        (assign, ":dist", 5), # This will cause the following try loop to run (makes it seem like the lightning is close to the ground)
                        (assign, ":near_enemy", 1), # ensures lightning will not keep going forward.
                    (try_end),
                  
                    (try_begin),
                    (lt,":dist",10), # is true when lightning is near ground or withing the desired range of the target agent
                        (val_add, ":times_near_ground", 1), # makes sure the lightning won't keep going
                        (particle_system_burst, "psys_suiton_exp", pos1, 25),  # large fire effect (see module_particle_effects.py)
                        #(particle_system_burst, "psys_war_smoke_tall", pos1, 1),  # large smoke effect (see module_particle_effects.py)
                        (play_sound,"snd_footstep_water"), # lightning sound (see module_sounds.py, will also need to add a sound file)
                        (copy_position, pos3, pos1),
                        (scene_prop_get_instance,":instance", "spr_explosion", 0),  # adds an explosion prop (see module_scene_props.py, will also need to add a resource)
                        (position_copy_origin,pos2,pos1), # not 100% sure if all of this stuff works
                        (prop_instance_set_position,":instance",pos2),
                        (position_move_z,pos2,1000),
                        (prop_instance_animate_to_position,":instance",pos2,175),
                        (assign,reg5,1000),
                    (try_end),
                (try_end),

        ##  This part of the code adds all the resulting damage to the agents who are hit                               
                (try_for_agents,":agent"),
                    (neq,":chosen",":agent"), ## added this to avoid killing shooter
                    (neq, ":chosen_horse", ":agent"), # added to avoid killing shooters horse
                    (agent_is_alive,":agent"), ## add this to not re-kill dead people
                    (neg|agent_is_wounded,":agent"), ## add this to not re-kill wounded people

                    #partial friendly fire protection
                    (agent_get_team, ":agent_team_ff", ":agent"),
                    (assign, ":deliver_damage", 1),
                    (try_begin),
                    (neg|teams_are_enemies, ":chosen_team", ":agent_team_ff"),
                        (store_random_in_range, ":random", 5, 5),
                        (try_begin),
                        (gt, ":random", 1), # 3 in 4 chance that ally will not be hurt by damaging weave that is targeting enemy
                            (assign, ":deliver_damage", 0),
                        (try_end),
                    (try_end),
                    (eq, ":deliver_damage", 1),
                    #end partial friendly fire protection
          
                    (agent_get_position,pos2,":agent"),
                    (get_distance_between_positions,":dist",pos3,pos2),
                        
                    # do 25 damage if lightning within 50 of agent
                    (try_begin),
                        (lt,":dist",50),
                        (store_agent_hit_points,":target_health",":agent",1),
                        (try_begin),
                            (gt,":target_health",25), # If target has more that 25 health, then just hurt them partially
                            (val_sub,":target_health",25),
                            (agent_set_hit_points,":agent",":target_health",1),
                            (agent_deliver_damage_to_agent,":chosen",":agent"),
                            (add_xp_to_troop,20,":chosen"), # Optional: give xp to shooter
                            (else_try), # If target has less than 25 health, then kill them
                            (agent_set_hit_points,":agent",0,0),
                            (agent_deliver_damage_to_agent,":chosen",":agent"),
                            (add_xp_to_troop,25,":chosen"),
                            (position_get_z, ":z_temp", pos2), # Add a small burning flame by their body
                            (val_add, ":z_temp", 300),
                            (position_set_z, pos2, ":z_temp"),
                        (try_end),
        ## What follows is 3 more instances of dealing lesser and lesser damage the further the target is from the lightning explosion
                    # do 15 damage if lightning within 50 to 125 of agent
                    (else_try),
                        (is_between,":dist",50,125),
                        (store_agent_hit_points,":target_health",":agent",1),
                        (try_begin),
                            (gt,":target_health",15),
                            (val_sub,":target_health",15),
                            (agent_set_hit_points,":agent",":target_health",1),
                            (agent_deliver_damage_to_agent,":chosen",":agent"),
                            (add_xp_to_troop,15,":chosen"),
                            (else_try),
                            (agent_set_hit_points,":agent",0,0),
                            (agent_deliver_damage_to_agent,":chosen",":agent"),
                            (add_xp_to_troop,20,":chosen"),
                            (position_get_z, ":z_temp", pos2),
                            (val_add, ":z_temp", 300),
                            (position_set_z, pos2, ":z_temp"),
                        (try_end),
                    # do 10 damage if lightning within 125 to 225 of agent
                    (else_try),
                        (is_between,":dist",125,225),
                        (store_agent_hit_points,":target_health",":agent",1),
                        (try_begin),
                            (gt,":target_health",10),
                            (val_sub,":target_health",10),
                            (agent_set_hit_points,":agent",":target_health",1),
                            (agent_deliver_damage_to_agent,":chosen",":agent"),
                            (add_xp_to_troop,10,":chosen"),
                            (else_try),
                            (agent_set_hit_points,":agent",0,0),
                            (agent_deliver_damage_to_agent,":chosen",":agent"),
                            (add_xp_to_troop,15,":chosen"),
                            (position_get_z, ":z_temp", pos2),
                            (val_add, ":z_temp", 300),
                            (position_set_z, pos2, ":z_temp"),
                        (try_end),
                    # do 5 damage if lightning within 225 to 350 of agent
                    (else_try),
                        (is_between,":dist",225,350),
                        (store_agent_hit_points,":target_health",":agent",1),
                        (try_begin),
                            (gt,":target_health",5),
                            (val_sub,":target_health",5),
                            (agent_set_hit_points,":agent",":target_health",1),
                            (agent_deliver_damage_to_agent,":chosen",":agent"),
                            (add_xp_to_troop,5,":chosen"),
                            (else_try),
                            (agent_set_hit_points,":agent",0,0),
                            (agent_deliver_damage_to_agent,":chosen",":agent"),
                            (add_xp_to_troop,10,":chosen"),
                            (position_get_z, ":z_temp", pos2),
                            (val_add, ":z_temp", 300),
                            (position_set_z, pos2, ":z_temp"),
                        (try_end),
                    (try_end),

                (try_end),
              
                #water weave end


                         ],),
    ]],

The code worked without the fac_kingdom at the end.The First type of writing would give a bug when compiling.The second makes the stuff not appear in game.Also,I have other jutsus that do not work only after adding the second type at the end.This is weird to me because such a simple thing gives me a hard time.I do not know what I am doing wrong.Its not like there is really anyother way of writing ,[],fac_kingdom_1], I dont understand how its also somehow blocking my code from executing ingame.
 
Last edited:
Solution
Hey brother, it's good to see you're still working on your Naruto project. So, let's look at the schema for an item:

["item_id", "Item_name_string", [("mesh_name", modifier)], flags, capabilities, value, stats, modifiers, [triggers], [faction_id]],

It's not firing because in your post the trigger variable is empty, and the trigger is currently in an unexpected variable, and since it's unexpected, I don't think the compiler will read it at all.

Python:
["suiton","Water Style Raging Waves",[("toxic_mist",0)],itp_type_thrown |itp_merchandise|itp_primary|itp_bonus_against_shield ,itc_staff, 4938 , weight(4)|spd_rtng(80) | shoot_speed(50) | thrust_damage(150 ,  pierce)|max_ammo(1)|weapon_length(65),imodbits_missile, 
[(ti_on_weapon_attack, [...
Hey brother, it's good to see you're still working on your Naruto project. So, let's look at the schema for an item:

["item_id", "Item_name_string", [("mesh_name", modifier)], flags, capabilities, value, stats, modifiers, [triggers], [faction_id]],

It's not firing because in your post the trigger variable is empty, and the trigger is currently in an unexpected variable, and since it's unexpected, I don't think the compiler will read it at all.

Python:
["suiton","Water Style Raging Waves",[("toxic_mist",0)],itp_type_thrown |itp_merchandise|itp_primary|itp_bonus_against_shield ,itc_staff, 4938 , weight(4)|spd_rtng(80) | shoot_speed(50) | thrust_damage(150 ,  pierce)|max_ammo(1)|weapon_length(65),imodbits_missile, 
[(ti_on_weapon_attack, [ ***YourBlockHere***])], [fac_kingdom_4],

These things happen. I actually didn't know the problem until I referred to my module_items to see what the empty list was in your item declaration
 
Upvote 0
Solution
Hey brother, it's good to see you're still working on your Naruto project. So, let's look at the schema for an item:

["item_id", "Item_name_string", [("mesh_name", modifier)], flags, capabilities, value, stats, modifiers, [triggers], [faction_id]],

It's not firing because in your post the trigger variable is empty, and the trigger is currently in an unexpected variable, and since it's unexpected, I don't think the compiler will read it at all.

Python:
["suiton","Water Style Raging Waves",[("toxic_mist",0)],itp_type_thrown |itp_merchandise|itp_primary|itp_bonus_against_shield ,itc_staff, 4938 , weight(4)|spd_rtng(80) | shoot_speed(50) | thrust_damage(150 ,  pierce)|max_ammo(1)|weapon_length(65),imodbits_missile,
[(ti_on_weapon_attack, [ ***YourBlockHere***])], [fac_kingdom_4],

These things happen. I actually didn't know the problem until I referred to my module_items to see what the empty list was in your item declaration


Thank you SupaNinjaMan.I didn't realise [(ti_on_weapon_attack, was a trigger.Next time I should think outside the box.Thanks
 
Upvote 0
Back
Top Bottom