Page 1 of 1

Custom railguns with user and team colors

Posted: Mon May 20, 2013 12:30 am
by Qent
Custom railguns that use A_RailAttack to change the attack damage or damage type cannot use the player's railcolor or team color directly. Team-colored custom railguns have been made by using inventory flags and identical Fire states with different colors. This is one possible way to use the player's railcolor in addition to his team color.
Spoiler: decorate.txt (Open)

Code: Select all

actor Railgun : DoomWeapon 5012 {
  SpawnID 164
  Radius 20
  Height 16
  Weapon.Selectionorder 100
  Weapon.SlotNumber 6
  Weapon.SlotPriority 0.75
  Weapon.AmmoUse 10
  Weapon.AmmoGive 40
  Weapon.AmmoType "Cell"
  Inventory.Pickupmessage "$PICKUP_RAILGUN"
  Obituary "$OB_RAILGUN"
  Decal RailScorch
  States {
    Ready:
      RLGG A 1 A_WeaponReady
      Loop
    Deselect:
      RLGG A 1 A_Lower
      Loop
    Select:
      RLGG A 1 A_Raise
      Loop
    Fire:
      RLGG E 0 A_GunFlash
      RLGG E 0 A_JumpIfInventory("TeamCounter", 4, "FireNoTeam")
      RLGG E 0 A_JumpIfInventory("TeamCounter", 3, "FireGoldTeam")
      RLGG E 0 A_JumpIfInventory("TeamCounter", 2, "FireGreenTeam")
      RLGG E 0 A_JumpIfInventory("TeamCounter", 1, "FireRedTeam")
      Goto FireBlueTeam
    FireNoTeam:
      RLGG E 0 A_JumpIfInventory("RailColorItem", 9, "Fire9")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 8, "Fire8")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 7, "Fire7")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 6, "Fire6")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 5, "Fire5")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 4, "Fire4")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 3, "Fire3")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 2, "Fire2")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 1, "Fire1")
      // Fall-through
    Fire0:
      RLGG E 0 A_RailAttack(100, 0, 1, "Blue", "White", 0, 1)
      Goto FireEnd
    Fire1:
      RLGG E 0 A_RailAttack(100, 0, 1, "Red", "White", 0, 1)
      Goto FireEnd
    Fire2:
      RLGG E 0 A_RailAttack(100, 0, 1, "Yellow", "White", 0, 1)
      Goto FireEnd
    Fire3:
      RLGG E 0 A_RailAttack(100, 0, 1, "Black", "White", 0, 1)
      Goto FireEnd
    Fire4:
      RLGG E 0 A_RailAttack(100, 0, 1, "Gray", "White", 0, 1)
      Goto FireEnd
    Fire5:
      RLGG E 0 A_RailAttack(100, 0, 1, "Gold", "White", 0, 1)
      Goto FireEnd
    Fire6:
      RLGG E 0 A_RailAttack(100, 0, 1, "Green", "White", 0, 1)
      Goto FireEnd
    Fire7:
      RLGG E 0 A_RailAttack(100, 0, 1, "White", "White", 0, 1)
      Goto FireEnd
    Fire8:
      RLGG E 0 A_RailAttack(100, 0, 1, "Purple", "White", 0, 1)
      Goto FireEnd
    Fire9:
      RLGG E 0 A_RailAttack(100, 0, 1, "Orange", "White", 0, 1)
      Goto FireEnd
    FireBlueTeam:
      RLGG E 0 A_JumpIfInventory("RailColorItem", 9, "FireBlue9")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 8, "FireBlue8")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 7, "FireBlue7")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 6, "FireBlue6")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 5, "FireBlue5")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 4, "FireBlue4")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 3, "FireBlue3")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 2, "FireBlue2")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 1, "FireBlue1")
      // Fall-through
    FireBlue0:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 00 FF", "Blue", 0, 1)
      Goto FireEnd
    FireBlue1:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 00 FF", "Red", 0, 1)
      Goto FireEnd
    FireBlue2:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 00 FF", "Yellow", 0, 1)
      Goto FireEnd
    FireBlue3:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 00 FF", "Black", 0, 1)
      Goto FireEnd
    FireBlue4:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 00 FF", "Gray", 0, 1)
      Goto FireEnd
    FireBlue5:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 00 FF", "Gold", 0, 1)
      Goto FireEnd
    FireBlue6:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 00 FF", "Green", 0, 1)
      Goto FireEnd
    FireBlue7:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 00 FF", "White", 0, 1)
      Goto FireEnd
    FireBlue8:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 00 FF", "Purple", 0, 1)
      Goto FireEnd
    FireBlue9:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 00 FF", "Orange", 0, 1)
      Goto FireEnd
    FireRedTeam:
      RLGG E 0 A_JumpIfInventory("RailColorItem", 9, "FireRed9")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 8, "FireRed8")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 7, "FireRed7")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 6, "FireRed6")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 5, "FireRed5")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 4, "FireRed4")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 3, "FireRed3")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 2, "FireRed2")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 1, "FireRed1")
      // Fall-through
    FireRed0:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF 00 00", "Blue", 0, 1)
      Goto FireEnd
    FireRed1:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF 00 00", "Red", 0, 1)
      Goto FireEnd
    FireRed2:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF 00 00", "Yellow", 0, 1)
      Goto FireEnd
    FireRed3:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF 00 00", "Black", 0, 1)
      Goto FireEnd
    FireRed4:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF 00 00", "Gray", 0, 1)
      Goto FireEnd
    FireRed5:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF 00 00", "Gold", 0, 1)
      Goto FireEnd
    FireRed6:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF 00 00", "Green", 0, 1)
      Goto FireEnd
    FireRed7:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF 00 00", "White", 0, 1)
      Goto FireEnd
    FireRed8:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF 00 00", "Purple", 0, 1)
      Goto FireEnd
    FireRed9:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF 00 00", "Orange", 0, 1)
      Goto FireEnd
    FireGreenTeam:
      RLGG E 0 A_JumpIfInventory("RailColorItem", 9, "FireGreen9")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 8, "FireGreen8")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 7, "FireGreen7")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 6, "FireGreen6")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 5, "FireGreen5")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 4, "FireGreen4")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 3, "FireGreen3")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 2, "FireGreen2")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 1, "FireGreen1")
      // Fall-through
    FireGreen0:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 FF 00", "Blue", 0, 1)
      Goto FireEnd
    FireGreen1:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 FF 00", "Red", 0, 1)
      Goto FireEnd
    FireGreen2:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 FF 00", "Yellow", 0, 1)
      Goto FireEnd
    FireGreen3:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 FF 00", "Black", 0, 1)
      Goto FireEnd
    FireGreen4:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 FF 00", "Gray", 0, 1)
      Goto FireEnd
    FireGreen5:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 FF 00", "Gold", 0, 1)
      Goto FireEnd
    FireGreen6:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 FF 00", "Green", 0, 1)
      Goto FireEnd
    FireGreen7:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 FF 00", "White", 0, 1)
      Goto FireEnd
    FireGreen8:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 FF 00", "Purple", 0, 1)
      Goto FireEnd
    FireGreen9:
      RLGG E 0 A_RailAttack(100, 0, 1, "00 FF 00", "Orange", 0, 1)
      Goto FireEnd
    FireGoldTeam:
      RLGG E 0 A_JumpIfInventory("RailColorItem", 9, "FireGold9")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 8, "FireGold8")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 7, "FireGold7")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 6, "FireGold6")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 5, "FireGold5")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 4, "FireGold4")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 3, "FireGold3")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 2, "FireGold2")
      RLGG E 0 A_JumpIfInventory("RailColorItem", 1, "FireGold1")
      // Fall-through
    FireGold0:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF FF 00", "Blue", 0, 1)
      Goto FireEnd
    FireGold1:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF FF 00", "Red", 0, 1)
      Goto FireEnd
    FireGold2:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF FF 00", "Yellow", 0, 1)
      Goto FireEnd
    FireGold3:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF FF 00", "Black", 0, 1)
      Goto FireEnd
    FireGold4:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF FF 00", "Gray", 0, 1)
      Goto FireEnd
    FireGold5:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF FF 00", "Gold", 0, 1)
      Goto FireEnd
    FireGold6:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF FF 00", "Green", 0, 1)
      Goto FireEnd
    FireGold7:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF FF 00", "White", 0, 1)
      Goto FireEnd
    FireGold8:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF FF 00", "Purple", 0, 1)
      Goto FireEnd
    FireGold9:
      RLGG E 0 A_RailAttack(100, 0, 1, "FF FF 00", "Orange", 0, 1)
      Goto FireEnd
    FireEnd:
      RLGG E 12
      RLGG F 6
      RLGG GHIJKLA 6
      RLGG M 0 A_ReFire
      goto Ready
    Flash:
      TNT1 A 5 bright A_Light1
      TNT1 A 5 bright A_Light2
      TNT1 A 0 bright A_Light0
      Goto LightDone
    Spawn:
      RAIL A -1
      Stop
  }
}

