Skip to content

Commit

Permalink
Some refactoring and fixes for zcbrahmn:
Browse files Browse the repository at this point in the history
* Use constants instead of values for timer events.
* Make sure downed brahmin can stand up when re-entering the map.
* Check brahmin's state before calling stand up anim sequence.
* Use ANIM_back_to_standing instead reverse-playing fall back anim
(more naturally and doesn't cause recovered brahmin to look "frozen".)
* Now all types of alcohol can be used on brahmin.

* Will need to review/sync other brahmn scripts.
  • Loading branch information
NovaRain committed Sep 2, 2024
1 parent fd7b08d commit fd63927
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 30 deletions.
68 changes: 38 additions & 30 deletions scripts_src/generic/zcbrahmn.ssl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ procedure push_p_proc;
#define br_mstr(x) message_str(SCRIPT_ZCBRAHMN,x)
#define br_floater(x) float_msg(self_obj, br_mstr(x), FLOAT_COLOR_NORMAL)

#define TIMER_WALK 1
#define TIMER_FLOAT 2
#define TIMER_POOP 3
#define TIMER_STAND_UP 4

procedure push_p_proc begin
Expand All @@ -48,44 +51,46 @@ procedure push_p_proc begin
if ((critter_state(self_obj) bwand DAM_KNOCKED_DOWN) == FALSE) then begin
reg_anim_clear(self_obj);
reg_anim_begin();
reg_anim_animate(self_obj,ANIM_hit_from_front,-1);
reg_anim_animate(self_obj,ANIM_fall_back,5);
reg_anim_animate(self_obj,ANIM_fall_back_sf,-1);
reg_anim_animate(self_obj, ANIM_hit_from_front, -1);
reg_anim_animate(self_obj, ANIM_fall_back, 5);
reg_anim_animate(self_obj, ANIM_fall_back_sf, -1);
reg_anim_end();
critter_injure(self_obj,DAM_KNOCKED_DOWN);
add_timer_event(self_obj, game_ticks(Random(10, 30)), TIMER_STAND_UP);
critter_injure(self_obj, DAM_KNOCKED_DOWN);
add_timer_event(self_obj, game_ticks(random(10, 30)), TIMER_STAND_UP);
ndebug("ahh Cow TIPPED you get +10 Hick Experience Points.");
end
end
end
end

procedure timed_event_p_proc begin
variable temp_poo;
if (fixed_param == 1) then begin
variable temp_poo;
if (fixed_param == TIMER_WALK) then begin
if ((critter_state(self_obj) bwand DAM_KNOCKED_DOWN) == FALSE) then begin
self_walk_to_tile(tile_num_in_direction(self_tile,random(0,5),random(1,3)));
self_walk_to_tile(tile_num_in_direction(self_tile, random(0, 5), random(1,3)));
end
flush_add_timer_event_sec(self_obj, random(45, 90), 1);
end if (fixed_param == 2) then begin
flush_add_timer_event_sec(self_obj, random(45, 90), TIMER_WALK);
end if (fixed_param == TIMER_FLOAT) then begin
br_floater(random(201, 205));
flush_add_timer_event_sec(self_obj, random(30, 45), 2);
end else if (fixed_param == 3) then begin
if (random(1,3) == 1) then begin
flush_add_timer_event_sec(self_obj, random(30, 45), TIMER_FLOAT);
end else if (fixed_param == TIMER_POOP) then begin
if (random(1, 3) == 1) then begin
br_floater(206);
ndebug("BRAHMIN IS POOING!!! hehehehe");
temp_poo := create_object_sid(PID_SMALL_GOO_3, 0, 0, SCRIPT_ZIBRAPOO);
//temp_poo := create_object_sid(random(PID_SMALL_GOO_1, PID_SMALL_GOO_3), 0, 0, SCRIPT_ZIBRAPOO);
//move_to(temp_poo, tile_num_in_direction(self_tile, self_inv_rot, 1), 0); --comment out by killap
move_to(temp_poo, tile_num_in_direction(self_tile, self_inv_rot, 1), self_elevation); //added by killap
end
flush_add_timer_event_sec(self_obj, random(120, 300), 3);
flush_add_timer_event_sec(self_obj, random(120, 300), TIMER_POOP);
end else if (fixed_param == TIMER_STAND_UP) then begin
reg_anim_clear(self_obj);
reg_anim_begin();
reg_anim_animate_reverse(self_obj, ANIM_fall_back, -1);
reg_anim_end();
critter_uninjure(self_obj, DAM_KNOCKED_DOWN);
if (critter_state(self_obj) bwand DAM_KNOCKED_DOWN) then begin
reg_anim_clear(self_obj);
reg_anim_begin();
reg_anim_animate(self_obj, ANIM_back_to_standing, -1);
reg_anim_end();
critter_uninjure(self_obj, DAM_KNOCKED_DOWN);
end
end
end

Expand All @@ -97,6 +102,7 @@ end

procedure pickup_p_proc begin
end

procedure talk_p_proc begin
end

Expand All @@ -119,21 +125,20 @@ end
procedure use_obj_on_p_proc begin
// if you give a Brahmin beer or booze, it'll fall down and take damage. This was pulled from the original
// fallout script
if ((obj_pid(obj_being_used_with) == PID_BEER)
or (obj_pid(obj_being_used_with) == PID_BOOZE)) then begin
if (is_alcohol(obj_being_used_with)) then begin
variable item := 0;
script_overrides;
item := obj_being_used_with;
rm_obj_from_inven(source_obj,obj_being_used_with);
rm_obj_from_inven(source_obj, obj_being_used_with);
destroy_object(item);
if ((critter_state(self_obj) bwand DAM_KNOCKED_DOWN) == FALSE) then begin
reg_anim_clear(self_obj);
reg_anim_begin();
reg_anim_animate(self_obj,ANIM_hit_from_front,-1);
reg_anim_animate(self_obj,ANIM_fall_back,5);
reg_anim_animate(self_obj,ANIM_fall_back_sf,-1);
reg_anim_animate(self_obj, ANIM_hit_from_front, -1);
reg_anim_animate(self_obj, ANIM_fall_back, 5);
reg_anim_animate(self_obj, ANIM_fall_back_sf, -1);
reg_anim_end();
critter_injure(self_obj,DAM_KNOCKED_DOWN);
critter_injure(self_obj, DAM_KNOCKED_DOWN);
end
end
end
Expand All @@ -142,7 +147,7 @@ procedure use_skill_on_p_proc begin
// a good science skill check will give you a little more info about the brahmin.
if (action_being_used == SKILL_SCIENCE) then begin
script_overrides;
if (is_success(roll_vs_skill(dude_obj,action_being_used,0))) then
if (is_success(roll_vs_skill(dude_obj, action_being_used, 0))) then
display_msg(br_mstr(101));
else
display_msg(br_mstr(102));
Expand All @@ -156,8 +161,11 @@ procedure map_enter_p_proc begin
set_self_team(TEAM_BRAHMIN);
set_self_ai(AI_GENERIC_BRAHMIN);
end
//flush_add_timer_event_sec(self_obj, random(15, 90), 1);
//flush_add_timer_event_sec(self_obj, random(5, 15), 2);
flush_add_timer_event_sec(self_obj, random(0, 1), 3);
if (critter_state(self_obj) bwand DAM_KNOCKED_DOWN) then begin
add_timer_event(self_obj, game_ticks(random(10, 30)), TIMER_STAND_UP);
end
//flush_add_timer_event_sec(self_obj, random(15, 90), TIMER_WALK);
//flush_add_timer_event_sec(self_obj, random(5, 15), TIMER_FLOAT);
flush_add_timer_event_sec(self_obj, random(0, 1), TIMER_POOP);
end
end
8 changes: 8 additions & 0 deletions scripts_src/headers/command_extra.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
#ifndef COMMAND_EXTRA_H
#define COMMAND_EXTRA_H

#define is_alcohol(x) ( \
(obj_pid(x) == PID_BEER) \
or (obj_pid(x) == PID_BOOZE) \
or (obj_pid(x) == PID_GAMMA_GULP_BEER) \
or (obj_pid(x) == PID_ROENTGEN_RUM) \
or (obj_pid(x) == PID_ROT_GUT) \
)

#define protected_from_gas(x) ( \
(obj_pid(get_armor(x)) == PID_POWERED_ARMOR) \
or (obj_pid(get_armor(x)) == PID_HARDENED_POWER_ARMOR) \
Expand Down

0 comments on commit fd63927

Please sign in to comment.