globalaccum breaks script_mover


(lispider) #1

Ok, I am on my second day of scripting and ive traced the problem I am having back to adding a global accum.

Heres my script sorry if im not overly descriptive but im pissed


game_manager
{
	spawn
	{
		// Game rules
		wm_axis_respawntime	3
		wm_allied_respawntime	3
	}
}

//=========================
//Moving Target 1 Script
//=========================
box01
{
	spawn
	{
	}
	trigger move
	{
		globalaccum 1 abort_if_equal 1
		globalaccum 1 inc 1
		followspline 0 path01_01 240 wait length -64
		followspline 0 path01_02 250 wait length -64
		followspline 0 path01_03 260 wait length -64
		followspline 0 path01_04 270 wait length -64
		followspline 0 path01_05 280 wait length -64
		followspline 0 path01_06 290 wait length -64
		followspline 0 path01_07 300 wait length -64
		followspline 0 path01_08 290 wait length -64
		followspline 0 path01_09 280 wait length -64
		followspline 0 path01_10 270 wait length -64
		followspline 0 path01_11 260 wait length -64
		followspline 0 path01_12 250 wait length -64
		followspline 0 path01_13 240 wait length -64
		followspline 0 path01_origin 120 wait length -64
		trigger box01 move
	}
	pain
	{
		playsound sound/area51/hit.wav
	}
	death
	{
		wm_announce "Target 1 Destroyed!"
		alertentity box01
		globalaccum 1 set 0
	}
}

Thats all it took to break the script_mover was changing it to global…

Can anyone tell me whats going on and why I am having such a hard time with a testmap???


(nUllSkillZ) #2

If you use accum instead of globalaccum the script works?

Hmm, the only idea that I have is that you have to set the globalaccum in the spawn script block of the game_manager script block the first time:


game_manager
{
	spawn
	{
		// Game rules
		wm_axis_respawntime	3
		wm_allied_respawntime	3

		globalaccum 1 set 0
	}
}

// ...

Only an idea.


(lispider) #3

tried that and using accum doesnt allow me to reset the accum under the “death” trigger,

Also tried setting globalaccum under the game_manager previously with no luck


(]UBC[ McNite) #4

I m pretty sure you can do what you want without a global accum and get around the prob that way. If you need to change the accum by an event that happens in another script you can always use triggers to make that happen.
(Not sure but I think I read somewhere that you can’t have global accums.)


(nUllSkillZ) #5

It should be possible to set the accum in the death part.


(lispider) #6

Ok so I got it working right :slight_smile: finally…

I am including my script fully commented so ANYONE who is not familiar with getting script_movers to work properly should look at this.


//=========================
// Moving Target 1 Script
//=========================
box01
{
	spawn
	{
	accum 1 set 1      // set the accum 1 for box01 to 1 so that trigger move runs
	wait 150           // make sure the accum is set before anything else is done
	}
	trigger move
	{
		accum 1 abort_if_not_equal 1	// do not run unless the accum 1 is set to 1

		remapshader textures/area51/target textures/area51/target	// redundant when issued the first time but sets the texture to visible

		remapshaderflush	// executes the previous statement or any remaps above it in the same trigger

		// follow path_corner2's all the way through
		gotomarker a01_p1 200 wait
		gotomarker a01_p2 600 wait
		gotomarker a01_p3 200 wait
		gotomarker a01_p4 300 wait
		gotomarker a01_p5 200 wait
		gotomarker a01_p6 300 wait
		gotomarker a01_p7 200 wait
		gotomarker a01_p8 300 wait
		gotomarker a01_p7 200 wait
		gotomarker a01_p6 300 wait
		gotomarker a01_p5 200 wait
		gotomarker a01_p4 300 wait
		gotomarker a01_p5 200 wait
		gotomarker a01_p4 300 wait
		gotomarker a01_p6 200 wait
		gotomarker a01_p4 300 wait
		gotomarker a01_p1 1000 wait

		accum 1 set 0	// break that loop so it only runs one time when triggered
		trigger box01 move	// do the loop baby!
		trigger pit01 open	// open the pit below ur feet cuz u cant shoot!
	}
	pain	// pain happens whenever the health on a script_mover is damaged
	{
		playsound sound/area51/hit.wav	// play the headshot sound when hit
	}
	death	// when script_movers health = 0 death occurs
	{
		wm_announce "Target 1 Destroyed!"	// !Target 1 Destroyed message on screen
		alertentity box01	// rest the health of the script_mover MUST be within the entity script
		accum 1 set 0		// set the accum 1 to 0 so the loop breaks if killed (prolly not needed)
		remapshader textures/area51/target textures/area51/invis	// make target invisible when killed (can use a setstate invis also)
		remapshaderflush						// execute previous remaps within trigger
		trigger pit01 setaccum1		// stop the pit from opening since u killed the target in time
		trigger door01 open		// open the door to next target because the target was killed in time
		trigger box01 move 		// finish moving the box to the end of the path? (not sure why I put this)
	}
	trigger reborn  // trigger to be called by other triggers
	{
		alertentity box01	// reset health on box01
		accum 1 set 1		// make it so the target can move again
	}
}
//==============
//    Pit 1
//==============
pit01
{
	spawn
	{
	accum 1 set 1		// set accum 1 to 1 so the movement will run
	wait 150		// make sure its set
	}
	trigger open
	{
		wait 4500	// nice long wait so the player doesnt just dies when entering the room
		accum 1 abort_if_not_equal 1	// only move if accum is correct
		gotomarker pit01_02 1000 wait	// move down like a bat out of hell through a trigger then onto a damage pit
		gotomarker pit01_01 1000 wait	// go back up after succesfully killing the person :)
	}
	trigger setaccum1
	{
	accum 1 set 0	// set the accum 1 to 0 so that the movement can be stopped if target is killed
	}
}

// Self explanitory if you have read the previous
//=============
//   Door 1
//=============
door01
{
	trigger open
	{
		gotomarker d01_02 200 wait
	}
	trigger close
	{
		gotomarker d01_01 200 wait
	}
}

I will also be uploading a tutorial map file for this script that shows how it all actually works, just incase someone still doesn’t understand :slight_smile: