System The Rune System [TRS]

Furby

Current occupation: News poster
Reaction score
144
The Rune System
by FURBY

version 1.01a

Preface: Many friends was asking me if I can make something like this. So I decided to make system for this.

What does this do: This system allows creators of maps to simple add runes to regions choosed by creator also set a lot of stuffs around.

Features:
  • You are able to change time in which are runes spawned at first time
  • You are able to change time in which are runes respawned after each pick
  • You are able to change if is rune placed randomly or exactly in center of region
  • You are able to add new or remove existing runes and regions in which are runes spawned

Requires: Jass NewGen Pack

Changelog:
version 1.00
  • First release
version 1.01
  • Fixed code
version 1.01a
  • Scope instead of library
  • Private Init instead of public Init
  • Added nulling of timer in Init
How to use:
Copy the trigger called TRS from the attached map or create a trigger named TRS, convert it to custom text, and replace everything inside it with the code below. Then you can addm remove or edit values in Editable Zone in trigger you created.

System code:
JASS:
//==============================================================================
//==============================================================================
//
//  TRS - THE RUNES SYSTEM BY FURBY - v1.01a
//
//  MORE INFO ON THE THEHELPER.NET AND CLANMAPZ.COM
//
//  thanks to Romek and Artificial for helping
//
//==============================================================================
//==============================================================================
scope TheRuneSystem initializer Init
    globals
        private integer array TheRuneType
        private rect array TheRuneRect
        private real array TheRuneRespawn
        private boolean array TheRuneRandomPlace
        private item array TheRunes
        private timer array TheRuneTimer
        private boolean TheRuneDebugMode = false
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//  EDITABLE ZONE - EDITABLE ZONE - EDITABLE ZONE - EDITABLE ZONE
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
    
        //How many types of runes system allowing
        private constant integer CountTheRuneTypes = 4
        
        //How many regions for runes system allowing
        private constant integer CountTheRuneRects = 3
        
        //How long time from start of the map runes will spawn
        private constant real FirstSpawnTime = 30.
        
    endglobals
    private function SetGlobalArray takes nothing returns nothing
        local integer i
        //Rawcodes of the runes
        //Be sure if you changed count of rune types in globals, variable: CountTheRuneTypes - base 4
        set TheRuneType[1] = 'rhe3'
        set TheRuneType[2] = 'rma2'
        set TheRuneType[3] = 'rspd'
        set TheRuneType[4] = 'rspl'
      //set TheRuneType[5] = ...
        
        //Regions where are runes spawned
        //Be sure if you changed count of rune regions in globals, variable: CountTheRuneRects - base 3
        set TheRuneRect[1] = gg_rct_TheRuneOne
        set TheRuneRect[2] = gg_rct_TheRuneTwo
        set TheRuneRect[3] = gg_rct_TheRuneThree
      //set TheRuneRect[5] = ...
        
        //If item should spawn at random place in region
        //Be sure if you changed count of rune regions in globals, variable: CountTheRuneRects - base 3
        set TheRuneRandomPlace[1] = false
        set TheRuneRandomPlace[2] = false
        set TheRuneRandomPlace[3] = true
      //set TheRuneRandomPlace[4] = ...
        
        set i = 1
        loop
            exitwhen(i>CountTheRuneTypes)
            set TheRuneRespawn<i> = 15.
            set i = i + 1
        endloop    
        
    endfunction
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//  END OF EDITABLE ZONE - END OF EDITABLE ZONE - END OF EDITABLE ZONE
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------   
    private function TheRuneDebug takes string s returns nothing
        if TheRuneDebugMode==true then
            debug call BJDebugMsg(s)
        endif
    endfunction
    private function TheRuneDebugChange takes nothing returns nothing
        if GetEventPlayerChatString()==&quot;-TRS debug on&quot; then
            set TheRuneDebugMode=true
        elseif GetEventPlayerChatString()==&quot;-TRS debug off&quot; then
            set TheRuneDebugMode=false
        endif
    endfunction
    private function GetRuneSpawnX takes integer Id returns real
        if TheRuneRandomPlace[Id]==true then
            return GetRandomReal(GetRectMinX(TheRuneRect[Id]), GetRectMaxX(TheRuneRect[Id]))
        else
            return GetRectCenterX(TheRuneRect[Id])
        endif
    endfunction
    private function GetRuneSpawnY takes integer Id returns real
        if TheRuneRandomPlace[Id]==true then
            return GetRandomReal(GetRectMinY(TheRuneRect[Id]), GetRectMaxY(TheRuneRect[Id]))
        else
            return GetRectCenterY(TheRuneRect[Id])
        endif
    endfunction
    private function GetItemId takes item TheItem returns integer
        local integer i = 1
        loop
            exitwhen(i&gt;CountTheRuneRects)
            if TheItem == TheRunes<i> then
                return i
            endif
            set i = i + 1
        endloop
        return 0
    endfunction
    private function RespawnItem takes nothing returns nothing
        local integer i = 1
        call TheRuneDebug(&quot;Respawn timer expired&quot;)
        loop
            exitwhen(i&gt;CountTheRuneRects)
            if GetExpiredTimer()==TheRuneTimer<i> then
                call TheRuneDebug(&quot;Creating item with id &#039;&quot; + I2S(i) + &quot;&#039;&quot;)
                set TheRunes<i> = CreateItem(TheRuneType[GetRandomInt(1,CountTheRuneTypes)],GetRuneSpawnX(i),GetRuneSpawnY(i))
            endif
            set i = i + 1
        endloop
        call DestroyTimer(GetExpiredTimer())
    endfunction
    private function Act takes nothing returns nothing
        local item TheItem = GetManipulatedItem()
        set TheRuneTimer[GetItemId(TheItem)] = CreateTimer()
        call TimerStart(TheRuneTimer[GetItemId(TheItem)], TheRuneRespawn[GetItemId(TheItem)], false, function RespawnItem)
        call TheRuneDebug(&quot;Respawn timer of rune started with &#039;&quot; + R2S(TheRuneRespawn[GetItemId(TheItem)]) + &quot;&#039; seconds&quot;)
        set TheItem = null
    endfunction
    private function Cond takes nothing returns boolean
        local item TheItem = GetManipulatedItem()
        call TheRuneDebug(&quot;Picking of item detected&quot;)
        if GetItemId(TheItem)!=0 then
            call TheRuneDebug(&quot;Detected item is rune with id &#039;&quot; + I2S(GetItemId(TheItem)) + &quot;&#039;&quot;)
            return true
        endif
        call TheRuneDebug(&quot;Detected item is not rune&quot;)
        return false
    endfunction
    private function FirstSpawn takes nothing returns nothing
        local integer i = 1
        call TheRuneDebug(&quot;First spawn timer expired&quot;)
        call DestroyTimer(GetExpiredTimer())
        loop
            exitwhen(i&gt;CountTheRuneRects)
            call TheRuneDebug(&quot;Creating rune with id &#039;&quot; + I2S(i) + &quot;&#039;&quot;)
            set TheRunes<i> = CreateItem(TheRuneType[GetRandomInt(1,CountTheRuneTypes)],GetRuneSpawnX(i),GetRuneSpawnY(i))
            set i = i + 1
        endloop
    endfunction
    private function True takes nothing returns boolean
        return true
    endfunction
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger() 
        local integer i 
        local timer tim = CreateTimer()
        call SetGlobalArray()
        set i = 1
        call TheRuneDebug(&quot;Starting first spawn timer with &#039;&quot; + R2S(FirstSpawnTime) + &quot;&#039; seconds&quot;)
        call TimerStart(tim, FirstSpawnTime, false, function FirstSpawn)
        set i = 0
        loop
            exitwhen(i&gt;11)
            call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_PICKUP_ITEM, Filter(function True))
            set i = i + 1
        endloop
        call TriggerAddCondition(t, Filter(function Cond))
        call TriggerAddAction(t, function Act)
        //  Debug set
        set i = 0
        loop
            exitwhen(i&gt;11)
            call TriggerRegisterPlayerChatEvent( t, Player(i), &quot;-TRS debug &quot;, false )
            set i = i + 1
        endloop
        call TriggerAddAction(t, function TheRuneDebugChange)
        set tim = null
    endfunction
endscope
//==============================================================================
//  END OF TRS - THE RUNES SYSTEM
//==============================================================================</i></i></i></i></i>


Demo Map:
 

Attachments

  • TheRuneSystem[TRS].w3x
    27.2 KB · Views: 376

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
Good job, I've been waiting for someone to post something like this and this is what I wanted. :thup:
 

Romek

Super Moderator
Reaction score
963
I still think the Debug messages should be simple "BJDebugMsg" instead of your own private function.
If someone wants debug messages, they'll have debug mode on, else they'll have it off. No need for another constant.

Actually, that amount of messages isn't needed. It's obvious enough that the system is starting, or spawning stuff. It's what it's meant to do. And really, the same messages will show up for pretty much every user which didn't edit the code under the configurables.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Is it okay if I use this in my map furby777 [with credits of course]?
Didn't see in your first post if I was allowed to or not [add that in?].
That is, if my map goes anywhere :p .
 

Romek

Super Moderator
Reaction score
963
Is it okay if I use this in my map furby777 [with credits of course]?
Didn't see in your first post if I was allowed to or not [add that in?].
That is, if my map goes anywhere :p .
The whole point of these resources being here is so that you can use them.
Credit's aren't needed unless the Author states so, but they're always appreciated by system / spell makers.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Alright, just wanted to make sure.
I'll put you in the credits furby, unless you don't want to be.
Thanks for this system, +rep!
 

Furby

Current occupation: News poster
Reaction score
144
I am not asking for any credit. However I appreciate small credits in F9 part. ;)
 

Romek

Super Moderator
Reaction score
963
Approved.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top