// Encodes the player's railcolor in inventory.
actor RailColorItem : Inventory {
  +INVENTORY.UNDROPPABLE
  Inventory.MaxAmount 9
}

// Encodes the player's team in inventory.
actor TeamCounter : Inventory {
  +INVENTORY.UNDROPPABLE
  Inventory.MaxAmount 255
}
Spoiler: railgun.acs (Open)

Code: Select all

#library "railgun"
#include "zcommon.acs"

#define MAXPLAYERS 64

// Script numbers used:
#define RAIL_INIT_ENTER 345
#define RAIL_INIT_RESPWAN 346
#define GET_RAILCOLOR 347
#define SEND_RAILCOLOR 348
#define RAIL_ITEM_ENTER 349
#define RAIL_ITEM_RESPAWN 350

// How frequently railcolor gets sent to the server:
#define LOOP_DELAY_TICS 35

int railColor[MAXPLAYERS];

script RAIL_INIT_ENTER ENTER CLIENTSIDE {
  if(ConsolePlayerNumber() != PlayerNumber())
    Terminate;
  ACS_Execute(GET_RAILCOLOR, 0, 0, 0, 0);
}

script RAIL_INIT_RESPWAN RESPAWN CLIENTSIDE {
  if(ConsolePlayerNumber() != PlayerNumber())
    Terminate;
  ACS_Execute(GET_RAILCOLOR, 0, 0, 0, 0);
}

