User Tools

Site Tools


lua:scripting:examples:olcscripts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
lua:scripting:examples:olcscripts [2015/03/15 08:52] – created vodurlua:scripting:examples:olcscripts [2016/10/02 03:26] (current) – [Reduce wealth of shops over 100%] vodur
Line 1: Line 1:
-Edit v1 and v2 values for all wands and staffs+====== OLC scripts ====== 
 + 
 +===== Edit all wands and staffs to have 50/50 charges =====
  
 <code lua> <code lua>
 do do
  
-local function menu_handlerch +for _,area in pairs(getarealist()) do 
-    sendtochar(ch, "Beginning the menu test.\n\r")+    for _,op in pairs(area.objprotos) do 
 +        if op.otype=="wand" or op.otype=="wand" then 
 +            if not(op.chargesleft==50or not(op.chargestotal==50) then 
 +                mdo("oedit "..op.vnum) 
 +                olc("v1 50") 
 +                olc("v2 50") 
 +                olc("done"
 +            end 
 +        end 
 +    end 
 +end
  
-    while true do +end 
-        sendtochar( ch, [[ +</code>
-[s]ex +
-[r]ace +
-[c]lass +
-[q]uit +
-]]) +
-        local cmd=coroutine.yield()+
  
-        if cmd=="s" then +===== Shop wands/staffs have 50/50 charges, otherwise set to -1/50 ===== 
-            sendtocharch"Your sex: "..ch.sex.."\n\r"+ 
-        elseif cmd=="r" then +-1 makes the # of charges randomize then item pops. 
-            sendtochar( ch"Your race: "..ch.race.."\n\r"+ 
-         elseif cmd=="c" then +<code lua> 
-            sendtocharch, "Your class: "..ch.class.."\n\r"+do 
-        elseif cmd=="q" then + 
-            return -- ends the con handler +    local cnter=0 
-        else +    local reset_check = {} 
-            sendtochar( "Unknown selection: "..cmd.."\n\r")+    for _,area in pairs(getarealist()) do 
 +        for _,room in pairs(area.roomsdo 
 +            local shop=false 
 +            for i,reset in ipairs(room.resetsdo 
 +                clearloopcount() 
 +                local cmd=reset.command 
 + 
 +                if cmd == "M" then 
 + 
 +                    if getmobproto(reset.arg1).shop then 
 +                        shop=true 
 + 
 +                    else 
 +                        shop=false 
 + 
 +                    end 
 +                elseif cmd == "G" then 
 + 
 +                    if shop==true then 
 +                        reset_check[reset.arg1]=true 
 +                    elseif reset_check[reset.arg1]==nil then 
 +                        reset_check[reset.arg1]=false 
 +                    end 
 +                end 
 +            end
         end         end
     end     end
- end 
  
-start_con_handlermob.descriptormenu_handler, mob )+    for _,area in pairs(getarealist()) do 
 +        for _,op in pairs(area.objprotos) do 
 +            if op.otype=="wand" or op.otype=="staff" then 
 +                local chargesleft_target 
 +                local chargestotal_target 
 +                if reset_check[op.vnum]==true then 
 +                    chargesleft_target=50 
 +                    chargestotal_target=50 
 +                else 
 +                    chargesleft_target=-1 
 +                    chargestotal_target=50 
 +                end 
 + 
 +                if not(op.chargesleft==chargesleft_target) or not(op.chargestotal==chargestotal_target) then 
 +                    mdo("oedit "..op.vnum) 
 +                    olc("v1 "..chargestotal_target) 
 +                    olc("v2 "..chargesleft_target) 
 +                    olc("done") 
 +                end 
 +            end 
 +        end 
 +    end
  
 end end
 </code> </code>
  
-<code> +===== Surreal reset culling ===== 
-Beginning the menu test+ 
-[s]ex +[[http://aarchonmud.com/forum/viewtopic.php?f=25&t=242|http://aarchonmud.com/forum/viewtopic.php?f=25&t=242]] 
-[r]ace + 
-[c]lass +<code lua
-[q]uit +do 
-s +local area=getroom(2031).area 
-Your sex: male + 
-[s]ex +for _,room in pairs(area.rooms) do 
-[r]ace +    local edited=false 
-[c]lass +    clearloopcount() 
-[q]uit +    local finished 
-r +    while not finished do 
-Your racewraith +        finished=true 
-[s]ex +        local num_resets=#room.resets 
-[r]ace + 
-[c]lass +        for i,reset in ipairs(room.resets) do 
-[q]uit +            if reset.command=="M" then 
-c +                goto(room.vnum) 
-Your classillusionist +                local rmax=reset.arg4 
-[s]ex +                local amax=reset.arg2 
-[r]ace +                local mvnum=reset.arg1 
-[c]lass + 
-[q]uit +                if amax>25 then 
-q +                    local newmax=25 
-lua>+                    rmax=math.min(rmax,newmax) 
 +                    --local newmax=math.max(20, amax/2) 
 +                        --newmax=math.min(amax, 50) 
 +                    edited=true 
 +                    mdo("reset "..i.." delete"
 +                    mdo("reset "..num_resets.." mob "..mvnum.." "..newmax.." "..rmax) 
 +                    finished=false 
 +                    break 
 +                end 
 +            end 
 +        end 
 +    end 
 +    if edited then mdo('reset') end 
 +end 
 + 
 +end 
 +</code> 
 +===== Burnproof flag removal / Nonmetal Weapon adjust ===== 
 + 
 +<code lua> 
 +function anti_burnproof() 
 +    local count = 0 
 +    for _,area in pairs(getarealist()) do 
 +        if not area:flag("clone") then 
 +            for _,op in pairs(area.objprotos) do 
 +                if op:extra("burnproof") and (op.otype == "armor" or op.otype == "weapon") then 
 +                    -- adjust damage using olc 
 +                    mdo("oedit " .. op.vnum) 
 +                    olc("extra burnproof"
 +                    olc("done"
 +                    count = count + 1 
 +                end 
 +            end 
 +        end 
 +    end 
 +    sendtochar(mob, "Removed burnproof flag from " .. count .. " items.\n"
 +end 
 + 
 +function nonmetal_weapons() 
 +    local count = 0 
 +    for _,area in pairs(getarealist()) do 
 +        if not area:flag("clone") then 
 +            for _,op in pairs(area.objprotos) do 
 +                if op:extra("nonmetal") and op.otype == "weapon" and op.level>= 1 and op.level <= 100 then 
 +                    -- remove burnproof flag using olc 
 +                    mdo("oedit " .. op.vnum) 
 +                    olc("adjust") 
 +                    olc("done"
 +                    count = count + 1 
 +                end 
 +            end 
 +        end 
 +    end 
 +    sendtochar(mob, "Adjusted damage for " .. count .. " nonmetal weapons.\n"
 +end 
 +</code> 
 +===== Reduce wealth of shops over 100% ===== 
 + 
 +<code lua> 
 +do 
 + 
 +local cnt = 0 
 + 
 +for _,area in pairs(getarealist()) do 
 +    for _,mp in pairs(area.mobprotos) do 
 +        if mp.shop and mp.wealthpcnt> 100 then 
 +            mdo("medit "..mp.vnum) 
 +            olc("wealth 100"
 +            olc('done'
 +            cnt = cnt + 1 
 + 
 +        end 
 +    end 
 +end 
 +local msg = "Updated wealth on "..cnt.." mobs via lua script" 
 +log(msg, 'secure'
 +end
 </code> </code>
  
lua/scripting/examples/olcscripts.1426409575.txt.gz · Last modified: 2015/03/15 08:52 by vodur