View topic - Resurrectable features/wrecks



All times are UTC + 1 hour


Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 02 Jul 2012, 17:03 
Moderator
User avatar

Joined: 26 Oct 2007, 15:21
There is a simple way of doing it, but it has some drawbacks, namely its mod specific.

Include the following example gadget in your map at /luarules/gadgets/map_resurrectable_feature.lua
Code:
function gadget:GetInfo()
  return {
    name      = "Resurrectabke wreck placer",
    desc      = "Resurrectabke wreck placer",
    author    = "beherith",
    date      = "2012 july",
    license   = "GNU GPL, v2 or later",
    layer     = 10,
    enabled   = true
  }
end

if (not gadgetHandler:IsSyncedCode()) then
  return false
end

function gadget:Initialize()
   wreck=Spring.CreateFeature('corstorm_dead', 2100, 0, 2000) --x,y,z positions
   Spring.SetFeatureResurrect(wreck,'corstorm')
end


Edit: This runs at frame 0, so the feature wont be on map until game start. If the feature is coded onto the map, then the procedure is a bit different, but setfeatureresurrect can still be used.


Top
 Offline Profile  
 
PostPosted: 02 Jul 2012, 18:40 
Tournaments Moderator
User avatar

Joined: 08 Dec 2007, 17:39
Location: UK - England
Image


Top
 Offline Profile  
 
PostPosted: 15 Jul 2012, 11:32 
Cursed Developer
User avatar

Joined: 17 Feb 2005, 22:05
There is a gadget in The Cursed for a long time now that works quite similar. I just have a custom feature parameter to define what to resurrect into and the gadget is run whenever a feature is created. I use it to have human bodies resurrected into skeletons.

Code:
function gadget:GetInfo()
  return {
    name      = "Resurretinto",
    desc      = "Reads out custom feature parameters to resurrect them into defined units",
    author    = "azaremoth",
    date      = "2009-17-10",
    license   = "GNU GPL, v2 or later",
    layer     = 0,
    enabled   = true,
  }
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

if (not gadgetHandler:IsSyncedCode()) then
  return false  --  no unsynced code
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

function gadget:FeatureCreated(fid, fTeam)
   local fdid = Spring.GetFeatureDefID(fid)
   local resurrectinto = FeatureDefs[fdid].customParams.resurrectintounit   
   if resurrectinto ~= nil then
      Spring.SetFeatureResurrect(fid, resurrectinto)
   else
      Spring.SetFeatureResurrect(fid, '')
   end
end

Featue defs:
Code:
local featureDefs = {
  dead = {
     customParams          = {
      resurrectintounit   = "tc_skeleton",
     },   

 [...]

  },
}
unitDef.featureDefs = featureDefs


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.