FANDOM


This quest example covers chests and npc tags.

Logic Edit

  1. Open a chest which gives a scroll item and also spawn monsters.
  2. Use the item to kill all the monsters.

Pseudocode Edit

Variable Edit

  • haveOpenedChest = false

Item Edit

  • Scroll (with event useItem)

Events Edit

getChestState (linked with "getState" of chest)
    return haveOpenedChest
_
openChest (linked with "openEvent" trigger of chest)
    set haveOpenedChest = true
    add item scroll
    spawn 2 monsters with tag "monster = true"
_
useItem (linked with option of Scroll item)
    for every npc in the map with the tag "monster = true":
        kill the npc

Maps Edit

Spawn a chest that gives a scroll and spawn 2 monsters.

Real Code Edit

Variable Edit

[VAR.haveOpenedChest]:false

Item Edit

n.newItem(ITEM.scroll, "Scroll", CST.ICON.planEquip,[
    n.newItem_option(EVENT.useItem,"Use")
]);

Events Edit

getChestState(key:number){
    return s.get(key,VAR.haveOpenedChest);
}
openChest(key:number){
    s.set(key,VAR.haveOpenedChest,true);
    s.addItem(key,ITEM.scroll);
    s.spawnNpcOnTop(key,MAP.main,NPC.bat,attrs => {
        attrs.tag = {[TAG.monster]:true};
    });
    s.spawnNpcOnTop(key,MAP.main,NPC.bat,attrs => {
        attrs.tag = {[TAG.monster]:true};
    });
}
useItem(key:number){
    s.forEachNpc(key,MAP.main,function(eid){
        s.killActor(eid);
    },{[TAG.monster]:true});
    s.completeQuest(key);
}

Map Edit

//Tiled project has a q1 spot on layer SPOT.
m.spawnLoot(mapUid, spots.q1,EVENT.getChestState,EVENT.openChest);


Walkthrough from Quest Template Edit

To create a new quest in the Raining Chain Editor:

  1. Create new quest. (Ctrl+Shift+P RCE:New Project)
  2. Add ids to the enums.
  3. Copy-paste the quest variable.
  4. Copy-paste the item.
  5. Copy-paste the events in EVENT_CLASS.
  6. Add the q1 spots in the .tmx file then "Update Spots". Once again, make sure to put the spot inbetween tiles.
  7. Copy-paste the npc spawning logic in the map onLoad().
  8. Test the quest. (Ctrl+Shift+P RCE:Test Project)

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.