[XP] Throw System

Started by LiTTleDRAgo, October 21, 2011, 12:03:04 am

Previous topic - Next topic

Sin86

http://www.sendspace.com/file/zzatfn

Link to demo with a completely default Blizz ABS on it.

However, the Throw System is exactly how you wanted the segments to be altered on your previous post.

LiTTleDRAgo


Sin86

Can still piick up but cannot throw. However this time, I can goto an event that takes me to another map without having attacks and skills being disabled.

Futendra

January 26, 2012, 03:35:03 pm #23 Last Edit: January 26, 2012, 03:48:12 pm by Futendra
I also can pick up but can't throw, maybe ask help of someone else? g_g, winkio,... ?

is this supposed to be in ""?
eval_text = "
class #{name}
if $BlizzABS
   alias update_for_throwing update_moving
   alias move_for_throwing move
else
   alias update_for_throwing update
end
alias pickup_check_event_trigger_there check_event_trigger_there
#--------------------------------------------------------------------------
# ● Check Event Pickup
#--------------------------------------------------------------------------
def player()  $game_player  end unless $BlizzABS
def check_event_trigger_there(triggers)
   throw_event(0)
   pickup_event   
   return if player.pickup_lock
   return if !player.pickup_lock_time.nil? && player.pickup_lock_time > 0
   pickup_check_event_trigger_there(triggers) 
end
#--------------------------------------------------------------------------
# ● Update Moving (BlizzABS)
#--------------------------------------------------------------------------
def update_moving(d)
   update_for_throwing(d)
   update_carry_time
   update_throw_position
end
#--------------------------------------------------------------------------
# ● Update (Non BlizzABS)
#--------------------------------------------------------------------------
def update
   update_for_throwing
   update_carry_time
   update_throw_position
end
#--------------------------------------------------------------------------
# ● Move (BlizzABS)
#--------------------------------------------------------------------------
def move(d)
   return if !player.pickup_lock_time.nil? && player.pickup_lock_time > 0 
   move_for_throwing(d)
end
#--------------------------------------------------------------------------
# ● Update Carry Time
#--------------------------------------------------------------------------
def update_carry_time
    if !player.pickup_lock_time.nil? && player.pickup_lock_time > 0
       player.pickup_lock_time -= 1
       sprite_normal if player.pickup_lock_time  == 0 ##
    end
    if !$game_temp.carry_time.nil? && $game_temp.carry_time > 0
       $game_temp.carry_time -= 1
       reset_pickup if $game_temp.carry_time == 0
    end 
  end 
#--------------------------------------------------------------------------
# ● Update Throw Position
#--------------------------------------------------------------------------
def update_throw_position
   $game_map.events.each_value {|event|
     if event.throw_active && !event.jumping?
       event.real_x = player.real_x
       event.real_y = player.real_y - 128
       event.x = player.x
       event.y = player.y
       sprite_carry
     end  }   
end
#--------------------------------------------------------------------------
# ● Throw Event
#--------------------------------------------------------------------------
def throw_event(type)
   return if !player.pickup_lock
   return if player.pickup_lock_time > 0
   return if $game_system.map_interpreter.running?
   $game_map.events.each_value {|event|
     return unless event.is_a?(Game_Event)
     if event.throw_active && !event.jumping?
       $game_temp.can_throw = true
       if type == 1
         event.throw_action(1)
       else 
         event.throw_action(event.throw)
       end
       return if !$game_temp.can_throw
       sprite_throw     
       $game_temp.throw_pos_x = event.x
       $game_temp.throw_pos_y = event.y
       player.pickup_lock_time = 15     
       event.throw_active = false
       player.pickup_lock = false         
       event.move_speed = event.pre_move_speed
       event.walk_anime = event.pre_walk_anime
     end  }   
end
#--------------------------------------------------------------------------
# ● Pickup Event
#--------------------------------------------------------------------------
def pickup_event   
   return if player.pickup_lock
   return if !player.pickup_lock_time.nil? && player.pickup_lock_time > 0   
   return if $game_system.map_interpreter.running?
   $game_map.events.each_value {|event|
     if player.front_pos?(event.x,event.y)
       return if event.throw.nil? || event.throw == 0
       return if event.erased
       return if event.through
       player.pickup_lock_time = 15
       event.throw_active = true
       player.pickup_lock = true
       sprite_throw
       event.jump(0,0)
       event.x = player.x
       event.y = player.y
       event.pre_walk_anime = event.walk_anime
       event.pre_move_speed = event.move_speed
       event.move_speed = 7
       event.walk_anime = false
     end }
   end
#--------------------------------------------------------------------------
# ● About Actor
#--------------------------------------------------------------------------
def about_actor
   @actor = {}
   @actor = {
     1 => $game_party.actors[0],
     2 => $game_party.actors[1],
     3 => $game_party.actors[2],
     4 => $game_party.actors[3],
     
     99 => $game_party.actors[99]  }
end
#--------------------------------------------------------------------------
# ● Sprite Throw
#--------------------------------------------------------------------------
def sprite_throw
   about_actor
   for i in 1..4
     name = @actor[i].character_name.to_s rescue ''
     if player.character_name == name or
        player.character_name == name + '_PICK'
       player.character_name = name + '_TRW'
     end
   end
