Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
weapon with different effects according to team

#1
Hello!
I want to add a new weapon model to xonotic that will have effects of different colors according to the owner team.
so I tought to add a condition in w_weapon(float req) before pointparticles(particleeffectnum(....)); (cf qcsrc/server/w_shotgun.qc)
"if (self.owner.team==blue)" for example. it didn't work than I figured out with a "print(ftost(self.owner.team))" that the function don't recognize the team neither the owner of the weapon, when in the void weapon_meleethink it does.
Is there a way to find the owner or the team there? or should I see elsewhere in the code?
Thank you
Reply

#2
I think per-team weapon effects colors has been already implemented or is at least being worked on. I suggest to ask on IRC either on #xonotic @ quakenet or #xonotic @ freenode.
[Image: 249.png] Latest track on soundcloud: Farewell - to a better Place (piano improvisation)
New to Xonotic? Check out my Newbie Corner!
<ZeRoQL> i think i got 1 proper quad and that cunt halogen fuck me over with a laser
Reply

#3
Thank you. And is the code released somewhere?
Reply

#4
If I remember correctly I heard that this is in the works and I think Samual's current spawn weapon concept already uses team based effects coloring. Maybe ask Samual about it. If the code is existent, you'll find it in some git branch.
[Image: 249.png] Latest track on soundcloud: Farewell - to a better Place (piano improvisation)
New to Xonotic? Check out my Newbie Corner!
<ZeRoQL> i think i got 1 proper quad and that cunt halogen fuck me over with a laser
Reply

#5
(08-21-2012, 02:56 AM)soukaina Wrote: Hello!
I want to add a new weapon model to xonotic that will have effects of different colors according to the owner team.
so I tought to add a condition in w_weapon(float req) before pointparticles(particleeffectnum(....)); (cf qcsrc/server/w_shotgun.qc)
"if (self.owner.team==blue)" for example. it didn't work than I figured out with a "print(ftost(self.owner.team))" that the function don't recognize the team neither the owner of the weapon, when in the void weapon_meleethink it does.
Is there a way to find the owner or the team there? or should I see elsewhere in the code?
Thank you

First of al, self.owner.team is wrong. I'll keep the error for now to avoid confusion about the team thing first.

When you write "self.owner.team == blue", you're assuming that there is a variable called "blue" (or a constant, but these are usually written in capital letters). This is not the case.

Have a look in server/constants.qh. The teams are defined there. .team is a .float: they are actually integer codes, not strings.
Code:
float COLOR_TEAM1       = 5;  // red
float COLOR_TEAM2       = 14; // blue
float COLOR_TEAM3       = 13; // yellow
float COLOR_TEAM4       = 10; // pink
So what you want is "self.owner.team == COLOR_TEAM1".

Don't forget that there are FOUR teams, not two. If you're going to code something specific to games that have two teams like CTF, make sure your code checks that it's the right gamemode before assuming things about the team counts.

Now, why is self.owner.team wrong? You said it works fine in shotgun_meleethink, and indeed it does. But shotgun_meleethink is a think function as you can can see in W_Shotgun_Attack2. W_Shotgun_Attack2 is called when you fire the secondary melee attack; it spawns a melee entity (meleetemp = spawn();) and assigns a think function to it, as well as a nextthink time. That way, when the nextthink time is reached, the think function is called with self set to the thinking entity. This entity's .owner is set to be the player in W_Shotgun_Attack2. So, when shotgun_meleethink is called, self is the melee entity, self.owner is the player, and self.owner.team is the player's team.

It's different in W_Shotgun_Attack and W_Shotgun_Attack2. In w_shotgun and all the other weapon action functions used in the weapon system as the second argument of REGISTER_WEAPON, self is the player entity. And W_Shotgun_Attack and W_Shotgun_Attack2 are called by w_shotgun. So what you want to use is self.team == COLOR_TEAM_1.
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds
Reply

#6
yes I know for the teams constants just didn't pay attention when I wrote it.
I tried to print everything on w_shotgun self.netname,ftos(self.team), self.owner.netname,ftos(self.owner.team)); but I get nothing, I got 0 for self.team when in melee think I get 14 and 5 for self.owner.team
Reply

#7
Where did you put the print line? It works for me. I added at the top of W_Shotgun_Attack
Code:
dprint(ftos(num_for_edict(self)),"\n");
and it prints 1, which is the entity number of player 1 (developer must be set to 1 if you use dprint, you can use print instead). What do you get?
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds
Reply

#8
aah I think we are talking about different functions the one I am talking act is for client side qc

I succeeded to change the muzzleflash effects from W_Shotgun_Attack but for the other impacts I think they are loaded in the csqc w_shotgun. is there a way to use the player team there?
Reply

#9
There is no csqc W_Shotgun_Attack.

