OSP Code Combat Homing Attack (Sonic Adventure)

Users who are viewing this thread

I have had a note regarding this at my discord and didn't want to let it sink there. So I thought I am going to create at least a thread for it, so that others can find it easier in case they are looking for something like this.
Edit:

Homing Attack by Morpheus__

dstn:
Digging through old moddb pages give interesting results. This dude basically made a Sonic the Hedgehog homing jump spin, and then shared the code in a comment response.

You can find the video here (forum doesn't allow embedding moddb videos):

Morpheus__
To perform a homing attack, you must press space 2 times, once you land on the ground, the homing attack is reset.

Source of inspiration:


Other info snippets (taken from moddb comments):
The player is the only one who can use this. The damage is determined by the animation in which the unit is, they are flagged as if in attack mode. The damage can increase with the stats by using
(store_agent_hit_points, ":ca_strength", ":agent", 1),
which assigns the damage, then :
(val_sub,":hp",":ca_strength"), [URL='https://www.moddb.com/tags/Victim']#Victim[/URL] hp subtracted

All the code I'm using for ai and user functions is adapted from Xenoargh's Shield Bash script, each function will be completely unique from eachother.
Credit goes to Morpheus (and Xenoargh)
Morpheus_:
Yes go ahead!
XD
free to use with / without credit.

Code Dump:

Code:
jump1 = (
   0, 0.01, 0, [(game_key_clicked, gk_jump)],
[    
(eq, "$jump_on", 0),  
(assign, "$jump_on", 1),                                  #Enable Homing Attack Status
(assign, "$jump2", 1),                                  #Enable Homing Attack Status
(assign, "$jump3", 1),                                  #Enable Homing Attack Status
(assign, "$jump4", 1),                                  #Enable Homing Attack Status
])

         
jump2 = (                                        
   0, 0.1, 0, [(eq, "$jump_on", 1),(neg|game_key_is_down, gk_move_forward) ,(game_key_clicked, gk_jump)],
[
(get_player_agent_no, ":agent"),                          #Agent Setz
(agent_is_active, ":agent"),                              #Agent Setz
(agent_is_alive, ":agent"),                               #Agent Setz
(try_begin),
    (agent_get_animation, ":agent_anim", ":agent", 0),        #Play Animation
    (this_or_next|eq, ":agent_anim", "anim_jump_loop"),                   #EQ
    (eq, ":agent_anim", "anim_jump_loop2"),                   #EQ
    (agent_set_animation, ":agent", "anim_homing_attack"),    #Homing Attack
    (agent_play_sound, ":agent", "snd_homing_attack"),        #Homing Attack Sound
    (display_message, "@Homing Attack Forward", 0xFFFFFF),            #Homing Attack String    


    (assign, "$jump2", 0),                                    #Enable Homing Attack 4
    (assign, "$jump3", 0),                                    #Enable Homing Attack 4
    (assign, "$jump4", 0),                                    #Enable Homing Attack 4  
(else_try),
                                                          #If Fails
(try_end),
])
 
jumpnormal = (                                        
   0, 0.1, 0, [(eq, "$jump_on", 1),(neg|key_is_down, key_left_control),(game_key_is_down, gk_move_forward),(neg|key_is_down, key_left_shift),(game_key_clicked, gk_jump)],
[
(get_player_agent_no, ":agent"),                          #Agent Setz
(agent_is_active, ":agent"),                              #Agent Setz
(agent_is_alive, ":agent"),                               #Agent Setz
(try_begin),
    (agent_get_animation, ":agent_anim", ":agent", 0),        #Play Animation
    (this_or_next|eq, ":agent_anim", "anim_jump_loop"),                   #EQ
    (eq, ":agent_anim", "anim_jump_loop2"),                   #EQ
    (agent_set_animation, ":agent", "anim_homing_attacknormal"),    #Homing Attack
    (agent_play_sound, ":agent", "snd_homing_attack"),        #Homing Attack Sound
    (display_message, "@Homing Attack Normal", 0xFFFFFF),            #Homing Attack String  
    (assign, "$jump2", 0),                                    #Enable Homing Attack 4
    (assign, "$jump3", 0),                                    #Enable Homing Attack 4
    (assign, "$jump4", 0),                                    #Enable Homing Attack 4    
(else_try),
                                                          #If Fails
(try_end),
])


jump4 = (
   0, 0.2, 0, [(eq, "$jump_on", 1),(key_is_down, key_left_control),(game_key_clicked, gk_jump)],
[                                                                    
(get_player_agent_no, ":agent"),                          #Agent Setz
(agent_is_active, ":agent"),                              #Agent Setz
(agent_is_alive, ":agent"),                               #Agent Setz
(try_begin),
    (agent_get_animation, ":agent_anim", ":agent", 0),        #Play Animation
    (eq, ":agent_anim", "anim_jump_loop"),                   #EQ
    (agent_set_animation, ":agent", "anim_homing_attack4"),   #Homing Attack
    (agent_play_sound, ":agent", "snd_homing_attack"),        #Homing Attack Sound
    (display_message, "@Homing Attack Air Rolling", 0xFFFFFF),            #Homing Attack String  

    (assign, "$jump2", 0),                                    #Enable Homing Attack 2
    (assign, "$jump4", 0),                                    #Enable Homing Attack 4
    (assign, "$jump4timer", 1),                               #Enable Homing Attack 4    
(else_try),
                                                          #If Fails
(try_end),
])  

jumphigh = (
   0, 0, 0, [(eq, "$jump_on", 1),(key_is_down, key_left_shift),(game_key_clicked, gk_jump)],
[          

(get_player_agent_no, ":agent"),                          #Agent Setz
(agent_is_active, ":agent"),                              #Agent Setz
(agent_is_alive, ":agent"),                               #Agent Setz
(try_begin),
    (agent_get_animation, ":agent_anim", ":agent", 0),        #Play Animation
    (eq, ":agent_anim", "anim_jump_loop"),                   #EQ
    (agent_set_animation, ":agent", "anim_homing_attackhigh"),   #Homing Attack
    (agent_play_sound, ":agent", "snd_homing_attack"),        #Homing Attack Sound
    (display_message, "@Homing Attack High", 0xFFFFFF),            #Homing Attack String  

    (assign, "$jump2", 0),                                    #Enable Homing Attack 2
    (assign, "$jump4", 0),                                    #Enable Homing Attack 4
    (assign, "$jump4timer", 1),                               #Enable Homing Attack 4    
(else_try),
                                                          #If Fails
(try_end),
])
jump4timer = (
   0, 2.0, 0, [(eq, "$jump_on", 1)],
[
(get_player_agent_no, ":agent"),                          #Agent Setz
(agent_is_active, ":agent"),                              #Agent Setz
(agent_is_alive, ":agent"),                               #Agent Setz
(try_begin),      
    (eq, "$jump4timer", 1),
    (agent_get_animation, ":agent_anim", ":agent", 0),        #Play Animation
    (this_or_next|eq, ":agent_anim", "anim_homing_attack4"),            #EQ
    (eq, ":agent_anim", "anim_homing_attackhigh"),                    #EQ
    (agent_set_animation, ":agent", "anim_jump_loop2"),   #Homing Attack
    (display_message, "@Homing Attacktimer", 0xFFFFFF),            #Homing Attack String  

    (assign, "$jump2", 0),                                    #Enable Homing Attack 2  
    (assign, "$jump3", 0),                                    #Enable Homing Attack 4
    (assign, "$jump4timer", 0),                                    #Enable Homing Attack 4      
(else_try),
                                                          #If Fails
(try_end),
])

jump_stop = (                    #On Landing
   0, 0, ti_once,
[(eq, "$jump_on", 1), ],

[                          
(get_player_agent_no, ":agent"),                          #Agent Setz
(agent_is_active, ":agent"),                              #Agent Setz
(agent_is_alive, ":agent"),                               #Agent Setz
(agent_get_animation, ":agent_anim", ":agent", 0),        #Play Animation
(this_or_next|eq, ":agent_anim", "anim_jump_end"),        #EQ
(eq, ":agent_anim", "anim_jump_end_hard"),                 #EQ  
(agent_play_sound, ":agent", "snd_blunt_hit"),        #Homing Attack Sound    
(assign, "$jump_on", 0),                                  #Disable Homing Attack Status
(assign, "$jump2", 0),                                    #Disable Homing Attack 2
(assign, "$jump3", 0),                                    #Enable Homing Attack 4
(assign, "$jump4", 0),                                    #Disable Homing Attack 4

 
])                  

jump_attack_distance_refresh = (                    #On Landing
   0, 0, 0,
[(eq, "$jump_on", 1),

],

[
(get_player_agent_no, ":agent"),
(agent_is_active, ":agent"),
(agent_is_alive, ":agent"),
#      (neg|agent_slot_ge, ":agent", sp_agent_shield_bash_timer, 1), #Less than.
                           
(agent_get_position, pos1, ":agent"),


(agent_get_animation, ":agent_anim", ":agent", 0),        #Play Animation
(this_or_next|eq, ":agent_anim", "anim_homing_attack"),            #EQ
(eq, ":agent_anim", "anim_homing_attacknormal"),                    #EQ

      (assign, ":victim", -1),
      (assign, ":minimum_distance", 150),
         
 
      (try_for_agents, ":suspect"),
          (agent_is_alive, ":suspect"),
         (agent_is_human, ":suspect"),
         (neg|agent_is_ally, ":suspect"),
         (agent_get_position, pos2, ":suspect"),
         (neg|position_is_behind_position, pos2, pos1), #Suspect can't be behind basher.
         (get_distance_between_positions, ":distance", pos1, pos2),
         (le, ":distance", ":minimum_distance"),    
         (assign, ":minimum_distance", ":distance"),
         (assign, ":victim", ":suspect"),
                                                                                                     #
      (try_end),
      (ge, ":victim", 0),

    (try_begin),
(store_agent_hit_points,":hp",":victim",1),
(store_agent_hit_points, ":ca_strength", ":agent", 1),    #AGENT STRENGTH MULTIPLIER
 (store_random_in_range,":randomaddi",5,5),         #RANDOM ADDITIONAL DAMAGE
                                    #
        (val_div,":ca_strength",":randomaddi"),    #Deal random damage between those two values             #                                                           #
        (val_sub,":hp",":ca_strength"),              #Victim hp subtracted                                                             #
        (agent_set_hit_points,":victim",":hp",1),                                                         #
        #(le,":hp",0),                                                                                     #
        (agent_deliver_damage_to_agent,":agent",":victim"),
          (assign, reg1, ":ca_strength"),
          (display_message, "@Damage dealt by attack: {reg1}",0xFF11FF11),
(agent_set_animation, ":agent", "anim_jump_loop"),   #Homing Attack
(agent_set_animation, ":victim", "anim_shield_strike"),                                              #
(agent_play_sound, ":agent", "snd_blunt_hitz2"),
      (display_message,"@Melee Attack",0xffffff),
(agent_get_troop_id, ":troop_id", ":victim"),
(troop_get_type, ":gender", ":troop_id"),
(try_begin),
(eq, ":gender", 0), #male              #GENDER CHECK
(agent_play_sound, ":victim", "snd_man_hit"),              #ZIKHALI
(else_try),
(agent_play_sound, ":victim", "snd_woman_hit"),
(try_end),
    (try_end),
])
 
Last edited:
Back
Top Bottom