UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: HitmanVere on June 12, 2015, 10:18:46 pm

Title: MOTD grenade disposal
Post by: HitmanVere on June 12, 2015, 10:18:46 pm
I was thinking of doing MOTD grenade disposal system, but more "futuristic". I know how to give players points with
Code Snippet
Plaintext
maps\_zombiemode_score::minus_to_player_score( cost );
But how would I go with trigger noticing grenades and then deleting them?
Title: Re: MOTD grenade disposal
Post by: Andy Whelan on June 12, 2015, 10:31:44 pm
I was thinking of doing MOTD grenade disposal system, but more "futuristic". I know how to give players points with
Code Snippet
Plaintext
maps\_zombiemode_score::minus_to_player_score( cost );
But how would I go with trigger noticing grenades and then deleting them?

This was the script I wanted as well but I forgot about it, lol
Title: Re: MOTD grenade disposal
Post by: Harry Bo21 on June 12, 2015, 10:43:01 pm
i did this with cherry

player.score += 20;
then some function about the hud from zombiemode_score ();
Title: Re: MOTD grenade disposal
Post by: HitmanVere on June 12, 2015, 10:56:01 pm
i did this with cherry

player.score += 20;
then some function about the hud from zombiemode_score ();

Not really what I was asking for, lol. But thanks for info
Title: Re: MOTD grenade disposal
Post by: Harry Bo21 on June 12, 2015, 11:20:25 pm
Not really what I was asking for, lol. But thanks for info
whoops, i read again

youd need a trigger damage and a "waittill" to detect if its damaged, then a check to make sure its a grenade that hit it
Title: Re: MOTD grenade disposal
Post by: HitmanVere on June 12, 2015, 11:27:27 pm
whoops, i read again

youd need a trigger damage and a "waittill" to detect if its damaged, then a check to make sure its a grenade that hit it

Something like this?
Code Snippet
Plaintext
ent waittill("trigger", player);
if(player getCurrentWeapon() == stielhandgranate)
player maps\_zombiemode_score::minus_to_player_score( 20 );
Dunno, if that would work, lol, atleast from distances
Title: Re: MOTD grenade disposal
Post by: Harry Bo21 on June 12, 2015, 11:28:13 pm
looks ok, except it would take not give 20 points, is that what you wanted?
Title: Re: MOTD grenade disposal
Post by: HitmanVere on June 12, 2015, 11:31:50 pm
looks ok, except it would take not give 20 points, is that what you wanted?

Whoops, yeah, need to set it as -20, lol. How can I then remove the grenade like in MOTD?
Title: Re: MOTD grenade disposal
Post by: Harry Bo21 on June 12, 2015, 11:33:48 pm
i cant remember exactly, but if you take a look at the better script, in there it shows you how to reference the betty itself

Otherwise i will look into it when i get back home, prob wont be too hard to get what you want

were talking about the pit under the first dogs head in motd right?
Title: Re: MOTD grenade disposal
Post by: HitmanVere on June 12, 2015, 11:35:50 pm
i cant remember exactly, but if you take a look at the better script, in there it shows you how to reference the betty itself

Otherwise i will look into it when i get back home, prob wont be too hard to get what you want

were talking about the pit under the first dogs head in motd right?

Yes, that thing. Dunno, if betty script would work, since in same script it sets it, but in this the model is set in weaponfile
Title: Re: MOTD grenade disposal
Post by: Harry Bo21 on June 12, 2015, 11:39:34 pm
The betty model in the file isnt used, but it still exists. They just set a "fake model" in the same place as the original placed model is, not sure why

but i remember you could access teh grenade that you fired

like :

grenade detonate()

would make it explode, grenade delete(), would just remove it, but you have to do the waittill before it correctly ( I would show you what i mean but im on my work pc, not at home ;) ), thats the only part youll need from the betty script
Title: Re: MOTD grenade disposal
Post by: lilrifa on June 13, 2015, 12:04:55 am
Code Snippet
Plaintext
watch_for_grenade()
{
self endon( "death" );
self endon( "disconnect" );

for (;;)
{
self waittill ( "grenade_fire", grenade, weaponName, parent );

switch( weaponName )
{
case "steilhandgrenate":
grenade disposal(self);
break;
}
}

}

disposal(player, trigger_targetname) {
for(;;) {
trig = getEnt("targetname", trigger_targetname);
trig waittill("trigger", who);
who maps\_zombiemode_score::add_to_player_score(20);
self delete();
player IPrintLnBold("Deleting Grenade");
}
}

