Go Back   Codemasters Forums > Action, RPG and Strategy Games > Operation Flashpoint: Dragon Rising > English > Operation Flashpoint: Dragon Rising - Mission Editing and Modding Chat Zone
Sign In
Register on CodeM

Operation Flashpoint: Dragon Rising - Mission Editing and Modding Chat Zone A little area for all you mission editors and modders to chat and discuss ideas.

Reply
 
LinkBack Thread Tools Display Modes
Old 28-10-2009, 04:12 AM   #1 (permalink)
Member
 
DemonFire's Avatar
 
Join Date: Oct 2009
Location: USA - GA
Posts: 61
Talking Spawn/Despawn on EXITING triggerzones

In a mission I'm making, units spawn when you enter a triggerzone and despawn when you leave that same triggerzone.

I give you the following code:

Code:
function onEnter_ts1(zoneName, unitName)
    OFP:activateEntitySet("s1");
end

function onLeave_ts1(zoneName, unitName)
    OFP:destroyEntitySet("s1");
end
Entity set is called "s1" and the triggerzone is called "ts1". This code doesn't work as of now and I don't know why....

Does anyone see any problems?
__________________
MAKE YOUR OWN ZOMBIE MISSIONS!

http://community.codemasters.com/for...54#post5850554
DemonFire is offline   Reply With Quote
Old 28-10-2009, 05:01 AM   #2 (permalink)
Senior Member
 
Join Date: Sep 2009
Posts: 212
Default

you don't need the " ; " after your commands. I'm not sure if that will make a difference though it may be worth a try.
__________________
Dumpster Babies

If your looking for like minded team players check out Tactical Gamer

Map Usage & Advanced AI Control Guide

"The ideal tyranny is that which is ignorantly self-administered by its victims. The most perfect slaves are, therefore, those which blissfully and unawaredly enslave themselves."

Dresden James
Fiddlestx is offline   Reply With Quote
Old 28-10-2009, 06:01 AM   #3 (permalink)
Member
 
Join Date: Oct 2009
Posts: 46
Default

The semicolon is optional in LUA. Assign your entity to a setID first, then use that setID to despawn them.

Code:
function onEnter_ts1(zoneName, unitName)
setID1 = OFP:activateEntitySet("s1");
end function onLeave_ts1(zoneName, unitName)
OFP:destroyEntitySet(setID1);
end
The number 1 in setID can be any number you wish. Just remember to give a unique number for each different entity set.
ZipD is offline   Reply With Quote
Old 28-10-2009, 11:22 AM   #4 (permalink)
Senior Member
 
Join Date: Oct 2009
Posts: 239
Default

I've found that destroyEntitySet can be unreliable, to the point that at times it just doesn't work at all. Using despawnEntity, on the other hand, seems to get 'em every time - but it does involve a lot of tedious coding.
__________________
Code:
function onFinishedTyping(userName, messageName)
    talking_sh*te=OFP:isUserName("private_pile")
    if talking_sh*te==true then
    OFP:clickButton("submit", "OVERRIDE")
    end
end
private pile is offline   Reply With Quote
Old 28-10-2009, 01:04 PM   #5 (permalink)
Member
 
DemonFire's Avatar
 
Join Date: Oct 2009
Location: USA - GA
Posts: 61
Default

Thanks for speedy replies everyone

Its true, the destroy entity set is really annoying. But its not working even after I've assigned IDs to everything.

Here is the revised code:

Code:
function onMissionStart()
ts2spawn = 0;
ts1spawn = OFP:activateEntitySet("s1");
end

function onEnter_ts1(zoneName, unitName)
	ts1spawn = OFP:activateEntitySet("s1");
end
function onLeave_ts1(zoneName, unitName)
	ts1spawn = OFP:destroyEntitySet("s1");
end

function onEnter_ts2(zoneName, unitName)
	ts2spawn = OFP:activateEntitySet("s2");
end
function onLeave_ts2(zoneName, unitName)
	ts2spawn = OFP:destroyEntitySet("s2");
end
__________________
MAKE YOUR OWN ZOMBIE MISSIONS!

http://community.codemasters.com/for...54#post5850554
DemonFire is offline   Reply With Quote
Old 28-10-2009, 01:21 PM   #6 (permalink)
Member
 
Join Date: Oct 2009
Posts: 46
Default

@Demonfire, did you use 'despawn' or 'destroy'? You said destroy was annoying and not working but your code uses destroy.

@Pile, I have the exact opposite results. Destroy works for me and despawn doesn't. Here's my mssn sample: http://www.filefront.com/14812401/test_despawn.rar