As for impacts, it seems CSQC has no idea which team the bullets belong to. In CSQC, w_shotgun is called from Ent_DamageInfo. As you can see, it gets the information from the server in that function with Read*() functions. This data is sent by the server by Damage_DamageInfo which calls Damage_DamageInfo_SendEntity via Net_LinkEntity. Damage_DamageInfo itself was called by W_BallisticBullet_Hit in the ballistic bullet system used by the shotgun serverside.

In short:
Code:
W_BallisticBullet_Hit (w_common.qc) --> Damage_DamageInfo (g_damage.qc) --> Net_LinkEntity (miscfunctions.qc) --> Damage_DamageInfo_SendEntity (g_damage.qc) --(SVQC to CSQC)--> Ent_DamageInfo (damage.qc) --> CQSC w_shotgun (server/w_shotgun.qc)

And there is no team info transmitted. DamageInfo's dmgowner.team is what you want to send to CSQC.

EDIT: It appears that CSQC team constants are different from SVQC's. You should ask somebody else about this because I don't know what to do with that. You might have to send a player number instead of a team number, and figure out the team based on the CSQC scoreboard entities.
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds
Reply

#10
Thanks a lot
I tried to send dmgowner.team from to csqc and with a print in damage.qc sometimes I get my 14 and 5 but sometimes I get 0 Sad((( whyyy ??

and no apparently team constants are the same in CSQC
Reply

#11
I mean the COLOR_TEAM1 etc variables, they don't have the same value in CSQC.

I don't know why, try printing the entity's .classname in the svqc side before sending the data.
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds
Reply

#12
Sometimes I get my correct infos (14 and 5 for teams just like SVQC variables ) sometimes I get 0,
maybe there is a frequency of sending infos, third parameter of Net_LinkEntity?? set there to 0.2

oh yes the dmgowner is either a bullet or a player,it's for the bullets that it sends 0
Reply

#13
It turned out that it works perfectly for the other weapons, the problem remains only for the shotgun. Any idea why?

for the shotgun it returns often "bullet" as classname of dmgowner when for the other weapons it's "player"
Reply

#14
Sorry, my mistake then. fireBallisticBullet spawns a ballistic bullet whose .owner is the player who shot the bullet. The bullet's touch function then calls W_BallisticBullet_Hit when it hits something, and if it's terrain it spawns a spark. In the bullet's touch function, self is the trigger, i.e. the bullet. Use self.owner to get the player.

I know absolutely nothing about this ballistic bullet system, I'm reading the same source files as you, and I think you should try to understand it yourself. It's much more rewarding when you're doing the work by yourself. All I did was search all qc files for DamageInfo, finding out what called it in the ballistic bullet system, and backtracking to a touch or think function, which tells me what "self" is defined as. Then, find where it's spawned to understand what its different variables mean and notice that .owner is the player.

EDIT: As for why it's also sometimes the player: RadiusDamage also calls DamageInfo, sending attacker as the dmgowner. That's the player. So for ballistic weapons (SG, MG, rifle) you get the bullet as dmgowner, and for splash damage it's the player.
EDIT2: I don't understand why it's that way, btw. I'll see if I can ask div about this.
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds
Reply

#15
Thanks a lot I tried self.owner it's not the player but I'll keep searching.
Reply

#16
Oops, my mistake, .owner is probably changed at one point. Use .realowner, the rest of the ballistic code seems to use that.
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds
Reply

#17
youhou yes I found it before u Big Grin
Reply

#18
I have a question ...........

why base the color off of team ? ... why not off of the shirt (or pants) color ... the player's color

then if your playing regular dm the effect fits with your characters color ....

also if the team colors are changed in the future (cause tbh yellow and pink suck as team colors ...) then your code will still work ...
its also independent to the amount of teams ... if the someone makes 12 team cft for some odd reason ... your code will still work
Reply

#19
Hi there !

I'm currently working on Soukaina's code and this thread interests me because i'd like to finish this fonctionnality about color effects according to team. This is done and i think it works fine.

But i now would like color effects depending on shirt player color when in a none per-team game mode, as hutty said.
I will allow user to choose one color on 15 proposed colors.

For now, here is how it is done :
Quote:damage.qc
if(plteam==14)
(get_weaponinfo(hitwep)).weapon_func(WR_IMPACTEFFECT_BLUE);
else if(plteam==5)
(get_weaponinfo(hitwep)).weapon_func(WR_IMPACTEFFECT_RED);
else if(plteam==10)
(get_weaponinfo(hitwep)).weapon_func(WR_IMPACTEFFECT_PINK);
else if(plteam==13)
(get_weaponinfo(hitwep)).weapon_func(WR_IMPACTEFFECT_YELLOW);

Quote:Example with w_laser.qc
if(req == WR_IMPACTEFFECT_RED)
pointparticles(particleeffectnum("laser_impact_red"), org2, w_backoff * 1000, 1);
else if(req == WR_IMPACTEFFECT_BLUE)
pointparticles(particleeffectnum("laser_impact_blue"), org2, w_backoff * 1000, 1);
else if(req == WR_IMPACTEFFECT_PINK)
pointparticles(particleeffectnum("laser_impact_pink"), org2, w_backoff * 1000, 1);
else if(req == WR_IMPACTEFFECT_YELLOW)
pointparticles(particleeffectnum("laser_impact_yellow"), org2, w_backoff * 1000, 1);

Quote:effectinfo.txt
Example for weapon "laser" and for color team "yellow"

effect laser_impact_yellow
type static
...
color 0xffff00 0xffff00
...
staincolor 0xffff00 0xffff00

effect laser_impact_yellow
type spark
color 0xffff00 0xffff00
...
staincolor 0xffff00 0xffff00

effect laser_impact_yellow
type smoke
color 0xffff00 0xffff00
...
staincolor 0xffff00 0xffff00
...

So, in effectinfo.txt, this is done this way, for every weapon and for every color team. In fact, only the values "colors" and "staincolor" change. Other values are duplicated...
It bothers me because it is quite ugly and i have lots of "if" conditions to add for every weapons to check for the player shirt color and "call" for the right color effect.

Do you think this is the best or easiest way to do it ? Or do you see any other way ?

Thanks
Reply

#20
I would like to see this Big Grin
XMPP Conferences
xonotic@conference.jabber.org → General discussion
xonotic@conf.jabberes.org → Spanish-speakers
I pronounce it Shonotic.
Reply

#21
well ... i already attempted using a _shirt texture for the laser bullet (it did not work) ... so I don't think there is an easier way ... although you could ignore the team check seeing as being on blue team makes your shirt blue ... so only checking for shirt is necessary
Reply

#22
(06-05-2013, 06:48 AM)Rerem Wrote: (...)

Hi!

When checking teams, you should be using the declared constants, not magic numbers.
Code:
NUM_TEAM_1 : red
NUM_TEAM_2 : blue
NUM_TEAM_3 : yellow
NUM_TEAM_4 : pink
In svqc, the palette color codes are simply (NUM_TEAM_x - 1).


I don't think there's a way to color all aspects of particles from the code.

You could avoid switch/case or nested ifs by giving each of the 16 effects a name based on its color code: laser_impact_12 for example. Then you can form the name programatically using ftos and strcat.

Also, use the same logic for teams as you do for shirt/pants colors: once you have the logic that gives you the effect name based on the base name and the color code, you can simply apply that to (NUM_TEAM_1 - 1), (NUM_TEAM_2 -1) and so on. You'll have to rename laser_impact_yellow to laser_impact_12, laser_impact_pink to laser_impact_9 etc.
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds
Reply

#23
Thanks for you replies ! I replaced this magic numbers and i see what to do next.

My problem now is to get the shirt color (topcolor) in qcsrc/client/damage.cq, how can i do it ? I'm trying many things, but i don't find the way to it...

EDIT : and, can you please make this thread UNSOLVED ?
Reply

#24
Why do you need to get the shirt color in CSQC? (the clientside code in qcsrc/client) Right, client-side effects.

I don't think I can support you any further in this, my QC and knowledge of the codebase are too rusty. You should read portions of the sources that you think are relevant to the issue. For example, in which place are shirt/pants colors visible in client code? The scoreboard comes to mind.

And that's precisely what you get when you search for "shirt" in all CSQC files. You get a match in scoreboard.qc, where hud_field_icon1_rgb is set to the relevant color. You can backtrack from there and see how that section of the code knows about the player's color, and you see it's obtained through a getplayerkeyvalue call with "colors" as the second argument.

Learn from the existing code and by trial and error first! Only then should you ask questions. It's easier for us to answer questions when you show what you tried and how it didn't work.
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds
Reply



Possibly Related Threads...
Thread Author Replies Views Last Post
  Can I adjust the weapon model size and stuff? Molnija 1 244 03-13-2019, 12:28 AM
Last Post: BuddyFriendGuy
  weapon size Molnija 0 505 12-03-2018, 05:22 AM
Last Post: Molnija
  Custom Weapon Balance - Live on /v/ server Antares* 30 8,073 09-30-2016, 11:52 AM
Last Post: Antares*
Rainbow curvegun (custom weapon) dingus 8 4,641 08-03-2016, 02:35 PM
Last Post: dingus
  Weapon models WIP help. Beagle 1 1,907 05-17-2015, 06:52 PM
Last Post: Beagle
  Weapon and Lightning Gun Testing Mario 18 9,611 11-11-2014, 08:02 PM
Last Post: Lee_Stricklin
Exclamation Join the Xonotic mapping team Mirio 2 4,980 06-14-2013, 04:31 AM
Last Post: Maddin
Information Spawn Weapon Concept: "Blaster" Samual 85 56,372 03-27-2013, 01:18 PM
Last Post: Samual
  Weapon Settings Question? kidx 22 10,366 08-30-2012, 08:04 PM
Last Post: Mr. Bougo
Question Supressing available weapon errors... cl_weaponsystem.qc confusion twistedlincoln 4 3,699 07-01-2012, 12:38 PM
Last Post: twistedlincoln

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-