Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hSpeed = 0;
- vSpeed = 0;
- //If just arriving in this state
- if (sprite_index != sPlayerHook)
- {
- hook = 0;
- hookX = 0;
- hookY = 0;
- hookStatus = HOOKSTATUS.EXTENDING;
- hookedEntity = noone;
- ///Update sprite
- sprite_index = sPlayerHook;
- image_index = floor(((direction div 45) + 1) * 0.5);
- image_speed = 0;
- }
- //Extend/Retract hook:
- var _speedHookTemp = speedHook;
- if (hookStatus != HOOKSTATUS.EXTENDING) _speedHookTemp *= -1;
- hook += _speedHookTemp;
- switch (image_index)
- {
- case 0: hookX = hook; break;
- case 1: hookY = -hook; break;
- case 2: hookX = -hook; break;
- case 3: hookY = hook; break;
- }
- //Hookshot state machine
- switch (hookStatus)
- {
- case HOOKSTATUS.EXTENDING:
- {
- //Finish Extending
- if (hook >= distanceHook) hookStatus = HOOKSTATUS.MISSED;
- //Check for hit
- var _hookHit = collision_circle(x+hookX,y+hookY,4,pEntity,false,true);
- if (_hookHit != noone)
- {
- //Act depending on what is hit:
- switch (_hookHit.entityHookable)
- {
- default: //Not hookable entity
- {
- //... else potentially harm enemy
- if (object_is_ancestor(_hookHit.object_index,pEnemy))
- {
- HurtEnemy(_hookHit,1,id,5);
- hookStatus = HOOKSTATUS.MISSED;
- }
- else
- {
- if (_hookHit.entityHitScript != -1)
- {
- with (_hookHit) script_execute(entityHitScript);
- hookStatus = HOOKSTATUS.MISSED;
- }
- }
- }break;
- case 1:
- {
- hookStatus = HOOKSTATUS.PULLTOPLAYER;
- hookedEntity = _hookHit;
- }break;
- case 2:
- {
- hookStatus = HOOKSTATUS.PULLTOENTITY;
- hookedEntity = _hookHit;
- }break;
- }
- }
- }break;
- //Pull the entity towards the hooked player
- case HOOKSTATUS.PULLTOPLAYER:
- {
- //Update distance/direction extended
- with (hookedEntity)
- {
- x = other.x + other.hookX;
- y = other.y + other.hookY;
- }
- }break;
- //Pull the PLAYER towards the hooked entity
- case HOOKSTATUS.PULLTOENTITY:
- {
- switch (image_index)
- {
- case 0: x += speedHook; break;
- case 1: y -= speedHook; break;
- case 2: x -= speedHook; break;
- case 3: y += speedHook; break;
- }
- }break;
- }
- //Finish retract and end state
- if (hook <= 0)
- {
- hookedEntity = noone;
- state = PLAYERSTATE.FREE;
- exit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement