So I have a custom script, where it spawns a different random powerup in 4 different locations each game, and to unlock the powerup they have to shoot 3 of the powerup. ie a nuke spawns in the start room, they shoot 3 other nukes, and they unlock it to use whenever they want.
The script works somewhat, but ONLY for the nuke powerup. When it spawns something other than a nuke, when I shoot the powerup, nothing happens, but when the nuke spawns in, I can shoot it just fine.
Also for some reason the FX only works for the powerup that is in the "cage"(tspawn_powerup). Can you actually have the same FX for multiple models at a time?
Try throwing a grenade at it, if it works then I think it is something to do with the models, where some take damage just fine and others don't. I stopped using that setcandamage because of this happening to me. I could be wrong. I found grenades worked but shooting the model didn't. I now wait for players to fire and check bullet trace, and if the player is looking at the object, and a few other things instead. Edit: Or use a trigger.
Also, I think you may want returns after each of your thread decide_tspawn_powerup(); so it doesn't try to spawn_tspawn_powerup(level.tspawn_powerup_model); undefined or the last level vars def.
This isn't the whole script I assume, missing decide_outside_powerup and others stuff, so I can't say what you are actually going for, but it looks like you will randomly select the order that the powerups will spawn, but will not spawn more than one of each?
FYI: Personally I would use an array, randomize it, then go in new order of the array. I would also subtract from total instead of ++ to the number shot, and then check against <= 0. Saves you a variable, and prevents mistakes.
Last Edit: January 06, 2016, 04:54:18 pm by MakeCents
Try throwing a grenade at it, if it works then I think it is something to do with the models, where some take damage just fine and others don't. I stopped using that setcandamage because of this happening to me. I could be wrong. I found grenades worked but shooting the model didn't. I now wait for players to fire and check bullet trace, and if the player is looking at the object, and a few other things instead. Edit: Or use a trigger.
Also, I think you may want returns after each of your thread decide_tspawn_powerup(); so it doesn't try to spawn_tspawn_powerup(level.tspawn_powerup_model); undefined or the last level vars def.
This isn't the whole script I assume, missing decide_outside_powerup and others stuff, so I can't say what you are actually going for, but it looks like you will randomly select the order that the powerups will spawn, but will not spawn more than one of each?
FYI: Personally I would use an array, randomize it, then go in new order of the array. I would also subtract from total instead of ++ to the number shot, and then check against <= 0. Saves you a variable, and prevents mistakes.
ya the decide_outside_powerup is for the 2nd powerup to spawn in. and ya it will not spawn more than one of each.
I use to have it set up with the trigger_damage but since the models are different sizes. It only worked if the player shot in one specific spot, so I decided to try this setcandamage.
If I decide to do it with the bullet trace, how would I accomplish that?
EDIT: Just tried with grenades and the powerup does disappear, so I guess it is something to do with the model.
Last Edit: January 06, 2016, 05:54:37 pm by thezombiekilla6
ya the decide_outside_powerup is for the 2nd powerup to spawn in. and ya it will not spawn more than one of each.
I use to have it set up with the trigger_damage but since the models are different sizes. It only worked if the player shot in one specific spot, so I decided to try this setcandamage.
If I decide to do it with the bullet trace, how would I accomplish that?
EDIT: Just tried with grenades and the powerup does disappear, so I guess it is something to do with the model.
Well, you could waittill each player "weapon_fired" and then check if they can see the powerup. You would get the powerup ent and thread a function that checked if they could see the powerup atm Something like this: (I edited some old functions I had available atm)
Well, you could waittill each player "weapon_fired" and then check if they can see the powerup. You would get the powerup ent and thread a function that checked if they could see the powerup atm Something like this: (I edited some old functions I had available atm)
It registers that I "shot the powerup" even if I wasnt aiming at it. So every time I shoot it acts like I am shooting at the powerup
I can check tonight if I modified that function or not. I added an isdefined check to the one function up above to make sure its a good object. Get back to you later on that function then.
Edit: commented out the damagecone function call, I don't use it currently anymore, maybe that was something...
Last Edit: January 06, 2016, 07:01:29 pm by MakeCents
I can check tonight if I modified that function or not. I added an isdefined check to the one function up above to make sure its a good object. Get back to you later on that function then.
Edit: commented out the damagecone function call, I don't use it currently anymore, maybe that was something...
I'd have to see your new script. I don't see why it would do that unless something was undefined, or something like that. I could be missing it though, that happens. I'm pretty sure that CanSeePowerup function is fine, but I never turned my pc on last night, passed out. I'll double check if I make it tonight.
This is the function I modified that I use in my hint system and it works:
Code Snippet
Plaintext
canSeeThisEnt(trig){//ent canSeeThisEnt(ent); self endon("disconnect"); //if(!self IsTouching(trig)) return false;//commented this out cause it's not relevant to your powerups if(distance2D(self.origin,trig.origin)<10) return true;//give me leeway if(!bulletTracePassed(self.origin,trig.origin,false,undefined)) return false; //Checks if player is at good angle angles = vectortoAngles(trig.origin - self.origin); trigangle = angles[1]; myangle = self.angles[1]; if(trigangle > 180) trigangle = trigangle - 360; looking = (myangle-trigangle); if(looking>340) looking = looking - 360; if(looking < -340) looking = looking + 360; if(looking > -35 && looking < 35 ) return 1; return 0; }
I don't see any differences.....
Edit: Could add some isdefined's to troubleshoot?
Code Snippet
Plaintext
CanSeePowerup(powerup){ self endon("disconnect"); if(!self DamageConeTrace(powerup.origin,self)) return false; if(!bulletTracePassed(self.origin,powerup.origin,false,undefined)) return false; //Checks if player is at good angle if(!IsDefined( trig.origin )) IPrintLn( "trig origin not defined" ); if(!IsDefined( self.origin )) IPrintLn( "self origin not defined" ); angles = vectortoAngles(powerup.origin - self.origin); trigangle = angles[1]; myangle = self.angles[1]; if(trigangle > 180) trigangle = trigangle - 360; looking = (myangle-trigangle); if(!IsDefined( looking )) IPrintLn( "looking is not defined" ); else IPrintLn( looking, " is looking" ); if(looking>340) looking = looking - 360; if(looking < -340) looking = looking + 360; IPrintLn( "Made it to decision time" ); if(looking > -35 && looking < 35 ) return 1; return 0; }
Last Edit: January 07, 2016, 07:07:10 pm by MakeCents
trace["position"] -> impact point of the bullet trace trace["entity"] -> if a model ( or player/zombie) is hit it will be defined like this trace["surface"] -> surface type if the hit brush/ent ( for impact fx for example ) trace["normal"] -> the normal angle of the impact surface ( again for example to play impact fx at the correct angle )
I use to have it set up with the trigger_damage but since the models are different sizes. It only worked if the player shot in one specific spot, so I decided to try this setcandamage.
Why don't you create one trigger_damage for each powerup (with its size) and move them to the powerup origin?
Why don't you create one trigger_damage for each powerup (with its size) and move them to the powerup origin?
I was thinking something similar when he first posted, but I was thinking of linking the trigger to the model. Then I wasn't sure if he was having multiple ones or not. 3 powerups, times 4 positions =12 ents plus the 4 position ents already... Idk, I guess I go overboard when counting assets and watching limits sometimes, lol. But really, one trigger about the average size prob would be good enough and the easiest.
Also, you can try this and see what it does for you, never works for me, always returned true: (replaced my function with isLookingAt function call)
Code Snippet
Plaintext
CheckFire(){ self endon("disconnect"); self endon("checkfire"); while(1){ self waittill("weapon_fired"); //if(!IsSubStr(self getCurrentWeapon(),"specific gun")) continue; powerups = GetEntArray("tspawn_collect_powerup","targetname"); if(isDefined(powerups) && powerups.size>0){ for(i=0;i<powerups.size;i++){ if(self isLookingAt(powerups[i])) iPrintLnBold("shot powerup");//modify this to do what you want } } } }
Last Edit: January 07, 2016, 07:42:35 pm by MakeCents
Why don't you create one trigger_damage for each powerup (with its size) and move them to the powerup origin?
I was going to do that but frankly, I already have way too many triggers in the map doing different stuff. Didnt really want to add 4 more triggers(probably close to limit anyway)
I was going to do that but frankly, I already have way too many triggers in the map doing different stuff. Didnt really want to add 4 more triggers(probably close to limit anyway)
You can use this temporarily to check your ents. Stay below 900 and you won't have Gspawn issues unless you spawn stuff a lot or in a loop by mistake where you'll get it no matter what then...