script GET_RAILCOLOR (void) CLIENTSIDE {
  int color = GetCVar("railcolor");
  str cmd = StrParam(s:"puke -", d:SEND_RAILCOLOR, c:' ', d:color);
  ConsoleCommand(cmd);
  Delay(LOOP_DELAY_TICS);
  Restart;
}

script SEND_RAILCOLOR (int color) NET {
  if(color < 0 || color > 9)
    color = 0;
  railColor[PlayerNumber()] = color;
  checkRailItems();
}

script RAIL_ITEM_ENTER ENTER {
  checkRailItems();
  giveTeamItems();
}

script RAIL_ITEM_RESPAWN RESPAWN {
  checkRailItems();
  giveTeamItems();
}

function void checkRailItems(void) {
  if(CheckInventory("RailColorItem") != railColor[PlayerNumber()]) {
    TakeInventory("RailColorItem", 999);
    GiveInventory("RailColorItem", railColor[PlayerNumber()]);
  }
}

function void giveTeamItems(void) {
  GiveInventory("TeamCounter", GetPlayerInfo(PlayerNumber(), PLAYERINFO_TEAM));
}

RE: Custom railguns with user and team colors

Posted: Mon May 20, 2013 12:36 am
by Ivan
So much for a simple effect...

RE: Custom railguns with user and team colors

Posted: Mon May 20, 2013 12:37 am
by Qent
I know, right? And "rainbow" doesn't even work. :sad:

RE: Custom railguns with user and team colors

Posted: Mon May 27, 2013 12:26 pm
by Lollipop
instead of teamcounter, why not have it look more like this?:
Fire:
RLGG E 0 A_GunFlash
RLGG E 0 A_JumpIfInventory("Team_blue", 4, "FireNoTeam")
RLGG E 0 A_JumpIfInventory("Team_gold", 3, "FireGoldTeam")
RLGG E 0 A_JumpIfInventory("Team_green", 2, "FireGreenTeam")
RLGG E 0 A_JumpIfInventory("Team_red", 1, "FireRedTeam")
Goto firenoteam

that makes it easyer for idiots like me to understand :P
also, if za had the railcolor function, you wouldnt come up with this great cycle through code for me to get ideas with for other things :P

RE: Custom railguns with user and team colors

Posted: Mon May 27, 2013 4:50 pm
by Qent
Because GetPlayerInfo(PlayerNumber(), PLAYERINFO_TEAM) returns a number, it seemed natural just to store that number as an inventory item.

RE: Custom railguns with user and team colors

Posted: Tue May 28, 2013 1:56 pm
by Lollipop
might seem natural to you, but I can't see the logic of using a non-item for an item based function........
but I guess that if it works, then it don't matter if it makes sense :razz:
but I personally prefer to have an item for the teams, as changes in the teaminfo can change how your weapon will behave, and therefore you will then need to recode the weapon.

RE: Custom railguns with user and team colors

Posted: Tue May 28, 2013 4:43 pm
by Qent
A non-item? It is an item though:

Code: Select all

