[System] Shared Research

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

User avatar
Bl00D R3av3r
Senior Member
Posts: 165
Joined: January 25th, 2008, 5:20 pm
Title: Lazy

[System] Shared Research

Post by Bl00D R3av3r »

I want a system in jass which does the following:
If player1 researches blubb at lvl 3
then set blubb as researched at lvl3 for player2, player3 etc.

And it should be easy to use, so that i just have to set the variables.
Last edited by Bl00D R3av3r on February 2nd, 2009, 10:49 am, edited 2 times in total.
Image
Sig by TheWand
User avatar
Syre
Forum Staff
Posts: 506
Joined: November 17th, 2008, 3:49 pm

Re: [System] Shared Research

Post by Syre »

Alright..well i spent like 15 minutes on this, so i apologize if its not 100%, but it should do until its polished more..What your gonna have to do is create a couple varibles. First off you need to create one for the teams (if your using multiple teams, if not just use one). Name it Team1, and the type Player Group. Make another just named Team2 and so on for other teams.

Next you will need to create a integer array for each spell. So to do this, again create a new varible. Name this the name your spell has, and have it as an integer. Now click array and make it the size of playable people..So 4 players, would be size of 4, 10 with the size of ten..whatever number of players you'll have, minus computer. By doing this it will make it so multiple people will be using the one variable.
Spoiler:

Code: Select all

Untitled Trigger 008
    Events
        Unit - A unit Finishes an upgrade
    Conditions
    Actions
        -------- Reds Upgrades --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Researched tech-type) Equal to Research Test 
                (Owner of (Researching unit)) Equal to Player 1 (Red)
                Research[1] Equal to 0
            Then - Actions
                Set Team1 = (All allies of Player 1 (Red))
                Player Group - Pick every player in Team1 and do (Player - Set the current research level of Disease Cloud to 1 for (Picked player))
                Set Research[1] = 1
                Set Research[2] = 1
                Custom script:   call DestroyForce(udg_Team1)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Researched tech-type) Equal to Research Test 
                Research[1] Equal to 1
                (Owner of (Researching unit)) Equal to Player 1 (Red)
            Then - Actions
                Set Team1 = (All allies of Player 1 (Red))
                Player Group - Pick every player in Team1 and do (Player - Set the current research level of Spiked Barricades to 1 for (Picked player))
                Set Research[1] = 2
                Set Research[2] = 2
                Custom script:   call DestroyForce(udg_Team1)
            Else - Actions
        -------- Blues Upgrades --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Researched tech-type) Equal to Research Test 
                (Owner of (Researching unit)) Equal to Player 2 (Blue)
                Research[2] Equal to 0
            Then - Actions
                Set Team1 = (All allies of Player 2 (Blue))
                Player Group - Pick every player in Team1 and do (Player - Set the current research level of Disease Cloud to 1 for (Picked player))
                Set Research[1] = 1
                Set Research[2] = 1
                Custom script:   call DestroyForce(udg_Team1)
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Researched tech-type) Equal to Research Test 
                Research[2] Equal to 1
                (Owner of (Researching unit)) Equal to Player 2 (Blue)
            Then - Actions
                Set Team1 = (All allies of Player 2 (Blue))
                Player Group - Pick every player in Team1 and do (Player - Set the current research level of Spiked Barricades to 1 for (Picked player))
                Set Research[1] = 2
                Set Research[2] = 2
                Custom script:   call DestroyForce(udg_Team1)
            Else - Actions
Above is the trigger itself. Ill explain what you have to do, but it should be quite easy. Please note though, i have two different upgrades using the same variables and conditions..This was purely made for me to do a few tests..

Alright, ill start explaining now. Some should be self explanitory but ill just explain most of it.
Oh...as another note..This trigger will get quite big depending on the players and how many spells. Since ive made this quite quickly its..not really compacted.

(Researched tech-type) Equal to Research Test = Replace with your upgrade.

Research[1] Equal to 0 = First varible. Conditon type is Integer Comparison. Choose the interger that youve named as your spell. When normal it should say "Spell Name[index] equal to 0". Change the index to a number, for the player researching. So for red, use the index 1, for blue, 2..and so on.

Set Team1 = (All allies of Player 1 (Red)) = Quite simple, just use the action "Set Variable", then select your team variable that was explained earlier. This of course would be the team..you should get the idea what to do with this.

Player Group - Pick every player in Team1 and do (Player - Set the current research level of Disease Cloud to 1 for (Picked player)) = This again is the team that you want. This would be what upgrade you wish to use. And of course, this is the level you want it to be at.

Set Research[1] = 1 = Same as above. This time just selecting the upgrade and array and adding 1. This will make it so the spell has multiple levels and cant be used twice, if your using it for something like adding stats.

Set Research[2] = 1 = The reason for this, is so that its the same for everyone on the team. Of course, if Red and Purple were on different teams, than you shouldn't set the research that red upgrades, to work for purple too. So for each person on the team you will need to make another one. This will make it so the upgrades work right and Red could don't click me level one, while blue buys level 2. And every member of the team gets the effect.

Custom script: call DestroyForce(udg_Team1) = This really has no point besides reduceing memory leaks, helping the game run better. Just use the action Custom Script and type this in. DestroyForce works to remove the player group.This just refers to the player group. udg Just refers that its a variable, while Team1 is the variable itself.

