osgrid.org
https://forums.osgrid.org/

Increase Speed For Zombie Rezzer?
https://forums.osgrid.org/viewtopic.php?f=5&t=6601
Page 1 of 1

Author:  Caesar Luxington [ Sat Sep 05, 2020 6:33 pm ]
Post subject:  Increase Speed For Zombie Rezzer?

Hi!

I have a zombie rezzer script that creates a zombie bot and deals damage when it gets close enough to you, how would I go about increasing the speed of the zombies?

{L_CODE}:
//The next 3 variables determine where you will respawn when you are killed - instead of being TP'd to your home sim.
string Destination; // Destination region is checked by the script on startup
vector LandingPoint = <128,128,22.5>; //Change these coords as you wish - Set to the centre of the region now.
vector LookAt = <1,1,1>; //Direction you will be looking at when you respawn
string NotecardName;
float Range;
list Sayings = ["Chomps","Slurrps","Crunches","Nom Noms","Tastes","Bites","Licks","Gnaws","Chews","Grinds","Sucks","Nibbles"];
list Bits = ["Nose","Hand","Arm","Leg","Head","Foot","Ear","Chest","Stomach","Thighs"];
integer SayingsNr;
integer BitsNr;
key npc;
key id;
integer n;
vector npcPos;
key Target;
vector toucherPos;
vector TargetPos;
vector Pos;
float Position;
integer Inc = 0;
integer DeathInc = 0;
integer DeathPoints=0;
integer BiteInc = 0;
integer Timer = 300;
string TargetName;
float Health;
integer CHAN;
string DeathAnim = "LB-belly3";
string CrouchAnim = "avatar_crouch";
string ZombieWalk = "Zombie_Walk";
string IdleAnim = "idle_1";
string ObjDes;
integer channel=500;
list Zombie=["Female 1","Female 2","Flame","Ghost","Reaper","Male"];//If you change the NPC notecards, change the name here
list SenseRange=["10","15","20","30","50","96"];//Initial sensor range
list HitPoints=["One","Two","Five","Ten","Twenty","Fifty"];//How many shots it takes to kill a zombie
integer hex2int(string hex)
{
    return(integer)("0x"+hex);
}
DelNPC()
{
    osNpcRemove(npc);
}
default
{
    state_entry()
    {
        Destination = llGetRegionName();
        llSetAlpha(1.0,ALL_SIDES);
        llMessageLinked(LINK_SET, 1,"B","");
        CHAN = 0;
        DeathInc = 0;
        Inc = 0;
        BiteInc = 0;
        DelNPC();
        llSetText("",<0,1,1>,1.0);
        llListen(channel, "", NULL_KEY, "");
    }
    changed(integer change)
    {
        if(change & 1024)
        {
            llResetScript();
        }
    }
    touch_start(integer ok)
    {
        id = llDetectedKey(0) ;
        llDialog(id, "Zombie Type ?", Zombie, channel);
    }
    listen(integer channel, string name, key id, string message)
    {
        if (llListFindList(Zombie+SenseRange+HitPoints, [message]) != -1) 
        {
            if(message == "Female 1")
            {
                NotecardName = "Female 1";
                llDialog(id, "Sensing Range ?", SenseRange, channel);
            }
            if(message == "Female 2")
            {
                NotecardName = "Female 2";
                llDialog(id, "Sensing Range ?", SenseRange, channel);
            }
            if(message == "Flame")
            {
                NotecardName = "Flame";
                llDialog(id, "Sensing Range ?", SenseRange, channel);
            }
            if(message == "Ghost")
            {
                NotecardName = "Ghost";
                llDialog(id, "Sensing Range ?", SenseRange, channel);
            }
            if(message == "Reaper")
            {
                NotecardName = "Reaper";
                llDialog(id, "Sensing Range ?", SenseRange, channel);
            }
            if(message == "Male")
            {
                NotecardName = "Male";
                llDialog(id, "Sensing Range ?", SenseRange, channel);
            } 
            if(message == "10")
            {
                Range = 10.0;
                llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel);
            }
            if(message == "15")
            {
                Range = 15.0;
                llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel);
            }
            if(message == "20")
            {
                Range = 20.0;
                llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel);
            }
            if(message == "30")
            {
                Range = 30.0;
                llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel);
            }
            if(message == "50")
            {
                Range = 50.0;
                llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel);
            }
            if(message == "96")
            {
                Range = 96.0;
                llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel);
            }
            if(message == "One")
            {
                DeathPoints = 1;
                state Sense;
            }
            if(message == "Two")
            {
                DeathPoints = 2;
                state Sense;
            }
            if(message == "Five")
            {
                DeathPoints = 5;
                state Sense;
            }
            if(message == "Ten")
            {
                DeathPoints = 10;
                state Sense;
            }
            if(message == "Twenty")
            {
                DeathPoints = 20;
                state Sense;
            }
            if(message == "Fifty")
            {
                DeathPoints = 50;
                state Sense;
            }
        }
    }
}
state Sense
{
    state_entry()
    {
        llMessageLinked(LINK_SET, 3,"B","");
        llSetText("",<0,1,1>,1.0);
        DeathInc = 0;
        Inc = 0;
        BiteInc = 0;
        llSetAlpha(0.0,ALL_SIDES);
        llSensorRepeat("","",AGENT,Range,PI,1.0);
    }
    touch_start(integer number)
    {
        osNpcStand(npc);
        llSleep(1.0);
        osNpcRemove(npc);
        llOwnerSay("Zombie Rezzer RESET");
        state default;
    }
    sensor(integer num)
    {
        integer i;
        for (i = 0; i < num; i ++)
        {
           
            Target = llDetectedKey(i);
            Health = osGetHealth(Target);
            TargetPos = llDetectedPos(i);
            Pos = llGetPos();
            Position = llVecDist(TargetPos,Pos);
            llSensorRemove();
            npcPos = llGetPos() + <0,0,0>;
            npc = osNpcCreate(NotecardName, "...", npcPos, NotecardName);
            state NPC_SIT;
        }
    }
}
state NPC_SIT
{
    state_entry()
    {
        llSensorRepeat("","",AGENT,96,PI,2.0);
        llSetText("",<1,0,0>,1.0);
        SayingsNr = llGetListLength(Sayings);
        BitsNr = llGetListLength(Bits);
        llPreloadSound("Growl");
        llPreloadSound("Scream2");
        llPreloadSound("scream1");
        llSetTimerEvent(10.0);
        CHAN = hex2int(llGetSubString(npc,0,7));
        if (CHAN < 0)
        {
            CHAN = -CHAN;
        }
        //llOwnerSay("NPC Key is: "+(string)npc+"\nNPC Channel is: "+(string)channel);
        llListen(CHAN, "", "", "");
    }
    listen(integer channel, string name, key OurIDs, string message)
    {
        if(channel == CHAN && message == "NPC")
        {
            osNpcStopMoveToTarget(npc);
            osNpcStand(npc);
            DeathInc = DeathInc +1;
            if(DeathInc<=DeathPoints)
            {
                llPlaySound("Scream2",1.0);
            }
            osAvatarPlayAnimation(npc,IdleAnim);
            //osAvatarPlayAnimation(npc,CrouchAnim);
            llSleep(1.25);
            if(DeathInc>=DeathPoints)
            {
                llSetTimerEvent(0.0);
                llSensorRemove();
                osNpcStopMoveToTarget(npc);
                osNpcStand(npc);
                osNpcPlayAnimation(npc,DeathAnim);
                llPlaySound("scream1",1.0);
                llSleep(5.0);
                llRegionSay(111,"Dead_Zombie");
                llRegionSay(112,(string)llKey2Name(Target));
                osNpcRemove(npc);
                state Sense;
                //llResetScript();
            }
            llSleep(0.25);
            osNpcPlayAnimation(npc,ZombieWalk);
        }
    }
    sensor(integer num)
    {
        integer i;
        for (i = 0; i < num; i ++)
        {
            llSleep(0.5);
            Target = llDetectedKey(i);
            Health = osGetHealth(Target);
            TargetName = llDetectedName(i);
            toucherPos   = llDetectedPos(i);
            npcPos = osNpcGetPos(npc);
            Position = llVecDist(toucherPos, npcPos);

            if (Position>1.0)
            {
                osNpcMoveToTarget(npc,toucherPos+<0,0,0>, OS_NPC_NO_FLY);
            }
            if (Position<3.0)
            {
                if(Health<=35.0)
                {
                   
                    if(BiteInc >=1 )
                    {
                        llRegionSay(111,"Dead");
                        BiteInc = 0;
                    }
                    osNpcSay(npc,"Hahaha.. You Died !!");
                    osTeleportAgent(Target, Destination, LandingPoint, LookAt);
                    osCauseHealing(Target, 50);
                }
                llRegionSay(112,(string)llKey2Name(Target));
                float FSaid = llFrand(SayingsNr);
                integer Said = llCeil(FSaid)-1;
                string Text = llList2String(Sayings,Said);
                float FSaid1 = llFrand(BitsNr);
                integer Said1 = llCeil(FSaid1)-1;
                string Text1 = llList2String(Bits,Said1);
                osNpcSay(npc,(string)Text+" "+(string)llKey2Name(Target)+"'s "+(string)Text1);
                BiteInc = BiteInc + 1;
                osCauseDamage(Target, 10.0);
                llRegionSay(111,"Bite");
                llSleep(2.0);
            }
        }
    }
    touch_start(integer number)
    {
        osNpcStand(npc);
        llSleep(1.0);
        osNpcRemove(npc);
        llOwnerSay("Zombie Rezzer RESET");
        state default;
    }
    timer()
    {
        Inc = Inc +10;
        integer Del = Timer-Inc;
        llSetText("Auto-Delete in "+(string)Del+" seconds",<1,0,0>,1.0);
        float Rand1 = llFrand(2.0);
        if(Rand1>= 1.0)
        {
            llPlaySound("Growl",1.0);
        }
        if(Inc>=Timer)
        {
            osNpcRemove(npc);
            state Sense;
            //llResetScript();
        }
    }
}


Thank you!

Author:  dj phil [ Sat Sep 05, 2020 7:50 pm ]
Post subject:  Re: Increase Speed For Zombie Rezzer?

Hi,

with osNpcMoveToTarget you can use OS_NPC_RUNNING

OS_NPC_RUNNING - if given, NPC avatar moves at running/fast flying speed, otherwise moves at walking/slow flying speed.
(More info @ osNpcMoveToTarget).

or simply with osSetSpeed, like this:
osSetSpeed(npc, 2.0);
(more info @ osSetSpeed).

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/