Jump to content
Come try out the Arcade, Link at the top of the website ×

Recommended Posts


  • Member ID:  907
  • Group:  ***- Inactive Clan Members
  • Followers:  96
  • Topic Count:  126
  • Topics Per Day:  0.02
  • Content Count:  2731
  • Content Per Day:  0.49
  • Reputation:   3928
  • Achievement Points:  26177
  • Solved Content:  0
  • Days Won:  13
  • Joined:  12/20/09
  • Status:  Offline
  • Last Seen:  
  • Birthday:  02/10/1969
  • Device:  Windows

Posted

Anyone have a working COD4 example of a drowning script for water? 

 

I could only find one tut online, and it's for COD2.  It looks like it MOSTLY works, but I have some non-starter bugs I don't feel like figuring out how to fix (it would involve me actually learning how to script instead of just hacking up other people's scripts. :)).

 

I know I had this working once before but have lost that data. :(



  • Member ID:  3036
  • Group:  ***- Inactive Clan Members
  • Followers:  32
  • Topic Count:  219
  • Topics Per Day:  0.04
  • Content Count:  9419
  • Content Per Day:  1.92
  • Reputation:   7515
  • Achievement Points:  62539
  • Solved Content:  0
  • Days Won:  21
  • Joined:  11/29/11
  • Status:  Offline
  • Last Seen:  
  • Birthday:  04/26/2008
  • Device:  Windows

Posted

Yea the script looks like it should work fine. However I would change the names of the progress bar hud elements to something with the mapname so they dont conflict with mods. Also only do one hud element if possible instead of three to save on hud assets.



  • Member ID:  907
  • Group:  ***- Inactive Clan Members
  • Followers:  96
  • Topic Count:  126
  • Topics Per Day:  0.02
  • Content Count:  2731
  • Content Per Day:  0.49
  • Reputation:   3928
  • Achievement Points:  26177
  • Solved Content:  0
  • Days Won:  13
  • Joined:  12/20/09
  • Status:  Offline
  • Last Seen:  
  • Birthday:  02/10/1969
  • Device:  Windows

Posted

This is the script I am using:

 

main()
{
    precacheShader("white");
    level.drown_barsize = 288;
    level.drown_time = 8;
    level.drown_hurttime = 6;

    drownage = getentarray("drown","targetname");
    for(d=0;d<drownage.size;d++)
        drownage[d] thread water();
}

water()
{
    self.ceiling = getent(self.target,"targetname");
    while(1)
    {
        self waittill("trigger", player);
        if(player.sessionstate == "playing" && !player isTouching(self.ceiling) && !isDefined(player.drowning))
            player thread drown(self);
    }
}

drown(trigger)
{
    self endon("disconnect");

    self.drowning = true;
    wait 0.15;

    water_vision = newClientHudElem(self);
    water_vision.x = 0;
    water_vision.y = 0;
    water_vision.alignX = "left";
    water_vision.alignY = "top";
    water_vision.horzAlign = "fullscreen";
    water_vision.vertAlign = "fullscreen";
    water_vision.sort = 0;
    water_vision.alpha = 0.75;
    water_vision.color = (0.16, 0.38, 0.5);
    water_vision setshader ("white", 640, 480);

    drown_bar_back = newClientHudElem(self);
    drown_bar_back.x = 320;
    drown_bar_back.y = 385;
    drown_bar_back.alignX = "center";
    drown_bar_back.alignY = "middle";
    drown_bar_back.alpha = 0.5;
    drown_bar_back.sort = 1;
    drown_bar_back.color = (0,0,0);
    drown_bar_back setShader("white", (level.drown_barsize + 4), 14);

    drown_bar = newClientHudElem(self);
    drown_bar.x = (320 - (level.drown_barsize / 2));
    drown_bar.y = 385;
    drown_bar.alignX = "left";
    drown_bar.alignY = "middle";
    drown_bar.alpha = 1;
    drown_bar.sort = 2;
    drown_bar.color = (1,1,1);
    drown_bar setShader("white", 1, 8);
    drown_bar scaleOverTime(level.drown_time, level.drown_barsize, 8);

    underwatertime = 0;
    damagetime = 0;
    while(self.sessionstate == "playing" && self isTouching(trigger) && !self isTouching(trigger.ceiling) && underwatertime < level.drown_time)
    {
        wait 0.05;
        underwatertime += 0.05;
        damagetime++;
        if(underwatertime >= level.drown_hurttime && damagetime >= 4)
        {
            radiusDamage(self.origin,9,1,1);
            damagetime = 0;
        }
    }

    if(self.sessionstate == "playing" && underwatertime >= level.drown_time) // Been underwater for too long
    {
        water_vision destroy();
        radiusDamage(self.origin,22, 3000, 3000);
        deathmethod[0] = " made a hole in the water and lay down quietly to rest forever.";
        deathmethod[1] = " paid a long lasting visit to Davy Jones's Locker.";
        deathmethod[2] = " went diving without breathing apparatus.";
        deathmethod[3] = " swam like a brick.";
        iPrintln(self.name + deathmethod[randomInt(deathmethod.size)]);
    }
    else if(self.sessionstate == "playing" && underwatertime < level.drown_time) // Came up for air
    {
        water_vision.alpha = 0.5;
        water_vision fadeOverTime(3);
        water_vision.alpha = 0;
        water_vision thread destroyaftertime(self);
    }
    else // Died or went to spectators while underwater
        water_vision destroy();

    drown_bar_back destroy();
    drown_bar destroy();
    self.drowning = undefined;
}

destroyaftertime(player)
{
    player endon("disconnect");
    wait 3;
    self destroy();
}

 

When I load the map I get this error:

 

"cannot cast undefined to string: (file 'maps/mp/mp_xi_bedlam_drown.gsc', line 15)

self.ceiling = getent(self.target,"targetname");

 

...



  • Member ID:  21469
  • Group:  ***- Inactive Clan Members
  • Followers:  4
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  204
  • Content Per Day:  0.05
  • Reputation:   176
  • Achievement Points:  1800
  • Solved Content:  0
  • Days Won:  0
  • Joined:  11/02/14
  • Status:  Offline
  • Last Seen:  
  • Birthday:  10/11/1972

Posted (edited)

the one on modsonline should work

 

http://modsonline.com/Forums-top-102885.html

Edited by Icey
Awards


  • Member ID:  907
  • Group:  ***- Inactive Clan Members
  • Followers:  96
  • Topic Count:  126
  • Topics Per Day:  0.02
  • Content Count:  2731
  • Content Per Day:  0.49
  • Reputation:   3928
  • Achievement Points:  26177
  • Solved Content:  0
  • Days Won:  13
  • Joined:  12/20/09
  • Status:  Offline
  • Last Seen:  
  • Birthday:  02/10/1969
  • Device:  Windows

Posted

the one on modsonline should work

 

http://modsonline.com/Forums-top-102885.html

 

Yeah that's exactly the script above.... I am pretty sure I did everything in the map correctly.  My trigger is a trigger.multiple with the targetname set to "drown."



  • Member ID:  3036
  • Group:  ***- Inactive Clan Members
  • Followers:  32
  • Topic Count:  219
  • Topics Per Day:  0.04
  • Content Count:  9419
  • Content Per Day:  1.92
  • Reputation:   7515
  • Achievement Points:  62539
  • Solved Content:  0
  • Days Won:  21
  • Joined:  11/29/11
  • Status:  Offline
  • Last Seen:  
  • Birthday:  04/26/2008
  • Device:  Windows

Posted (edited)

    self.ceiling = getent(self.target,"targetname");

 

That is likely wrong, Like 15.

 

self.target I assume is the trigger entity in this case for the ceiling part. Likely the drowning part set the target as the ceiling entity. Which is how heli nodes work. The target is the next node in the chain. The ceiling entity needs a targetname so the line can find it.

Edited by Sammy


  • Member ID:  907
  • Group:  ***- Inactive Clan Members
  • Followers:  96
  • Topic Count:  126
  • Topics Per Day:  0.02
  • Content Count:  2731
  • Content Per Day:  0.49
  • Reputation:   3928
  • Achievement Points:  26177
  • Solved Content:  0
  • Days Won:  13
  • Joined:  12/20/09
  • Status:  Offline
  • Last Seen:  
  • Birthday:  02/10/1969
  • Device:  Windows

Posted

Yeah I am wondering if the way they did the ceiling to avoid the "water vision" when your feet are in the water but not your head is the best way to do it.

 

Anyway I took the ceiling references out of the script and it works fine - but the caveat is that if your feet are in ankle deep water you are drowning.  I'm considering just moving the trigger brushes so they are deeper in the water instead of right at the surface... of course this then brings up the issue of people crouching on the edges.  But you can't shoot through my water, so maybe it will be okay.  I'll test it out.



  • Member ID:  907
  • Group:  ***- Inactive Clan Members
  • Followers:  96
  • Topic Count:  126
  • Topics Per Day:  0.02
  • Content Count:  2731
  • Content Per Day:  0.49
  • Reputation:   3928
  • Achievement Points:  26177
  • Solved Content:  0
  • Days Won:  13
  • Joined:  12/20/09
  • Status:  Offline
  • Last Seen:  
  • Birthday:  02/10/1969
  • Device:  Windows

Posted

SO I guess my question now is... how do I check to see if the player's head is under water....



  • Member ID:  907
  • Group:  ***- Inactive Clan Members
  • Followers:  96
  • Topic Count:  126
  • Topics Per Day:  0.02
  • Content Count:  2731
  • Content Per Day:  0.49
  • Reputation:   3928
  • Achievement Points:  26177
  • Solved Content:  0
  • Days Won:  13
  • Joined:  12/20/09
  • Status:  Offline
  • Last Seen:  
  • Birthday:  02/10/1969
  • Device:  Windows

Posted (edited)

Ignore my last e-mail I understand it now.  Basically the ceiling is the top of the water, so I made a trigger brush and put it above the water, and made it a trigger.multiple, then gave it a targetname of ceiling.  In the script, I need to check that the player is touching the "drown" targetname, but NOT touching the "ceiling" targetname at the same time.  The only way they could do that, is if they are under the ceiling brush, and in the water.... duh.

 

So now it works the way it's supposed to.  Once I created the trigger brush and gave it a targetname, I just changed this line:

 

self.ceiling = getent(self.target,"targetname");

 

To this:

 

self.ceiling = getent("ceiling","targetname");

Edited by Bogleg


  • Member ID:  3036
  • Group:  ***- Inactive Clan Members
  • Followers:  32
  • Topic Count:  219
  • Topics Per Day:  0.04
  • Content Count:  9419
  • Content Per Day:  1.92
  • Reputation:   7515
  • Achievement Points:  62539
  • Solved Content:  0
  • Days Won:  21
  • Joined:  11/29/11
  • Status:  Offline
  • Last Seen:  
  • Birthday:  04/26/2008
  • Device:  Windows

Posted

For future reference you can also do it by just getting the eye position of the player instead of putting dual triggers all over the place. The player is in the water trigger. Use the Z origin of the trigger. Add its height. Then see if the eye is above it. If the eye doesnt work you can also use the player origin and add an offset based on stance.

 

eye = player getEye();

if( eye[2] > trigger.origin[2] + Zoffset ) )

continue;

else

player startDrowning();



  • Member ID:  3773
  • Group:  ***- Inactive Clan Members
  • Followers:  39
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  3138
  • Content Per Day:  0.68
  • Reputation:   2983
  • Achievement Points:  24456
  • Solved Content:  0
  • Days Won:  10
  • Joined:  10/06/12
  • Status:  Offline
  • Last Seen:  
  • Birthday:  11/03/1966

Posted

Nice read.

 

Thank you, Programmers of >Xi<! Ayaq



  • Member ID:  390
  • Group:  ***- Inactive Clan Members
  • Followers:  32
  • Topic Count:  411
  • Topics Per Day:  0.07
  • Content Count:  4252
  • Content Per Day:  0.74
  • Reputation:   3052
  • Achievement Points:  35639
  • Solved Content:  0
  • Days Won:  7
  • Joined:  09/14/09
  • Status:  Offline
  • Last Seen:  
  • Birthday:  05/08/1959
  • Device:  Windows

Posted

Hmmmmmmmmmmmmmmmmmmm ok and I want to learn to map? HeeeeeeeeeeeeeeeeeeeeeeeeHaaaaaaaaaaaaaaaaaaW!



  • Member ID:  21469
  • Group:  ***- Inactive Clan Members
  • Followers:  4
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  204
  • Content Per Day:  0.05
  • Reputation:   176
  • Achievement Points:  1800
  • Solved Content:  0
  • Days Won:  0
  • Joined:  11/02/14
  • Status:  Offline
  • Last Seen:  
  • Birthday:  10/11/1972

Posted

Hmmmmmmmmmmmmmmmmmmm ok and I want to learn to map? HeeeeeeeeeeeeeeeeeeeeeeeeHaaaaaaaaaaaaaaaaaaW!

 

 

best is to start here, pick the game u wanna make a map for and start reading and testing.

this site will become your best friend when u want to make a map.

 

http://wiki.modsrepository.com/index.php?title=Main_Page

Awards

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.