RMXP

스크립트 함수처리(?) 관련 질문

by Lighna posted Dec 19, 2012
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄
Extra Form

@state 라는 해시에 여러 상태이상을 구현하려고 합니다만, 이상하게도 구조적으로 이상한건 느껴지지 않는데 정상적으로 작동되지 않아 여기에 올려봅니다..; ㅡㅜ

 

class Game_Character

 

 

> > initialize


  #State
    @state = {}
    istate = {}
    con  = {}
   
    istate = {
     'time' => 0,
     'degree' => 0}
    
    con  = {
     '출혈' => istate,
     '기절' => istate,
     '독'   => istate,
     '탈진' => istate,
     '다운' => istate,
     '넉백' => istate}
    
    @state = {
     'life' => nil,
     'dead' => nil,
     'con'=> con,
     'con_add'=> con}

 

> > update
     lasc_manager

 

> > lasc_manager    
    #횡스크롤용 방향세팅
    lasc_way
    #각종 State 업데이트
    lasc_state

> >   lasc_state   


      #지속시간 업데이트
        for i in @state['con'].keys
          case
            when @state['con'][i]['time'] > 0
                 @state['con'][i]['time'] -= 1
            when @state['con'][i]['time'] == 0
                if @state['con'][i]['degree'] > 0
                 @state['con'][i]['degree'] = 0
                end
          end
        end
       #정보 업데이트
        for i in @state['con'].keys
          if @state['con_add'][i]['degree'] > 0
            case
              when @state['con'][i]['degree'] > 0
                if @state['con_add'][i]['degree'] > @state['con'][i]['degree']
                  @state['con'][i]['degree'] = @state['con_add'][i]['degree']
                  @state['con'][i]['time'] += @state['con_add'][i]['time']*(
                  @state['con_add'][i]['degree']/((@state['con_add'][i]['degree']+@state['con'][i]['degree'])/2).to_i)

                elsif @state['con_add'][i]['degree'] <= @state['con'][i]['degree']
                  @state['con'][i]['time'] += @state['con_add'][i]['time']*(
                  @state['con'][i]['degree']/((@state['con_add'][i]['degree']+@state['con'][i]['degree'])/2).to_i)
                end
              when @state['con'][i]['degree'] == 0
                @state['con'][i]['time'] = @state['con_add'][i]['time']
                @state['con'][i]['degree'] = @state['con_add'][i]['degree']
                 
            end
            @state['con_add'][i]['degree'] = 0
            @state['con_add'][i]['time'] = 0
          end
        end
      #상태 효과
      case
        #●
        when @state['con']['출혈']['time'] > 0
          @hp -= @state['con']['출혈']['degree']
        #●
        when @state['con']['기절']['time'] > 0
          @active_manage['attack_take'] = false
          @active_manage['move'] = false
          if @state['con']['기절']['time'] <= 1
            @active_manage['attack_take'] = true
            @active_manage['move'] = true
          end
        #●
        when @state['con']['넉백']['time'] > 0
            pn('넉백')
          r = (@way == 'R'? 1 : -1)
                p '4'
          if @way == 'R'# R 6 L 4
            for i in 0..@state['con']['넉백']['degree']
                p 'a'
              if !passable?(@x-i,@y,4)
                moveto(@x-i+1,@y,4)
                p 'o'
                break
              end
            end
          else
            for i in 0..@state['con']['넉백']['degree']
              if !passable?(@x+i,@y,6)
                moveto(@x+i-1,@y,6)
                break
              end
            end
          end
        end

.

.

.

.이런식으로 되어있습니다만, 작동하지 않습니다 ㅠ

 

@state['con_add']['넉백']['time']=200;@state['con_add']['넉백']['degree']=2

라고 해놓으면,  넉백이라는 해시키뿐만 아니라 다른 키들도 전부 위와같은 값으로 바뀌며,

얼마정도 지나면 전부 0으로 되돌아가 버립니다.

 

어느부분이 잘못된건지... 미치겠습니다 ㅠ 저에게 구원의 손길을 ㅠㅠㅠㅠ.........

 

 

Who's Lighna

profile

스트레스 받는다.