I want spawn encharge to work


(Comida Japonesa) #1

Good afternoon, how are you? I need help. Here’s what I want the spawn encharge to do in the following way, for the axis to start at the spawn where the ally will capture the flag and after the goal is destroyed, then the axis is moved to another spawn, that the capture flag is not black and appears that was captured by the axis or allied, which also appears in the description that only one team captured the flag, that on the command map appears the icon of who captured the flag, follows the images:

scripts:

destroyable objective:

allied spawn:

axis spawn:

neutral spawn:

please could someone help me


(KeMoN) #2

Hello there,
I just had a quick look and on first glance, it seems like there is quite a bit going on there.
On the first script image it seems like you are not using consistent naming schemes. The entity routine is called new_spawn but you try to trigger it as new spawn and new_Spawn here and there. I don’t know if the engine is case sensitive there (as in, whether new_Spawn and new_spawn are handled the same), but it certainly doesn’t help.
In Radiant it looks like your targetname is not always one string. allied spawn is two. You should concatenate that with an underscore to allied_spawn.

I do recommend to double check all variable names and go through the script and ensure consistent naming schemes. If you can’t fix it like this, feel free to attach the map and script file and I can have a look after the holidays, when things are a bit less hectic.


(Comida Japonesa) #3

here is the map file for you to check

mapadeteste34.pk3 (12.2 KB)


(KeMoN) #4

Alrighty, so first of all, I urge you to check your targetname and scriptname fields for consistency again. They are supposed to be single string and in the files you shared it’s still targetname: blue spawn for example, while it’s supposed to be targetname: blue_spawn.

Anyway, let’s get into it. I tried to load the map in-game which prompted a setautospawn error. This is related to the following two script lines:
setautospawn "capture_spawn" 1
setautospawn "capture_spawn" 0

setautospawn is aimed at the description key rather than the target key in the entity.

Compare this to Siwa Oasis, where the game_manager sets the following two lines:
setautospawn "Old City" 1
setautospawn "Old City" 0
This corresponds to this:

====================================================

Another thing is to use consistent naming schemes, which I also recommended in my last post.
Your flag entity has wildly different names, while the Oasis flag has the same base name ‘oldcity’ and only further specifies with the suffix ‘flag’ and ‘spawn’.



It’s good practice to have targetname and scriptname be identical to help with clarity of the script, so you can understand what’s going on more easily.

====================================================

You then correctly target the neutral_spawn entities, which are all the relevant spawn entities. The team_WOLF_objective (few images above), however, specifies default_axis. That is alright, but it needs to be reflected by the spawn entities. So for all team_CTF_redspawn entities with targetname: neutral_spawn you need to specify the startactive spawnflag as seen in the following image:

====================================================

For the scripting part, I would strongly suggest to try and use more concise routines.
This is the script you provided, let’s go through it and try to understand it.

new_spawn
{
  spawn
  {
    accum 0 set 0 
   }
   
   trigger allied_capture
   {
   accum 0 abort_if_equal 1
   
   trigger new_spawn bunker_flagblue
   trigger new_spawn setallies
   }
   
   trigger setallies
   {
      accum 0 abort_if_equal 1
	  accum 0 set 1
	  
	  alertentity spawn
	  alertentity neutral_spawn
	  setautospawn "2nd_axis_spawn" 0
	 }
	 
	 trigger axis_capture
	 {
	   accum 0 abort_if_equal 0
	   
	  trigger new_spawn bunker_flagred
	  trigger new_spawn setaxis
	 }
	 
	 trigger setaxis
	 {
	   accum 0 abort_if_equal 0
	   accum set 0
	   
	   alertentity spawn
	   alertentity neutral_spawn
	   
	 }
	 
	 trigger blue_flagblue
	 {
	   wm_announce "allied capture the spawn"
	  }
	  
	  trigger bunker_flagred
	  {
	    wm_announce "axis capture the spawn"
	   }
	   
	   trigger kill
	   {
	     remove
	    }
		
		trigger gone
		{
		   accum 0 abort_if_equal 1
		   alertentity spawn
		   alertentity neutral_spawn
		   setautospawn "capture_apawn" 0
		   setautospawn "capture_spawn" 1
		 }
}

