Hello. I'm trying to create my own infinite damage weapon that fires hitscans, but I can't quite figure out how to script it in. Here's what I've been trying:
Inside nazi_zombie_my_mapname.gsc, inside main() at the very bottom, I have
"level" is a global function here, yea? I know with vars they are global if you use level on them, but what about functions?
Not sure what you mean, but he threaded his function from main() in his mapname.gsc. The main() function is called by 'level' so if you refer to self in there you refer to the level var. If you mean that by using 'level.' you make a var global, and 'level' itself is also global but you cant use a function global if you thread/call it with 'level'
To the OP, for the wepaon you could do something like this ( or just set the damage really high in the weapon file ? ) You could also add your code in _spawner in the gib_on_damage function, that's allready watching each zomb for damage so it's easy to add in there as well.
From your mapname.gsc main() thread this:
Code Snippet
Plaintext
level thread infinite_damage_init();
And then add these functions:
Code Snippet
Plaintext
infinite_damage_init() { while (1) { zombs = getaiarray( "axis" ); for( i=0 ; i<zombs.size ; i++ ) { if( !isdefined( zombs[i].tracked ) ) // make sure we dont thread this function over and over, so we set this to true when we 'track' a zombie { zombs[i].tracked = true; zombs[i] thread infinite_damage_zombs(); } }
wait 0.3; } }
infinite_damage_zombs() // here self is the zombie, because that's the one that threaded this function { self endon( "death" );
while (1) { self waittill( "damage", amount, attacker, direction_vec, point, type ); if( isplayer( attacker ) && attacker GetCurrentWeapon() == "tokarev" && type != "MOD_MELEE" ) // if the damage is done by a player with a tokarev, break the loop { break; } }
Not sure what you mean, but he threaded his function from main() in his mapname.gsc. The main() function is called by 'level' so if you refer to self in there you refer to the level var. If you mean that by using 'level.' you make a var global, and 'level' itself is also global but you cant use a function global if you thread/call it with 'level'
To the OP, for the wepaon you could do something like this ( or just set the damage really high in the weapon file ? ) You could also add your code in _spawner in the gib_on_damage function, that's allready watching each zomb for damage so it's easy to add in there as well.
From your mapname.gsc main() thread this:
Code Snippet
Plaintext
level thread infinite_damage_init();
And then add these functions:
Code Snippet
Plaintext
infinite_damage_init() { while (1) { zombs = getaiarray( "axis" ); for( i=0 ; i<zombs.size ; i++ ) { if( !isdefined( zombs[i].tracked ) ) // make sure we dont thread this function over and over, so we set this to true when we 'track' a zombie { zombs[i].tracked = true; zombs[i] thread infinite_damage_zombs(); } }
wait 0.3; } }
infinite_damage_zombs() // here self is the zombie, because that's the one that threaded this function { self endon( "death" );
while (1) { self waittill( "damage", amount, attacker, direction_vec, point, type ); if( isplayer( attacker ) && attacker GetCurrentWeapon() == "tokarev" && type != "MOD_MELEE" ) // if the damage is done by a player with a tokarev, break the loop { break; } }