Jump to content
Sign in to follow this  
deanolium

Mod Script Findings

Recommended Posts

I've moved from trying to refactor the game to thoroughly gutting it. The scripts are full of circular dependencies and some very disadvantageous design "patterns". The worst part is where the g_Campaign and g_CampaignClassic and g_GM variables are involved. Seriously, WTF?!??!? [..]

I'm very much looking forward to your ventures into the engine's inerts ...

Happy hunting.

Edited by Guess Who

Share this post


Link to post
Share on other sites

It's crazy. And seeing how the game tanks on metacritic (zero positive critic reviews, as of today), I expect two official patches, tops. And most likely not the clean rewrite the game's scripted part needs.

That's why I do it.

I hope they open up their multi player functionality in case they crippled it, because if the engine can be convinced to leave it to the script side, it should be possible (not easy!) to build multi player as a community project.

Edited by Thygrrr

Share this post


Link to post
Share on other sites

I'm researching cloaking devices and stuff for making movies and wondered if anyone has come across controls for the HUD and 3rd person camera position, plus the ability to snapshot a texture from a vehicles surrounding and paste it on that vehicle, the cloak is a bit out of my league but I'll give it a go.

Share this post


Link to post
Share on other sites
I'm researching cloaking devices and stuff for making movies and wondered if anyone has come across controls for the HUD and 3rd person camera position, plus the ability to snapshot a texture from a vehicles surrounding and paste it on that vehicle, the cloak is a bit out of my league but I'll give it a go.

You dont have to snapshot a texture, just make the current one simi transparent.

Share this post


Link to post
Share on other sites

proto native void SetWidgetEventHandler(widget parent, ScriptedWidgetEventHandler eventHandler);

OMG. And there I was wondering if I had to write my own dispatcher for widget events (because ccgame.c registers a somewhat crappy-written global one). This is so powerful. :-)

I wonder if the Enforce scripting language can do multiple inheritance.

---------- Post added at 17:51 ---------- Previous post was at 16:10 ----------

Slowly getting there with the gutting.

Anyone in need of a half-decent logger can use this thing I just hacked together...

//File logger.h
//Written by Thygrrr, this file is in the public domain

class Logger
{
int logfile;
int padding;

//Main utility function, takes a class or NULL from which it automatically derives the ClassName.
void log(class source, string message)
{
	string src;

	if (source)
	{
		src = ClassName(source);
	}
	else
	{
		src = "()";
	}

	string line = "";
	int len = strlen(src);

	//Automatically extend the padding to our new maximum source length.
	if (len > padding)
	{
		padding = len;
	}

	for (int i = padding - len; i > 0;  i--)
	{
		line += " ";
	}

	line += src;
	line += ": " 
	line += message;

	FPrintln(logfile, line);
}

//Constructor, takes a sigle filename. The file will be written into the current profile directory.
void Logger(string filename)
{
	logfile = OpenFile("$profile:" + filename, FILEMODE_WRITE);
	log(this, "Logger('" + filename + "')");
}

//Destructor
void ~Logger()
{
	log(this, "~Logger()");
	CloseFile(logfile);
}	
}

and put this into script.c near the start, but after proto.h is included.

#include "scripts/logger.h"
Logger logger;

and this at the end

int main(string cliparams)
{
logger = new Logger("global.log");
return 0;
}

Please note that this doesn't properly destroy the logger object at the end (meaning you will lack one line of log, the last line from Logger itself).

Edited by Thygrrr

Share this post


Link to post
Share on other sites

But right off the bat I see a huge bug, what if the current hp is exactly .7?

Then it's caught by the else block, and thus sets the health to zero, destroying it. So not a bug, just misreading the code.

Share this post


Link to post
Share on other sites

Cutscenes & Script Code in XMLs

Cutscenes use lots of embedded script code that runs in the scope of script.c and the other .c files.

This means you CAN programmatically execute code. That means you CAN write a Mod Loader, as long as the mods are non-destructive.

