The official --=jscam=-- thread

For AI and campaign script related discussions and questions
Alpha993
Rookie
Rookie
Posts: 16
Joined: 16 Dec 2016, 15:56
Location: Italy, Cervignano del Friuli, UD

Re: The official --=jscam=-- thread

Post by Alpha993 » 25 Dec 2016, 01:54

CAM_VICTORY_OFFWORLD doesn't have access to callback. This is an offworld mission where you only need a single unit to reach the crashed transport area. CAM_VICTORY_STANDARD requires you to kill all the units, which isn't needed in this level.

User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 626
Joined: 26 Sep 2016, 19:56

Re: The official --=jscam=-- thread

Post by Berserk Cyborg » 25 Dec 2016, 02:14

Did not notice that... But off world missions should have access to extra win conditions in the future. You could try using camNextLevel directly which might work.

Alpha993
Rookie
Rookie
Posts: 16
Joined: 16 Dec 2016, 15:56
Location: Italy, Cervignano del Friuli, UD

Re: The official --=jscam=-- thread

Post by Alpha993 » 27 Dec 2016, 22:47

Currently in need of a way to access colours as the downed team is supposed to have the same colour as the player.
Edit:
Current commits of JS, constructive criticism is welcome. Changed victory conditions so that units are transferred only if the transport is alive (victory flag = 1).
Will a break in

Code: Select all

//victory condition: transport must be alive
            if (downedTransportUnits[i].health !== NULLOBJECT)
            {
                playSound(successSound);
                customVictoryFlag = 1;
            }
stop the for loop?
Last edited by Alpha993 on 30 Dec 2016, 00:16, edited 1 time in total.

User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 626
Joined: 26 Sep 2016, 19:56

Re: The official --=jscam=-- thread

Post by Berserk Cyborg » 29 Dec 2016, 22:59

There are also .wrf files that you need to edit for each level(cam2 here). Typically you just need to delete the the .vlo/.slo lines associated with that specific level and add this to the end of it:

directory "script/campaign"
file JAVASCRIPT "X.js"
(where X is the name of the javascript file for that level. Look at what I did for cam1end.wrf here).

Other than that 2-1 looks good.
Edit: A break there would work. Also you could move some of your global variables into the functions themselves.

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3753
Joined: 03 Aug 2006, 19:39

Re: The official --=jscam=-- thread

Post by Per » 30 Dec 2016, 00:26

Alpha993 wrote:Currently in need of a way to access colours as the downed team is supposed to have the same colour as the player.
I think this information should be available in the playerData array, in the colour member field. Or do you need a way to set it?

Alpha993
Rookie
Rookie
Posts: 16
Joined: 16 Dec 2016, 15:56
Location: Italy, Cervignano del Friuli, UD

Re: The official --=jscam=-- thread

Post by Alpha993 » 30 Dec 2016, 00:34

This is the particular snippet of WZScript I have yet to convert

Code: Select all

	createAlliance(newPlayer, curPlayer);
//make player 0 (newPlayer) units belong to player 1 (curPlayer)

    //save the old colour so we can set it back again
    oldColour = getPlayerColour(curPlayer);

	newColour = getPlayerColour(newPlayer);
	setPlayerColour(newColour, curPlayer);	//make curPlayer units newPlayer colour
A similar thing, if I remember correctly, should happen in ... Gamma 3? When Nexus takes over Gamma Team's base in the north.


Also, apparently I inverted this part

Code: Select all

curPlayer	int	1
newPlayer	int	0
when setting the alliance, human player being 0 and AI being 1 instead of 1/0, but I don't see how much of a difference this would make, except having to flip the variables in WZScript. Shouldn't pose any problem in JS, as long as everything is scripted correctly.

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3753
Joined: 03 Aug 2006, 19:39

Re: The official --=jscam=-- thread

Post by Per » 30 Dec 2016, 00:43

Ok, I added a changePlayerColour(player, colour) function now (2e3d23d0a5896d42f3160f675665e4e1df982024).