If you thread that function in your mapname.gsc, it should wait until you've thrown a grenade, and then it should check for a grenade hitting the trigger. After the grenade hits, it will both delete the grenade so that it does not explode, and give the player 20 points.

Edit: Make sure to thread it on a player
Title: Re: MOTD grenade disposal
Post by: HitmanVere on June 13, 2015, 12:10:19 am
Code Snippet
Plaintext
watch_for_grenade()
{
self endon( "death" );
self endon( "disconnect" );

for (;;)
{
self waittill ( "grenade_fire", grenade, weaponName, parent );

switch( weaponName )
{
case "steilhandgrenate":
grenade disposal(self);
break;
}
}

}

disposal(player, trigger_targetname) {
for(;;) {
trig = getEnt("targetname", trigger_targetname);
trig waittill("trigger", who);
who maps\_zombiemode_score::add_to_player_score(20);
self delete();
player IPrintLnBold("Deleting Grenade");
}
}

If you thread that function in your mapname.gsc, it should wait until you've thrown a grenade, and then it should check for a grenade hitting the trigger. After the grenade hits, it will both delete the grenade so that it does not explode, and give the player 20 points.

Will test this tomorrow, thanks. Although I dont get this part:
Code Snippet
Plaintext
trig = getEnt("targetname", trigger_targetname);
Do I change that and also in function name?
Title: Re: MOTD grenade disposal
Post by: lilrifa on June 13, 2015, 12:12:26 am
I used trigger_targetname as a variable, so you can pass different triggers through the function. Just change it from trigger_targetname to the targetname of your trigger in the watch_for_grenade() function, and you should be all set.
Title: Re: MOTD grenade disposal
Post by: HitmanVere on June 13, 2015, 12:15:29 am
I used trigger_targetname as a variable, so you can pass different triggers through the function. Just change it from trigger_targetname to the targetname of your trigger in the watch_for_grenade() function, and you should be all set.

Alright, thanks, will test tomorrow
Title: Re: MOTD grenade disposal
Post by: Harry Bo21 on June 13, 2015, 01:33:05 am
Code Snippet
Plaintext
self waittill ( "grenade_fire", grenade,

^ and thats the part i was searching for :)

"grenade" will then reference that object for the rest of that function :)
Title: Re: MOTD grenade disposal
Post by: lilrifa on June 13, 2015, 01:40:04 am
Sorry, that script was more adjusted for Black Ops. Here's one that's more World at War oriented.

Code Snippet
Plaintext
watch_for_grenade()
{
self endon( "death" );
self endon( "disconnect" );

for (;;)
{
self waittill("grenade_fire",grenade,weapname);
self IPrintLnBold(weapname);
if(weapname == "fraggrenade" || weapname == "Stielhandgranate") {
self IPrintLnBold("Grenade Thrown");
grenade thread disposal(self, "grenade_check_trig");
}
}
}

disposal(player, trigger_targetname) {
player IPrintLnBold("Checking for trig");
trig = getEnt(trigger_targetname, "targetname");
checking = 1;
while(checking) {
wait(0.05);

if(self isTouching(trig)) {
player maps\_zombiemode_score::add_to_player_score(20);
self delete();
player IPrintLnBold("Deleting Grenade");
}

checking = 0;
}
}
Title: Re: MOTD grenade disposal
Post by: MZslayer11 on June 13, 2015, 01:58:11 am
*bookmarks for later use*
Title: Re: MOTD grenade disposal
Post by: lilrifa on June 13, 2015, 03:09:49 am
*bookmarks for later use*

If you do use it, make sure to credit me please. Also, if you need any script requests, I may be able to help.
Title: Re: MOTD grenade disposal
Post by: MZslayer11 on June 13, 2015, 03:18:39 am
If you do use it, make sure to credit me please. Also, if you need any script requests, I may be able to help.

I may just be using the part that disables the grenade if it touches the trigger, for the lava on town. If I use any part of the script I will definitely give you credit.  ;)
Title: Re: MOTD grenade disposal
Post by: lilrifa on June 13, 2015, 03:47:32 am
I may just be using the part that disables the grenade if it touches the trigger, for the lava on town. If I use any part of the script I will definitely give you credit.  ;)

Thanks, man!
Title: Re: MOTD grenade disposal
Post by: DidUknowiPwn on June 13, 2015, 07:31:22 am
What's this grenade disposal you speak of
Title: Re: MOTD grenade disposal
Post by: Harry Bo21 on June 13, 2015, 08:01:48 am
the pit thing in MOTD, you throw grenades in it, they burn up and give you 20 points for each one thrown

