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

SP zones

HOT
broken avatar :(
Created 12 years ago
by daedra descent
0 Members and 1 Guest are viewing this topic.
9,231 views
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
I'm trying to add zones to SP but no matter what i try the game always freezes and the console gives no hint as to why. I've tried changing the code up a bit but it its always the same result.

Code:
Code Snippet
Plaintext
begin_zone_think(zone)
{
while(1)
{
players = get_players();

zone = getEntarray(zone, "targetname");

if(players istouching(zone) )
{
zone.is_active = true;
}
else
{
zone.is_active = false;
}
}

if(zone.is_active == true)
{
zone_spawners = getEntarray(zone.target, "targetname");

zone_spawners dospawn();
}
wait(1);
}

Obviously the way the AI is spawned is stupid. It was just something i put in there to see what would happen.
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
Just looked over it quickly, you cannot call IsTouching() on an array of entities.

- Phil.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Just looked over it quickly, you cannot call IsTouching() on an array of entities.

- Phil.

Does this look any better?

Code Snippet
Plaintext
begin_zone_think()
{
if(!isdefined(level.zones) )
{
level.zones = [];
level.zones = getEntarray("initial_zone", "targetname");
}
while(1)
{
players = get_players();

zone = GetArrayKeys( level.zones );

for( i=0; i<zone.size; i++ )
{
if(players istouching(zone[i]) )
{
level.zone[i].is_active = true;
level.zone_spawners = get_zone_specific_spawners(zone[i]);
}
else
{
level.zone.is_active = false;
}
}

wait(.5);

if(isdefined(level.zone_spawners) )
{
level.zone_spawners.count = 9999;
level.zone_spawners dospawn();
}
wait(1);
}
}
get_Zone_specific_spawners(zone)
{
if(!isdefined(zone) )
{
zone = undefined;
}

zone_spawners = zone.target + "_spawners";

return zone_spawners;
}

I added/changed it a bit because i had gotten it to load but it still doesn't spawn AI when a player walks into a zone.
Last Edit: March 02, 2014, 12:56:06 pm by daedra descent
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
You are still calling IsTouching() on an array.

- Phil.
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 6 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
yaphil cant he do something like this in the for loop?

Code Snippet
Plaintext
for( i=0; i<zone.size; i++ )
        {
    for( i=0; i<players.size; i++ )
            {
                     if(players[i] istouching(zone[i]) )
                     {
                       level.zone[i].is_active = true;
                       level.zone_spawners = get_zone_specific_spawners(zone[i]);
                     }
                     else
                     {
                       level.zone.is_active = false;
                     }
}
        }
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
I am not the best at scripting but as for the array that wont work with istouching() don't just have to make it look like this?

Code Snippet
Plaintext
begin_zone_think(zone)
{
    while(1)
    {
        players = get_players();
       
        zone = getEnt(zone, "targetname");
       
        if(players istouching(zone) )
        {
            zone.is_active = true;
        }
        else
        {
            zone.is_active = false;
        }
    }
   
    if(zone.is_active == true)
    {
        zone_spawners = getEntarray(zone.target, "targetname");

        zone_spawners dospawn();
    }
    wait(1);
}

First there is an array entity, and it is being called by an istouching() which YaPhil says it is not working. Then if you maybe just remove the array entity at the top which I did here now and not remove the array entity at the bottom because that entity is not being called by an istouching()

Am I right about this? I don't know if this will work but I did as Phil said, removed the array.
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
Am I right about this? I don't know if this will work but I did as Phil said, removed the array.
I have never said one should remove the array. Also, you removed the zone array not the player array which IsTouching() is being called on.
jjbradman got the basic idea right, you have to do a for loop through the players array and test for every player entity individually. Obviously you have to change up your logic to accomodate for this. Also since you now have a for loop inside a for loop make sure to name the counting variables different in the inner loop, otherwise it won't work like you want it to.

- Phil.
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
I have never said one should remove the array. Also, you removed the zone array not the player array which IsTouching() is being called on.
jjbradman got the basic idea right, you have to do a for loop through the players array and test for every player entity individually. Obviously you have to change up your logic to accomodate for this. Also since you now have a for loop inside a for loop make sure to name the counting variables different in the inner loop, otherwise it won't work like you want it to.

- Phil.

I'm sorry Phil, I assumed that you mean't to remove the array. I thought you mean't the zone array itself.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Alright i removed the array on the zone variable, and added it to players so it would check for each individual player, but its still not spawning AI when i enter a zone(the ai is a spawner if it helps any).

code:
Code Snippet
Plaintext
begin_zone_think()
{
if(!isdefined(level.zones) )
{
level.zones = [];
level.zones = getEntarray("initial_zone", "targetname");
}
while(1)
{
players = get_players();

zone = GetArrayKeys( level.zones );

for( i=0; i<players.size; i++ )
{

if(players[i] istouching(zone) )
{
level.zone.is_active = true;
level.zone_spawners = get_zone_specific_spawners(zone);
}
else
{
level.zone.is_active = false;
}
}

wait(.5);

if(level.zone.is_active)
{
level.zone_spawners.count = 9999;
level.zone_spawners dospawn();
}
wait(1);
}
}
get_Zone_specific_spawners(zone)
{
if(!isdefined(zone) )
{
zone = undefined;
}

zone_spawners = zone.target;

return zone_spawners;
}
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
Alright i removed the array on the zone variable
I never said to remove any array...

- Phil.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
I never said to remove any array...

- Phil.

I changed it so it would put all the players into an array, not the zones. since i can't use istouching(); with an array i have no use for it, right?

EDIT: Nevermind, i was just confused on what you meant.

Re-Edit: Still not working. I added a lprintln("player in zone"); and it keeps saying i'm in the zone when i'm not, it also doesn't get the spawners of a zone.
Last Edit: March 02, 2014, 11:25:30 pm by daedra descent
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
Well, how does your script look like currently?

- Phil.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Code Snippet
Plaintext
begin_zone_think()
{
if(!isdefined(level.zones) )
{
level.zones = [];
level.zones = getEntarray("initial_zone", "targetname");
}
while(1)
{
players = get_players();

zone = GetArrayKeys( level.zones );

for( i=0; i<zone.size; i++ )
{

for( i=0; i<players.size; i++ )
{

if(players[i] istouching(zone[i]) )
{
level.zone[i].is_active = true;
level.zone_spawners = get_zone_specific_spawners(zone[i]);

iprintln("Player in zone");
}
else if(!players[i] istouching(zone[i]) )
{
level.zone.is_active = false;
iprintln("player not in zone");
}
}
}

wait(.5);

if(level.zone.volumes.is_active)
{
level.zone_spawners.count = 9999;
level.zone_spawners dospawn();
iprintln("AI spawned");
}
wait(1);
}
}
get_Zone_specific_spawners(zone)
{
if(!isdefined(zone.volumes) )
{
zone = undefined;
}

zone_spawners = zone.target;

return zone_spawners;

iprintln("Got spawners");
}

I made it look more like JJbrad's edit and how it looks in _zombiemode_zone_manager.gsc.

EDIT: *facepalm* i forgot to change the I in the players loop. My bad. Still doesn't work though.
Last Edit: March 03, 2014, 01:34:11 am by daedra descent
broken avatar :(
×
broken avatar :(
Location: usYork, SC
Date Registered: 30 March 2013
Last active: 12 years ago
Posts
24
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Coder
Signature
PROxFTW
×
blackbird431's Groups
blackbird431's Contact & Social LinksPROxFTWiso4lif3PROxFTWJTAGxHACKER
The reason it isn't working is because you have the same variable for player and zone.
But here test this for now
Code Snippet
Plaintext
begin_zone_think()
{
    if(!isdefined(level.zones) )
    {
        level.zones = [];
        level.zones = getEntarray("initial_zone", "targetname");
    }
    while(1)
    {
        players = get_players();

        zone = GetArrayKeys( level.zones );

        for( a=0; a<zone.size; a++ )
        {

            for( i=0; i<players.size; i++ )
            {

                if(players[i] istouching(zone[a]) )
                {
                    level.zone[a].is_active = true; //Unsure if '[a]' has to be there but just test it for now
                    level.zone_spawners = get_zone_specific_spawners(zone[a]);

                    iprintln("Player in zone");
                }
                else if(!players[i] istouching(zone[a]) )
                {
                    level.zone[a].is_active = false; //Unsure if '[a]' has to be there but just test it for now
                    iprintln("player not in zone");
                }
            }
        }
       
        wait(.5);
   
        if(level.zone.volumes.is_active)
        {
            level.zone_spawners.count = 9999;
            level.zone_spawners dospawn();
            iprintln("AI spawned");
        }
        wait(1);
    }
}
get_Zone_specific_spawners(zone)
{
    if(!isdefined(zone.volumes) )
    {
        zone = undefined;
    }
   
    zone_spawners = zone.target;

    return zone_spawners;

    iprintln("Got spawners");
}
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
The reason it isn't working is because you have the same variable for player and zone.
But here test this for now
Code Snippet
Plaintext
begin_zone_think()
{
    if(!isdefined(level.zones) )
    {
        level.zones = [];
        level.zones = getEntarray("initial_zone", "targetname");
    }
    while(1)
    {
        players = get_players();

        zone = GetArrayKeys( level.zones );

        for( a=0; a<zone.size; a++ )
        {

            for( i=0; i<players.size; i++ )
            {

                if(players[i] istouching(zone[a]) )
                {
                    level.zone[a].is_active = true; //Unsure if '[a]' has to be there but just test it for now
                    level.zone_spawners = get_zone_specific_spawners(zone[a]);

                    iprintln("Player in zone");
                }
                else if(!players[i] istouching(zone[a]) )
                {
                    level.zone[a].is_active = false; //Unsure if '[a]' has to be there but just test it for now
                    iprintln("player not in zone");
                }
            }
        }
       
        wait(.5);
   
        if(level.zone.volumes.is_active)
        {
            level.zone_spawners.count = 9999;
            level.zone_spawners dospawn();
            iprintln("AI spawned");
        }
        wait(1);
    }
}
get_Zone_specific_spawners(zone)
{
    if(!isdefined(zone.volumes) )
    {
        zone = undefined;
    }
   
    zone_spawners = zone.target;

    return zone_spawners;

    iprintln("Got spawners");
}

Yeah i changed that right after i posted the code hence why i made the edit.

The if statement still isn't working correctly, it says i'm in the zone when i'm not.

 
Loading ...