Skip to content

Commit

Permalink
Made hittable_attache objects correctly get filtered by the guard fun…
Browse files Browse the repository at this point in the history
…ction that prevents more than one collision between two specific objects from firing per frame.
  • Loading branch information
rkettering committed Aug 24, 2015
1 parent 357764a commit 10b8dbd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions data/object_prototypes/base/hittable.cfg
Expand Up @@ -110,21 +110,23 @@ properties: {
if(not collide_with_area in ['attack','thrown'],
handle_unusual_collisions(_collide_with, collide_with_area, all_collisions, collision_index),
handle_it( get_hittable_root_object(_collide_with))
if(_collide_with is obj hittable,
handle_it(_collide_with),
if(_collide_with is obj hittable_attache, handle_it(_collide_with._parent_obj))
)
where handle_it = def(obj hittable collide_with) -> commands if(all_collisions != null and collision_index != null, if(not find( filter(all_collisions, get_hittable_root_object(value.collide_with).type = collide_with.type and value.collide_with_area = collide_with_area), value.collision_index < collision_index), process_collision(collide_with)), process_collision(collide_with))
where handle_it = def(obj hittable collide_with) -> commands if(all_collisions != null and collision_index != null, if(not find( filter(all_collisions, get_hittable_root_object(value.collide_with).type = get_hittable_root_object(collide_with).type and value.collide_with_area = collide_with_area), value.collision_index < collision_index), process_collision(collide_with)), process_collision(collide_with))
where process_collision = def(obj hittable collide_with) -> commands if(collide_with.team != team and (not team in collide_with.teams_which_wont_get_hurt_by_me) and collide_with.team != 'evil_harmless' and (not (collide_with.team = 'evil' and team = 'evil_harmless')),
//[get_hit_by(collide_with), debug('cycle: ' + cycle + ' victim: ' + me.type + ' attacker: ' + collide_with.type)]
null
get_hit_by(collide_with)
)
)",
/*
In any collision logic, we want everything to take into consideration ONLY the very root hittable object; never the attaches. This translates a reference to either one into the root, only.
*/
get_hittable_root_object: "def( custom_obj _obj) -> obj hittable
if(_obj is obj hittable, _obj, (obj hittable_attache <- _obj)._parent_obj)
get_hittable_root_object: "def( custom_obj my_obj ) -> obj hittable
if(my_obj is obj hittable, my_obj, my_obj._parent_obj asserting my_obj is obj hittable_attache)
",
/*
Expand Down

0 comments on commit 10b8dbd

Please sign in to comment.