SirCumferance

Damage to Shield first

May 4th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var list, col, ins, hit;
  2.  
  3. hit=false
  4. list=ds_list_create();//create list
  5. col=instance_place_list(x,y,all,list,true);//list all collissions
  6.  
  7.  
  8. for(i = 0; i<col; i+=1){
  9.     ins = ds_list_find_value(list,i);
  10.    
  11.     if(variable_instance_exists(ins,"game_health") and ins != id){//check if instance has health
  12.         if(variable_instance_exists(ins,"game_shield")){//check if instance has shield
  13.             if(ins.game_shield>argument0){//check if shield is above 0
  14.                 ins.game_shield-=argument0//damage shield
  15.                 hit=true
  16.             }else{//if shield = 0 or below
  17.                 ins.game_health-=argument0//damage health
  18.                 hit=true
  19.             }
  20.         }else{
  21.             ins.game_health-=argument0//if no shield, damage health
  22.             hit=true
  23.         }
  24.     }
  25. }
  26.  
  27. ds_list_destroy(list)//destroy list
  28.  
  29. return(hit)//return if an instance has been "damaged"
Add Comment
Please, Sign In to add comment