UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Infinite Damage Weapon

broken avatar :(
Created 8 years ago
by Sounder1995
0 Members and 1 Guest are viewing this topic.
3,988 views
broken avatar :(
×
broken avatar :(
Location: usPennyslvania, United States
Date Registered: 25 October 2015
Last active: 7 years ago
Posts
63
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Just a gamer and modding novice...
Signature
"All life's a Transformers movie; no one knows what's going on. " - Sounder 2015
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?
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 1 year ago
Posts
1,187
Respect
1,404Add +1
Forum Rank
Zombie Colossus
Primary Group
Community Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
Signature
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntstuffy@BluntZombieBluntStuffyStuffyZombie
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
broken avatar :(
×
broken avatar :(
Location: ruMoscow
Date Registered: 30 July 2013
Last active: 2 months ago
Posts
152
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
×
BuIlDaLiBlE's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
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?
Marked as best answer by Sounder1995 8 years ago
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 1 year ago
Posts
1,187
Respect
1,404Add +1
Forum Rank
Zombie Colossus
Primary Group
Community Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntstuffy@BluntZombieBluntStuffyStuffyZombie
"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
}


Last Edit: September 10, 2016, 11:17:03 am by BluntStuffy
broken avatar :(
×
broken avatar :(
Location: usPennyslvania, United States
Date Registered: 25 October 2015
Last active: 7 years ago
Posts
63
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Just a gamer and modding novice...
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.
broken avatar :(
×
broken avatar :(
Location: ruMoscow
Date Registered: 30 July 2013
Last active: 2 months ago
Posts
152
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
×
BuIlDaLiBlE's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Not sure what you mean
I mean what is the purpose of that "level" before calling the function?

 
Loading ...