// Encodes the player's team in inventory.
actor TeamCounter : Inventory {
  +INVENTORY.UNDROPPABLE
  Inventory.MaxAmount 255
}
As far as I can tell, I'm doing just what you would do, but naming it differently. So four TeamCounters == one Team_gold.

You also seem to be a little confused about what A_JumpIfInventory is doing.
Lollipop wrote: RLGG E 0 A_JumpIfInventory("Team_gold", 3, "FireGoldTeam")
This will jump to the FireGoldTeam state if you have three or more Team_gold items. If you have one item for each team, then there is no need to give three of them. (BTW you missed FireBlueTeam.)

RE: Custom railguns with user and team colors

Posted: Thu May 30, 2013 3:33 pm
by Lollipop
bummer, I forgot to change the number of items :P
also, I think I missed the team counter actor, not that I got any real idea why you then linked me over to playerinfo?......
anyways, this system can be used for other (more awesome lol) things than just a railgun with different colors :P

RE: Custom railguns with user and team colors

Posted: Tue Jun 18, 2013 5:17 pm
by Qent
Well as it turns out, this may all have been for nothing! Sure, I guess you could use this method to add one or two more railcolors. But if you find some other more awesome thing than a railgun with different colors to do, post it here!

RE: Custom railguns with user and team colors

Posted: Wed Jun 19, 2013 8:48 am
by Lollipop
Well, just anything that change the states depending on inventory items in its behaviour, simple as that really, you could have all players have IS_TEAMCOLORHERE as their start inventory item, and then they can just colorrofl with anything, or you could have something like this?:
RED: projectile bonus
BLUE: hitscan bonus

and then if the weapon finds the corresponing teamitem, it launches FireBlue/FireRed and they look the same but their A_firebullets have a different damage and also the projectiles will be other actors :)

Just say'in

RE: Custom railguns with user and team colors

Posted: Wed Jun 26, 2013 8:39 pm
by Balrog
Lollipop wrote: Well, just anything that change the states depending on inventory items in its behaviour, simple as that really, you could have all players have IS_TEAMCOLORHERE as their start inventory item, and then they can just colorrofl with anything, or you could have something like this?:
RED: projectile bonus
BLUE: hitscan bonus

and then if the weapon finds the corresponing teamitem, it launches FireBlue/FireRed and they look the same but their A_firebullets have a different damage and also the projectiles will be other actors :)

Just say'in
That is overly complex, unbalanced, and just plain stupid. Just sayin'.

And why can't you just use blank parameters for spiralcolor and corecolor?

RE: Custom railguns with user and team colors

Posted: Thu Jun 27, 2013 5:21 pm
by Lollipop
Well, balance measures would be possible... somehow, BUT SOME PEOPLE ARE JUST TOO LAZY TESTING THEIR SHIT TO SEE IF ITS BALANCED.
Complex it is not, and parameters for railcolors dun work as desired, also every railgunshot could be varying in this manner *too lazy to make an example*

RE: Custom railguns with user and team colors

Posted: Thu Jun 27, 2013 7:52 pm
by Qent
Many earlier mods have used inventory items to mark what team a player is on for team-colored plasma, rails, damagetypes, and other weapon-related things. Here I was mainly interested in sending an ordinary cvar (e.g. railcolor) from the client to the server automatically, without making a new function to set it.

RE: Custom railguns with user and team colors

Posted: Fri Jun 28, 2013 3:10 am
by Ænima
Lollipop wrote: BUT SOME PEOPLE ARE JUST TOO LAZY TESTING THEIR SHIT TO SEE IF ITS BALANCED.
Lollipop wrote: i'm too lazy to make an example
You're accusing Balrog of being "too lazy" to playtest a modification that you yourself are "too lazy" to create?

[spoiler]Image[/spoiler]








­


­

­
Also, I agree with Balrog. Even the concept of something like this:
RED: projectile bonus
BLUE: hitscan bonus
... is unbalanced at the most basic level. No matter how much you nerf the hitscans or buff the projectile damage, the fact of the matter is that hitscans are almost always better when it comes to PVP.

That is, assuming that what you meant was "buff red team players' projectiles, and buff blue's hitscans".

RE: Custom railguns with user and team colors

Posted: Fri Jun 28, 2013 11:28 am
by Lollipop
Ænima wrote: -snip-
1. Well, all I said about lazyness is that I myself is too lazy to make an example thing, and did therefore not accuse balrog of anything.

2. I have been looking for that picture.

3. the idea was basic and quickly thought out, and again, I'm too lazy to do something about it anyway. Also it was a state of an example on just what such an alteration of a weapons behaviour could do (basically anything).