I'll cook up a proof of concept.

---------- Post added at 22:13 ---------- Previous post was at 22:12 ----------

Request: Can someone list all the files and subdirectories in their Documents/Carrier Command on Windows 7 folder?

---------- Post added at 22:38 ---------- Previous post was at 22:13 ----------

Keword proto

Not exactly what the "proto" keyword is for. I thought it was for pure virtual / abstract methods. This is not true.

Fully abstract methods are implemented simply by omitting the method body. The correct derived instance methods are then called.

Share this post


Link to post
Share on other sites
Cutscenes & Script Code in XMLs

---------- Post added at 22:13 ---------- Previous post was at 22:12 ----------

[/color]Request: Can someone list all the files and subdirectories in their Documents/Carrier Command on Windows 7 folder?

---------- Post added at 22:38 ---------- Previous post was at 22:13 ----------

.

Packed or unpacked?

Share this post


Link to post
Share on other sites

That directory should not contain any packed files. I mean the profile directory, not the game directory.

It should roughly look like this, but I need to know the exact structure:

zj831e.png

Share this post


Link to post
Share on other sites

Basicly just like that, I have:

campaigns.log

ccsettings.xml

crash.log

enforce.mdmp

error.log

filesystem.log

Then I have a profile folder just like you with achievements.achv and all the .save files

Share this post


Link to post
Share on other sites

Okay, and that's all in the "Carrier Command on Windows 7" folder, or is it in some kind of sub folder? (like my steam numbers in the picture I posted).

Thanks!

---------- Post added at 20:45 ---------- Previous post was at 19:26 ----------

keyword private

There is a "private" keyword. Used on some destructors (to disallow explicit deletion, as it seems). Slightly weird way to do this.

... and another insight:

//! Player
class Player extends ScriptableCore
{
//! inspect relationship
proto native bool IsEnemyOf( Player other );

//! retrieve in-game name
proto native owned string GetName();
};

(the AI representation of Players and other game objects appears to be completely disjunct from the game and visual representations - not entirely sure if that makes sense but it makes our work even harder, because there is an additional layer of abstraction and a black box round trip to native code in the way now)

---------- Post added at 22:35 ---------- Previous post was at 20:45 ----------

Named Types

Type("Carrier") returns the class as a type object.

Used for type comparisons, and can possibly even be used for runtime instantiations (with the Spawn(...) function call).

Still looking for a decent way to execute script code at script runtime (i.e. including additional code and maybe even running a "main" method in there)

---------- Post added at 22:38 ---------- Previous post was at 22:35 ----------

No truly abstract classes

Classes that have abstract functions (no function body) can actually be instantiated. I assume the function calls are no-ops in that case.

Edited by Thygrrr

Share this post


Link to post
Share on other sites

Its just the file names that I posted located in C:\Users\Tontow\Documents\CarrierCommand

And then the saves and achev are in C:\Users\Tontow\Documents\CarrierCommand\Tontow

Share this post


Link to post
Share on other sites

Sorry, where can you get the CC unpacker tool? I know silly question and all that.

Share this post


Link to post
Share on other sites

So if I made code changes, will I have to put the c++ file into a smiliar directory structure under ccpath\scripts\ and the game will use this file then? Thx.

Share this post


Link to post
Share on other sites
So if I made code changes, will I have to put the c++ file into a smiliar directory structure under ccpath\scripts\ and the game will use this file then? Thx.

For the steam vershion, yes. For the non-steam, you will need to pack the files into .pac1 file (aka a patch file) and name it patch01.pak. (aka a fake patch)

If you already have a patch01.pak , then you can name it patch02.pak .

Share this post


Link to post
Share on other sites
Hi..

I really do love this game, it is very fun to play, and would hate if it would go to waste so I ended up here and found the fantastic Carrier Tool!

[ Awesome mod thing cut for quickness ]

Great one, how do I get this into my game?!

Nvm. Think I'm getting the hang of it..

