Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // room script file
- #define wa1 1
- #define wa2 2
- #define tp1_x 260
- #define tp1_y 88
- #define tp2_x 382
- #define tp2_y 314
- int doStuffafterTeleporting;
- int dsat_x, dsat_y;
- function afterTeleporting() {
- int p = doStuffafterTeleporting;
- // non blocking walk
- if (p == 1) player.Walk(dsat_x, dsat_y);
- // blocking walk
- if (p == 2) player.Walk(dsat_x, dsat_y, eBlock);
- doStuffafterTeleporting = 0;
- }
- function WalkTo(this Character*, int x, int y, BlockingStyle blocking) {
- int wa_this = GetWalkableAreaAt(this.x - GetViewportX(), this.y - GetViewportY());
- int wa_target = GetWalkableAreaAt(x - GetViewportX(), y - GetViewportY());
- if (wa_this == wa_target) {
- this.Walk(x, y, blocking);
- return;
- }
- else {
- if (blocking == eBlock) {
- doStuffafterTeleporting = 2;
- dsat_x = x;
- dsat_y = y;
- if (wa_this == wa1) player.Walk(tp1_x, tp1_y, eBlock);
- if (wa_this == wa2) player.Walk(tp2_x, tp2_y, eBlock);
- }
- else {
- // some more work to be done
- }
- }
- }
- function poster_Interact()
- {
- player.WalkTo(305, 225, eBlock);
- }
- function room_RepExec()
- {
- if (IsTimerExpired(20)) afterTeleporting();
- }
- bool region1_active = true, region2_active = true;
- Region *lastRegion;
- void repeatedly_execute_always() {
- if (lastRegion == null) lastRegion = region[0];
- Region *currentRegion = Region.GetAtRoomXY(player.x, player.y);
- if (currentRegion != lastRegion) {
- // stepping off lastRegion
- if (lastRegion == region[wa1]) {
- region1_active = true;
- }
- if (lastRegion == region[wa2]) {
- region2_active = true;
- }
- // stepping on currentRegion
- if (currentRegion == region[wa1]) {
- if (region1_active) {
- region2_active = false;
- player.StopMoving();
- player.x = 382;
- player.y = 314;
- currentRegion = region[wa2];
- if (doStuffafterTeleporting > 0) SetTimer(20, 1);
- }
- }
- else if (currentRegion == region[wa2]) {
- if (region2_active) {
- region1_active = false;
- player.StopMoving();
- player.x = 260;
- player.y = 88;
- currentRegion = region[wa1];
- if (doStuffafterTeleporting > 0) SetTimer(20, 1);
- }
- }
- }
- lastRegion = currentRegion;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement