Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Request placeable barricades?
#1
Hey, could someone release a tutorial on how to make placeable barricades for zombie mods or pm me how to do it. Thanks.
Reply

#2
Spawn model, linkTo(player), wait until key pressed, unlink?
Like this, at 1:18 min
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#3
i see, thanks will see what i can do Tongue
Reply

#4
Here's my code from this mod.
I used bipo's code
Code:
#include common_scripts\utility;
#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;
#include zom\include\_functions;

giveBarrel(type)
{
    if(self.isHoldBarricade == false)
    {
        self.isHoldBarricade = true;
    
        if (!isdefined(type))
        type = 0;
        
        level.barrels[type] ++;
        self.carryObj = spawn("script_model", (0,0,0));
        self.carryObj.origin = self.origin + AnglesToForward(self.angles)*48;
        self.carryObj.master = self;
        
        
        self.carryObj.type = type;

        self.carryObj.maxhp = 200;
        if (self.carryObj.type == 1)
        {
            self.carryObj setmodel("global_explosive_barrel");
            level.held_mg++;
            self.carryObj.maxhp = 60;
            self.carryObj linkto(self);
        }
        else if (self.carryObj.type == 2)
        {
            self.carryObj setmodel("p_glo_barricade_wood_barb_pow");
            self.carryObj.angles = (self.angles - (0,180,0));
            level.held_bar++;
            self.carryObj linkto(self);
            
        }
        else if (self.carryObj.type == 3)
        {
            self.carryObj setmodel("mp_supplydrop_boobytrapped_nc");
            self.carryObj.angles = (self.angles - (0,180,0));
            self.carryObj.origin = self.carryObj.origin + (0,0,20);
            self.carryObj linkto(self);
            level.held_bar1++;
        }
        else if (self.carryObj.type == 4)
        {
            self.carryObj setmodel("tombstone2");
            self.carryObj.angles = (self.angles - (0,180,0));
            self.carryObj.origin = self.carryObj.origin;
            
            self.carryObj linkto(self);
        }
        else if(self.carryObj.type == 5)
        {
            self.carryObj setmodel("mp_supplydrop_boobytrapped_nc");

            self.carryObj.angles = (self.angles - (0,180,0));
            self.carryObj.origin = self.carryObj.origin + (0,0,20);
            
            self.carryObj linkto(self);
            level.held_bar1++;
        }
        else if (self.carryObj.type == 6)
        {
            self.carryObj setmodel("global_explosive_barrel");
            level.held_mg++;
            self.carryObj.maxhp = 60;
            self.carryObj linkto(self);
        }
        
        self.carryObj.hp = self.carryObj.maxhp;
        wait .1;
        self.canUse = false;
        self disableweapons();
        self thread placeBarrel();
    }
    else
    {
        // why not just 'return'?
        self iprintLnBold("You already bought barricade.");
    }
}


cratePhysics()
{
        forcePointVariance = 100.0;
        vertVelocityMin = -10.0;
        vertVelocityMax = 10.0;
      
        forcePointX = RandomFloatRange( 0-forcePointVariance, forcePointVariance );
        forcePointY = RandomFloatRange( 0-forcePointVariance, forcePointVariance );
        forcePoint = ( forcePointX, forcePointY, 0 );
        forcePoint += self.origin;
      
        initialVelocityZ = RandomFloatRange( vertVelocityMin, vertVelocityMax );
        initialVelocity = ( 0, 0, initialVelocityZ );
        self PhysicsLaunch(forcePoint,initialVelocity);
      
        self thread update_crate_velocity();
}

update_crate_velocity()
{
        self endon( "entityshutdown" );
        self endon( "stationary" );
        self.velocity = ( 0,0,0 );
        self.old_origin = self.origin;
        while( IsDefined( self ) )
        {
                self.velocity = ( self.origin - self.old_origin );
                self.old_origin = self.origin;
                wait( 0.01 );
        }
}

makeBarricade()
{
    self.bar_type = 0;
    self.workingPart = 0;
    self.isUsable = 0;
}

placeBarrel()
{
    wait 1;
    self iprintlnbold("^2Press Left Mouse Key for Place Barricade");
    while (1)
    {
        if (self attackbuttonpressed())
        {
            newpos = PlayerPhysicsTrace(self.carryObj.origin, self.carryObj.origin - (0,0,1000));
            
            if (BulletTrace(self GetEye(), newpos, false, self.carryObj)["fraction"] == 1 && BulletTrace(self GetEye(), newpos + (0,0,48), false, self.carryObj)["fraction"] == 1 && BulletTrace(newpos, newpos + (0,0,48), false, self.carryObj)["fraction"] == 1 )
            {
                self.carryObj unlink();
                self thread maps\mp\_medals::processModMedal("MEDAL_ZOMBIE_PLACED");
                logPrint("zomx;placedbars;"+self.name+";\n");
                wait .05;
                playfx( level._effect["zom_elec"], newpos );
                wait .2;
                self.carryObj playsound("zmb_door_slide_open");
                self.carryObj.bar_type = 1;
                self.carryObj.origin = newpos;
                self.carryObj.angles = self.angles;
                level.dynamic_barricades[level.dynamic_barricades.size] = self.carryObj;

                if(self.carryObj.type == 2)
                {
                    self.isHoldBarricade = false;
                    self.carryObj thread doBarrierDamage(self);
                    self.carryObj.angles = (self.angles - (0,90,0));
                    level thread maps\mp\_popups::DisplayTeamMessageToAll( "Placed a shock barrier!", self );
                    level.barss++;
                }
                else if(self.carryObj.type == 1)
                {
                    self.isHoldBarricade = false;
                    self.carryObj thread addObstacle(self, 0.1);
                    self.carryObj.angles = (self.angles - (0,90,0));
                    level thread maps\mp\_popups::DisplayTeamMessageToAll( "Placed a explodable barrel!", self );
                }
                else if(self.carryObj.type == 3)
                {
                    self.carryObj setmodel("mp_supplydrop_boobytrapped");
                    self.isHoldBarricade = false;
                    self.carryObj.angles = (self.angles - (0,0,0));
                    self.carryObj.origin = newpos + (0,0,15);
                    //self.carryObj thread timeout(getDvarInt("zomx_bartime"));
                    self.carryObj thread dmg();
                    level thread maps\mp\_popups::DisplayTeamMessageToAll( "Placed a barricade!", self );
                }
                else if(self.carryObj.type == 4)
                {
                    self.isHoldBarricade = false;
                    self.carryObj.angles = (self.angles - (0,0,0));
                    self.carryObj thread electric_trap_move_switch(self);
                    level thread maps\mp\_popups::DisplayTeamMessageToAll( "Placed a trap!", self );
                }
                else if(self.carryObj.type == 5)
                {
                    self.carryObj setmodel("mp_supplydrop_boobytrapped");
                    self.isHoldBarricade = false;
                    self.carryObj.angles = (self.angles - (0,0,0));
                    self.carryObj.origin = newpos + (0,0,15);
                    self.carryObj thread dmg();
                    self.carryObj thread cratePhysics();
                    level thread maps\mp\_popups::DisplayTeamMessageToAll( "Placed a physical barricade!", self );
                }
                else if (self.carryObj.type == 6)
                {
                    self.isHoldBarricade = false;
                    self.carryObj thread addObstacle(self, 4);
                    self.carryObj addMG();
                    self.carryObj = undefined;
                    
                    level thread maps\mp\_popups::DisplayTeamMessageToAll( "Bought MG Barrel", self );

                }
                self.isHoldBarricade = false;
                iprintln( "^2"+ self.name + " ^2placed a ^1barricade^2." );
                self.carryObj playSound("zmb_metal_repair");
                self.canUse = true;
                self enableweapons();
                wait .1;
                
                return ;
            }
            else
            {
                self iprintlnbold("^1Can not place barricade here!");
            }
            wait 1;
        }
        wait .1;
    }
    
}

addMG()
{
    self.turret = SpawnTurret("auto_turret", self.origin + (0,0,48) + anglestoforward(self.angles)*-6, "auto_gun_turret_mp");
    self.turret setmodel("weapon_m60_MG_Setup");
    self.turret.angles = self.angles;
    self thread deleteMG(40);
}

deleteMG(time)
{
    wait time;
    if (isdefined(self.turret))
    {
        level.held_mg -= 1;
        self.turret delete();
        self delete();
    }
}


doBarrierDamage(owner)
{
    level endon("game_ended");
    self endon( "disconnect" );
    self endon( "death" );
    self thread deleteBarrier(getDvarInt("zomx_bartime"));
    for( ;; )
    {
        wait 0.01;
        extraBoundary = ( 40, 40, 40 );
        for( i = 0; i < level.players.size; i ++ )
        {
            if( isDefined( self ) && level.players[i] IsTouching( self, extraBoundary ) && level.players[i].team == "axis")
            {
                //owner radiusDamage(self.origin, 70, 10, 10, owner);
                owner RadiusDamage( self.origin, 256, 50, 40, owner, "MOD_EXPLOSIVE" );
                level.players[i].diedByBarrel = true;
                wait 2;
            }
        }
        wait .1;
    }
}

deleteBarrier(time)
{
    wait time;
    if (isdefined(self))
    {
    level.held_bar -= 1;
    level.barss -= 1;
    self delete();
    }
}


addObstacle(owner, waittime)
{
    self endon("exploded_barrel");
        self thread barrelDeath(owner, waittime);
        wait .1;
}

