• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Problem with custom ressources

Status
Not open for further replies.
Level 2
Joined
Mar 20, 2013
Messages
5
Hey guys! Some months ago me and a friend started on a new map with me mainly as the terrainer and him as the coder - sadly we had to stop the development due to not having enough time and even lost contact shortly afterwards which resulted in the map just wasting space on my harddrive.
Some weeks ago I started to continue working on the map again but I need help with one of his JASS triggers since I mainly work with GUI (Already started to learn JASS though), thanks in advance if anyone can help me :grin:

The map is a survival game based on the game Metro: Last Light where players have to utilize 4 custom ressources: Bullets, Metal, Oil and Stone. Im having problems with a trigger which adds ressources to the amount the player already has. Other triggers regarding the CRS are already fully functional, e.g. ressource deductions, refunds, multiboard showing the ressources you have, costs of the structures, etc. but this one is missing and Im not able to create such a trigger myself in JASS yet. Here are the Main Initiation trigger & the main library functions:
JASS:
scope Initiation initializer MainInit

globals
    integer array Resource_Bullets
    integer array Resource_Metal
    integer array Resource_Oil
    integer array Resource_Stone
    integer array Costs_Bullets
    integer array Costs_Metal
    integer array Costs_Oil
    integer array Costs_Stone
endglobals

private function Setup takes nothing returns nothing

/**************** CONFIGURABLES ******************/

/**************************************************
***** Grant 8 Starting Resources Of Each Type *****
*********/ local integer StartAmount = 8 /*********
**************************************************/

/*************************************************/
    set CC_i = 1
    loop
        exitwhen CC_i > 12
        set Resource_Bullets[CC_i] = StartAmount
        set Resource_Metal[CC_i] = StartAmount
        set Resource_Oil[CC_i] = StartAmount
        set Resource_Stone[CC_i] = StartAmount
        set CC_i = CC_i + 1
    endloop
    
/*************************************************/
endfunction

private function MainInit takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function Setup)
    call TriggerRegisterTimerEvent(t, 0, false)
    set t = null
endfunction

endscope
JASS:
library CRS 
/* 
    Functions to Set, Deduct, and Refund custom resources 
                                                            */
// Use this function to set the costs of structures
function SetCost takes integer i, integer x1, integer x2, integer x3, integer x4 returns nothing
    set Costs_Bullets[i] = x1
    set Costs_Metal[i] = x2
    set Costs_Oil[i] = x3
    set Costs_Stone[i] = x4
endfunction

// Use this function to deduct from your resources
function DeductCosts takes integer p, integer i returns nothing
    set Resource_Bullets = Resource_Bullets - Costs_Bullets[i]
    set Resource_Metal = Resource_Metal - Costs_Metal[i]
    set Resource_Oil = Resource_Oil - Costs_Oil[i]
    set Resource_Stone = Resource_Stone - Costs_Stone[i]
endfunction

// Use this function to refund your resources
function RefundCosts takes integer p, integer i returns nothing
    set Resource_Bullets = Resource_Bullets + Costs_Bullets[i]
    set Resource_Metal = Resource_Metal + Costs_Metal[i]
    set Resource_Oil = Resource_Oil + Costs_Oil[i]
    set Resource_Stone = Resource_Stone + Costs_Stone[i] 
endfunction

endlibrary

My JASS skills are pretty horrible so I wasnt able to come up with a working trigger yet so you guys are pretty much my last hope since I'd like to not waste the time my friend put into these JASS triggers and rewriting them in GUI would be too time consuming :thumbs_up:

What the 2 triggers I need should do:
- Increase the amount of the integer Resouce_Bullets by 1 for every kill a player does [Every player has ofc his own amount of ressources]
- Increase the amount of the interger(s) Resource_Metal / Oil / Stone by 1 after a special building is constructed every X seconds of game time. [1 specific building type for every custom ressource]
Feel free to let me know if you need more infos / code of the other triggers regarding the CRS and I will provide additional ressources.

- Zer0o
 
Last edited:
Level 2
Joined
Mar 20, 2013
Messages
5
JASS:
call TriggerRegisterTimerEventSingle(t, 0)
->
JASS:
call TriggerRegisterTimerEvent(t, 0, false)
Fix'd :p

Btw i don't really understand what do you clearly want ;)
Anyway new to THW so go introduce yourself :D

Well I'll explain it this way: Im gonna use a Custom Ressource System for the map Im currently working on instead of gold & lumber. I already have the triggers which set up the costs, the multiboard which shows the ressources, refunds the ressources when you cancel an upgrade / building, etc because a friend of mine who worked on the map with me already did that stuff. I still need triggers which gives the players ressources though. Cant play a map if you dont get ressources eh? :grin:

I suck at JASS and mainly use GUI atm so Im not able to do it myself just yet so I need your help <.<

What the 2 triggers I need should do:
- Increase the amount of Resouce_Bullets by 1 for every kill a player does [Every player has ofc his own amount of ressources]
- Increase the amount of Resource_Metal / Oil / Stone by 1 after a special building is constructed every X seconds of game time. [1 specific building type for every custom ressource]

These buildings will also be upgradeable :p Hope this is a better explanation!
Edit: Introduction - Done :D
 
Last edited:
Status
Not open for further replies.
Top