Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: azrealg on August 05, 2016, 11:58:13 pm
Title: Weapon Script[helpmeObiwan]
Post by: azrealg on August 05, 2016, 11:58:13 pm
My understand of CodWAW scripting is < 1 :derp: I am trying to just simply get when a zombie is shot by a player and iprintln("Shot detected"); I am getting into using the fx editor and would like to start making some custom weapon scripts, but I can't seem to detect even when a zombie has been shot by a player holding a specific gun, which is step one in the process. Overall my questions to any of the more experienced coders or scripters here are as follows:
1.) I have seen from the thundergun and scavenger script and freezegun that the projectile impact notify is used. Are there others (I haven't been able to find any in all the gsc I've searched through) that deal with bullet, explosive, gas impact? or is basically every script weapon limited to using projectile_impact ? 2.) What logic can be used to solve my problem of collecting the zombie shot, the player who shot him, and the weapon used to doSomething(); perhaps I have the idea completely wrong but there is 0 documentation tutorials or help on this subject.
The script below does not work. To clear out some of the basic responses I will get, I will say the weapon is added to dlc3 and _zombiemode_weapons properly, included in mod.csv and checked in the compiler. using the console the give crossbow command successfully gives my player a crossbow in game so I am pointing to the correct weapon.
Please help, coding gods of WAW, I want to make interesting shit here.
crossbow_rdy() { for( ;; ){ level waittill( "connecting", player ); wait .1; ai = getaiarray("axis"); for(i=0;i<ai.size;i++) player watch_for_crossbow(player, ai); }}
Title: Re: Weapon Script[helpmeObiwan]
Post by: Soy-Yo on August 06, 2016, 12:19:35 am
To get when and how a zombie is damaged: I'm not sure what direction_vec is. Probably the direction of the bullet (?). I guess that point is the impact point. And type is the MOD (MOD_MELEE, MOD_BURNED, MOD_PISTOL_BULLET, etc.). Don't know if it gives more info.
Title: Re: Weapon Script[helpmeObiwan]
Post by: azrealg on August 06, 2016, 08:40:56 am
Thank you very much for a fast reply I appreciate the help. I was able to get the script working and very well to the point that it is seamless in game at detecting zombie damage and type/ weapon. The waittill("death") can also be used instead if you only wanted to do something on death, but my purposes is setting up a basic weapon script which can be used to attach effects, damage events, physics etc to a specific group of weapons being fired. I want to make a base template for lack of better words in which I can make several scripted weapons with different effects.
I will post the code I have, but I see already some downsides to using this notify as opposed to how let's say the scavenger script works. In the scavenger script the players are all threaded to waittill("projectile_impact") this means even if your projectile hits not one zombie, the point, vector, player can be used for useful things, Like spawning effects, returning the lost ammo, etc. My original question was if anyone knows more about the different player notifications when shooting guns, I know projectile_impact is one but I can find no information on any of the others. I have tried bullet_impact and bullet_small_impact and they don't seem to work but perhaps they are in another format?
Title: Re: Weapon Script[helpmeObiwan]
Post by: Soy-Yo on August 06, 2016, 04:26:21 pm
Thank you very much for a fast reply I appreciate the help. I was able to get the script working and very well to the point that it is seamless in game at detecting zombie damage and type/ weapon. The waittill("death") can also be used instead if you only wanted to do something on death, but my purposes is setting up a basic weapon script which can be used to attach effects, damage events, physics etc to a specific group of weapons being fired. I want to make a base template for lack of better words in which I can make several scripted weapons with different effects.
I will post the code I have, but I see already some downsides to using this notify as opposed to how let's say the scavenger script works. In the scavenger script the players are all threaded to waittill("projectile_impact") this means even if your projectile hits not one zombie, the point, vector, player can be used for useful things, Like spawning effects, returning the lost ammo, etc. My original question was if anyone knows more about the different player notifications when shooting guns, I know projectile_impact is one but I can find no information on any of the others. I have tried bullet_impact and bullet_small_impact and they don't seem to work but perhaps they are in another format?
There is a "weapon_fired" notify on the player every time he fires his weapon. And "grenade_fired" for any grenade thrown: If I'm not wrong grenade is the actual grenade model. There must some more notifies but these are the only ones I can think of right now.
And as for your script, your getting all zombies every 0.1 seconds and threading the function for zombies that has already been "used" (can express it better in English lol, but I think you can understand me). I would recommend you moving the damage_check() function to where zombies are spawned in _zombiemode.gsc: So the function is only called once for each zombie. Or maybe adding a boolean attribute to the zombies and check it before threading the function.
Another thing is that you can thread the function on an entity, so you don't have to pass the zombie as a parameter. You can use: And then get the ai in the other function as self:
Title: Re: Weapon Script[helpmeObiwan]
Post by: BluntStuffy on August 06, 2016, 07:05:29 pm
1.) I have seen from the thundergun and scavenger script and freezegun that the projectile impact notify is used. Are there others (I haven't been able to find any in all the gsc I've searched through) that deal with bullet, explosive, gas impact? or is basically every script weapon limited to using projectile_impact ?
for grenade-weapons, returns the actual grenade, and the weaponfile-name for projectile weapons, returns the impact point of the projectile and the weaponfile-name for any weapon that's using the 'fire-button'. doesn't return anything ( pretty sure ), you can use the getcurrentweapon() function right after it in most cases.. And then there's obv the waittilll damage on zombies themselfs like you allready used:
There are one or two other notify's for grenades ( pullback and explode i think ) but nothing that's really usefull beside's these ones..
Quote
2.) What logic can be used to solve my problem of collecting the zombie shot, the player who shot him, and the weapon used to doSomething(); perhaps I have the idea completely wrong but there is 0 documentation tutorials
And like Soy-Yo mentioned, you want to thread that in another way on zombies, because this way you are threading it on every zombie in the map, also if it's allready been threaded in the previous loop. You could simply add a var to solve that as well:
Title: Re: Weapon Script[helpmeObiwan]
Post by: azrealg on August 06, 2016, 09:15:13 pm
Alright cool, very useful info and I'm sure someone in the future will find all of this helpful too. I will try to get this worked into _zombiemode from what I can see though, the function will need to keep checking. If I only thread it one time when the zombie spawns. It will only thread one time per zombie which would use alot less processing, but not the desired effect.
How about it guys? Is it easier to simply have a seperate script constantly checking zombies or to write a looping function in _zombiemode which keeps looping until the zombie dies?
Title: Re: Weapon Script[helpmeObiwan]
Post by: thezombieproject on August 06, 2016, 10:29:43 pm
What logic can be used to solve my problem of collecting the zombie shot, the player who shot him, and the weapon used to doSomething(); perhaps I have the idea completely wrong but there is 0 documentation tutorials or help on this subject.
cant you simply use zombiemode spawner for this?
go to _zombiemode_spawner.gsc
find FUNCTION...
zombie_gib_on_damage()
add this line under if( !IsDefined( self ) ) { return; }
So it looks like this. (IMAGE) https://gyazo.com/9b8984463fbb0b5f339eab2046168676
next add this to the bottom of the script (change and add whatever checks to this fuction you need )
self.damageWeapon - is the weapon used to damage zombie amount - is the amount of damage caused by weapon attacker - is the player who caused damage type - is the type of damage used to damage zombie
Title: Re: Weapon Script[helpmeObiwan]
Post by: azrealg on August 08, 2016, 08:23:23 pm
Tzp I tried your suggestion worked better than what I had before thanks for the advice, but basically It looks like it is still better for functional reasons that I run a separate while loop outside of the main gscs. Also after making a teleport crossbow weapon and teleing around to test the scripts reliability After hours of testing, what I can see is that if I insert at the gib, death checks and weapons which do not deal damage besides a killing blow or force enemies to start ragdoll sometimes will not return a println and no teleport. There is complications with Harrybo21s newest perk system pack a punch, I think it has to do with his custom trigger script which keeps returning errors with setting hint string for individual players. Regardless when elements of that fail it will sometimes not check at gib or even tagged from spawn like I had the code before with blunty's assistance, for the rest of the game until restart. Which means there is a random chance that any script I do could glitch and not work for the rest of the game. Instead of making checks I decided to go back to a small loop outside of the main script with a small wait. Reliability wise I think that works the best although it may not be as efficient?
Or maybe I'm wrong?, I appreciate the input thanks all.
Title: Re: Weapon Script[helpmeObiwan]
Post by: azrealg on August 08, 2016, 08:27:47 pm
I should mention, that before writing the above message, I tried a function which grabbed enemies damaged, and rethreaded self when still alive. It has the same issues but the added issue of lag. Some guns fire so fast, the script will actually not rethread sometimes and again that means for the entire rest of the game. Also when 6 bullets strike you may get only 3-5 executions of the script if it didn't glitch.