Alpha993
Rookie
Rookie
Posts: 16
Joined: 16 Dec 2016, 15:56
Location: Italy, Cervignano del Friuli, UD

Re: The official --=jscam=-- thread

Post by Alpha993 » 30 Dec 2016, 01:07

Am I correct in assuming that changePlayerColour accepts the colour ID as input?

Code: Select all

changePlayerColour(downedTransportTeam, 0);
Something like this.

Many thanks for the function, by the way, very appreciated. :3

User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 626
Joined: 26 Sep 2016, 19:56

Re: The official --=jscam=-- thread

Post by Berserk Cyborg » 30 Dec 2016, 02:36

@Per Could you add something like this to the scripts (taken from cam2ax.slo):

Code: Select all

forceDamageObject(X, Y);
where X is either a droid or structure and Y is the remaining health percentage of that object.

Alpha993
Rookie
Rookie
Posts: 16
Joined: 16 Dec 2016, 15:56
Location: Italy, Cervignano del Friuli, UD

Re: The official --=jscam=-- thread

Post by Alpha993 » 30 Dec 2016, 18:01

I'm starting the conversion work on cam2b/bx, just so we don't overlap our efforts.

Edit: Alright, I'm a bit lost as to how to make artifacts drop from specific buildings (i.e. the heavy factory in the base directly north on CAM_2B).

Nevermind, just had to delve a bit deeper into the use of JSON. Group management is definitely going to be an interesting challenge.

Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3753
Joined: 03 Aug 2006, 19:39

Re: The official --=jscam=-- thread

Post by Per » 30 Dec 2016, 23:53

Added setHealth(object, health %) in 62a7c961683266d7ce53fdd23b3fe913d9b9b01a. Not tested, though :-)

The colour is an ID, similar in range to player IDs.

User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 626
Joined: 26 Sep 2016, 19:56

Re: The official --=jscam=-- thread

Post by Berserk Cyborg » 31 Dec 2016, 01:40

Per wrote:Added setHealth(object, health %) in 62a7c961683266d7ce53fdd23b3fe913d9b9b01a. Not tested, though :-)
Tested it and it works (for droids/structures anyway). Thanks!

Seeing as I am almost done with 2-a I will take cam 2-2 and related sub-missions.

Alpha993
Rookie
Rookie
Posts: 16
Joined: 16 Dec 2016, 15:56
Location: Italy, Cervignano del Friuli, UD

Re: The official --=jscam=-- thread

Post by Alpha993 » 31 Dec 2016, 01:46

Haven't tested my scripts for SUB_2_1, but if someone would do it, I would very much appreciate it. :3

... though I know I should test my own stuff. :oops:

User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 626
Joined: 26 Sep 2016, 19:56

Re: The official --=jscam=-- thread

Post by Berserk Cyborg » 31 Dec 2016, 06:12

Alpha993 wrote:Haven't tested my scripts for SUB_2_1
Just did. Had to fix a few things though. Those 'S' levels do not need label files since the only coordinates that change are the transporter exit point and the next level. Also simplified your 2-1x script.

Also you need to make the four rocket cyborgs near the upper left corner of the map a group and give them an order of CAM_ORDER_ATTACK and add the objective blip for this mission (there are three more unused base blips should you wish to setup bases. the LZ one is not needed). And the unit transfer stuff is currently broken upon going to 2-b.

blip data (look at prox2-1)
updated sub 2-1 files:
base.zip
(3.79 KiB) Downloaded 55 times

Alpha993
Rookie
Rookie
Posts: 16
Joined: 16 Dec 2016, 15:56
Location: Italy, Cervignano del Friuli, UD

Re: The official --=jscam=-- thread

Post by Alpha993 » 31 Dec 2016, 13:47

Is there a function to set up radar blips? I've looked at the libcampaign documentation, but I don't see a function that can set them up, though I can only see enumBlips or hackAddMessage with PROX_MSG type being involved.
As for groups, I could use some guidance, since I have to manage groups in 2b too.

Also, I'm interested into the logic train of thought behind the changes, aside the use of the newly made setHealth and the use of world units in sub_2_1s.

Post Reply