end
#--------------------------------------------------------------------------
# ● Sprite Carry
#--------------------------------------------------------------------------
def sprite_carry
   about_actor
   for i in 1..4
     name = @actor[i].character_name.to_s rescue ''
     if player.character_name == name or
        player.character_name == name + '_TRW'
       player.character_name = name + '_PICK'   
     end
   end
end
#--------------------------------------------------------------------------
# ● Normal
#--------------------------------------------------------------------------
def sprite_normal
   about_actor
   for i in 1..4
     name = @actor[i].character_name.to_s rescue ''
     if player.character_name == name + '_PICK' or
        player.character_name == name + '_TRW'
       player.character_name = name
     end
   end
end
end"

Sin86

January 26, 2012, 06:42:56 pm #24 Last Edit: January 26, 2012, 07:01:18 pm by Sin86
I found out why I can't throw.

I did a process looking to find what scripts were wrong, deleted them out and that wasn't what caused it. I tried removing any paraell processes, didn't work either. I came to a point to where it all comes to how many enemies and destroyable objects are on the screen as well as events that are not tagged as enemies or objects are on the screen. It kind of depends on how many enemy/object events are and also how many non-enemie/object events are on the maps.


For instance, I got 8 enemy/objects on my screen and 2 normal events and 1 rock event(rock event depicts a rock that you can pick up and throw). At that point I can pick up but not throw. However, if I remove one of the enemy/objects from the map(6 are destroyable, 2 are not, I however remove one that is destroyable), then I can throw my rock around.

LiTTleDRAgo


Sin86

I don't get it. I tried working this new version on one demo with no other scripts besides this and the current Blizz ABS and it works. Yet I do it with another demo that also just uses no other scripts besides this and the current Blizz ABS and that one did not work. Both rock events have the same event names too in both demos and the confirm keys on both are also Enter as well.

LiTTleDRAgo

forget to mention

character can't pick / throw if didn't have "_Pick" & "_TRW" graphic 

Sin86

January 26, 2012, 09:57:02 pm #28 Last Edit: January 26, 2012, 09:59:52 pm by Sin86
Ah, that explains why the other demo character didn't pick up the rock. No message shown like in the other versions.

Sweet, I can throw rocks just about anywhere regardless of how many events/enemies/objects there are.

Thank you so much Littledrago, it really works now(and thank Moghunter too).


Oh yeah, is there also a way on how you can have it to where once you throw a rock, it crumbles and can't be used again unless you leave and re-enter the map?

LiTTleDRAgo

update to 0.50

Spoiler: ShowHide


how about that?

Sin86

Really good but now if you throw an object after it explodes, well if you leave the room and come back in a first time, the rock will disappear and the animation will play. Leave the room a 2nd time and come back in a 2nd time the rock will come back. Pick it up and throw it again, you will have to leave and come back in twice.

LiTTleDRAgo

try adding this line

Quote
  alias upd_for_throw update
  def update
    upd_for_throw
    if @throwed && @thssw && !jumping?
      $game_self_switches[[$game_map.map_id,@id,@thssw]] = true
      $game_map.need_refresh = true
      @throwed = false
    end
  end
end

Sin86

It worked.

Once again, thank you very much.

Futendra

January 28, 2012, 06:13:41 am #33 Last Edit: January 28, 2012, 06:32:12 am by Futendra
Can you update this so when the first block in front of the player is unpassable, you cannot throw the item?

Now when you throw it when there is an unpassable block in front of the player, it drops under the player.

Also, could you make it impossible to throw at through events? Maybe with a tag like <Unpassable>

LiTTleDRAgo

done, update to 0.52

btw I already use <Unpassable> on another script so I change it to <BlockThrow>

Futendra

Quote from: LiTTleDRAgo on January 28, 2012, 08:28:46 pm
done, update to 0.52

btw I already use <Unpassable> on another script so I change it to <BlockThrow>


Also, I use idle sprites for Blizz-ABS and when I picked something up, the idle sprites overwrite the picked-up sprites. I need the idle sprites because of some other bug...

LiTTleDRAgo

done, updated to 0.53

try it out

Boba Fett Link

This looks epic. It'll be perfect once you add pixel movement compatibility!
This post will self-destruct in 30 seconds.

Futendra

Quote from: Boba Fett Link on January 29, 2012, 03:42:22 pm
This looks epic. It'll be perfect once you add pixel movement compatibility!


Agreed!

Also, now the "idle" when something is picked up keeps walking!

+ The rocks don't hit enemies?

LiTTleDRAgo

Quote from: Futendra on January 29, 2012, 03:48:34 pm
Quote from: Boba Fett Link on January 29, 2012, 03:42:22 pm
This looks epic. It'll be perfect once you add pixel movement compatibility!


Agreed!

Also, now the "idle" when something is picked up keeps walking!

+ The rocks don't hit enemies?


I can't understand your statement perfectly

is this what you mean?
- when player picked something up, his sprite keeps walking (like step animation is activated)?
- the rocks didn't do anything when hit an enemy?