Forum

> > Carnage Contest > Flood script required
Forums overviewCarnage Contest overviewLog in to reply

English Flood script required

12 replies
To the start Previous 1 Next To the start

old Flood script required

Jela331
User Off Offline

Quote
Hello everyone. I'm working on a Carnage Contest mission, but I need a script in which the flood weapon gets used every 5 seconds. Thanks.


Long story short:
Spoiler >

old Re: Flood script required

DC
Admin Off Offline

Quote
You need:
• cc cmd getframe (50 frames = 1 sec)
• the modulo operator % (giving the remainder of a division)
• copy&paste the stuff for flooding from the flood weapon script
In the mission update (not drawing!) function:
1
2
3
if (getframe() % (50*5))==0 then
	-- insert flooding snippet here
end

The remainder of getframe() / (50*5) is 0 every 5 seconds. That's how it works.
(You could also increase a variable each frame and execute the flooding when it reaches 50*5 but with the modulo solution you don't have to use a variable at all.)

old Re: Flood script required

Johnfaber
User Off Offline

Quote
Well, I tried, and managed to make it create an error message every five seconds stating "flood" is a nil value. So I'm on the right track. Hold onto your whatever you use to hold on.
EDIT: I did it, but I need to sort things out. I'll test some more. But you can consider your problem solved!
EDIT the second: I'm sort of done. However, I can't figure out how to implement sounds. But if you give me the map I can compose it to a level.
edited 2×, last 22.09.12 05:31:26 pm

old Re: Flood script required

Jela331
User Off Offline

Quote
user Johnfaber has written
Well, I tried, and managed to make it create an error message every five seconds stating "flood" is a nil value. So I'm on the right track. Hold onto your whatever you use to hold on.
EDIT: I did it, but I need to sort things out. I'll test some more. But you can consider your problem solved!
EDIT the second: I'm sort of done. However, I can't figure out how to implement sounds. But if you give me the map I can compose it to a level.


The mission will have 20+ maps, so, do you only need one or every one of them?

old Re: Flood script required

Johnfaber
User Off Offline

Quote
I could use one for testing, but you can give me all of them and I can script additional events, such as text appearing on the screen when passing a certain point, increasing the floodrate over time or even-probably, I'll have to test if that works first- lowering the waters again. If you want that, that is.
edited 3×, last 22.09.12 09:45:26 pm

old Re: Flood script required

Johnfaber
User Off Offline

Quote
Of course. Save it in the missions folder as general.lua. The wining position is defined as a node called "win".
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
node={}

-- light effect around player
function lightfx()
	x=getplayerx(0)
	y=getplayery(0)
	particle(p_muzzle,x,y)
	particlesize(0.8,2.0)
	particlerotation(0)
	particlealpha(1.0)
	particlefadealpha(0.04)
	particlecolor(255,255,0)
	for i=1,10 do
		particle(p_flare,x+math.random(-1000,1000)/100,y+math.random(-1000,1000)/100)
		size=math.random(200,500)/100
		particlesize(size,size)
		particlefadealpha(math.random(10,20)/1000)
		particlecolor(255,255,0)
		particlespeed(0,-math.random(20,150)/100)
	end
end

-- start function
function mission_start()
	-- save win node position
	node.win={}
	node.win.x=getnodex("win")
	node.win.y=getnodey("win")
	if node.win.x==0 then
		node.win.x=-100000000
	end
	-- start fx
	lightfx()
	playsound(sfx_turn_you)
	-- call customt start function
	customstart()
end
-- custom start function for additional functionality. overwritten by map scripts 000.lua-XXX.lua
function customstart()
end

-- draw function (just calls custom)
function mission_draw()
	-- call custom draw function
	customdraw()
end
-- custom draw function for additional functionality. overwritten by map scripts 000.lua-XXX.lua
function customdraw()
end

-- update function
function mission_update()
	-- check if player wins (is close to win node)
	if (getframe()%5)==0 then
		-- win?
		x=getplayerx(0)
		y=getplayery(0)
		if math.abs(x-node.win.x)<20 then
			if math.abs(y-node.win.y)<20 then
				win()
			end
		end
	end
	if (getframe() % (50*5))==0 then
     -- insert flooding snippet here
		watery(getwatery()-150)
	end
	-- call custom update function
	customupdate()
end
-- custom update function for additional functionality. overwritten by map scripts 000.lua-XXX.lua
function customupdate()
end
edited 2×, last 23.09.12 06:59:20 am

old Re: Flood script required

Jela331
User Off Offline

Quote
user Johnfaber has written
You're welcome. Help you again anytime. You just post that thing soon so I can experiment with it.


Okay. I'll put you in the credits btw, when I upload the mission.

old Re: Flood script required

Jela331
User Off Offline

Quote
user Johnfaber has written
Thanks, I appreciate it. You don't mind if I use the script for myself?


User "Myself" or you? Btw, of course you can, you made the script.
To the start Previous 1 Next To the start
Log in to replyCarnage Contest overviewForums overview