The reason ive shown two is to show ya what to do for multiple levels, you can probably figure out what to do on your own there.

This is where it gets big though..Since im not really good at this stuff and it was quickly done the players arent really compacted...So..since i wanted to have it all done with one trigger, instead of making multiple triggers for each color, ive made it this way. What ive shown you only works for player 1 and 2. To make it for more players you will have to copy the actions and paste for the other players.

Now..you should be pretty much done..one final thing has to be done though. You need to add the ability that you want to the units that you want to be affected. For example, i used a Orc Burrow, to test the effects of the upgrade. Now since orc burrows start with the upgrade Spiked Barricades, that worked fine in a test, while disease cloud dident. You have to add the ability disease cloud to every unit you want the upgrade to work for. Now this can get quite spacious if your using an ability as a base, like disease cloud is as the Icon will show up with the unit. However for a basic upgrade like damage increase or defense, like barricades are, the icon doesn't show up. If your using the upgrade for abilitys, then to make it so the icon doesnt show, thats a whole different thing. For that you should look into Spell Books..as you can have multiple things there and make it so they dont show up...

I think ive made it as clear as i could but its probably still quite confusing. If you need more help just ask. (It seems i took more time writing this entire thing than on the trigger itself...lol)

Edit: Ive forgot to add something. Making more abilities...You'll just have to retrace the steps. You can add more abilitys right to the this trigger. To organize ive just comments seperateing red from blue..just post whatever upgrades ya want for each section..Each upgrade will require another new interger varible as stated above. Overall its a bit confuseing to explain but when you understand it, it should be quite easy to make a number of upgrade of your choice.
Image
User avatar
Bl00D R3av3r
Senior Member
Posts: 165
Joined: January 25th, 2008, 5:20 pm
Title: Lazy

Re: [System] Shared Research

Post by Bl00D R3av3r »

I really hoped somebody would find an easier way to do this(the way you do it was the way i was trying it),
because this way is really big and i think im going to request this in jass(or a mod can move this...)
whatever
Image
Sig by TheWand
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: [System] Shared Research

Post by Aero »

Instructions: Make a trigger called "Team Research" and put the following code into it.
Spoiler:

Code: Select all

constant function NumberOfPlayers takes nothing returns integer
return 12 //The number of players in the map
endfunction

function Trig_Team_Research_Actions takes nothing returns nothing
local integer researchId = GetResearched()
local player researcher = GetOwningPlayer(GetTriggerUnit())
local integer researchLevel = GetPlayerTechCount(researcher,researchId,true)
local integer i = 0
loop
    exitwhen i>=NumberOfPlayers()
    if GetPlayerTechCount(Player(i),researchId,true)<researchLevel then
        call SetPlayerTechResearched(Player(i),researchId,researchLevel)
    endif
    set i=i+1
endloop
set researcher = null
endfunction

//===========================================================================
function InitTrig_Team_Research takes nothing returns nothing
    set gg_trg_Team_Research = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Team_Research,EVENT_PLAYER_UNIT_RESEARCH_FINISH)
    call TriggerAddAction(gg_trg_Team_Research,function Trig_Team_Research_Actions)
endfunction
Under: constant function NumberOfPlayers takes nothing returns integer

It currently says "return 12". Change 12 to the number of players in the map, or the number of players you want to have the shared research for.

For example: There are 8 players in the game but I only want shared tech for players 1-6. Change return 12 to return 6.

If this system is not what you want then be more specific.
User avatar
Bl00D R3av3r
Senior Member
Posts: 165
Joined: January 25th, 2008, 5:20 pm
Title: Lazy

Re: [System] Shared Research

Post by Bl00D R3av3r »

thank you very much just a last question what do i have to change if i want it only researched for players 2-10 or something like that
Image
Sig by TheWand
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: [System] Shared Research

Post by Aero »

In order to do that, you need to use the following code (Same trigger name)
Spoiler:

Code: Select all

constant function Range_Start takes nothing returns integer
return 2
endfunction

constant function Range_End takes nothing returns integer
return 10
endfunction

function Trig_Team_Research_Actions takes nothing returns nothing
local integer researchId = GetResearched()
local player researcher = GetOwningPlayer(GetTriggerUnit())
local integer researchLevel = GetPlayerTechCount(researcher,researchId,true)
local integer i = Range_Start()-1
local integer pid = GetPlayerId(researcher)
if pid>=i and pid<Range_End() then 
    loop
        exitwhen i>=Range_End()
        if GetPlayerTechCount(Player(i),researchId,true)<researchLevel then
            call SetPlayerTechResearched(Player(i),researchId,researchLevel)
        endif
        set i=i+1
    endloop
endif
set researcher = null
endfunction

//===========================================================================
function InitTrig_Team_Research takes nothing returns nothing
    set gg_trg_Team_Research = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Team_Research,EVENT_PLAYER_UNIT_RESEARCH_FINISH)
    call TriggerAddAction(gg_trg_Team_Research,function Trig_Team_Research_Actions)
endfunction
Just change:

constant function Range_Start takes nothing returns integer
return 2
endfunction

constant function Range_End takes nothing returns integer
return 10
endfunction

return 2 and return 10. For example --> Players 6-12 would be return 6 for Range_Start and return 12 for Range_End.