The spawn routine specifies things at map start when the entity spawns. On map start, however, all accums are initiated with a default value of 0, so the routine below currently is redundant and can be removed entirely. I do understand that it is helpful for clarity of the script, so it also doesn’t hurt if you keep it in.

spawn
{
   accum 0 set 0 
}

The routine trigger allied_capture specifies what you want to happen when Allies capture the flag.

trigger allied_capture
{
   accum 0 abort_if_equal 1
   
   trigger new_spawn bunker_flagblue
   trigger new_spawn setallies
}

accum 0 abort_if_equal 1 is fine. It aborts the execution of this routine if an Allied player touches the flag, while it is already Allied. The next lines reference to other script routines. The first one is a simple announcement:

trigger blue_flagblue
{
   wm_announce "allied capture the spawn"
}

In my eyes this makes the setup unnecessarily complicated, because the announcement can easily be put into the previous routine.
The second one is a bit more complex so let’s go through it.

trigger setallies
{
   accum 0 abort_if_equal 1
   accum 0 set 1
	  
   alertentity spawn
   alertentity neutral_spawn
   setautospawn "2nd_axis_spawn" 0
}

accum 0 abort_if_equal 1 is not strictly necessary here, because that line is only executed if that requirement is already given. In the previous routine you already have that line, so it’s redundant here.
accum 0 set 1 tells the script that the flag is held by the Allies. That is good that you put it there. The game now alerts the team_WOLF_objective. By doing so it switches its state from Axis to Allied.
The game also alerts all spawn entities with targetname: neutral_spawn. By doing so, the state of each spawn entity is switched. That is why it is important to have the spawnflag startactive set for Axis spawns. All active spawns are switched off and all inactive spawns are switched on by the alertentity line. In other words, Axis spawns get disabled, Allied spawns get enabled.
The script then sets the fallback autospawn for Axis. In this case 2nd_axis_spawn, which does not exist! It’s called axis spawn as seen in the image below.

The routine trigger axis_capture does the same thing, just for the Axis instead of Allies. The only difference here is that you don’t set a fallback spawn for the Allies. I don’t know if that’s intentional or not.
With the adjustments, the new script routine for that entity is the following:

new_spawn
{
   spawn
   {
      accum 0 set 0 // tells the script the flag is owned by Axis
   }
   
   trigger allied_capture
   {
      accum 0 abort_if_equal 1 //tells the game to stop here if the flag is already Allied.
      accum 0 set 1 //tells the game that the flag is now Allied.

      wm_announce "allied capture the spawn" //announcement moved here from other subroutine.
      alertentity spawn //tells the game to switch the state of the WOLF objective.
      alertentity neutral_spawn // tells the game to switch the state of the targeted spawn entities.
      setautospawn "axis spawn" 0 //FIXED! tells the game which spawn the Axis should use now.
   }
   
   trigger axis_capture
   {
      accum 0 abort_if_equal 0 //tells the game to stop here if the flag is already Axis.
      accum 0 set 0 //tells the game that the flag is now Axis.

      wm_announce "axis capture the spawn" //announcement moved here from other subroutine.
      alertentity spawn //tells the game to switch the state of the WOLF objective.
      alertentity neutral_spawn // tells the game to switch the state of the targeted spawn entities.
      setautospawn "allied spawn" 1 //ADDED! tells the game which spawn the Allies should use now.
   }
	   
   trigger gone //UNRELATED TO FLAG; LEAVE FOR LATER
   {
      accum 0 abort_if_equal 1
      alertentity spawn
      alertentity neutral_spawn
      setautospawn "capture_apawn" 0 //TYPO!
      setautospawn "capture_spawn" 1
      remove //moved here from other subroutine
   }
}

I’d suggest to leave the wall out for now, because there are other things in there that need fixing. Report back once you got the flag spawn working and we can have a look.
Last but not least, again: targetname and scriptname need to be single string! Replace the space in the targetname of the following entities with an underscore ‘_’



(Comida Japonesa) #5

