I'd like to do 2 relatively simple things --- The end goal is to measure accuracy by comparing V1 with V2 percentage wise.
variable V1 increases with every shot with every weapon, obviously first line in decorate fire sequence.
variable V2 Increases when a certain projectile hits an actor defined in an array (All enemy classes manually listed)
Bullets will increase the V1 and V2 by 1, while heavier stuff increase them more, the logic is that there is more leeway to miss with bullets since that is easier (chaingun/rifle style weapons) while missing heavy hitting ones should penalize the accuracy more, that is why when a plasma shot is fired, v1 increases by 6, if it misses, it takes a greater toll on your accuracy than missing 1 bullet, you get the logic.
This needs to be done in ACS and Decorate. IF Zscript must be involved, then I must somehow pull that variable from Z to ACS (don't know if it's possible)
1) Increase some global like variable in every weapon's firing sequence
2) Somehow do checks in all the projectiles, if they hit one of the designated classes, increase second global like variable
Projectile hits certain enemies = variable raises
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
-
- Posts: 83
- Joined: Thu Jan 25, 2018 1:37 pm
-
- Posts: 1606
- Joined: Mon Jun 12, 2017 12:57 am
Re: Projectile hits certain enemies = variable raises
In decorate and acs it require too much crutches, adhesive tape and swearing to put it together. And then some kicks to make it work.
In zscript you can do something like
1. Create base projectile class.
2. Override in this base class specialmissilehit virtual where you check what projectile hit something or wall.
3. If hit something add to global variable some numder.
4. Than inherit from this base projectile all other projectiles.
If you already have decorate projectiles you even dont need convert it to zscript, since decorate actors can inherit from zscript, but not vice versa.
In zscript you can do something like
1. Create base projectile class.
2. Override in this base class specialmissilehit virtual where you check what projectile hit something or wall.
3. If hit something add to global variable some numder.
4. Than inherit from this base projectile all other projectiles.
If you already have decorate projectiles you even dont need convert it to zscript, since decorate actors can inherit from zscript, but not vice versa.
Code: Select all
class prjctl : fastprojectile
{
override int SpecialMissileHit (Actor victim)
/*crib
"victim" means "whom projectile hit"
"return 1" means "projectile die on hit with victim"
"return -1" means "projectile rip through victim"
"if(victim is "some actor name")" means "return true if victim is some kind of 'some actor name' "
"Super.SpecialMissileHit(victim)" means "check can projectile hit victim or no in general", this function return 1 or -1
*/
{
if(super.SpecialMissileHit(victim) == 1)//can hit
{
if(victim is "doomimp")
{
global variable which you create += 5;
}
if(victim is "other class")
{
global variable which you create += 13;
}
return 1;
}
return -1;
}
}
-
- Posts: 83
- Joined: Thu Jan 25, 2018 1:37 pm
Re: Projectile hits certain enemies = variable raises
Thank you, this is what I was looking for. This solves the V2, as for V1, another similar class to this will have to be fired in each decorate definiton for weapons, multiple of these would have to be made for each weapon.
Fire plasma gun = Summon zscript Plasma tracker which always increases the global variable by 6 and then dies
Fire Rocket Launcher = Summon zscript Rocket Tracker += 10
etc ..
Also, this is a zscript global variable right ? i've looked at the definiton and it's still unclear to me, acs declaration stuff is so simple
https://zdoom.org/wiki/ZScript_global_variables
Can I use an ACS Global variable like
global int 1:V1;
global int 2:V2;
and have the zscript actors increase these ?
Fire plasma gun = Summon zscript Plasma tracker which always increases the global variable by 6 and then dies
Fire Rocket Launcher = Summon zscript Rocket Tracker += 10
etc ..
Also, this is a zscript global variable right ? i've looked at the definiton and it's still unclear to me, acs declaration stuff is so simple
https://zdoom.org/wiki/ZScript_global_variables
Can I use an ACS Global variable like
global int 1:V1;
global int 2:V2;
and have the zscript actors increase these ?
-
- Posts: 1606
- Joined: Mon Jun 12, 2017 12:57 am
Re: Projectile hits certain enemies = variable raises
You can do so inside this projectile too.But fir this you must override post begin play virtual. It calls each time actor take it first "breath" in gzdoom.
Kinda. In it iki page described basic method ho to do so.
If you need store this v1 and v2 you better store it to special inventory item. Also it store them through levels.
Like this
You must give this item to player and then in base projectile class find this item in player inventory.
About changing acsvariable from ascript actor...I dont know.
Technicaly acs run as thinker, which you can manipulate from zscript. But Im not sure that numbers and all other stuff in this acs thinker have readable and suitable form.
Code: Select all
class base projectile
{
override void postbeginplay()
{
super.postbeginplay();
inventory roster = target.findinventory("statistical_data");
if(roaster != null) {statistical_data(roaster).v1 or v2 += number;}
}
}
If you need store this v1 and v2 you better store it to special inventory item. Also it store them through levels.
Like this
Code: Select all
class statistical_data : inventory
{
int V1;
int V2;
default{inventory.maxammount 1;}
}
Code: Select all
class previously defined base projectile
{
sample text
override int SpecialMissileHit (Actor victim)
{
inventory table = target.findinventory("statistical_data");//try to find item in target inventory, if dont find return null
if(table == null){return super.SpecialMissileHit(victim);}//if no item just call default function
if(table != null)
{
same code as before, but change all "global variable which you create" to "statistical_data(table).v1/v2 respectively"
}
}
}
About changing acsvariable from ascript actor...I dont know.
Technicaly acs run as thinker, which you can manipulate from zscript. But Im not sure that numbers and all other stuff in this acs thinker have readable and suitable form.
-
- Posts: 83
- Joined: Thu Jan 25, 2018 1:37 pm
Re: Projectile hits certain enemies = variable raises
ACS:
Script "Accuracy" Open
{
Give player inventory item statistical_data (1)
While(True)
{
Delay(1)
Compare V1 and V2 percentage wise
If percentage is between 95-100%
AccuScore = 6000;
If perfentage is between 90-95%
Accuscore=5600;
......
delay(1)
}
Zscript:
Script "Accuracy" Open
{
Give player inventory item statistical_data (1)
While(True)
{
Delay(1)
Compare V1 and V2 percentage wise
If percentage is between 95-100%
AccuScore = 6000;
If perfentage is between 90-95%
Accuscore=5600;
......
delay(1)
}
Zscript:
Code: Select all
class BulletFireProjectileCheck : fastprojectile
{
override int SpecialMissileHit (Actor victim)
{
inventory table = target.findinventory("statistical_data");
if(table == null){return super.SpecialMissileHit(victim);}
if(table != null)
{
if(super.SpecialMissileHit(victim) == 1)//can hit
{
if(victim is "doomimp")
{
statistical_data(table).v2 += 1;
}
if(victim is "Hellknight")
{
statistical_data(table).v2 += 1;
}
return 1;
}
}
return -1;
}
override void postbeginplay()
{
super.postbeginplay();
inventory roaster = target.findinventory("statistical_data");
if(roaster != null) {statistical_data(roaster).v1 += 1;}
}
}
class statistical_data : inventory
{
int V1;
int V2;
default{inventory.maxammount 1;}
}
Last edited by Collegia Titanica on Wed Aug 29, 2018 11:51 am, edited 1 time in total.
-
- Posts: 83
- Joined: Thu Jan 25, 2018 1:37 pm
Re: Projectile hits certain enemies = variable raises
I reallllyyy prefer working with global variables rather than items.
-
- Posts: 1606
- Joined: Mon Jun 12, 2017 12:57 am
Re: Projectile hits certain enemies = variable raises
Then just copy-paste example from wiki.