same pit you throw the axe in to upgrade it
Title: Re: MOTD grenade disposal
Post by: HitmanVere on June 13, 2015, 09:01:00 am
Sorry, that script was more adjusted for Black Ops. Here's one that's more World at War oriented.

Code Snippet
Plaintext
watch_for_grenade()
{
self endon( "death" );
self endon( "disconnect" );

for (;;)
{
self waittill("grenade_fire",grenade,weapname);
self IPrintLnBold(weapname);
if(weapname == "fraggrenade" || weapname == "Stielhandgranate") {
self IPrintLnBold("Grenade Thrown");
grenade thread disposal(self, "grenade_check_trig");
}
}
}

disposal(player, trigger_targetname) {
player IPrintLnBold("Checking for trig");
trig = getEnt(trigger_targetname, "targetname");
checking = 1;
while(checking) {
wait(0.05);

if(self isTouching(trig)) {
player maps\_zombiemode_score::add_to_player_score(20);
self delete();
player IPrintLnBold("Deleting Grenade");
}

checking = 0;
}
}

This method does not work btw, no iPrints or anything
Title: Re: MOTD grenade disposal
Post by: lilrifa on June 13, 2015, 09:11:43 am
I tested it, and it worked for me.

Double Post Merge: June 13, 2015, 09:21:39 am
I threaded it after _zombiemode::main() by doing
Code Snippet
Plaintext
p = get_players();
for(i=0;i<p.size;i++) {
  p[i] thread watch_for_grenade();
        p[i] IPrintLnBold("Player Connected");
}

And the two functions are at the bottom of my mapname.gsc

Code Snippet
Plaintext
watch_for_grenade()
{
self endon( "death" );
self endon( "disconnect" );

for (;;)
{
self waittill("grenade_fire",grenade,weapname);
self IPrintLnBold(weapname);
if(weapname == "fraggrenade" || weapname == "Stielhandgranate") {
self IPrintLnBold("Grenade Thrown");
grenade thread disposal(self, "grenade_check_trig");
}
}
}

disposal(player, trigger_targetname) {
player IPrintLnBold("Checking for trig");
trig = getEnt(trigger_targetname, "targetname");
checking = 1;
while(checking) {
wait(0.05);

if(self isTouching(trig)) {
player maps\_zombiemode_score::add_to_player_score(20);
self delete();
player IPrintLnBold("Deleting Grenade");
}

checking = 0;
}
}
Title: Re: MOTD grenade disposal
Post by: HitmanVere on June 13, 2015, 09:30:13 am
I tested it, and it worked for me.

Double Post Merge: June 13, 2015, 09:21:39 am
I threaded it after _zombiemode::main() by doing
Code Snippet
Plaintext
p = get_players();
for(i=0;i<p.size;i++) {
  p[i] thread watch_for_grenade();
        p[i] IPrintLnBold("Player Connected");
}

And the two functions are at the bottom of my mapname.gsc

Code Snippet
Plaintext
watch_for_grenade()
{
self endon( "death" );
self endon( "disconnect" );

for (;;)
{
self waittill("grenade_fire",grenade,weapname);
self IPrintLnBold(weapname);
if(weapname == "fraggrenade" || weapname == "Stielhandgranate") {
self IPrintLnBold("Grenade Thrown");
grenade thread disposal(self, "grenade_check_trig");
}
}
}

disposal(player, trigger_targetname) {
player IPrintLnBold("Checking for trig");
trig = getEnt(trigger_targetname, "targetname");
checking = 1;
while(checking) {
wait(0.05);

if(self isTouching(trig)) {
player maps\_zombiemode_score::add_to_player_score(20);
self delete();
player IPrintLnBold("Deleting Grenade");
}

checking = 0;
}
}

Alright, iPrints do show now, but grenade does not get removed nor does it give points
Edit: Doesnt print Deleting grenade either
Another edit: It works on certain angle 0_0
Title: Re: MOTD grenade disposal
Post by: lilrifa on June 13, 2015, 09:37:58 am
I noticed that as well, however I could not resolve the issue.
Title: Re: MOTD grenade disposal
Post by: HitmanVere on June 13, 2015, 09:38:54 am
I noticed that as well, however I could not resolve the issue.

Might be with size of trigger, dunno. Oh well, solved
Title: Re: MOTD grenade disposal
Post by: lilrifa on June 13, 2015, 09:46:54 am
Alrighty