What do you guys think of SCII's scripting language .galaxy?
playergroup gv_allPlayers = PlayerGroupAll();
void gf_exampleFunc () {
text lv_txtPlayer = StringToText("Player ")
text lv_txt = StringToText(" is a nigger.");
int lv_i;
Adding it to the shitty toy languages thread as we speak.
Name:
Anonymous2012-03-02 12:27
Should I stop using prefixes so much btw?
lv_ is local variable
gf_ is global function
gv_ is global variable
c_ is constant
lp_ is local parameter
gt_ is game trigger
etc.
I think I should only use c_ and gv_ probably, and I usually neglect using gf_ or gt_ when naming my functions. Prefixes are not necessary at all I just use them because from what I've seen from the GUI generated code it uses them.
playergroup gv_allPlayers = PlayerGroupAll();
void exampleFunc () {
text txtPlayer = StringToText("Player ")
text txt = StringToText(" is a nigger.");
int i;
playergroup gv_allPlayers = PlayerGroupAll();
void exampleFunc () {
text txt = StringToText("Player ")
text txt2 = StringToText(" is a nigger.");
int i;
>>8
It's alright, but you should give your variables more meaningful names.
gv_playergroup might be better as playersInGame or just allPlayers. text txt would be better as text playerName. text txt2 it's hard to tell what this does from the name. text msg would be better.
Name:
Anonymous2012-03-02 12:50
playergroup is the name for a kind of variable in .galaxy
void ExampleFunc () {
text playerName = StringToText("Player ");
text msg = StringToText(" is a nigger.");
int i;
void ExampleFunc2 () {
text msg = StringToText(" is a nigger.");
int i;
while(i < c_maxPlayers) {
UIDisplayMessage(gv_allPlayers, c_messageAreaDebug, PlayerName(i) + msg); //PlayerName shows the players name instead of like I had it before where it says "Player " then the number of the player.
i += 1;
}
}
I changed the <= to < because c_maxPlayers = 16 but player 16 is an invalid player you only ever get when you kill something with the script instead of a unit being killed by a players effect, unit, or whatever ingame.
Name:
Anonymous2012-03-02 12:52
Perfected?
playergroup allPlayers = PlayerGroupAll();
void ExampleFunc () {
text msg = StringToText(" is a nigger.");
int i;
while(i < c_maxPlayers) {
UIDisplayMessage(allPlayers, c_messageAreaDebug, PlayerName(i) + msg); //PlayerName shows the players name instead of like I had it before where it says "Player " then the number of the player.
i += 1;
}
}
So how come .galaxy is a shit language? If I learn a proper language what should I be using? C++?
Name:
Anonymous2012-03-02 12:56
Normally I have all the player names saved at map init to an array btw, one array with colour and the other without.
Name:
Anonymous2012-03-02 12:57
>>11
Learn how to match up braces buddy.
Like this
playergroup allPlayers = PlayerGroupAll();
void ExampleFunc ()
{
text msg = StringToText(" is a nigger.");
int i;
while(i < c_maxPlayers)
{
UIDisplayMessage(allPlayers, c_messageAreaDebug, PlayerName(i) + msg); //PlayerName shows the players name instead of like I had it before where it says "Player " then the number of the player.
i += 1;
}
}
Name:
Anonymous2012-03-02 13:03
>>13
That makes my code very long though and there's this retarded limit we have on how many lines of code we can have at max because Activision-blizzard herps hard. How did you use syntax hilighting?
>>15
This is a comment taken from the .natives list
// A02 Well, it might. But it's also a simply explained rule. No one will remember the
// alternative, which is something like actors/scopes created by ActorCreate, and create
// messages sent by the user. It also leads to simpler, less bug-prone C++ code on my end. :)
The most important point from the wikipedia article:
Most of the time, knowing the use of a variable implies knowing its type. Furthermore, if the usage of a variable is not known, it cannot be deduced from its type.
The job of the variable name is to describe the role of the variable. If your name is descriptive enough, you shouldn't need to explicitly indicate the datatype. In my opinion, if a variable name feels like it could use a type identifier, it means the semantics chosen are not accurately describing the variable's role.
Note that this is not usually the case with object instances, because the name they'd be borrowing from (the class being instantiated) would have also been named using these same criteria -- hence the "type" will have additional semantic meaning.
Name:
Anonymous2012-03-02 14:39
//==================================================================================================
//
// Generated Map Script
//
// Name: Blue Physics
// Author: BlueBerryWizard
//
//==================================================================================================
include "TriggerLibs/NativeLib"
//--------------------------------------------------------------------------------------------------
// Custom Script: Map Variables
//--------------------------------------------------------------------------------------------------
// Player groups
playergroup gv_allPlayers = PlayerGroupAll();
playergroup gv_activePlayers = PlayerGroupActive();
// Player names & attributes
color[16] gv_playerColor;
text[16] gv_playerName;
text[16] gv_playerNameColored;
// Unit Attributes
bool[c_IndexArraySize] gv_unitIndex;
int[c_IndexArraySize] gv_uWeapon;
// Test
unit gv_volcanoMarine;
//--------------------------------------------------------------------------------------------------
// Custom Script: Terrain Gen Variables
//--------------------------------------------------------------------------------------------------
int gv_terrainDialog;
int gv_terrainLabel;
//--------------------------------------------------------------------------------------------------
// Custom Script: Index Unit
//--------------------------------------------------------------------------------------------------
int IndexUnit (unit lp_unit) {
int lv_i = 1;
while(gv_unitIndex[lv_i]) {
if (lv_i > 8190) {
DebugMsg("<c val=\"FF0000\">WARNING:</c> Stack overload.");
break;
}
lv_i += 1;
}
gv_unitIndex[lv_i] = true;
UnitSetCustomValue(lp_unit, c_uIndex, lv_i);
//DebugMsg("<c val=\"FF0000\">CV:</c> " + IntToString(lv_i));
return lv_i;
}
//--------------------------------------------------------------------------------------------------
// Custom Script: Custom Value
//--------------------------------------------------------------------------------------------------
int gf_CV (unit lp_unit) {
return FixedToInt(UnitGetCustomValue(lp_unit, c_uIndex));
}
//--------------------------------------------------------------------------------------------------
// Custom Script: Ally Player
//--------------------------------------------------------------------------------------------------
// Function to set a player to be allied to another player.
void AllyPlayer (int lp_player1, int lp_player2, bool lp_ally) {
PlayerSetAlliance(lp_player1, c_allianceIdPassive, lp_player2, lp_ally);
PlayerSetAlliance(lp_player1, c_allianceIdVision, lp_player2, lp_ally);
//PlayerSetAlliance(lp_player1, c_allianceIdChat, lp_player2, lp_ally);
PlayerSetAlliance(lp_player1, c_allianceIdTrade, lp_player2, lp_ally);
PlayerSetAlliance(lp_player1, c_allianceIdPushable, lp_player2, lp_ally);
PlayerSetAlliance(lp_player1, c_allianceIdSeekHelp, lp_player2, lp_ally);
PlayerSetAlliance(lp_player1, c_allianceIdGiveHelp, lp_player2, lp_ally);
}
//--------------------------------------------------------------------------------------------------
// Custom Script: Apply Physics
//--------------------------------------------------------------------------------------------------
void ApplyPhysics (unit lp_unit, int lp_index, point lp_pos, point lp_posOffset, int lp_phyBehvSet) {
// Position coordinates
gv_posX[lp_index] = PointGetX(lp_pos);
gv_posY[lp_index] = PointGetY(lp_pos);
gv_posZ[lp_index] = PointGetHeight(lp_pos);
// Velocity values
gv_velX[lp_index] = PointGetX(lp_posOffset) - gv_posX[lp_index];
gv_velY[lp_index] = PointGetY(lp_posOffset) - gv_posY[lp_index];
gv_velZ[lp_index] = PointGetHeight(lp_posOffset) - gv_posZ[lp_index];
// Acceleration values (set to default)
gv_accelX[lp_index] = 0.0;
gv_accelY[lp_index] = 0.0;
gv_accelZ[lp_index] = 0.0;
// Behaviours that apply under certain physics events
gv_phyBehvSet[lp_index] = lp_phyBehvSet;
// Physics unit group
UnitGroupAdd(gv_physicsUG, lp_unit);
// Projectile Collide Behaviour (already on projectiles by default)
// UnitBehaviorAdd(lp_unit, c_collideBehaviour, lp_unit, 1);
}
void ApplyVelocity (int lp_index, fixed lp_accelerationX, fixed lp_accelerationY, fixed lp_accelerationZ) {
// Acceleration values
gv_accelX[lp_index] = lp_accelerationX;
gv_accelY[lp_index] = lp_accelerationY;
gv_accelZ[lp_index] = lp_accelerationZ;
}
//--------------------------------------------------------------------------------------------------
// Custom Script: Projectile Create
//--------------------------------------------------------------------------------------------------
int gf_ProjectileCreate (unit lp_projectile, string lp_model, fixed lp_speed, fixed lp_damage, fixed lp_size, string lp_tint) {
// Projectile Custom Value
int lv_cv = IndexUnit(lp_projectile);
lv_pt = PointWithOffsetPolar(lp_pointA, lv_distance, lv_angle + RandomFixed(-gv_weaponSpray[lp_weaponType], gv_weaponSpray[lp_weaponType]));
// Added Z adjustments based on height of point A and point B, the height of the unit, and z spray
PointSetHeight(lv_pt, lv_zwB + 0.5 + RandomFixed(-gv_weaponSprayZ[lp_weaponType], gv_weaponSprayZ[lp_weaponType]));
ApplyPhysics(lv_u, lv_cv, lp_pointA, lv_pt, gv_weaponPhyBehvSet[lp_weaponType]);
//gv_accelZ[lv_cv] = gv_weaponProjZAccel[lp_weaponType];
gv_velZ[lv_cv] += gv_weaponProjZVel[lp_weaponType];
UnitSetPosition(lv_u, lv_pt, true);
// Subtract terrain height so the unit ignores terrain height during its movement
UnitSetHeight(lv_u, gv_posZ[lv_cv] - lv_zw, c_physicsTimerInterval);
//--------------------------------------------------------------------------------------------------
// Custom Script: Order Supplies Dialog Create
//--------------------------------------------------------------------------------------------------
void gt_OrderSuppliesDialogCreate_Func () {
const int lv_width = 400 + 22;
const int lv_height = 600;
const int lv_anchor = c_anchorLeft;
const int lv_offsetX = 25;
const int lv_offsetY = 0;
const bool lv_modal = false;
const string lv_bgImage = gv_bg2;
const string lv_style = "<s val=\"ModCenterSize16Bold\">";
text lv_labelStyle = StringToText("<s val=\"ModCenterSize12Bold\">");
text lv_innerLabelStyle = StringToText("<s val=\"ModCenterSize16Bold\">");
text lv_txt;
int lv_i;
int lv_i2;
//--------------------------------------------------------------------------------------------------
// Custom Script: Vote Variables
//--------------------------------------------------------------------------------------------------
const string c_voteBg = "Assets\\Textures\\ui_voicechat_background_talkeritem.dds";
const string c_voteOptionButton = "Assets\\Textures\\ui_battle_missionbuttonicon_normalpressed.dds";
const string c_voteOptionButtonHover = "Assets\\Textures\\ui_battle_missionbuttonicon_normaloverpressedover.dds";
const int c_voteOptionsCount = 30;
int gv_voteMenuDialog;
int gv_voteMenuTitle;
int[c_voteOptionsCount] gv_voteMenuLabel;
int[c_voteOptionsCount] gv_voteMenuButton;
int[c_voteOptionsCount] gv_voteLabel;
text[c_voteOptionsCount] gv_optionButtonText;
timer gv_voteTimer = TimerCreate();
timer gv_voteCountdownTimer = TimerCreate();
int gv_voteMenuTimerLabel;
bool[16] gv_hasVoted;
int[c_voteOptionsCount] gv_votesFor;
int[c_voteOptionsCount] gv_votedFor;
int gv_votesCast;
int gv_votingPlayers = PlayerGroupCount(PlayerGroupActive());
int gv_voteOptionsCount;
string gv_votingOn;
//--------------------------------------------------------------------------------------------------
// Custom Script: Call Vote
//--------------------------------------------------------------------------------------------------
void gf_callVote (string lp_votingOn, fixed lp_timeToVote, string lp_title, string lp_subtitle, int lp_voteOptionsCount) {
const string lv_style = "<s val=\"ModCenterSize24Bold\">";
text lv_txt;
int lv_i;
// ---------------------------------------------------------------
// Call the vote
// ---------------------------------------------------------------
if (TimerGetRemaining(gv_voteTimer) > 0) {
UIDisplayMessage(gv_allPlayers, c_messageAreaDebug, StringToText("Vote in progress; wait until current vote is over to begin a new vote."));
return;
}
while (lv_i <= 15) {
gv_hasVoted[lv_i] = false;
lv_i += 1;
}
// ---------------------------------------------------------------
// Set up the vote dialog.
// ---------------------------------------------------------------
// The number of vote options can not exceed the maximum possible.
if (lp_voteOptionsCount > c_voteOptionsCount) {
lp_voteOptionsCount = c_voteOptionsCount;
}
// Resize the dialog depending on the number of options available.
DialogSetSize(gv_voteMenuDialog, 400, 70 + 70 + (25 * lp_voteOptionsCount));
// Set the title & the subtitle, e.g. "Mode", "Select game mode"
lv_txt = StringToText("<c val=\"F85F34\">" + lp_title + "</n><s val=\"ModCenterSize20\">" + lp_subtitle);
DialogControlSetPropertyAsText(gv_voteMenuTitle, c_triggerControlPropertyText, gv_allPlayers, StringToText(lv_style) + lv_txt);
// Set the timer text.
lv_txt = StringToText("<c val=\"EA0F3A\">" + FixedToString(TimerGetRemaining(gv_voteTimer), 2) + " seconds left to vote");
DialogControlSetPropertyAsText(gv_voteMenuTimerLabel, c_triggerControlPropertyText, gv_allPlayers, lv_txt);
// Show the vote dialog.
DialogSetVisible(gv_voteMenuDialog, gv_allPlayers, true);
}
Name:
Anonymous2012-03-02 14:46
//--------------------------------------------------------------------------------------------------
// Custom Script: On Vote
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Selects the option which has been voted for the most; if 2 or more options are tied it picks at
// random between the tied options.
//--------------------------------------------------------------------------------------------------
int gf_SelectVote (int lp_optionsCount) {
int lv_i;
int lv_i2;
int lv_picked;
int[c_voteOptionsCount] lv_pkd;
while(lv_i <= lp_optionsCount) {
if (lv_i2 < gv_votesFor[lv_i]) { // If the current option being evaluated has more votes than
lv_i2 = gv_votesFor[lv_i]; // the previous selected one, select the current option.
lv_picked = lv_i;
}
DebugMsg("Option (" + IntToString(lv_i) + ") has " + IntToString(gv_votesFor[lv_i]) + " votes");
lv_i += 1;
}
// Find all options which may be tied with the same number of votes as the rest.
lv_i = 0;
lv_i2 = -1;
while(lv_i <= lp_optionsCount) {
if (gv_votesFor[lv_i] == gv_votesFor[lv_picked]) {
lv_i2 += 1;
lv_pkd[lv_i2] = lv_i;
}
lv_i += 1;
}
// If multiple options are tied with the same number of votes pick one at random.
lv_picked = lv_pkd[RandomInt(0, lv_i2)];
return lv_picked;
}
//--------------------------------------------------------------------------------------------------
// Tally up the votes when they're ready or the timer has expired and select an option.
// Do whatever based on the option selected here.
//--------------------------------------------------------------------------------------------------
bool gt_onVote_Func (bool testConds, bool runActions) {
int lv_modeSelected = gf_SelectVote(gv_voteOptionsCount);
if (gv_votingOn == "Game Mode") {
//gf_SetUpGame(lv_modeSelected);
} else if (gv_votingOn == "Kick Player") {
if (lv_modeSelected < 16) {
GameOver(lv_modeSelected, c_gameOverDefeat, false, false);
}
} else if (gv_votingOn == "Many Options") {
UnitCreate(1, "Roach", c_unitCreateIgnorePlacement, lv_modeSelected, Point(128 + RandomFixed(-24, 24), 128 + RandomFixed(-24, 24)), RandomFixed(0, 360));
CameraPan(lv_modeSelected, UnitGetPosition(UnitLastCreated()), 1.0, -1, -1, false);
}
//--------------------------------------------------------------------------------------------------
// Custom Script: Vote Configures
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Functions that configure a vote, setting the text for each option, start the vote with a certain
// amount of time to vote before it automatically casts the vote, and setting the title / subtitle.
//--------------------------------------------------------------------------------------------------
void gf_VotePickGameMode() {
gv_optionButtonText[0] = StringToText("Random");
gv_optionButtonText[1] = StringToText("Team Deathmatch");
gv_optionButtonText[2] = StringToText("Capture The Flag");
gv_optionButtonText[3] = StringToText("Survival");
gv_optionButtonText[4] = StringToText("Bomb The Base");
gv_optionButtonText[5] = StringToText("Zerg vs Marines");
gf_callVote("Game Mode", 15.0, "Mode", "Select game mode", 5);
}
void gf_VoteKickPlayer() {
int lv_i;
while(lv_i <= 15) {
gv_optionButtonText[lv_i] = gv_playerNameColored[lv_i] + StringToText(" (P") + IntToText(lv_i) + StringToText(")");
lv_i += 1;
}
gv_optionButtonText[16] = StringToText("Do Not Kick Anyone");
gf_callVote("Kick Player", 30.0, "Kick", "Select player to be kicked", 16);
}
void gf_VoteManyOptions() {
int lv_i;
while(lv_i < 30) {
gv_optionButtonText[lv_i] = StringToText("Option: ") + TextWithColor(IntToText(lv_i + 1), ColorWithAlpha(100 - lv_i*5, lv_i*5, RandomFixed(0, 100), 0));
lv_i += 1;
}
gf_callVote("Many Options", 5.0, "Many Options", "A whole lot of options", 29);
}
//--------------------------------------------------------------------------------------------------
// Custom Script: Vote Cast
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// This function is what allows players to vote and to switch their vote before the vote expires.
//--------------------------------------------------------------------------------------------------
void gf_VoteCast (int lp_dialogControl, int lp_player) {
text lv_style = StringToText("<s val=\"ModCenterSize12\">");
playergroup lv_pg = PlayerGroupSingle(lp_player);
int lv_i;
//--------------------------------------------------------------------------------------------------
// Custom Script: on Death
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Recycle the index of units when they're dead.
//--------------------------------------------------------------------------------------------------
bool gt_onDeath_Func (bool testConds, bool runActions) {
unit lv_u = EventUnit();
int lv_cv = FixedToInt(UnitGetCustomValue(lv_u, c_uIndex));
//--------------------------------------------------------------------------------------------------
// Custom Script: on Collide
//--------------------------------------------------------------------------------------------------
bool gt_onDamage_Func (bool testConds, bool runActions) {
unit lv_u = EventUnitDamageSourceUnit(); // Unit dealing damage.
unit lv_u2 = EventUnit(); // Unit taking damage.
string lv_ut = UnitGetType(lv_u);
fixed lv_hp = UnitGetPropertyFixed(lv_u, c_unitPropLife, true);
int lv_cv = FixedToInt(UnitGetCustomValue(lv_u, c_uIndex));
point lv_ptA = UnitGetPosition(lv_u);
point lv_ptB = UnitGetPosition(lv_u2);
fixed lv_zwA = WorldHeight(c_heightMapGround, lv_ptA) + UnitGetHeight(lv_u);
fixed lv_zwB = WorldHeight(c_heightMapGround, lv_ptB) + UnitGetHeight(lv_u2);
if (lv_ut == c_projectile) {
//((a.vel.x + b.vel.x)/4)*-1
if (lv_zwA - lv_zwB > -0.5 && lv_zwA - lv_zwB < 1.0) {
// Apply damage when a projectile hits an enemy.
UnitDamage(lv_u, c_damageNormal, lv_u2, gv_projDmg[lv_cv]);
UnitKill(lv_u);
}
}
return true;
}
//--------------------------------------------------------------------------------------------------
// The unit isn't actually being damaged here... this is done as a way to do unit enums efficiently.
void gt_onDamage_Init () {
TriggerAddEventUnitDamaged(gt_onDamage, null, c_unitDamageTypeAny, c_unitDamageEither, c_damageProjectile);
}
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
// Custom Script: Player Income
//--------------------------------------------------------------------------------------------------
//---------- Configurable Constants ----------
// The time interval that we add resources to each player.
const fixed c_playerIncomeUpdateInterval = 0.5;
// The income is how much of the given resource is earned per interval.
const fixed c_playerIncome = 5.0;
//--------------------------------------------
trigger gt_PlayerIncomeUpdate = TriggerCreate("gt_PlayerIncomeUpdate_Func");
bool gt_PlayerIncomeUpdate_Func (bool testConds, bool runActions) {
int lv_i;
//--------------------------------------------------------------------------------------------------
// Custom Script: Map Info Variables
//--------------------------------------------------------------------------------------------------
int gv_mapInfoDialog;
int gv_mapInfoLabel;
//--------------------------------------------------------------------------------------------------
// Custom Script: Map Info Dialog Create
//--------------------------------------------------------------------------------------------------
void gt_MapInfoDialogCreate_Func () {
const int lv_width = 400;
const int lv_height = 38;
const int lv_anchor = c_anchorTopRight;
const int lv_offsetX = 25;
const int lv_offsetY = 326;
const bool lv_modal = false;
const string lv_bgImage = "Assets\\Textures\\blank.dds";
const string lv_style = "<s val=\"ModCenterSize16Bold\">";
// Check if mapmaker is present in the game.
if (PlayerHandle(lv_i) == "1-S2-1-1305364") {
DebugMsg("Mapmaker <c val=\"30C8FA\">ChuckNorris</c> is present in the game.");
}
>>42
Well wat do? My script is very fast & I'm considered really skilled relative to the average mapmaker who just uses GUI or some shit...
Name:
Anonymous2012-03-02 16:01
If you're "really skilled", why are you asking for our opinions? No matter how good you get at making maps with a shitty scripting language, that's all you'll ever be able to do. Make shitty maps. Don't bother learning the "good" way to do things, because no matter what you do, it will be shit.
Name:
Anonymous2012-03-02 16:07
>>44
You didn't pay attention to my use of relative did you? Of course I'm total shit compared to actual programmers. Also why do you hate SCII custom maps so much or do you assume my maps are shit while others are not?
y u hatin'?
Name:
Anonymous2012-03-02 16:11
Oh and also considered.
I feel like a massive faggot right now in the presence of you programming gods.
>>46
1. You are a massive faggot and we love you for it. In the butt.
2. The true programming gods on this board will not participate in conversations like this. They scoot around in buried threads from over a year ago, trading inscrutable secret messages and exchanging sage wisdom beyond the reach of mortal eyes. Look up to them, yes, but know that they are out of reach to us as well.
3. Programming is not actually valuable. Problem solving is. A good problem solver with no experience programming will quickly become a good programmer, especially if he has to work with other people's code. A bad problem solver will be a bad programmer even after a lifetime of experience. Prioritize accordingly.
4. It's good that you're asking questions but always remember that the people you ask will often turn out to be blithering idiots, or more likely just have no useful input on your problem. The latter is helped by making sure you ask good questions.
>>50
Maybe I should drop the use of the lv_ prefix for locals but continue with the prefixes for globals... or are you talking about c_ vs gv_? It's not very clear to me which prefix you're proclaiming to be redundant. Could be a parameter if it's not a local or global variable. That's about it though.
Name:
Anonymous2012-03-02 17:09
>>52
I'm claiming that either one will obsolete as long as the other is being used. Keeping the global one would be better though.
Name:
Anonymous2012-03-02 17:10
Forgot to remove the gt_ prefix from my previous script I just made, it's there because I copypasted an older script (template) then rewrote it to save time.