barrelDeath(owner, item)
{
    self endon("exploded_barrel");
    
    while(1)
    {
        wait item;
        for( i = 0; i < level.players.size; i++ )
            {
                bot = level.players[i];
            if(distance(self.origin, bot.origin) < 77 && isAlive(bot) && bot.team == "axis")
            {
                    owner radiusDamage( bot.origin, 500, 360, 290, owner );
                    explosionOrigin = self.origin;
                    rot = randomfloat(360);
                    explosionEffect = spawnFx( level._effect["zom_mine_expl"], explosionOrigin + (0,0,50), (0,0,1), (cos(rot),sin(rot),0) );
                    triggerFx( explosionEffect );
                    self playsound("mpl_sd_exp_suitcase_bomb_main");
                    level.barrels_held -= 1;
                    wait .1;
                    self delete();
                    if (isdefined(self.turret))
                    {
                        self.turret delete();
                    }
                    self notify("exploded_barrel");
                    return;
            }
        }
        wait .1;
    }
}

timeout(time)
{
    self endon("deleted2");
    wait time;
    self delete();
}

dmg()
{
    pTemp = "";
    self.health = 250;
    self setCanDamage(true);
    for(;;)
    {
        self waittill("damage", eInflictor, attacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, psOffsetTime, deathAnimDuration, type);
        attacker thread maps\mp\gametypes\_damagefeedback::updateDamageFeedback(sHitLoc);
        
        
        if(attacker.team == "axis")
        {
            self playSound("zmb_metal_repair");
            if(attacker.zom_fastcrash == true)
            {
                self.health -= 30;
                attacker iprintlnbold("^1Barricade health: ^2" + self.health + "^7(^1Faster crashing^7)");
            }
            else
            {
                attacker iprintlnbold("^1Barricade health: ^2" + self.health);
            }
            
        }
        else
        {
            attacker iprintlnbold("^1Can't destroy friendly barricade.");
            self.health = 250;
        }
        if( (self.health <= 0) && (self.name != pTemp) )
        {
            wait .1;
            self notify("stationary");
            self notify("deleted2");
            self delete();
            attacker thread maps\mp\gametypes\_rank::updateRankScoreHUD( 30 );
        
            pTemp = self.name;
            break;
        }
    wait 0.05;
    }
}

electric_trap_move_switch(owner)
{
    self endon("trap2");
    self playsound("zmb_elec_start");
    self playloopsound("zmb_elec_loop");
    self thread play_electrical_sound();
    self thread fxs2();
    for(;;)
    {
        owner RadiusDamage( self.origin, 270, 330, 75, owner, "MOD_EXPLOSIVE" );
        self playsound("amb_sparks_l_b");
        wait 2;
    }
}


play_electrical_sound()
{
    self endon("trap2");
    while(1)
    {    
        wait(randomfloatrange(0.1, 0.5));
        self playsound("zmb_elec_arc");
    }
}

fxs2()
{
    playfx(level._effect["surv_trap"], self.origin + (0,0,20) );
    wait 16;
    playfx(level._effect["surv_trap"], self.origin + (0,0,20));
    wait 17;
    self stoploopsound("zmb_elec_loop");
    self delete();
    self notify("trap2");
}
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#5
Lightspeed, how would I go about incorporating this into a survival mod as a purchaseable item?

I added the code under the purchasing block, but I'm getting script compile errors. I got it to load and play without any errors but now when I "purchase" the barricade it won't give me the object to place.

I'm using the following portion to give myself the mp_supplydrop_boobytrapped as a barricade:


Code:
{
            self.carryObj setmodel("mp_supplydrop_boobytrapped_nc");

            self.carryObj.angles = (self.angles - (0,180,0));
            self.carryObj.origin = self.carryObj.origin + (0,0,20);
            
            self.carryObj linkto(self);
            level.held_bar1++;
}

I took that from the givebarrel(type) code and put it under the purchase hotkey

I wasn't sure how to add the cratephyiscs and velocity sections in there or how to reference them, as well as the placebarrel code..
Reply

#6
(10-07-2012, 03:05)wise Wrote: Lightspeed, how would I go about incorporating this into a survival mod as a purchaseable item?

I added the code under the purchasing block, but I'm getting script compile errors. I got it to load and play without any errors but now when I "purchase" the barricade it won't give me the object to place.

I'm using the following portion to give myself the mp_supplydrop_boobytrapped as a barricade:


Code:
{
            self.carryObj setmodel("mp_supplydrop_boobytrapped_nc");

            self.carryObj.angles = (self.angles - (0,180,0));
            self.carryObj.origin = self.carryObj.origin + (0,0,20);
            
            self.carryObj linkto(self);
            level.held_bar1++;
}

I took that from the givebarrel(type) code and put it under the purchase hotkey

I wasn't sure how to add the cratephyiscs and velocity sections in there or how to reference them, as well as the placebarrel code..

anyone got any feedback? I've been unable to get this to work properly..
Reply

#7
To get one of the barricades out just use
Code:
giveBarrel(id)
Simple. Fuck yea!
Reply



Forum Jump:


Users browsing this thread:
3 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.