Move to the left to destroy 'EntityLeft' and move to the right to despawn 'EntityRight'. Leaving the triggerzones respawns the respective entity.

The code:
Code:
SetID1 = 0;
SetID2 = 0;

function onMissionStart()
	-- Spawn both entity sets when the mission starts
	setID1 = OFP:activateEntitySet("EntityLeft");
	setID2 = OFP:activateEntitySet("EntityRight");
end 

-- this function displays messages in the log
function showMsg(strMessage)
	OFP:displaySystemMessage(strMessage);
end

-- uses destroyentityset to remove entities
function onEnter_tzDestroy(zoneName, unitName)
		showMsg("Destroying left entity..");
	OFP:destroyEntitySet(setID1);
end

-- uses despawnentity to remove entities
function onEnter_tzDespawn(zoneName, unitName)
	showMsg("Despawning right entity..");
	OFP:despawnEntity(setID1);
end

-- respawns entities on the left when player leaves the zone
function onLeave_tzdestroy(zoneName, unitName)
	showMsg("Re-activating left entity..");
	setID1 = OFP:activateEntitySet("EntityLeft");
end

-- respawns entities on the right when player leaves the zone
function onLeave_tzdespawn(zoneName, unitName)
	showMsg("Re-activating right entity..");
	setID2 = OFP:activateEntitySet("EntityRight");
end
NOTE: I find that OnLeave_zoneName requires the zonename to be in lower caps. In fact, that holds true for alot of things that don't work as they should. If anyone should find themselves wondering why something simple don't work, just change the names to lower caps.

Last edited by ZipD; 28-10-2009 at 01:31 PM.
ZipD is offline   Reply With Quote
Old 28-10-2009, 04:31 PM   #7 (permalink)
Member
 
DemonFire's Avatar
 
Join Date: Oct 2009
Location: USA - GA
Posts: 61
Default

Thanks ZipD, this works!!

I'll upload my mission when its done (conversations might take a while though)

Thanks everyone XD
__________________
MAKE YOUR OWN ZOMBIE MISSIONS!

http://community.codemasters.com/for...54#post5850554
DemonFire is offline   Reply With Quote
Old 08-11-2009, 06:09 AM   #8 (permalink)
Junior Member
 
Join Date: Apr 2003
Posts: 5
Default

I find I still can't get this to work, no matter what I try. I get the "Entered South Middle Zone" msg, but never the "Despawned Radio Tower Set" msg (or the tank "test2").

Any ideas? I can get one group to spawn, but can't then switch them off so I can spawn others


Code:
function onEnter_sthmiddlezone_usmc(zoneName, unitName)  --When entering the South Middle Zone
	OFP:activateEntitySet("sthmiddleset")  --Turn on South Middle Zone entity set
	OFP:destroyEntitySet("radiotowerset")  --Destroy RadioTower set
	OFP:destroyEntitySet("villageset")  --Destroy Village set
	OFP:destroyEntitySet("nthmiddleset")  --Destroy North Middle set
	OFP:displaySystemMessage("Entered South Middle Zone")
end

function onDespawnEntitySet_radiotowerset( setID )
	OFP:destroyVehicle("test2")
	OFP:displaySystemMessage("Despawned Radio Tower Set")
end
Leone is offline   Reply With Quote
Old 08-11-2009, 06:38 AM   #9 (permalink)
Member
 
DemonFire's Avatar
 
Join Date: Oct 2009
Location: USA - GA
Posts: 61
Default

Code:
function onEnter_sthmiddlezone_usmc(zoneName, unitName)  --When entering the South Middle Zone
    OFP:activateEntitySet("sthmiddleset")  --Turn on South Middle Zone entity set
    OFP:destroyEntitySet("radiotowerset")  --Destroy RadioTower set
    OFP:destroyEntitySet("villageset")  --Destroy Village set
    OFP:destroyEntitySet("nthmiddleset")  --Destroy North Middle set
    OFP:displaySystemMessage("Entered South Middle Zone")
end
Take out all the stuff in red. Make sure all your unit names and entity set names match the ones in the code and it should work.
__________________
MAKE YOUR OWN ZOMBIE MISSIONS!

http://community.codemasters.com/for...54#post5850554
DemonFire is offline   Reply With Quote
Old 08-11-2009, 11:45 AM   #10 (permalink)
Junior Member
 
Join Date: Apr 2003
Posts: 5
Default

Ahh, thanks! Yes, totally forgot about that.
Leone is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.