Lol COMBAT_CHICKEN Best function ever.

---------- Post added at 18:20 ---------- Previous post was at 17:28 ----------

File islandtacticsguard.h

bool AddEnemy( Object o )

{

if(EnemiesCnt >= 32)

return false;

Change that to 48 or higher, might increase island defenses (might slow down PC be careful)

Edited by disorder

Share this post


Link to post
Share on other sites

Just wondering, what is the exact language that this is in?

I like to use notepad ++ as my editor, and it can't too much until I know what I'm working with.

Or is the language something that BI came up with inhouse just for CC?

I'm asking because I want to make some basic changes to make the game harder:

- make the enemy strength slider bar max value to where it is impossable to kill the enemy carrier in a direct incounter.

- change how the enemy select what type of island it wants. I had a game where he had nothing but factorys; no wonder he ran out of fuel.

Also, is there some way to have the game generate more islands even if they are duplacate islands on the map? After one or 2 games, I'm starting to feel a little clostrophoibic compaired to the orignal CC.

Share this post


Link to post
Share on other sites

It's a proprietary, interpreted scripting language, with some features resembling C++. I think it's part of the Enforce engine, you don't need a compiler, the game interprets/compiles the script at runtime.

No idea why you need a correct definition - Notepad++ will do fine with it, I use it every day. It recognizes the files as either c++ or c, which is not too far off. You may want to add a few keywords/typewords to your style configurator if your as o.c. as I am when it comes to good syntax highlighting:

proto native event string class

Share this post


Link to post
Share on other sites

Is it possible for someone to make a mod that makes all enemy islands "Deadly" rated? I've played two strategy games now with the enemy strength at max, but there's always a mixture of island strengths.

Share this post


Link to post
Share on other sites
I found this code:

if ( AvoidEnemyCarrier )
WriteNeed( Logger, mem, this, GOTO_ISLAND, enCurr.GetArea(), 0, 9 );
else
{

if ( myCurr == enCurr && d < 320.0 ) // 1000m
{
WriteNeed( Logger, mem, this, ASSAULT_CARRIER, enemy.GetID(), 0, 9 );
else
WriteNeed( Logger, mem, this, GOTO_ISLAND, enCurr.GetArea(), 0, 9 );
}

I only have a basic understanding of coding but wouldn't it be more appropriate to change the && into a || rather than removing "myCurr == enCurr" completely?

That way the enemy carrier should attack you if you come within range OR you both end up on the same island (regardless of distance).

I've already been tinkering with the classic_campaign and islandsgenerator files to make the skirmish mode a lot more similar to the original.

Things like 1 starting island each, spreading out the islands to increase travelling time/fuel usage, taking away advanced starting equipment (+ no main gun on the carrier) and forcing the player to import the stockpile from 'off the board' at the beginning of the game goes a looooong way to increasing the time it takes to win. It makes the first half of the game a massive island grab to establish resources and build your forces. It also means that making a b-line for the enemy carrier is guaranteed suicide because you just don't have the weapons to defeat it until well into the game. It also means the enemy carrier will not head directly for you because it has to capture an island chain first.

Looking into making enemy island units more likely to attack the carrier too.

Really looking forward to Thygrrr's barebones mod. Having it stripped back and arranged better will make it a lot easier for noobs like me to build the perfect strategy campaign :D

Share this post


Link to post
Share on other sites

Guys, what does the new Beta mean for the existing mods?

Share this post


Link to post
Share on other sites

First of all I'd like to say that I sincerely appreciate all of your findings. It's amazing how ingenious the BI community is! Keeping with tradition, all BI games support modability, as is the case with planned support for CCGM. To make your lives easier, we are planning to release our developer tools in a few weeks. Some preliminary manuals will be released on the BIWiki soon. We are observing your needs and will try to address these in the next patch, so feel free to state what you feel is missing. Don't stop asking questions, we take them into account when writing tutorials.

best regards,

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×