UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: Sounder1995 on September 10, 2016, 01:52:43 am

Title: Infinite Damage Weapon
Post by: Sounder1995 on September 10, 2016, 01:52:43 am
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

Code Snippet
Plaintext
level thread infinite_damage(self.origin, self.attacker);

I then go on to define infinite_damage() at the bottom of the .gsc file as follows:
Code Snippet
Plaintext
infinite_damage(origin, attacker)
{
self endon( "disconnect" );


players = get_players();

while (1)
{
self waittill( "damage", amount, attacker, direction_vec, point, type );
if(attacker GetCurrentWeapon() == "tokarev" )
{
setPlayerIgnoreRadiusDamage( true );
self.attacker radiusDamage( self.origin, 1, self.maxHealth + 666, self.maxhealth + 666, self.attacker, self.damagemod );
setPlayerIgnoreRadiusDamage( false );
self doDamage( self.maxHealth + 666, self.origin, attacker );
// self doDamage( self.maxHealth + 666, self.origin, self );
// self doDamage( self.maxHealth + 666, self.origin, player );
}
/*
for ( i = 0; i < players.size; i++ )
{
// damagemod = zombies[i].damagemod;
// attacker = zombies[i].attacker;
// weapon = zombies[i].damageWeapon;
zombies = getAIArray( "axis");
for ( j = 0; j < zombies.size; j++ )
{

// current_weapon = players[ j ] getCurrentWeapon();
// if(zombies[j].attacker GetCurrentWeapon() == "tokarev" )
// {
self doDamage( self.maxHealth + 666, self.origin, attacker );
// if(current_weapon == "tokarev" )
// {
// zombies[i] doDamage( zombies[i].Health + 666, zombies[i].origin);
// }
}
}
*/
}
}

Anyone know how to properly script this?
Title: Re: Infinite Damage Weapon
Post by: BluntStuffy on September 10, 2016, 02:49:52 am
Code Snippet
Plaintext
level thread infinite_damage(self.origin, self.attacker);


self is 'level' here not a player or a zombie so that where things start to go wrong
Title: Re: Infinite Damage Weapon
Post by: BuIlDaLiBlE on September 10, 2016, 10:22:23 am
self is 'level' here not a player or a zombie so that where things start to go wrong
"level" is a global function here, yea? I know with vars they are global if you use level on them, but what about functions?
Title: Re: Infinite Damage Weapon
Post by: BluntStuffy on September 10, 2016, 11:15:55 am
"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;
}
}

self doDamage( self.maxHealth + 666, self.origin, attacker ); // kill the zombie
}


Title: Re: Infinite Damage Weapon
Post by: Sounder1995 on September 10, 2016, 12:49:23 pm
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;
}
}

self doDamage( self.maxHealth + 666, self.origin, attacker ); // kill the zombie
}



Hooray! It worked! Thanks for the help, BluntStuffy! :) Haven't seen you in SpiderBite's stream in a long time. Hope everything's going alright.
Title: Re: Infinite Damage Weapon
Post by: BuIlDaLiBlE on September 10, 2016, 12:55:57 pm
Not sure what you mean
I mean what is the purpose of that "level" before calling the function?