Call of Duty: Black Ops 3 => Help Desk => Scripting => Topic started by: Wolfilms on June 11, 2017, 10:58:49 pm
Title: Make the zombies ignore you?
Post by: Wolfilms on June 11, 2017, 10:58:49 pm
How do I make it so that when I step into a trigger, all the zombies go somewhere else and ignore me?
Title: Re: Make the zombies ignore you?
Post by: Archaicvirus on June 13, 2017, 09:01:06 pm
Create a script_struct in radiant, give it a targetname of custom_poi. Then create a trigger_multiple where you want the safe zone to be. Now, select the struct first, then select the trigger, hit W to link them. Place the struct where you want the zombies to go when you're in the exclusion zone. Then do this in gsc:
Title: Re: Make the zombies ignore you?
Post by: Wolfilms on June 13, 2017, 09:12:55 pm
I will test this when I get the chance, so thanks! But 1 question I have is how linking the struct and the trigger change the outcome of what the zombies do?
Title: Re: Make the zombies ignore you?
Post by: Archaicvirus on June 13, 2017, 09:20:30 pm
Linking the struct to the trigger does nothing, other then making the trigger easier to grab in script. It's just something I generally do to keep things simple. But essentially when you link two objects, the object that targets the other gains the kvp: target: (targetname of targeted object). So now struct.target equals the targetname of the object that the struct is targeting. COnfusing?
Title: Re: Make the zombies ignore you?
Post by: Wolfilms on June 13, 2017, 09:21:52 pm
It's a little confusing, but I think I understand. Thanks
Title: Re: Make the zombies ignore you?
Post by: Archaicvirus on June 13, 2017, 09:39:44 pm
Haha yea sorry man, it's kind of hard to explain, but it's really easy in the end. Double Post Merge: June 13, 2017, 10:04:39 pmActually to be honest, linking the two objects does do more then what I described before. Generally when you link objects, the targeted object will auto-generate a targetname kvp. It will be like "auto1" or if you've linked a lot of objects, "auto17". This is useful for a lot of different reasons. Lets say you wanted to make multiple exclusion zones, you could link the two objects like I said, then save them as a prefab. So when you stamp copies of that prefab around the map, the targetname of the struct will stay the same, but each trigger will have an "auto3" or some number generated unique to it's parent's struct. That way you could do something like this:
I haven't tested this exact script, but it comes from one of my scripts and I'm doing something similar, although I wrote this a little different for your application. But again linking objects does have a benefit depending on what you're trying to do. This method makes it so you don't have to write a separate function each time you want to make another exclusion zone. And also I haven't tried this with a trigger multiple, but I have this working on a trigger_use. So you might not want a hintstring on a trigger multiple.
Another idea you could do, is make multiple exclusion zones (triggers), but link only one struct to all of them, so no matter which exclusion zone the player is in, the zombies will always go to the same place.
Title: Re: Make the zombies ignore you?
Post by: Wolfilms on June 13, 2017, 10:52:20 pm
Oh wow, great explanation. Thank you. But another question I have, that I've seen in other code, what does foreach() do and how do you use it?
Title: Re: Make the zombies ignore you?
Post by: Archaicvirus on June 14, 2017, 12:27:29 am
Foreach means you are iterating through an array (in this case), so you are saying for each item in this group, do this to them. Here's a more practical explanation.
Hope that explains it a little better.
edit* - Fixed some typos in the scripts and the earlier replies as well.
Title: Re: Make the zombies ignore you?
Post by: Wolfilms on June 14, 2017, 01:28:30 pm
That is a great explanation. Thanks :)
Title: Re: Make the zombies ignore you?
Post by: Archaicvirus on June 14, 2017, 11:59:50 pm
Glad to help man, just let me know how it works out for you with an answer, if you would.
Title: Re: Make the zombies ignore you?
Post by: Wolfilms on June 16, 2017, 10:08:49 pm
Ok, so I just tested it. It works, but after I leave the trigger the zombies keep going to the script_struct. Any thoughts on why?
Title: Re: Make the zombies ignore you?
Post by: Archaicvirus on June 17, 2017, 05:04:57 am
I got your pm, but if you don't mind, post the exact script you're using in code tags here, and I'll take a look at it. That way other people can learn from this, and I can see which one of my examples you're using. And also, what is your radiant setup? Give me a brief explanation on the trigger and struct setup you have. A screen shot of their kvp's will also help.
Title: Re: Make the zombies ignore you?
Post by: Wolfilms on June 17, 2017, 01:36:10 pm
So all I did was take out the else statement, but nothing changed in the game. The zombies still always go to the POI even after I leave the trigger.
You could always do some type of cooldown. That's how I have mine set up and it's working fine. I'm using a trigger_use though, and it just waits 60 seconds then sets poi.poi_active to false then waits for trigger input again. That might be a better way to do it. Although it is possible to do it the way you're doing it, for some reason poi.poi_active isn't getting set to false. You could do something like this
Title: Re: Make the zombies ignore you?
Post by: Harry Bo21 on June 20, 2017, 12:36:19 pm
doing this will break on co-op
everyone will be safe as long as one person is in the POI
Title: Re: Make the zombies ignore you?
Post by: Wolfilms on June 20, 2017, 02:11:33 pm
Is it possible to have it so that every player in the game has to hit a trigger?
Like I said before it's probably a lot easier just to make the trig a trigger_use, I have it working fine this way. This is the exact script I'm using with only minor changes to take out some of my checks.
Also this is just a proof of concept script that I made, so you should think about a way to limit this so players can't just keep using it over and over again. The cooldown in the script really should be called "poi active time" or something like that, because cooldown makes more sense to be the time after the poi expires, and before it can be triggered again. You can use a simple wait(time) or some other check. Here's a short vid demonstrating how I'm using it with the script I provided you.
Title: Re: Make the zombies ignore you?
Post by: Wolfilms on June 20, 2017, 07:11:27 pm
Like I said before it's probably a lot easier just to make the trig a trigger_use, I have it working fine this way. This is the exact script I'm using with only minor changes to take out some of my checks.
Also this is just a proof of concept script that I made, so you should think about a way to limit this so players can't just keep using it over and over again. The cooldown in the script really should be called "poi active time" or something like that, because cooldown makes more sense to be the time after the poi expires, and before it can be triggered again. You can use a simple wait(time) or some other check. Here's a short vid demonstrating how I'm using it with the script I provided you.
(Content removed from quote.)
Ok, thanks. I planned on making this just like a cool, hidden feature in my map so in no way do I intend to make it OP. Thanks everyone!
Title: Re: Make the zombies ignore you?
Post by: buttkicker845 on June 20, 2017, 07:12:20 pm
does the variable still exist in bo3? if it does you could just do something like this
this can also be done with a volume instead of a trigger
PS:this is a quick example you want to do other checks before setting the .ignoreme variable such as if the player is in laststand because if you dont its possible they would become a target if they are downed and not in the trigger zone
Title: Re: Make the zombies ignore you?
Post by: Archaicvirus on June 20, 2017, 07:20:52 pm
does the variable still exist in bo3? if it does you could just do something like this
this can also be done with a volume instead of a trigger
PS:this is a quick example you want to do other checks before setting the .ignoreme variable such as if the player is in laststand because if you dont its possible they would become a target if they are downed and not in the trigger zone
That's a really good idea.
I appreciate everyone else's input too, that's why I always come here to ugx. That and I'm always having problems myself lol