SHARE
TWEET

[RO] Campfire - Herc v1.1

Emistry Jun 23rd, 2018 (edited) 369 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // http://herc.ws/board/topic/16037-campfire-to-regenerate-hpsp/
  2. // https://github.com/dastgirp/HPM-Plugins/blob/master/src/plugins/npc-duplicate.c
  3. // https://pastebin.com/SWd3DWn1 (rA src mod)
  4.  
  5. /* db/item_db2.conf
  6.  
  7. {
  8.     Id: 7035
  9.     AegisName: "Matchstick"
  10.     Name: "Matchstick"
  11.     Type: 2
  12.     Buy: 100
  13.     Weight: 10
  14.     BuyingStore: true
  15.     Delay: 1000
  16.     Script: <" callfunc("func_CreateCampFire", rand(2, 5), 60, rand(1,10)); ">
  17. },
  18.  
  19. {
  20.     Id: 1019
  21.     AegisName: "Wooden_Block"
  22.     Name: "Trunk"
  23.     Type: 2
  24.     Buy: 60
  25.     Weight: 10
  26.     BuyingStore: true
  27.     Delay: 1000
  28.     Script: <" callfunc("func_UpdateCampFire", rand(3, 10), 60, rand(5,15)); ">
  29. },
  30.  
  31. {
  32.     Id: 902
  33.     AegisName: "Tree_Root"
  34.     Name: "Tree Root"
  35.     Type: 2
  36.     Buy: 12
  37.     Weight: 10
  38.     BuyingStore: true
  39.     Delay: 1000
  40.     Script: <" callfunc("func_UpdateCampFire", rand(1, 5), 30, rand(1,8)); ">
  41. },
  42.  
  43. */
  44.  
  45.  
  46. function    script  func_CreateCampFire {
  47.    
  48.     .@cid = getcharid(CHAR_ID_ACCOUNT);
  49.    
  50.     .@range = getarg(0, 3);     // Heal Range
  51.     .@duration = getarg(1, 60); // Duration
  52.     .@rate = getarg(2, 1);      // Heal Rate
  53.  
  54.     getmapxy(.@map$, .@mapx, .@mapy, UNITTYPE_PC);
  55.  
  56.     if(getmapxy(.@npc_map$, .@x, .@y, UNITTYPE_NPC, sprintf("Camp Fire#CF_%d",.@cid)) == 0)
  57.         donpcevent "Camp Fire#" + sprintf("CF_%d", .@cid) + "::OnCampFireEnd";
  58.  
  59.     showscript "Starting a Camp Fire...";
  60.     specialeffect(EF_FIREWALL2, AREA, .@cid);
  61.     progressbar "0xFFFFFF", 1;
  62.    
  63.     duplicatenpc("cf_main", "Camp Fire", sprintf("CF_%d", .@cid), .@map$, .@mapx, (.@mapy - 1), DIR_SOUTH, 10252, .@range, .@range);
  64.    
  65.     set(getvariableofnpc(getd(sprintf(".CF_%d_range", .@cid)), "Camp Fire#" + sprintf("CF_%d", .@cid)), .@range);
  66.     set(getvariableofnpc(getd(sprintf(".CF_%d_duration", .@cid)), "Camp Fire#" + sprintf("CF_%d", .@cid)), .@duration);
  67.     set(getvariableofnpc(getd(sprintf(".CF_%d_healrate", .@cid)), "Camp Fire#" + sprintf("CF_%d", .@cid)), .@rate);
  68.     donpcevent "Camp Fire#" + sprintf("CF_%d", .@cid) + "::OnCampFireStart";
  69.    
  70.     return;
  71. }
  72.  
  73. function    script  func_UpdateCampFire {
  74.  
  75.     .@cid = getcharid(CHAR_ID_ACCOUNT);
  76.    
  77.     .@range = getarg(0, 3);     // Heal Range
  78.     .@duration = getarg(1, 60); // Duration
  79.     .@rate = getarg(2, 1);      // Heal Rate
  80.  
  81.     getmapxy(.@map$, .@mapx, .@mapy, UNITTYPE_PC);
  82.  
  83.     if(getmapxy(.@npc_map$, .@x, .@y, UNITTYPE_NPC, sprintf("Camp Fire#CF_%d",.@cid)) == 0) {
  84.         if (.@npc_map$ != .@map$ || distance(.@mapx, .@mapy, .@x, .@y) > 5) {
  85.             dispbottom "<Camp Fire> You're too far away from the Campfire.";
  86.         }
  87.         else {
  88.             showscript "!!";
  89.             specialeffect(EF_FIREWALL2, AREA, "Camp Fire#" + sprintf("CF_%d", .@cid));
  90.            
  91.             .@range = min(8, getvariableofnpc(getd(sprintf(".CF_%d_range", .@cid)), "Camp Fire#" + sprintf("CF_%d", .@cid)) + .@range);
  92.             .@duration = min(300, getvariableofnpc(getd(sprintf(".CF_%d_duration", .@cid)), "Camp Fire#" + sprintf("CF_%d", .@cid)) + .@duration);
  93.             .@rate = min(15, getvariableofnpc(getd(sprintf(".CF_%d_healrate", .@cid)), "Camp Fire#" + sprintf("CF_%d", .@cid)) + .@rate);
  94.            
  95.             set(getvariableofnpc(getd(sprintf(".CF_%d_range", .@cid)), "Camp Fire#" + sprintf("CF_%d", .@cid)), .@range);
  96.             set(getvariableofnpc(getd(sprintf(".CF_%d_duration", .@cid)), "Camp Fire#" + sprintf("CF_%d", .@cid)), .@duration);
  97.             set(getvariableofnpc(getd(sprintf(".CF_%d_healrate", .@cid)), "Camp Fire#" + sprintf("CF_%d", .@cid)), .@rate);
  98.         }
  99.     }
  100.     else {
  101.         dispbottom "<Camp Fire> Start a Campfire...";
  102.     }
  103.    
  104.     return;
  105. }
  106.  
  107.  
  108. -   script  Camp Fire::cf_main  FAKE_NPC,{
  109.     end;
  110.    
  111. OnCampFireStart:
  112.     getmapxy(.@map$, .@x, .@y, UNITTYPE_NPC);
  113.    
  114.     .@npcname$ = strnpcinfo(NPC_NAME_HIDDEN);
  115.    
  116.     do {
  117.         .@range = getd(sprintf(".%s_range", .@npcname$));
  118.         .@healrate = getd(sprintf(".%s_healrate", .@npcname$));
  119.        
  120.         specialeffect EF_DRAGONSMOKE, AREA;
  121.         showscript "HEAL: "+.@healrate+"% | AREA:"+.@range+" | TIME: "+getd(sprintf(".%s_duration", .@npcname$));
  122.        
  123.         setd(sprintf(".%s_duration", .@npcname$)), getd(sprintf(".%s_duration", .@npcname$)) - 1;
  124.        
  125.         areapercentheal(.@map$, (.@x - .@range), (.@y - .@range), (.@x + .@range), (.@y + .@range), .@healrate, .@healrate);
  126.         sleep 1000;
  127.        
  128.         .@counter++;
  129.         if (.@counter > 0 && .@counter % 10 == 0 && .@healrate > 1) // every 10 seconds reduce heal rate
  130.             setd(sprintf(".%s_healrate", .@npcname$), getd(sprintf(".%s_healrate", .@npcname$)) - 1);
  131.         if (.@counter > 0 && .@counter % 30 == 0 && .@range > 1) // every 30 seconds reduce range
  132.             setd(sprintf(".%s_range", .@npcname$), getd(sprintf(".%s_range", .@npcname$)) - 1);
  133.        
  134.     } while (getd(sprintf(".%s_duration", .@npcname$)) > 0);
  135.    
  136.     setd(sprintf(".%s_range", .@npcname$), 0);
  137.     setd(sprintf(".%s_duration", .@npcname$), 0);
  138.     setd(sprintf(".%s_healrate", .@npcname$), 0);
  139.     duplicateremove(strnpcinfo(NPC_NAME_UNIQUE));
  140.     end;
  141.  
  142. OnCampFireEnd:
  143.     .@npcname$ = strnpcinfo(NPC_NAME_HIDDEN);
  144.     setd(sprintf(".%s_duration", .@npcname$), 0);
  145.     awake strnpcinfo(NPC_NAME_UNIQUE);
  146.     end;
  147.  
  148. OnTouch:
  149.     specialeffect(EF_HEAL, AREA, getcharid(CHAR_ID_ACCOUNT));
  150.     dispbottom("You are feeling warm and cozy.");
  151.     end;
  152. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top