I managed to make the spawn work, now it only lacks the dynamite where after the wall is destroyed the axis loses the spawn of the flag and the ally gets the spawn of the flag, here the file:

mapadeteste34.pk3 (12.3 KB)

also missing the flag to appear if it was allied or axis captured instead of getting dark


(KeMoN) #6

Well done, for getting it to work. I understand scripting isn’t the most intuitive thing ever.
The flag being black is due to non-existing lightgrid.
Replace ambient: 14 with _minlight: 14 in worldspawn and adjust the value as necessary. If the flag is still too dark, add _mingridlight: 25 to worldspawn.

I have the feeling that you don’t really read what I write. Same thing with the bsp decompiling a few weeks ago, so here it goes again in capslock and bold font.
PLEASE ENSURE CONSISTENT NAMING SCHEMES IN YOUR MAP!

For the flag spawn you use four different terms. The team_WOLF_obj is called spawn and targets capture_spawn. The team_WOLF_checkpoint is called new_spawn and targets neutral_spawn. This is not only difficult to keep an overview over, but it also significantly increases your chances of errors. In the script the spawn is correctly handled by the new_spawn routine. However, the wall tries to trigger neutral_spawn routine. I strongly suggest, once again, to go through your map and fix the names. Siwa Oasis will most likely include understandable names which you can adjust to your needs.

========================================
I will just raise the issue of non-uniform targetname and scriptname again. It works, but it’s just difficult to understand and I think it would be easier for you if you would use consistent names.


This is the current script routine for the wall.

wall
{
  spawn
  {
  wait 200
  constructible_class 3
  }
  
  death
  {
    trigger neutral_spawn kill
	trigger neutral_spawn gone
	
	wm_announce "allied has destroyed the metal wall"
   }
}

Here you can see the problem of inconsistent names. Your spawn is handled by the new_spawn routine in the script, but your wall routine tries to call neutral_spawn, which does not exist in the script. Change it to this:

wall
{
   spawn
   {
      wait 200
      constructible_class 3
   }
  
   death
   {
      trigger new_spawn gone
      wm_announce "allied has destroyed the metal wall"
   }
}

We still need to adjust the gone subroutine in new_spawn so let’s have a look at that:

   trigger gone //UNRELATED TO FLAG; LEAVE FOR LATER
   {
      accum 0 abort_if_equal 1
      alertentity spawn
      alertentity neutral_spawn
      setautospawn "capture_apawn" 0 //TYPO!
      setautospawn "capture_spawn" 1
      remove //moved here from other subroutine
   }

The line accum 0 abort_if_equal 1 stops the execution if the flag is Allied. So if the Allies hold the flag and then the wall gets blown, the flag won’t disappear, because the script stops there.
We still want to hide the flag though, I presume, so we need to add setstate new_spawn invisible before the previous line to hide the flag.
The alertentity lines are correct as we do want the spawns to switch from Axis to Allies if the flag is held by Axis before the wall is blown.
The setautospawn lines are once again coming back to your inconsistent naming schemes. There is no ‘capture_spawn’ or ’ capture_apawn’ in your map.
For the Allies, you probably want autospawn at the flag spawn, so that would be setautospawn "spawn" 1 and for the Axis probably the fallback spawn, so that would be setautospawn "axis spawn" 0.

That brings us to this new subroutine for trigger gone:

   trigger gone
   {
      setstate new_spawn invisible //Hides the flag
      accum 0 abort_if_equal 1 //Stops execution if flag is Allied
      alertentity spawn //Changes WOLF_obj from Axis to Allies
      alertentity neutral_spawn //Changes spawns from Axis to Allies
      setautospawn "axis spawn" 0 //Axis fallback spawn
      setautospawn "spawn" 1 //Allied flag spawn
      remove //remove the flag entity
   }

Hope that helps.


(Comida Japonesa) #7

I did it, it worked very well with allied, I also did the spawn encharge on the same map so that with the axis capturing the flag I changed a few things.

a curiosity: what is the accum 0 abort_if_equal 1, accum 0 abort if equal 0, accum 0 set 1 , accum 0 set 0, setstate invisible, set state defaut on maps in general?